Skip to content
Memory corruption Disclosed report Advanced

Type confusion in partial.setstate, partial_repr, partial_call leads to memory corruption, reliable control flow hijack

A type confusion flaw in Python's functools.partial methods (setstate, repr, call) allows memory corruption. An attacker could reliably control the instruction pointer by calling repr on a corrupted partial object.

nedw Follow

Originally disclosed on HackerOne

Bounty$1,000 View original
  • Fixed in 43 days
  • Paid in 43 days
  • Disclosed after 7 months

See my official writeups here:

http://bugs.python.org/issue25944 http://bugs.python.org/issue25945

The maintainers merged these bug reports. In one case, the type confusion leads to a reliable control of the instruction pointer as calling repr on a corrupted partial calls a function pointer that is controlled reliably by the user. I've uploaded that case here as well.

The original report as published on HackerOne, by nedw. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

An attacker could reliably control the instruction pointer.

What the attacker needed

Ability to create or manipulate a partial object

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Python's functools.partial lets you pre-fill arguments of a function. A bug in how it handles certain internal states can confuse the program about what type of object it is dealing with, leading to memory corruption. This means an attacker might be able to take over the program's execution flow.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by nedw

View all

1 more disclosed report, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.