Skip to content
Memory corruption Advisory Advanced CVE-2026-87578

Use after free in Receiver (CVE-2026-87578)

A use-after-free was identified in CastMessagePortImpl::MaybeClose, where calling the client error callback can synchronously tear down and delete the object, after which the code still reads and runs its on_close_ closure. An attacker controlling a renderer could close the Mojo pipe to trigger this and potentially hijack the instruction pointer in the browser process.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 3 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 CastMessagePortImpl::MaybeClose in the browser process. Calling client_->OnError can trigger a synchronous destruction cascade that deletes the CastMessagePortImpl instance. The code subsequently continues to execute and evaluate the on_close_ callback from the freed memory of the deleted instance.

Affected files:

  • components/cast_streaming/browser/cast_message_port_impl.cc
  • components/cast_streaming/browser/cast_message_port_impl.h

Estimated timestamp from git blame: 2020-12-04

Description

A potential Use-After-Free (UAF) vulnerability has been identified in CastMessagePortImpl::MaybeClose() within components/cast_streaming/browser/cast_message_port_impl.cc. Under specific conditions, invoking the error callback on client_ initiates a synchronous teardown sequence on the same call stack. This sequence results in the deletion of the CastMessagePortImpl instance. When the execution unwinds back to the caller frame, the method attempts to read and execute the in-object on_close_ closure member variable on the already-freed this pointer.

Because on_close_ is a base::OnceClosure (which wraps a reference-counted BindStateBase pointer) rather than a raw_ptr, MiraclePtr (BackupRefPtr) does not protect against or mitigate this memory safety violation.

Potential Step-by-Step Sequence

(Note: These are potential steps identified through static code analysis; we do not currently have a running proof-of-concept exploit.)

  1. During the initial connection handshake phase when is_initialized_ is still false, a connection error or channel closure is encountered on the MessagePort channel (for example, if a compromised Renderer process abruptly closes the Mojo IPC pipe of the MessagePort).
  2. This triggers CastMessagePortImpl::OnPipeError(), which synchronously calls CastMessagePortImpl::MaybeClose().
  3. Inside MaybeClose(), client_->OnError() is called on line 104 with kCastV2CastSocketError.
  4. client_ (a ReceiverSessionMessenger instance) synchronously executes ReportError(), propagating the error to the registered Open Screen callback lambda, which synchronously calls ReceiverSessionClient::OnError().
  5. Because initialization is not yet complete (is_initialized_ == false), OnError() synchronously calls EndSession(), which triggers a sequence of termination events:
    • ReceiverSessionImpl::OnSessionEnded()
    • StreamingReceiverSessionClient::OnStreamingSessionEnded()
    • StreamingRuntimeApplication::OnError()
    • StreamingRuntimeApplication::StopApplication()
  6. Inside StopApplication(), receiver_session_client_.reset() is called. This triggers a synchronous destruction cascade of all owned components, including StreamingReceiverSessionClient, ReceiverSessionImpl, CastStreamingSession, and eventually CastMessagePortImpl (this is deallocated).
  7. The execution flow unwinds back to CastMessagePortImpl::MaybeClose() (line 107) and evaluates if (on_close_). Since this has been deleted, it performs a Use-After-Free read and subsequently calls std::move(on_close_).Run() on line 110, allowing a potential instruction pointer hijack in the unsandboxed Browser process.

Proposed Remediation

To prevent this vulnerability, use a base::WeakPtr to check for the instance's liveness before accessing any member variables or running callbacks after client_->OnError() is called.

Add a base::WeakPtrFactory<CastMessagePortImpl> weak_factory_{this}; to CastMessagePortImpl and update MaybeClose to:

C++
void CastMessagePortImpl::MaybeClose() {
  base::WeakPtr<CastMessagePortImpl> weak_this = weak_factory_.GetWeakPtr();
  if (message_port_) {
    message_port_.reset();
  }
  if (client_) {
    client_->OnError(
        openscreen::Error(openscreen::Error::Code::kCastV2CastSocketError));
  }
  if (weak_this && weak_this->on_close_) {
    std::move(weak_this->on_close_).Run();
  }
}

Evaluated with Chrome root at commit: b1520ef4a76878853a31f0943b565e42060edec8


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.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 error callback runs synchronously and destroys the object, but the method does not check that the instance is still alive before touching its members.

Impact

A compromised renderer could potentially hijack the instruction pointer in the unsandboxed browser process, though no working exploit was demonstrated.

What the attacker needed

Compromised renderer; error during initial handshake

The fix

It should be fixed by holding a weak pointer and checking liveness before accessing members or running callbacks after the error callback.

How it was found

  1. A connection error or channel closure occurs on the MessagePort while the object is not yet initialised.
  2. OnPipeError synchronously calls MaybeClose.
  3. MaybeClose calls the client error callback.
  4. The error propagates and, since initialisation is incomplete, EndSession runs and tears down the session.
  5. StopApplication resets the session client, destroying CastMessagePortImpl.
  6. Execution returns to MaybeClose, which reads and runs on_close_ on the freed object.

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.

When a program frees an object but keeps using it, that is a use-after-free. Here, reporting an error causes the object to be destroyed while the same function is still running, so it then reads memory that no longer belongs to it. Because this happens in the browser process, which has more privileges, an attacker might be able to take control of 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.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.