Use after free in Media (CVE-2026-8549)
A cross-thread data race in MediaFoundationStreamWrapper allows a Media Foundation threadpool thread to access a raw pointer to a demuxer stream while the media thread concurrently nulls it during teardown, bypassing BackupRefPtr protections. This could lead to a use-after-free and potential remote code execution in the MediaFoundationCdm utility process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 43 days
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: A cross-thread data race exists in MediaFoundationStreamWrapper where a Media Foundation threadpool thread can access the demuxer_stream_ raw_ptr while the media thread concurrently nulls it during teardown. This can bypass BackupRefPtr protections and lead to a Use-After-Free and potential Remote Code Execution in the MediaFoundationCdm utility process.
Affected files:
media/renderers/win/media_foundation_stream_wrapper.hmedia/renderers/win/media_foundation_stream_wrapper.ccmedia/renderers/win/media_foundation_audio_stream.ccmedia/renderers/win/media_foundation_video_stream.ccmedia/renderers/win/media_foundation_source_wrapper.ccmedia/renderers/win/media_foundation_renderer.ccmedia/mojo/services/mojo_renderer_service.h
Estimated timestamp from git blame: 2021-11-27
Description
A potential cross-thread data race and Use-After-Free (UAF) vulnerability exists in the Media Foundation rendering pipeline in Chrome for Windows. The vulnerability is caused by a lack of synchronization when accessing demuxer_stream_ (a raw_ptr<DemuxerStream>) in MediaFoundationStreamWrapper. It is accessed by both the Chromium media thread during teardown and a Media Foundation threadpool thread during media playback validation.
Technical Details
-
Data Race on
demuxer_stream_: InMediaFoundationStreamWrapper, the memberdemuxer_stream_is not protected by a lock when accessed or modified in certain paths.- MF Threadpool: The Media Foundation framework invokes
IMFTrustedInput::GetInputTrustAuthority()on an internal threadpool thread. This callsIsEncrypted(), which dereferencesdemuxer_stream_to call virtual methods likeaudio_decoder_config()(media_foundation_audio_stream.cc:64). - Media Thread: During renderer shutdown,
MediaFoundationStreamWrapper::DetachDemuxerStream()nulls thedemuxer_stream_pointer (media_foundation_stream_wrapper.cc:130). This happens without acquiringlock_.
- MF Threadpool: The Media Foundation framework invokes
-
BackupRefPtr (BRP) Bypass & UAF: In
MojoRendererService(mojo_renderer_service.h),renderer_is declared aftermedia_resource_. Due to C++ destruction rules,renderer_is destroyed first.- As
renderer_shuts down, it callsDetachDemuxerStream(), which nulls theraw_ptr, dropping its BRP refcount to zero. - If the MF thread extracts the underlying raw pointer via
operator->just before the media thread nulls it, the MF thread holds a dangling raw pointer. - After
renderer_is destroyed,MojoRendererServicedestroysmedia_resource_, which frees the underlyingMojoDemuxerStreamAdapter. Because theraw_ptrwas already nulled, PartitionAlloc does not quarantine the memory. - The MF thread then uses its extracted raw pointer to make a virtual call (
audio_decoder_config()), hitting the freed memory.
- As
Potential Attack Steps
(Note: These are suggested steps based on code analysis; a working exploit has not been fully verified.)
- An attacker serves a page with a
<video>element using Encrypted Media Extensions (EME) to select the hardware-secure Media Foundation renderer. - As the protected media pipeline sets up, the Media Foundation threadpool repeatedly invokes
GetInputTrustAuthority(). - The attacker rapidly triggers a renderer teardown (e.g., by navigating away or removing the video element) to initiate a race between the media thread's shutdown sequence and the concurrent MF threadpool activity.
- The MF thread reads the raw pointer from
demuxer_stream_but is preempted before making the virtual call. - The media thread nulls
demuxer_stream_and frees the underlyingMojoDemuxerStreamAdapter. - The attacker shapes the heap in the utility process via concurrent Mojo IPCs to replace the freed memory with a fake object and vtable.
- The MF thread resumes, dereferences the dangling pointer, and calls the forged vtable, leading to RCE in the sandboxed
MediaFoundationCdmutility process.
Suggested Fix
- Protect
demuxer_stream_access withlock_insideMediaFoundationStreamWrapper(e.g., inDetachDemuxerStream()andIsEncrypted()). - Ensure that any accesses to the demuxer stream on the MF thread either hold the lock for the duration of the call or that the MF threadpool is guaranteed to be fully drained/joined before the stream is detached and the underlying resource is destroyed.
Evaluated with Chrome root at commit: a9cbf6e8b275fe4147435aa905f3b7f5a656f5f0
Results from 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 missing lock around the demuxer_stream_ pointer, allowing concurrent access and modification without synchronisation.
Impact
Could lead to remote code execution in the sandboxed MediaFoundationCdm utility process, though a working exploit has not been fully verified.
What the attacker needed
Victim visits attacker page; browser supports EME and Media Foundation; Windows OS
The fix
Should be fixed by protecting demuxer_stream_ access with lock_ and ensuring the MF threadpool is drained before detaching the stream.
How it was found
- An attacker serves a page with a video element using Encrypted Media Extensions to select the hardware-secure Media Foundation renderer.
- The Media Foundation threadpool repeatedly invokes GetInputTrustAuthority during pipeline setup.
- The attacker rapidly triggers renderer teardown to race the media thread's shutdown with the MF threadpool activity.
- The MF thread reads the raw pointer but is preempted before making a virtual call.
- The media thread nulls the pointer and frees the underlying object.
- The attacker shapes the heap to replace the freed memory with a fake object and vtable, then the MF thread resumes and calls the forged 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 frees memory but keeps using it, like deleting a file and then trying to open it. Here, two threads (independent parts of the program) race: one frees a pointer while the other still uses it, which can let an attacker take control. The report suggests this could allow running malicious code inside a sandboxed helper process.
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.