Use after free in WebRTC (CVE-2026-79187)
A use-after-free and data race can occur when replacing a WebRTC track if the parent iframe is detached during the operation, causing a track adapter to be destroyed on the wrong thread. An attacker could potentially corrupt memory and achieve remote code execution, though no working proof of concept is provided.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 2 months
Flapjack, 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 Use-After-Free and data race can occur when replacing a WebRTC track if the parent iframe is detached during the operation. This detachment kills the main thread task runner, causing a cross-thread task to fail and destroy a track adapter on the wrong thread. Concurrent modification of the track's sink vector on the main thread leads to a Use-After-Free memmove on the signaling thread.
Affected files:
third_party/blink/renderer/modules/peerconnection/rtc_rtp_sender_impl.ccthird_party/blink/renderer/modules/peerconnection/webrtc_media_stream_track_adapter_map.ccthird_party/blink/renderer/modules/peerconnection/webrtc_media_stream_track_adapter.ccthird_party/blink/renderer/modules/mediastream/media_stream_video_track.cc
Estimated timestamp from git blame: 2018-01-08
Summary
A Use-After-Free (UAF) and data race vulnerability exists in WebRTC's track replacement logic. If an attacker detaches the iframe hosting an RTCPeerConnection exactly while a replaceTrack operation is communicating with the WebRTC signaling thread, the callback task intended for the main thread is rejected because the task runner has shut down. The rejection causes the callback closure and its captured AdapterRef to be destroyed synchronously on the signaling thread. This triggers a destruction chain that modifies the MediaStreamVideoTrack's sink vectors without locks. A concurrent interaction with the track from the main thread can cause the vector to reallocate, resulting in the signaling thread performing a UAF memmove on a freed backing buffer.
Potential Exploitation Steps
Note: These steps trace the theoretical path through the codebase. We do not have a working Proof of Concept.
- Setup: An attacker creates an
iframeand initializes anRTCPeerConnectioninside it, acquiring a local videoMediaStreamTrack. A reference to this track is leaked to the parent window. - Trigger
replaceTrack: The attacker callsRTCRtpSender.replaceTrack(track). - Task Queued: On the main thread,
RTCRtpSenderImpl::ReplaceTracksynchronously creates aWebRtcMediaStreamTrackAdapterand anAdapterRef. It posts a task (ReplaceTrackOnSignalingThread) to the WebRTC signaling thread, capturing theAdapterRefin the closure. - Iframe Detachment: The attacker uses the parent window to immediately detach the
iframe. This destroys the iframe's execution context, shutting down itsmain_task_runner_. - Task Execution and Failure: The signaling thread executes
ReplaceTrackOnSignalingThread. It finishes its work and attempts to postReplaceTrackCallbackback to the main thread viaPostCrossThreadTask, moving theAdapterRefinto the new closure. - Closure Destruction: Because
main_task_runner_is dead,PostCrossThreadTaskreturns false. TheOnceClosureis destroyed immediately on the caller thread (the signaling thread). - Unsafe Destruction Chain: The closure's destruction destroys the
AdapterRef.~AdapterRefobserves it is the final reference and callsadapter->Dispose(). - Thread-Hostile Access: The disposal chain continues on the signaling thread:
DisposeLocalVideoTrack()->~MediaStreamVideoWebRtcSink()->DisconnectFromTrack()->MediaStreamVideoTrack::RemoveSink(). Note that release builds bypass theDCHECK_CALLED_ON_VALID_THREADmacro. - The Memory Operation:
RemoveSink()callsWTF::Vector::erase()onsinks_. Because the vector holds pointers, this translates to amemmoveon the signaling thread to shift elements down. - The Race and UAF: Concurrently, the attacker uses the parent window to interact with the leaked track reference (e.g., calling
clone()). This triggerssinks_.push_back()on the main thread. If this causes the vector toExpandCapacity(), the old backing buffer is freed by the main thread exactly while the signaling thread is executing amemmoveon it.
By carefully timing the reallocation and spraying replacement objects (like an ArrayBuffer backing store), the attacker can cause the signaling thread to shift the contents of the newly allocated object by 8 bytes, corrupting pointers or lengths and leading to arbitrary read/write and Remote Code Execution.
Suggested Fix
Ensure that the destruction of WebRTC adapters and the resulting disconnection from Blink tracks always occurs on the main thread.
In WebRtcMediaStreamTrackAdapterMap::AdapterRef::~AdapterRef(), if the current thread is not the main thread, the call to removed_adapter->Dispose() should be posted to the main thread (using a task runner that is guaranteed to outlive the ExecutionContext, or by ensuring thread-safe disposal). Alternatively, ensure MediaStreamVideoTrack operations use proper locking, though keeping Blink object modification strictly on the main thread is generally preferred.
Evaluated with Chrome root at commit: 2155cb00003ec35716a76ed3246eae995f87b7ff
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 destruction of a WebRTC track adapter can happen on the signaling thread instead of the main thread, leading to unsynchronised access to a shared vector.
Impact
An attacker could potentially corrupt memory and achieve arbitrary read/write and remote code execution, but no working exploit is demonstrated.
What the attacker needed
Ability to run JavaScript in a browser; victim visits a malicious page; timing control over iframe detachment
The fix
Ensure that the destruction of WebRTC adapters and the resulting disconnection from Blink tracks always occurs on the main thread.
How it was found
- Create an iframe with an RTCPeerConnection and leak a reference to a local video track to the parent window.
- Call replaceTrack on the sender, which posts a task to the signaling thread.
- Detach the iframe from the parent window, shutting down its main task runner.
- The signaling thread executes the task and fails to post the callback back, destroying the closure and adapter on the signaling thread.
- The adapter disposal calls RemoveSink on the track, performing a memmove on the signaling thread.
- Concurrently, the parent window interacts with the leaked track (e.g., calling clone), causing a vector reallocation and a use-after-free.
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's real-time communication feature. When a web page is closed at just the wrong moment, the browser can free memory that is still being used, which might let an attacker run their own code. The report is theoretical and no working exploit is shown.
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.