A Tale of Two Exploits
A type confusion flaw in the ActionScript 2 NetConnection class let a crafted native function object pass a type check and be treated as a NetConnection, so a caller-supplied number was used as a pointer. An attacker could use this to read memory, bypass ASLR and redirect execution, and the bug was exploited in the wild in exploit kits shortly after it was patched.
googleprojectzero.blogspot.com
Published on googleprojectzero.blogspot.com
Posted by Natalie Silvanovich, Collision Investigator and (Object) Field Examiner
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The NetConnection type check accepted any Object whose prototype chain contained a NetConnection, but native function objects are Objects with non-null native data, so a caller-controlled number was cast to a pointer.
Impact
An attacker could read memory to defeat ASLR and redirect the instruction pointer, and the bug was exploited in the wild by exploit kits, though the author notes the exploit is not fully reliable and is limited to 32-bit platforms.
What the attacker needed
Victim runs a malicious SWF; 32-bit Flash plugin; user visits a page hosting the exploit
The fix
The normal check was updated to verify that the object's native function pointer is null, so native function objects no longer pass, and Adobe patched it in March 2015.
How it was found
- Create a native function object with ASnative, giving it a chosen numeric value as its native data.
- Create a NetConnection and set the function object's __proto__ to it so the type check passes.
- Call a NetConnection method on the function object, causing the chosen value to be used as a pointer.
- For the proof of concept, spray BitmapData buffers so a guessed address lands in controlled pixel memory.
- Use the nearID getter as an info leak to find libc, then point execution at a ROP gadget.
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 write-up has not been written yet. The Original tab links to the source.
Flash's older scripting language, ActionScript 2, stores objects with a label saying what type they are, and functions that use an object check that label first. Here the check could be fooled by a special built-in function object whose stored value is a number the attacker chooses, so the program treated that number as a memory address. That let an attacker read and write memory in the browser plugin, which can lead to running their own code.
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.