Webkit ImageLoader dispatchPendingErrorEvent use-after-free vulnerability
A use-after-free vulnerability exists in WebKit's ImageLoader when handling image error events, triggered by a crafted web page. An attacker could exploit this to cause a crash and potentially achieve information leak or further memory corruption.
Originally disclosed on Cisco Talos
A use-after-free vulnerability exists in the way certain events are processed for ImageLoader objects of Webkit WebKitGTK 2.30.4. A specially crafted web page can lead to a potential information leak and further memory corruption.
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 ImageLoader destructor does not check for pending operations before freeing the object, leading to a stale reference being used during event dispatch.
Impact
A malicious web page could lead to a use-after-free vulnerability and potential remote code execution, though the text notes that with proper memory layout control and heap grooming an attacker could achieve information leak and possibly further memory corruption.
What the attacker needed
Victim visits a malicious webpage
How it was found
- An associated event handler is executed because of an error in static HTMLImageElement `html_image`
- Event handler code is executed till `adoptNode` which will result in exception, which in turn triggers eventhandler again
- Same thing happens for the 3rd time (until eventhandler counter is exhausted) when nested event handlers begin to unwind.
- Rest of the eventhandler is executed
- Event handler unwinding ends up executing `new ImageData(1024, 1024);` three times.
- Finally, `onload` handler is triggered which executes `main` function in which `new ImageData(1024, 1024);` and `new Image();` are created.
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 happens when a program frees memory but keeps using it, like deleting a file but still opening it. Here, a web page can trick the browser into using image data after it has been freed, which can crash the browser or let an attacker run their own code. The victim just needs to visit a malicious page.
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.