Use after free in WebCodecs (CVE-2026-11683)
A same-thread garbage-collected handle was passed into a callback that crossed to the media thread, so when the originating worker was terminated the handle was destroyed on the wrong thread. This unsynchronised destruction could corrupt heap metadata or cause a use-after-free inside the renderer.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 13 days
Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A potential thread-safety issue in VideoEncoder::isConfigSupported allows a same-thread cppgc::Persistent handle to be destructed on the media thread instead of its origin worker thread. This occurs when the originating worker thread is terminated, causing subsequent task posting to fail and triggering inline destruction of transitively bound callback states. The resulting off-thread call to PersistentRegionBase::FreeNode() executes without synchronization in release builds, potentially leading to heap metadata corruption or a use-after-free.
Affected files:
third_party/blink/renderer/modules/webcodecs/video_encoder.ccthird_party/blink/renderer/platform/heap/heap_barrier_callback.h
Estimated timestamp from git blame: 2024-02-29
Root Cause Analysis
In VideoEncoder::isConfigSupported() (third_party/blink/renderer/modules/webcodecs/video_encoder.cc), a same-thread cppgc::Persistent<ScriptPromiseResolver> handle is allocated using WrapPersistent(resolver) and embedded within the done_callback_ member of HeapBarrierCallback. The resulting find_any_callback is subsequently passed to CrossThreadBindOnce to establish gpu_retrieved_callback for retrieving GPU factories.
CrossThreadBindOnce utilizes static assertions (CheckGCedTypeRestrictions and kCheckNoThreadUnsafeRefCounted in third_party/blink/renderer/platform/wtf/functional_internal.h) to prevent thread-unsafe or garbage-collected types from crossing thread boundaries. However, these compile-time checks only inspect the direct parameters of the top-level callback wrapper; they do not recursively inspect the base::BindState or bound arguments of nested callbacks (such as the base::RepeatingCallback returned by HeapBarrierCallback). Consequently, the same-thread Persistent handle successfully bypasses the cross-thread static safety assertions.
Potential Trigger Scenario
(Note: These are potential steps based on source-code tracing, as our current verification environment does not have the ability to run live exploit payloads.)
- A page instantiates a Web Worker that calls
VideoEncoder.isConfigSupported()withhardwareAccelerationset to'prefer-hardware'. - The implementation enters
VideoEncoder::isConfigSupported(), creates a same-threadPersistent<ScriptPromiseResolver>, wraps it insideHeapBarrierCallback, and transfers the callback across the thread boundary viaRetrieveGpuFactoriesWithKnownEncoderSupport()to query hardware capabilities. - Since capabilities are not yet fully initialized, the callback is registered inside
MojoCodecFactory::NotifyEncoderSupportKnown()(media/mojo/clients/mojo_codec_factory.cc:120). During registration,base::BindPostTaskToCurrentDefault(std::move(callback))wraps it with aBindPostTaskTrampolinereferencing the worker thread's task runner. - While the GPU process is probing capabilities, the parent page calls
worker.terminate(), which shuts down and inactivates the worker thread's task runner. - Once capability probing completes, the media thread receives the reply and invokes
MojoCodecFactory::Notifier::Notify()on the media thread. - The media thread executes
BindPostTaskTrampoline::Run(), which attempts to post the callback to the dead worker's task runner. This fails (PostTaskreturnsfalse). - Because the post-task fails, the trampoline's destructor
~BindPostTaskTrampoline()executes immediately on the media thread. - The destructor attempts a fallback post-task to clean up, which also fails, forcing immediate inline destruction of the trampoline's captured callback (
callback_) on the media thread. - This triggers a cascading destruction chain on the media thread:
~OnceCallback()->~BarrierCallbackInfo()->~OnceCallback(the done callback) ->~BasicPersistent().
Consequences and Security Impact
When ~BasicPersistent() executes on the wrong thread, it calls Clear(), which invokes PersistentRegionBase::FreeNode() to return the node to the heap's persistent region.
- Heap Metadata Corruption: In
PersistentRegion::FreeNode(), the thread check is guarded byCPPGC_DCHECK(IsCreationThread())(v8/include/cppgc/internal/persistent-node.h:162). SinceDCHECKmacros are compiled out in non-debug (official/release) builds, the destruction proceeds on the media thread without synchronizations or locks. This results in an unsynchronized data race on thefree_list_head_pointer, potentially corrupting the allocator's free list and enabling subsequent use-after-free or type confusion of garbage-collected objects. - Use-After-Free: If the worker thread's heap has already been destroyed,
BasePage::FromPayload()will mask the payload address to find the page header, referencing a freed page and leading to wild memory reads/writes.
Both cases can result in exploitable memory corruption inside the sandboxed renderer process.
Suggested Fix
To prevent the same-thread Persistent handle from being destroyed on a different thread, we should avoid binding same-thread persistent handles directly into callbacks that cross thread boundaries. Instead, the ScriptPromiseResolver should be wrapped using a thread-safe handle or cross-thread persistent handle, such as MakeCrossThreadHandle or CrossThreadPersistent, when passed through the HeapBarrierCallback chain.
Evaluated with Chrome root at commit: b1520ef4a76878853a31f0943b565e42060edec8
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
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 the cross-thread binding checks only inspect the top-level callback parameters and do not recurse into nested bound callbacks, so a same-thread persistent handle slipped across the thread boundary.
Impact
In release builds the unsynchronised free could corrupt the allocator free list or reference a freed page, potentially leading to exploitable memory corruption inside the sandboxed renderer; the report notes the trigger was traced from source and not verified with a live payload.
What the attacker needed
A page that can run a Web Worker; hardware acceleration requested; worker terminated during probing
The fix
The same-thread persistent handle should be replaced with a thread-safe or cross-thread handle such as MakeCrossThreadHandle or CrossThreadPersistent before it is passed through the heap barrier callback chain.
How it was found
- A worker calls VideoEncoder.isConfigSupported() asking for hardware acceleration.
- The implementation wraps a same-thread persistent resolver in a heap barrier callback and sends it to the media thread to query GPU factories.
- Because capabilities are not ready, the callback is registered with a post-task trampoline tied to the worker's task runner.
- The parent page terminates the worker while probing is still in progress, inactivating its task runner.
- When the media thread receives the reply, posting back to the dead worker fails and the trampoline is destroyed inline on the media thread.
- That cascading destruction frees the persistent node on the media thread without synchronisation.
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.
Some objects in the browser are only safe to touch from the thread that created them. This report shows a handle to such an object being carried into work done on another thread, and then destroyed there when the original worker disappears. Doing that without locks can corrupt the browser's memory bookkeeping, which in the worst case an attacker could turn into code execution inside the sandboxed renderer.
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.