Use after free in Modularization (CVE-2026-106315)
A use-after-free vulnerability exists in Breakout Box when a MediaStreamTrack is transferred to a Worker that is immediately terminated. An attacker could potentially achieve remote code execution in the renderer by exploiting a race condition between the IO thread and the Worker's heap termination.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 6 months
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: A potential Use-After-Free exists in Breakout Box when a MediaStreamTrack is transferred to a Worker that is immediately terminated. An ordering inversion allows a CrossThreadPersistent handle to be set after the Worker's teardown mitigation has run, leading to a data race between the IO thread and the Worker's Oilpan heap termination. This allows the IO thread to dereference a freed object, potentially leading to remote code execution in the renderer.
Affected files:
third_party/blink/renderer/modules/breakout_box/frame_queue_underlying_source.ccthird_party/blink/renderer/modules/breakout_box/frame_queue_transferring_optimizer.ccthird_party/blink/renderer/modules/breakout_box/transferred_frame_queue_underlying_source.ccthird_party/blink/renderer/modules/breakout_box/media_stream_video_track_underlying_source.cc
Estimated timestamp from git blame: 2022-08-31
Vulnerability Details
When a Breakout Box stream (like a MediaStreamTrackProcessor's readable stream) is transferred to a Web Worker, a race condition can occur during Worker termination that bypasses lifecycle mitigations and leads to a Use-After-Free (UAF).
- Transfer and Callback Serialization: When the stream is deserialized on the Worker thread,
FrameQueueTransferringOptimizer::PerformInProcessOptimizationallocates aTransferredFrameQueueUnderlyingSourceon the Worker's Oilpan (cppgc) heap. It then usesPostCrossThreadTaskto send aconnect_host_callbackback to the Main thread to link the host to this new source. - Mitigation Bypass: If the Worker is terminated immediately and the Main thread is artificially blocked (e.g., via a busy loop), the
connect_host_callbacksits in the Main thread's task queue. The Worker thread begins shutdown, which synchronously firesContextDestroyed(). This callsClearTransferredSource()on the host object to safely detach the stream. However, because theconnect_host_callbackhasn't run yet,transferred_source_is still null, rendering this teardown mitigation completely ineffective. - Late Attachment: The Main thread unblocks, processes its task queue, and executes the delayed
connect_host_callback(callingTransferSource()). This sets the host'stransferred_source_to aCrossThreadPersistenthandle pointing to the Worker's Oilpan object—an object belonging to a heap that is currently in the process of being destroyed. - Data Race on IO Thread: The Worker thread continues its termination sequence and calls
cppgc::HeapBase::Terminate(). This function severs all cross-thread roots by non-atomically zeroing out theraw_pointers insideCrossThreadPersistenthandles. Crucially, this happens without acquiring the host'slock_. - Use-After-Free: Concurrently, the underlying media track delivers a frame to the IO thread, triggering
QueueFrame(). The IO thread acquireshost->lock_and readstransferred_source_. Due to the lack of synchronization withHeapBase::Terminate(),CrossThreadPersistent::Get()can load a non-null pointer just before the Worker zeroes it out. The IO thread then callstransferred_source_->QueueFrame(...). Because the Oilpan heap sweep has already freed the target object, this results in a UAF. Since the memory is managed by Oilpan, it is not protected by MiraclePtr (BackupRefPtr).
Potential Steps to Trigger
Note: These are suggested steps to theoretically trigger the vulnerability; our tooling agent does not currently have the capability to run and verify a live proof-of-concept.
- Create a video track (e.g., from a
<canvas>capture) and wrap it in aMediaStreamTrackProcessor. - Call
postMessageto transfer the processor'sreadablestream to a Web Worker. - Immediately call
worker.terminate()from the Main thread. - Execute a brief busy-loop (
while (Date.now() < start + X) {}) on the Main thread to ensure the Worker'sContextDestroyedruns before the Main thread processes theconnect_host_callback. - Flood the video track with frames (e.g., via
requestAnimationFramedrawing to the canvas) to force the IO thread to callQueueFrame()at the exact moment the Worker'scppgcheap is terminating. - The IO thread dereferences the freed
TransferredFrameQueueUnderlyingSourceobject, where an attacker who has groomed the Worker's heap could potentially control the vtable/mutex state for Remote Code Execution.
Suggested Fix
CrossThreadPersistent handles are documented as non-thread-safe against concurrent GC clearing, meaning host->lock_ alone cannot protect the handle if the target heap terminates.
The safest fix is to prevent TransferSource from attaching the handle if the target context is already tearing down.
- Add a boolean flag (e.g.,
is_transfer_aborted_) toFrameQueueUnderlyingSource, guarded bylock_. - In
ClearTransferredSource()(which runs duringContextDestroyed), setis_transfer_aborted_ = true;inside the lock. - Modify
TransferSource()to check this flag while holding the lock. Ifis_transfer_aborted_is true, drop the incomingTransferredFrameQueueUnderlyingSourceand do not assign it totransferred_source_.
This ensures that if the Worker dies before the connection is fully established, the delayed callback won't accidentally wire up a dangling pointer to a dying heap.
Evaluated with Chrome root at commit: a9cbf6e8b275fe4147435aa905f3b7f5a656f5f0
Results from so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
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 a race condition where a cross-thread callback attaches a persistent handle to a worker's heap after the worker has begun termination, and the handle is cleared without proper synchronisation, leading to a use-after-free.
Impact
An attacker could potentially achieve remote code execution in the renderer, though the report notes this is theoretical and not verified with a live proof-of-concept.
What the attacker needed
Ability to run JavaScript in the browser; victim visits a malicious page; timing control to trigger race
The fix
The fix should add a flag to prevent TransferSource from attaching the handle if the target context is already tearing down.
How it was found
- Create a video track and wrap it in a MediaStreamTrackProcessor.
- Transfer the processor's readable stream to a Web Worker using postMessage.
- Immediately call worker.terminate() from the main thread.
- Execute a busy-loop on the main thread to delay processing of the connect_host_callback.
- Flood the video track with frames to trigger QueueFrame() on the IO thread during heap termination.
- The IO thread dereferences the freed object, potentially allowing control of the vtable/mutex for remote code execution.
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.
This report describes a memory safety bug in a web browser component. When a video stream is passed to a background worker and that worker is shut down at the same time, the browser can try to use memory that has already been freed, which could let an attacker run 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.