Use after free in WebRTC (CVE-2026-7987)
A race condition in WebRTC audio rendering allows a use-after-free of the audio transport callback object. An attacker could potentially hijack a virtual call and achieve remote code execution within the renderer sandbox.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 35 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: A race condition in WebRtcAudioDeviceImpl::RenderData allows a potential use-after-free of the AudioTransport callback object. The lock protecting the callback pointer is released before the virtual method PullRenderData is called, allowing the underlying object to be destroyed on another thread.
Affected files:
third_party/blink/renderer/modules/webrtc/webrtc_audio_device_impl.ccthird_party/blink/renderer/modules/webrtc/webrtc_audio_device_impl.hthird_party/webrtc/media/engine/webrtc_voice_engine.ccthird_party/webrtc/audio/audio_state.h
Estimated timestamp from git blame: 2025-09-30
Description
A potential use-after-free (UAF) vulnerability exists in the WebRTC audio rendering path in Blink. The issue stems from a race condition in WebRtcAudioDeviceImpl::RenderData where a pointer to a webrtc::AudioTransport object is extracted and used after the object it points to can be freed during the teardown of a WebRTC session.
In third_party/blink/renderer/modules/webrtc/webrtc_audio_device_impl.cc, the RenderData() method (which runs on the high-priority real-time audio render thread) acquires a lock to check the state of the audio device. However, it releases this lock before invoking the virtual method PullRenderData() on the audio_transport_callback_ member. Concurrently, when a session is closed (e.g., via pc.close() in JavaScript), WebRtcVoiceEngine::Terminate() is called on the WebRTC worker thread, which clears this callback and subsequently destroys the object it points to.
Vulnerability Details
In WebRtcAudioDeviceImpl::RenderData (lines 56-117):
65: base::AutoLock auto_lock(lock_);
... // Checks playing state and total playout delay
96: DCHECK(audio_transport_callback_);
99: } // <-- lock_ released here
...
117: audio_transport_callback_->PullRenderData( // <-- UAF: raw_ptr evaluated without lock
The audio_transport_callback_ member is declared as a raw_ptr<webrtc::AudioTransport, DanglingUntriaged>.
During teardown, WebRtcVoiceEngine::Terminate() in third_party/webrtc/media/engine/webrtc_voice_engine.cc executes the following sequence on the WebRTC worker thread:
568: adm()->StopPlayout();
569: adm()->StopRecording();
570: adm()->RegisterAudioCallback(nullptr); // Sets audio_transport_callback_ = nullptr under lock
571: adm()->Terminate();
The AudioTransportImpl object is owned by the AudioState object as a member variable. Once the last reference to the AudioState scoped_refptr is dropped (which occurs following Terminate() and the destruction of the Call object), the AudioState and its member AudioTransportImpl are destroyed.
Exploitation and MiraclePtr Bypass
The critical race window exists between the extraction of the raw C++ pointer via operator->() at line 117 and the completion of the PullRenderData() virtual method call.
If the real-time audio render thread is preempted immediately after evaluating the raw_ptr but before (or during) the virtual function execution, the worker thread can concurrently execute the teardown sequence. The worker thread calls RegisterAudioCallback(nullptr), which overwrites the raw_ptr. This crucial step decrements the MiraclePtr (BackupRefPtr) reference count for the AudioTransportImpl allocation down to zero.
Subsequently, the worker thread drops the last reference to the AudioState object, causing its destruction. Because the MiraclePtr refcount is already zero, PartitionAlloc physically frees the memory back to the heap, completely bypassing the quarantine mechanism.
The attacker can then rapidly reallocate the newly freed heap chunk using WebAssembly or WebAudio heap spraying on another thread. When the preempted audio render thread resumes, it uses the previously extracted dangling raw pointer to invoke the virtual method PullRenderData() on the attacker-controlled memory chunk, leading to a virtual call hijack and Remote Code Execution (RCE) within the renderer sandbox.
Suggested Attacker Steps
Note: These are potential steps; our tooling agent cannot yet run code to verify them.
- Host a malicious webpage that executes JavaScript to create a WebRTC connection (
new RTCPeerConnection()) and add an audio track to initiate the audio rendering pipeline. - The browser's native audio subsystem invokes
WebRtcAudioDeviceImpl::RenderData()on a high-priority real-time thread. - The attacker's JavaScript asynchronously calls
pc.close()to abruptly terminate the WebRTC session, triggeringWebRtcVoiceEngine::Terminate()on the WebRTC worker thread. - The audio render thread evaluates
audio_transport_callback_->and extracts the raw pointer, but is then preempted by the OS scheduler. - The worker thread executes
Terminate(), setting the callback tonullptr(dropping the MiraclePtr refcount to 0) and destroying theAudioStateobject, physically freeing theAudioTransportImplmemory. - The attacker uses a concurrent worker thread to rapidly allocate memory (heap spraying), successfully reallocating the exact same memory chunk with attacker-controlled data (including a fake vtable).
- The audio render thread resumes, dereferences the dangling raw pointer, and executes the attacker-controlled virtual method, resulting in RCE.
Suggested Fix
Due to the real-time constraints of the audio render thread, extending the base::AutoLock auto_lock(lock_) scope to cover the entire RenderData() method (including the PullRenderData call) could introduce unacceptable latency or deadlocks if the WebRTC worker thread is heavily loaded. A better approach might involve holding a strong reference (scoped_refptr) to the AudioState (or the underlying transport) locally within the RenderData scope to ensure the object's lifetime extends until the method completes, or utilizing a thread-safe mechanism to ensure the worker thread waits for the audio thread to exit its processing loop before destroying the object.
Evaluated with Chrome root at commit: e9e0fcbb690b1a8c1a26c81c2a9ea23d6e178368
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 the lock protecting the callback pointer is released before the virtual method is called, allowing the object to be destroyed concurrently.
Impact
An attacker could potentially achieve remote code execution within the renderer sandbox, though the report notes the steps are unverified.
What the attacker needed
Victim visits a malicious webpage; browser supports WebRTC audio; attacker can win a race condition
The fix
The fix should hold a strong reference to the AudioState locally within RenderData to extend the object's lifetime, or use a thread-safe mechanism to wait for the audio thread to finish before destroying the object.
How it was found
- Host a malicious webpage that creates a WebRTC connection and adds an audio track.
- The browser's audio subsystem calls RenderData on a high-priority thread.
- The attacker's JavaScript calls pc.close() to terminate the session.
- The audio thread extracts the raw pointer but is preempted.
- The worker thread frees the callback object and the AudioState.
- The attacker sprays the heap to reallocate the freed chunk with a fake vtable.
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 use-after-free happens when a program keeps a pointer to memory after that memory has been freed, and then uses it again. Here, the audio thread grabs a pointer to an object, but before it calls a function on it, another thread frees that object. If an attacker can control what gets placed in that freed memory, they might 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.