Use after free in Chromecast (CVE-2026-95372)
A use-after-free vulnerability exists in Chromecast's BackendDecryptor because the callback member is destroyed before the vendor-owned decryptor. If a vendor decryptor notifies its delegate during destruction, it invokes the already-freed callback, potentially leading to memory corruption or control flow hijacking.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 2 months
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. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A potential Use-After-Free (UAF) vulnerability exists in BackendDecryptor because the callback member decrypt_cb_ is declared after the vendor-owned decryptor_ member. Consequently, decrypt_cb_ is destroyed first, so any delegate notification triggered during the vendor decryptor's destruction will invoke the already-destructed callback.
Affected files:
chromecast/media/cma/pipeline/backend_decryptor.hchromecast/media/cma/pipeline/backend_decryptor.cc
Estimated timestamp from git blame: 2018-02-12
Summary
In BackendDecryptor (chromecast/media/cma/pipeline/backend_decryptor.h), the member declaration order causes decrypt_cb_ to be destroyed before the vendor-owned decryptor_ object. If a platform-specific, out-of-tree AudioDecryptor implementation notifies its delegate of aborted operations during its destructor, it calls into the partially-destroyed BackendDecryptor and invokes the freed callback, resulting in a Use-After-Free (UAF) vulnerability on the media thread in the unsandboxed browser process.
Root Cause Analysis
In chromecast/media/cma/pipeline/backend_decryptor.h (lines 49-52):
std::unique_ptr<TaskRunnerImpl> task_runner_;
std::unique_ptr<MediaPipelineBackend::AudioDecryptor> decryptor_;
DecryptCB decrypt_cb_;
Because decrypt_cb_ is declared after decryptor_, the compiler-generated default destructor destroys decrypt_cb_ first.
Next, the destructor of std::unique_ptr<MediaPipelineBackend::AudioDecryptor> decryptor_ runs. The AudioDecryptor contract (chromecast/public/media/media_pipeline_backend.h, line 309) states:
Aborts all the pending operations once the object is deleted.
If an OEM/vendor implementation of AudioDecryptor implements this by notifying the delegate of failure for outstanding pending buffers (e.g., via delegate_->OnPushBufferForDecryptComplete(kBufferFailed)), it calls back into BackendDecryptor after decrypt_cb_ has already been destructed.
In BackendDecryptor::OnPushBufferForDecryptComplete (chromecast/media/cma/pipeline/backend_decryptor.cc, line 57-68):
void BackendDecryptor::OnPushBufferForDecryptComplete(
MediaPipelineBackend::BufferStatus status) {
if (wait_eos_)
return;
DCHECK(decrypt_cb_);
decrypt_cb_.Run(
decrypt_success_ && status == MediaPipelineBackend::kBufferSuccess,
std::move(ready_buffers_));
}
Calling decrypt_cb_.Run() after decrypt_cb_ is destructed triggers a Use-After-Free of its underlying base::internal::BindStateBase object.
Potential Attack Scenario
Since we do not currently have a working proof of concept successfully executed (due to our tooling constraints and the platform-specific nature of the vendor shlib), the following steps outline a potential path an attacker might follow to trigger this vulnerability:
- A compromised renderer initiates an encrypted audio stream playback via Mojo, causing the browser to allocate a
BackendDecryptorand a platform-specificAudioDecryptor. - The renderer pushes an encrypted media buffer. The vendor
AudioDecryptoraccepts it and returnskBufferPending. - The renderer sends a
Flushcommand (or closes the connection), leading toAvPipelineImpl::Flush()which callsdecryptor_.reset()(chromecast/media/cma/pipeline/av_pipeline_impl.cc, line 137). - During destruction of
BackendDecryptor,decrypt_cb_is destroyed, freeing its ref-countedBindStateBasecontainer on the heap. - The vendor's
~AudioDecryptordestructor runs and callsdelegate_->OnPushBufferForDecryptComplete(kBufferFailed)synchronously. BackendDecryptor::OnPushBufferForDecryptCompleteis invoked and callsdecrypt_cb_.Run(). This dereferences the dangling pointer to the freedBindStateBase, resulting in memory corruption or control flow hijacking.
Suggested Fix
To resolve this issue, the declaration order of the class members in BackendDecryptor should be modified so that decrypt_cb_ is declared before decryptor_ (and is thus destroyed after it). Additionally, we should explicitly clear the delegate reference in the destructor before destroying members:
// In chromecast/media/cma/pipeline/backend_decryptor.cc:
BackendDecryptor::~BackendDecryptor() {
if (decryptor_) {
decryptor_->SetDelegate(nullptr);
}
}
Evaluated with Chrome root at commit: b5b015ea5f690560237d1f0cff1405844cd12b8d
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
The member declaration order causes the callback to be destroyed before the vendor decryptor, so if the decryptor's destructor notifies the delegate, it calls a freed callback.
Impact
A compromised renderer could trigger a use-after-free in the unsandboxed browser process, potentially leading to memory corruption or control flow hijacking, though no working proof of concept was executed.
What the attacker needed
Compromised renderer; vendor-specific AudioDecryptor implementation; encrypted audio stream playback
The fix
The fix is to declare decrypt_cb_ before decryptor_ so it is destroyed after, and to explicitly clear the delegate in the destructor.
How it was found
- A compromised renderer initiates an encrypted audio stream playback via Mojo, causing the browser to allocate a BackendDecryptor and a platform-specific AudioDecryptor.
- The renderer pushes an encrypted media buffer. The vendor AudioDecryptor accepts it and returns kBufferPending.
- The renderer sends a Flush command (or closes the connection), leading to AvPipelineImpl::Flush() which calls decryptor_.reset().
- During destruction of BackendDecryptor, decrypt_cb_ is destroyed, freeing its ref-counted BindStateBase container on the heap.
- The vendor's ~AudioDecryptor destructor runs and calls delegate_->OnPushBufferForDecryptComplete(kBufferFailed) synchronously.
- BackendDecryptor::OnPushBufferForDecryptComplete is invoked and calls decrypt_cb_.Run(). This dereferences the dangling pointer to the freed BindStateBase, resulting in memory corruption or control flow hijacking.
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 tries to use it again, which can let an attacker control what happens next. Here, a callback function is destroyed before another object that might call it, so if that object calls the callback during its own destruction, it uses freed memory. This could allow an attacker to crash the browser or potentially run malicious 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.