Type Confusion in WebRTC (CVE-2026-7988)
A thread-affine garbage-collection handle is passed to a WebRTC background thread and can be destroyed there if the frame is detached, causing an unlocked data race on the cppgc free-list. This can corrupt the heap and potentially lead to renderer remote code execution.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 34 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 without the security team.
Overview: RTCRtpSenderImpl::SetParameters incorrectly passes a thread-affine cppgc::Persistent handle to a WebRTC background thread. If the frame is detached, the callback is destroyed off-thread, causing an unlocked data race in the cppgc free-list. This leads to heap corruption and potential renderer RCE.
Affected files:
third_party/blink/renderer/modules/peerconnection/rtc_rtp_sender_impl.ccthird_party/blink/renderer/modules/peerconnection/rtc_rtp_sender.ccv8/include/cppgc/internal/persistent-node.h
Estimated timestamp from git blame: 2025-08-26
Summary
A vulnerability exists in RTCRtpSenderImpl::SetParameters where a thread-affine cppgc::Persistent handle is illicitly transferred to and potentially destroyed on a background thread. This off-thread destruction bypasses cppgc thread-safety expectations, creating an unlocked data race on the PersistentRegion free-list, leading to memory corruption in the renderer process.
Technical Details
When RTCRtpSender::setParameters is called, it allocates a SetParametersRequest on the garbage-collected heap. In RTCRtpSenderImpl::SetParameters (third_party/blink/renderer/modules/peerconnection/rtc_rtp_sender_impl.cc), this request is wrapped using WrapPersistent(request) and bound into a base::OnceCallback.
To pass this callback to the WebRTC signaling thread, the code wraps the callback using CrossThreadBindOnce(std::move(callback)). CrossThreadBindOnce normally employs CheckGCedTypeRestrictions to prevent thread-unsafe types (like Persistent) from crossing thread boundaries. However, because the Persistent handle is embedded inside the functor (base::OnceCallback) rather than passed as a bound argument, the compile-time checks trivially pass, and the handle is successfully wrapped into a CrossThreadOnceFunction.
On the WebRTC signaling thread, this function is captured in a lambda and passed to webrtc_sender_->SetParametersAsync. Under normal conditions, the lambda posts the callback back to the main thread upon completion. However, if the frame's task runner has been shut down (e.g., due to iframe detachment), PostCrossThreadTask returns false. The task is dropped and destroyed inline on the background thread, invoking the ~BasicPersistent() destructor off-thread.
Impact
PersistentRegionBase::FreeNode is not thread-safe. When invoked from a background thread, it performs a lock-free update of free_list_head_ (node->InitializeAsFreeNode(free_list_head_); free_list_head_ = node; nodes_in_use_--;).
Concurrently, allocations on the main thread will call TryAllocateNodeFromFreeList, which also reads and writes the free-list head without locks. This data race corrupts the free-list, leading to a double-allocation of a PersistentNode. Because PersistentNode is a tagged union (overlapping the owner_ pointer and next_ pointer), an attacker can cause type-confusion and inject controlled owner_ pointers. During the next garbage collection, the GC's Iterate phase will follow these corrupted pointers, resulting in arbitrary memory read/write and potential Remote Code Execution (RCE) in the renderer process.
Potential Reproduction Steps
Note: These are suggested steps for reproducing the vulnerability based on static analysis, as our tooling agent cannot yet run a live proof of concept.
- In an attacker-controlled iframe, create an
RTCPeerConnectionand a sender viaaddTransceiver. - Execute
sender.setParameters(...). - While the task is processing in libwebrtc, detach the iframe (e.g.,
iframe.remove()). This shuts down the Blink task runner. - When the async operation completes, the signaling thread attempts to post back to the main thread but fails, dropping and destroying the
Persistenthandle off-thread. - Concurrently, loop the rapid creation of GC objects (e.g.,
ScriptPromiseResolvercreations) on the main thread to collide with the background thread'sFreeNodeexecution, corrupting thecppgcfree-list. - Observe heap corruption or a crash during the next GC cycle.
Suggested Fix
Update RTCRtpSenderImpl::SetParameters to use WrapCrossThreadPersistent(request) instead of WrapPersistent(request). CrossThreadPersistent safely handles off-thread destruction by locking the region's free-list operations. Alternatively, the blink layer should correctly type-check nested functors in CrossThreadBindOnce to prevent base::OnceCallback wrappers from obscuring thread-affine arguments.
Evaluated with Chrome root at commit: ff3d2b74fa39431785bd60e51463b08fcc71ee33
Results 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 thread-affine cppgc::Persistent handle is wrapped inside a callback that is passed to a background thread, and the compile-time check misses it because the handle is nested inside the functor rather than a bound argument.
Impact
The data race can corrupt the cppgc free-list, leading to type confusion and potentially arbitrary memory read/write and remote code execution in the renderer process.
What the attacker needed
Attacker-controlled iframe; ability to detach the iframe; timing to race the background thread
The fix
The code should use WrapCrossThreadPersistent instead of WrapPersistent, or the blink layer should correctly type-check nested functors in CrossThreadBindOnce.
How it was found
- In an attacker-controlled iframe, create an RTCPeerConnection and a sender via addTransceiver.
- Execute sender.setParameters(...).
- While the task is processing in libwebrtc, detach the iframe (e.g., iframe.remove()).
- When the async operation completes, the signaling thread attempts to post back to the main thread but fails, dropping and destroying the Persistent handle off-thread.
- Concurrently, loop the rapid creation of GC objects on the main thread to collide with the background thread's FreeNode execution.
- Observe heap corruption or a crash during the next GC cycle.
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 garbage collector keeps track of objects using small handles. Some handles are only safe to use on the thread that created them. Here, a handle is handed to a background thread, and if the page is closed at the wrong moment, that background thread frees the handle. Two threads then change the same list without a lock, which can corrupt memory and 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.