Webkit fireEventListeners use-after-free vulnerability
A use-after-free exists in WebKitGTK's fireEventListeners when a media group change triggers an asynchronous event after the document has been torn down. An attacker could craft a web page that causes memory corruption and potentially remote code execution when the victim visits it.
Originally disclosed on Cisco Talos
An exploitable use-after-free vulnerability exists in WebKitGTK browser version 2.30.3 x64. A specially crafted HTML web page can cause a use-after-free condition, resulting in remote code execution.
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the fireEventListeners function calls scriptExecutionContext() and downcasts it to Document without checking that the document is still alive, so a timer-driven media event can reach a freed object.
Impact
With heap grooming an attacker could turn the use-after-free into arbitrary code execution, though the report only demonstrates a crash under AddressSanitizer.
What the attacker needed
Victim visits a malicious web page; WebKitGTK 2.30.3 build; autoplay allowed
How it was found
- Load the crafted page in MiniBrowser with autoplay allowed and console logging enabled.
- The page creates an audio context and nodes and connects them.
- A mutation observer reacts to attribute changes on the audio element and repeatedly reinserts parsed body elements.
- The fuzzing loop clears the document body and then sets the mediaGroup property on the audio element.
- The media group change schedules an asynchronous event that fires after the document has been freed, and AddressSanitizer reports a heap-use-after-free.
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.
A use-after-free is when a program keeps a pointer to memory it has already released and then reads or writes through it. Here the browser frees a document object but a delayed media event still tries to use it, so an attacker who controls the page could shape that freed memory and hijack execution.
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.