Use after free in Cast (CVE-2026-15902)
The cast_streaming component has two use-after-free flaws in how FrameInjectingDemuxer cleans up its pointer in DemuxerConnector. An attacker could potentially trigger a dangling pointer dereference, leading to memory corruption and possibly remote code execution in the renderer process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 37 days
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: The cast_streaming component contains two potential Use-After-Free (UAF) vulnerabilities involving DemuxerConnector. These occur because FrameInjectingDemuxer does not reliably clean up its raw pointer from the connector or uses base::Unretained, leading to dangling pointers that can be dereferenced during Mojo disconnect events or delayed tasks.
Affected files:
components/cast_streaming/renderer/frame/demuxer_connector.cccomponents/cast_streaming/renderer/frame/frame_injecting_demuxer.cc
Estimated timestamp from git blame: 2020-06-09
Two potential Use-After-Free (UAF) vulnerabilities exist in the cast_streaming component of Cast Receiver builds. They stem from improper lifecycle management of the FrameInjectingDemuxer object and its interaction with the DemuxerConnector.
Issue 1: Dangling Pointer via Bypassed Cleanup
DemuxerConnector (living on the renderer's main thread) stores a raw pointer to a FrameInjectingDemuxer in its demuxer_ member. The demuxer attempts to clean up this pointer in its destructor:
// components/cast_streaming/renderer/frame/frame_injecting_demuxer.cc
FrameInjectingDemuxer::~FrameInjectingDemuxer() {
if (was_initialization_successful_) {
original_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&DemuxerConnector::OnDemuxerDestroyed,
base::Unretained(demuxer_connector_)));
}
}
If the initialization of the demuxer is aborted before completion (e.g., the media element is destroyed), was_initialization_successful_ remains false. The cleanup task is silently skipped, leaving DemuxerConnector::demuxer_ as a dangling pointer.
Subsequently, if the Cast Streaming Mojo connection is dropped, DemuxerConnector::OnReceiverDisconnected runs:
// components/cast_streaming/renderer/frame/demuxer_connector.cc
void DemuxerConnector::OnReceiverDisconnected() {
// ...
if (demuxer_ && !is_demuxer_initialized_) {
OnStreamsInitialized(mojom::AudioStreamInitializationInfoPtr(),
mojom::VideoStreamInitializationInfoPtr());
}
}
Because the dangling pointer is non-null and initialization never completed, this calls OnStreamsInitialized, which executes demuxer_->OnStreamsInitialized(...), dereferencing the freed memory.
Potential Trigger Steps (Theoretical):
- A malicious Cast Receiver app sets a
<video>source to"data:cast_streaming_receiver". - Initialization begins, setting the
demuxer_pointer in theDemuxerConnector. - The attacker's JS abruptly removes the
<video>element, destroying the demuxer before initialization finishes. - The attacker disconnects the underlying Cast session (Mojo disconnect).
- The disconnection handler dereferences the dangling pointer.
Issue 2: UAF via Unretained Task
During initialization, FrameInjectingDemuxer::Initialize (on the media thread) posts a task back to the main thread to register itself:
original_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&DemuxerConnector::SetDemuxer,
base::Unretained(demuxer_connector_),
base::Unretained(this)));
If the demuxer is destroyed after this task is posted but before it executes on the main thread, DemuxerConnector::SetDemuxer will operate on a freed pointer. If a previous demuxer was already set, SetDemuxer immediately invokes a method on the freed pointer (demuxer->OnStreamsInitialized(...)).
Impact
These UAFs can potentially lead to Remote Code Execution (RCE) within the renderer process. By grooming the heap after the demuxer is freed but before the dangling pointer is dereferenced, an attacker could hijack virtual method calls or object members. While MiraclePtr (raw_ptr) mitigates these to crashes on supported platforms, it remains fully exploitable on platforms without it (such as older 32-bit Cast devices).
Suggested Fix
- Unconditional Cleanup: Remove the
if (was_initialization_successful_)check in~FrameInjectingDemuxer(). TheDemuxerConnectorshould always be notified when the demuxer is destroyed, regardless of initialization state. - Use Weak Pointers: Instead of
base::Unretained(this), the demuxer should use abase::WeakPtrwhen posting theSetDemuxertask to ensure the task is safely canceled if the object is destroyed.
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 demuxer's destructor skips notifying the connector when initialisation was not successful, and a posted task uses a raw pointer without a weak reference, leaving dangling pointers.
Impact
These UAFs could potentially lead to remote code execution in the renderer process, though MiraclePtr mitigates them to crashes on supported platforms and they remain fully exploitable on platforms without it.
What the attacker needed
Malicious Cast Receiver app; victim uses Cast Receiver build
The fix
The fix should remove the conditional check so cleanup always runs, and use weak pointers instead of raw pointers for posted tasks.
How it was found
- A malicious Cast Receiver app sets a video source to a special data URL.
- Initialization begins, setting the demuxer pointer in the connector.
- The attacker's JavaScript abruptly removes the video element, destroying the demuxer before initialization finishes.
- The attacker disconnects the underlying Cast session.
- The disconnection handler dereferences the dangling pointer.
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 reference to an object after it has been deleted, then later tries to use it. Here, the code fails to tell a connector that a demuxer object is gone, so the connector later calls a method on freed memory. This can crash the program or, with careful memory manipulation, let an attacker 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.