Skip to content
Memory corruption Advisory Advanced CVE-2024-2886

Use after free in WebCodecs (CVE-2024-2886)

A use-after-free in Chromium's WebCodecs code arises from the incorrect assumption that PinArrayBufferContent() keeps the backing store from being reallocated. An attacker could trigger an immediate crash, and the reporter argues the flaw is likely exploitable through data races on non-shared ArrayBuffers.

Seunghyun Lee Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 6 days

This is a sub-bug from the primary pwn2own bug. This is tracking the memory safety issues from the incorrect assumption that PinArrayBufferContent() prevents the backing store itself from being reallocated. I am going to leave the full details in the main bug, but I am breaking this one out separately to track fixes:

  1. Run a webserver to serve the given poc.html file (e.g. python3 -m http.server -b 127.0.0.1 8000)
  2. Start Chrome or Edge
  3. Assert that hardware accelerated compositing is enabled.
  4. Visit chrome://gpu
  5. Check that Compositing: Hardware accelerated
  6. If not, kill all chrome.exe or msedge.exe process and retry from step 2 with --ignore-gpu-blocklist flag added (if this still fails, hardware is likely ancient or is lacking proper graphics driver support)
  7. Browse to http://127.0.0.1:8000/poc.html
  8. Result should be an immediate crash with STATUS_ACCESS_VIOLATION.

The reporter also notes that:

Triggering the bug via ArrayBuffer.prototype.transfer and its variants is blocked behind --harmony-rab-gsab-transfer flag from M105 which is later enabled by default in M114 (commit 6387763c).

And has a non-transfer-based version to trigger this as well; that being said, I believe the underlying flaw is the same.

This bug is still likely to be exploitable without ArrayBuffer.prototype.transfer by exploiting data races on non-shared ArrayBuffers, for example with the following execution order:

  1. Create ArrayBuffer ab on main JS thread
  2. Create a worker thread
  3. Dispatch VideoFrame.copyTo(ab) operation
  4. Zero-copy transfer ab to the worker thread via postMessage()
  • Now the worker thread is able to operate on the ArrayBuffer concurrently with the main JS thread
  1. Race the two operations:

I've confirmed that the data race does trigger by hitting a check (int 3; ud2;) with TypedArray.prototype.sort() - this is included in the attachments as poc_no_transfer.html [...]

And finally the reporter's thoughts on a fix:

Stop acquiring raw pointers and base::span of ArrayBuffer-like objects across awaitable points or threaded operations. Either steal the underlying backing store as if we detach the buffer (this violates spec), or mark the buffer as shared (only internally). Marking it as shared should not actually make it a SharedArrayBuffer, but instead should result in all non-shared ArrayBuffer optimizations to be avoided while being internally shared

And followup work that would be good to carry out (but IMO out of scope here):

Validate and mark all unsafe buffer usages as per https://issues.chromium.org/issues/40284755, notably initial spanification points that are worthy of marking UNSAFE_BUFFERS()

The original report as published on the Chromium issue tracker, by Seunghyun Lee (@0x10n) of KAIST Hacking Lab, via Pwn2Own 2024. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 code assumed PinArrayBufferContent() kept the ArrayBuffer backing store alive and stable, but the backing store could still be reallocated while a raw pointer or span was held across an awaitable or threaded operation.

Impact

The proof of concept causes an immediate browser crash, and the reporter believes the same flaw is likely exploitable without the transfer API by racing a copy operation against worker-thread buffer operations.

What the attacker needed

Victim visits a crafted page; hardware accelerated compositing enabled

The fix

The reporter recommends never holding raw pointers or spans of ArrayBuffer-like objects across awaitable or threaded operations, and instead stealing the backing store or internally marking the buffer as shared; the text does not state that a fix was applied.

How it was found

  1. Serve the proof-of-concept HTML file from a local web server.
  2. Start Chrome or Edge and confirm hardware accelerated compositing is enabled via chrome://gpu.
  3. If compositing is not hardware accelerated, kill the browser processes and restart with the ignore-gpu-blocklist flag.
  4. Browse to the proof-of-concept page.
  5. Observe an immediate crash with STATUS_ACCESS_VIOLATION.

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 program can hold a reference to a block of memory (a buffer) while another part of the program frees or moves that memory. If the first part then keeps using the old reference, it reads or writes memory that no longer belongs to it, which is called a use-after-free. Here the browser's media code made that mistake, so a crafted page could crash the browser and might be turned into code 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.

More by Seunghyun Lee

View all

1 more disclosed report, best first.

More from Google Chrome

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.