Use after free in Media (CVE-2026-7352)
A use-after-free race condition exists in Android's MediaDrmBridge due to unsynchronised access to a native pointer field. An attacker who compromises a renderer process could potentially exploit this to achieve remote code execution in the GPU process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 27 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 potential Use-After-Free (UAF) vulnerability exists in MediaDrmBridge on Android due to missing synchronization on the mNativeMediaDrmBridge field. Mismatched threading between Chrome's dedicated media thread and Android's MediaDrm callbacks allows the GPU main thread to invoke JNI methods using a dangling pointer, potentially leading to Remote Code Execution (RCE) in the GPU process.
Affected files:
media/base/android/java/src/org/chromium/media/MediaDrmBridge.javamedia/base/android/media_drm_bridge.ccmedia/base/android/media_drm_bridge.h
Estimated timestamp from git blame: 2024-05-28
Description
A potential Use-After-Free (UAF) race condition exists in the Android MediaDrmBridge implementation. On Android, Chrome's GPU process creates the MediaDrmBridge on a dedicated base::ThreadPool task runner. Because this native thread lacks a Java Looper, Android's MediaDrm listener APIs (e.g., OnKeyStatusChangeListener) fall back to dispatching callbacks on the application's Main Looper, which corresponds to the GPU Main Thread.
When the DRM session is destroyed, the C++ MediaDrmBridge is deleted on the ThreadPool thread, which calls into Java's MediaDrmBridge.destroy() to set mNativeMediaDrmBridge = 0. However, the mNativeMediaDrmBridge field is a primitive long and is accessed without volatile or synchronized modifiers.
If a DRM callback fires concurrently on the GPU Main Thread, it reads the stale, non-zero mNativeMediaDrmBridge pointer. Due to the lack of synchronization, this introduces a Time-of-Check to Time-of-Use (TOCTOU) and data visibility race. The GPU Main Thread then passes the dangling pointer back to C++ via JNI. The C++ code (e.g., MediaDrmBridge::OnSessionKeysChange) attempts to access members of the freed object (like task_runner_->PostTask), leading to a virtual call on a freed object.
Potential Attacker Steps
Note: Our tooling agent does not have the ability to run code, so these are suggested steps based on static analysis.
- Setup: An attacker compromises a Renderer process and sends a Mojo IPC request to the GPU process to create a Widevine DRM session.
- Heap Grooming: The attacker uses GPU IPCs (e.g., WebGL/WebGPU) to groom the GPU process heap, preparing to reclaim the memory block of the
MediaDrmBridgeonce freed. - Trigger: The attacker triggers an asynchronous DRM event (such as a key status change) via the DRM session.
- Race: Concurrently, the attacker drops the Mojo connection to the
MediaService, initiating the teardown of theMediaDrmBridgeon the ThreadPool thread. - UAF Execution: The ThreadPool thread frees the C++ object and clears the Java pointer. Simultaneously, the GPU Main Thread processes the DRM callback, reads the stale native pointer due to the missing synchronization, and calls into C++.
- RCE: The JNI invocation lands in
MediaDrmBridge::OnSessionKeysChangeon the freed object. The attacker-controlled reclaimed memory allows them to hijack the virtual method calltask_runner_->PostTask(), achieving Remote Code Execution in the GPU process.
Suggested Fix
- Java-Side Synchronization: Implement
synchronizedblocks around all accesses tomNativeMediaDrmBridge(similar to howMediaCodecBridgehandlesmNativeMediaCodecBridge). This ensures the pointer check and JNI invocation are atomic relative todestroy(). - C++ Side WeakPtr: Consider changing the JNI architecture to pass an ID or handle that can be safely resolved on the C++ side using a thread-safe mechanism, or pass a raw pointer to an object that strictly vends
base::WeakPtrs, rather than passing a raw pointer to theMediaDrmBridgeitself.
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 the missing synchronization (no volatile or synchronized) on the mNativeMediaDrmBridge field allows a stale pointer to be read and used after the native object is freed.
Impact
A compromised renderer could potentially achieve remote code execution in the GPU process, though this is a suggested scenario from static analysis and not yet confirmed.
What the attacker needed
Compromised renderer process; ability to send Mojo IPC to GPU process; ability to trigger DRM events
The fix
The issue should be fixed by adding synchronized blocks around all accesses to mNativeMediaDrmBridge and considering a C++ WeakPtr-based design.
How it was found
- Compromise a renderer process and send a Mojo IPC to create a Widevine DRM session.
- Use GPU IPCs to groom the GPU process heap for reclaiming the freed object.
- Trigger an asynchronous DRM event such as a key status change.
- Concurrently drop the Mojo connection to initiate teardown of the MediaDrmBridge.
- The ThreadPool thread frees the object and clears the Java pointer while the GPU main thread reads the stale pointer and calls into C++.
- The JNI call lands on the freed object, allowing hijack of a virtual method call for remote code execution.
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 then keeps using a pointer to that memory. Here, a pointer to a native object is read without proper locking, so a callback can use it after the object is destroyed. This could let an attacker who already controls one part of the browser run code in another, more privileged part.
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.