Use after free in Media (CVE-2026-11130)
A cross-thread data race on a callback member in Chrome's speech recognition client can free the callback's internal state while the main thread still holds a pointer to it. A malicious page could rapidly toggle audio tracks to trigger this use-after-free and potentially gain renderer code execution.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 53 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 Chrome Security team.
Overview: A cross-thread data race occurs in ChromeSpeechRecognitionClient due to unsynchronized access to the on_ready_callback_ member across the main and media threads. This race can cause a Use-After-Free of the callback's internal BindStateBase object. A malicious webpage could potentially trigger this by rapidly toggling audio tracks to achieve renderer Remote Code Execution.
Affected files:
chrome/renderer/media/chrome_speech_recognition_client.ccchrome/renderer/media/chrome_speech_recognition_client.h
Estimated timestamp from git blame: 2023-05-17
Summary
A cross-thread data race exists in ChromeSpeechRecognitionClient regarding the on_ready_callback_ member variable. This base::OnceCallback is concurrently modified on the media thread and executed on the main thread without synchronization. This race can lead to the premature destruction of the callback's underlying BindStateBase object, resulting in a potential Use-After-Free (UAF).
Technical Details
- Media Thread Write:
AudioRendererImpl::Initialize()runs on the media task runner and callsspeech_recognition_client_->SetOnReadyCallback(...). InChromeSpeechRecognitionClient::SetOnReadyCallback, the incoming callback is move-assigned to theon_ready_callback_member variable without any locking. - Main Thread Read/Execute:
ChromeSpeechRecognitionClient::OnRecognizerBound()is triggered as a Mojo reply callback and executes on the main thread. It checksif (on_ready_callback_)and then consumes the callback viastd::move(on_ready_callback_).Run(). - The Race Condition:
base::OnceCallbackencapsulates ascoped_refptr<internal::BindStateBase>. If the main thread attempts tostd::moveand run the callback at the exact same moment the media thread assigns a new callback to it, a data race occurs on thescoped_refptr's internal raw pointer (ptr_). - The UAF: Because the read/write of
ptr_is not atomic, thescoped_refptr's reference count can drop to zero on the media thread (causing theBindStateBaseto be deleted and freed), while the main thread still holds a dangling copy of the pointer. When the main thread subsequently attempts to invoke the callback, it dereferences this freed pointer to call thepolymorphic_invoke_function pointer.
Because scoped_refptr uses RAW_PTR_EXCLUSION for its internal pointer, this object is not protected by MiraclePtr (BackupRefPtr). Exploitation of this UAF allows direct control over an instruction pointer.
Potential Trigger Steps
Note: These are suggested steps; our tooling agent does not have the ability to run or verify arbitrary code execution.
- An attacker hosts a webpage containing an
<audio>or<video>element with multiple audio tracks. - The user visits the page with Live Caption or Speech Recognition enabled.
- The attacker's JavaScript initiates a tight loop that rapidly toggles the active audio track (e.g.,
audioTracks[0].enabled = falsethentrue). - Each track change forces
RendererImpl::ReinitializeAudioRenderer, scheduling a newAudioRendererImpl::Initialize()call on the media thread, which repeatedly overwriteson_ready_callback_. - Simultaneously, the browser process replies to the
BindRecognizerMojo request, schedulingOnRecognizerBoundon the main thread. - The attacker synchronizes the track toggling such that the callback assignment on the media thread collides with the callback execution on the main thread.
- The attacker utilizes JavaScript heap spraying to reclaim the freed
BindStateBasememory region and populate it with a fake object and a controlledpolymorphic_invoke_pointer, hijacking control flow when the main thread executes the callback.
Suggested Fix
Access to on_ready_callback_ must be synchronized. A straightforward fix is to introduce a base::Lock (or reuse the existing is_recognizer_bound_lock_) to protect all reads, writes, and moves of on_ready_callback_.
For example, in OnRecognizerBound:
SpeechRecognitionClient::OnReadyCallback callback_to_run;
{
base::AutoLock auto_lock(is_recognizer_bound_lock_);
is_recognizer_bound_ = true;
callback_to_run = std::move(on_ready_callback_);
}
is_multichannel_supported_ = is_multichannel_supported;
if (callback_to_run)
std::move(callback_to_run).Run();
And similarly wrap the assignment in SetOnReadyCallback within the same lock.
Evaluated with Chrome root at commit: 096fc8fdbfacf2546485756d03f160a3d04fcc9b
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
The on_ready_callback_ member is written on the media thread and read/moved on the main thread without any synchronisation, so the reference-counted pointer inside it is raced.
Impact
Exploitation could allow renderer remote code execution, though the report notes the trigger steps were not run or verified.
What the attacker needed
Victim visits attacker page; Live Caption or Speech Recognition enabled; precise timing of track toggling
The fix
Access to the callback should be protected by a lock covering all reads, writes and moves, as the report's suggested patch does.
How it was found
- Host a page with a media element that has multiple audio tracks.
- Get the victim to open it with Live Caption or Speech Recognition enabled.
- Use JavaScript to rapidly toggle the active audio track in a tight loop.
- Each toggle reinitialises the audio renderer and overwrites the callback on the media thread.
- Time the toggling so the overwrite collides with the main-thread callback execution.
- Heap-spray to reclaim the freed object and hijack control flow.
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 callback is a stored function that gets run later. Here two threads (separate streams of work inside the browser) touch the same stored callback at the same time without a lock, so one can delete it while the other is still about to use it. Using memory after it has been freed lets an attacker try to put their own data there and steer the program.
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.