Use after free in Chromecast (CVE-2026-87588)
A data race exists in Chromecast's URL loader throttle provider where a background worker thread reads a map of raw pointers without synchronisation while the main thread deletes entries, leading to a use-after-free. An attacker could potentially exploit this to achieve arbitrary code execution in the renderer process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 6 months
Flapjack (go/flapjack), an LLM-powered static analysis tool, has identified the following potential security issue.
Overview: A critical thread-safety violation exists in CastURLLoaderThrottleProvider where a background worker thread accesses CastActivityUrlFilterManager::activity_url_filters_ (a base::flat_map) without synchronization. This map is concurrently modified on the main thread when RenderFrames are destroyed, causing a Data Race and a Use-After-Free. Because the map stores raw UrlFilterReceiver* pointers instead of raw_ptr, the resulting UAF bypasses MiraclePtr (BRP) and could allow an attacker to achieve Arbitrary Code Execution in the renderer process.
Affected files:
chromecast/renderer/cast_url_loader_throttle_provider.ccchromecast/renderer/cast_activity_url_filter_manager.ccchromecast/common/activity_filtering_url_loader_throttle.cc
Estimated timestamp from git blame: 2023-11-07
Description
A critical thread-safety vulnerability exists in the Chromecast renderer implementation, specifically within CastURLLoaderThrottleProvider and CastActivityUrlFilterManager. This flaw leads to a Data Race and a potential Use-After-Free (UAF) that bypasses MiraclePtr (BRP) protections, potentially allowing an attacker to achieve Arbitrary Code Execution (RCE) in the sandboxed renderer process.
The vulnerability stems from CastURLLoaderThrottleProvider::CreateThrottles being invoked on background worker threads (e.g., when a DedicatedWorker calls fetch()). Inside this method, it accesses cast_activity_url_filter_manager_->GetActivityUrlFilterForRenderFrameToken(). This method subsequently searches activity_url_filters_, which is a base::flat_map<blink::LocalFrameToken, UrlFilterReceiver*>.
However, CastActivityUrlFilterManager is a main-thread object, and its activity_url_filters_ map is modified exclusively on the main thread when RenderFrames are created or destroyed (via OnRenderFrameCreated and OnRenderFrameRemoved). Because there is no synchronization (such as a base::Lock) protecting this flat_map, a worker thread calling find() can race with the main thread executing erase().
Impact and BRP Bypass
The activity_url_filters_ map stores raw UrlFilterReceiver* pointers. When an iframe is removed, the UrlFilterReceiver::OnDestruct() method executes delete this; on the main thread, immediately freeing the memory before the map is erased.
Because the map uses a raw C++ pointer rather than raw_ptr<UrlFilterReceiver>, MiraclePtr (BRP) does not quarantine the allocation. A worker thread racing to call find() can retrieve this dangling, freed pointer. Dereferencing it to call it->second->GetUrlFilter() retrieves an attacker-controlled ActivityUrlFilter*, which is then used by the networking stack. When ActivityFilteringURLLoaderThrottle::FilterURL is called, it executes virtual methods on the attacker-controlled object, leading to RCE.
Potential Attack Scenario
Note: These are suggested steps; a working Proof of Concept has not yet been developed to verify this sequence end-to-end.
- Setup: An attacker hosts a malicious page loaded by the Chromecast browser. The page dynamically creates an
iframeelement. - Worker Creation: The iframe executes JavaScript to spawn a DedicatedWorker (
new Worker('worker.js')). The renderer initializes the worker'sURLLoaderThrottleProvideron the main thread, passing it a raw pointer to theCastActivityUrlFilterManager. - The Race:
- On the worker thread, the JavaScript initiates a network request (
fetch()), which invokesCastURLLoaderThrottleProvider::CreateThrottles. - Concurrently, on the main thread, the attacker removes the iframe from the DOM (
iframe.remove()).
- On the worker thread, the JavaScript initiates a network request (
- UAF Triggered: The iframe removal destroys the
RenderFrame, executingUrlFilterReceiver::OnDestruct(), which callsdelete this;and frees the receiver's memory. The worker thread'sfind()operation executes precisely at this moment, retrieving the dangling pointer from the unsynchronizedflat_map. - Exploitation: The attacker uses heap spraying on the main thread to reclaim the freed
UrlFilterReceivermemory with a forged object. The worker thread dereferences this fake object, retrieves a fakeActivityUrlFilter, and when the network request proceeds, the throttle executesurl_filter_->UrlMatchesWhitelist(url)on the attacker-controlled memory, hijacking the execution flow.
Suggested Fix
To resolve this vulnerability, the CastActivityUrlFilterManager must be made thread-safe for concurrent reads from worker threads.
- Add Synchronization: Introduce a
base::Lockorbase::ReadWriteLockwithinCastActivityUrlFilterManagerto protect all accesses (reads and writes) to theactivity_url_filters_map. - Use Smart Pointers: Change the map definition to store
std::unique_ptr<UrlFilterReceiver>orscoped_refptr<UrlFilterReceiver>to ensure the object remains alive while it is being accessed, or change it tobase::raw_ptr<UrlFilterReceiver>to enable MiraclePtr protections against the UAF.
Evaluated with Chrome root at commit: 9760e6c70cd33a320713361f17c6dcca85648c0f
Results from Flapjack so far have been promising, but it can be wrong in its deductions. At this time, it does not produce proof of concepts or fuzzer tests. If this proves to be a false positive, please close as WAI; data from false positives will be used to improve Flapjack’s 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 map of raw pointers is accessed from multiple threads without a lock, and the pointers are not protected by MiraclePtr, so a freed object can be dereferenced.
Impact
A worker thread racing to call find() can retrieve a dangling, freed pointer, and dereferencing it could allow an attacker to achieve arbitrary code execution in the renderer process.
What the attacker needed
Attacker hosts a malicious page; victim loads the page in Chromecast browser; page creates an iframe and a worker
The fix
The map should be protected with a lock and store smart pointers or raw_ptr to prevent use-after-free.
How it was found
- An attacker hosts a malicious page that creates an iframe.
- The iframe spawns a DedicatedWorker.
- The worker calls fetch(), invoking CreateThrottles on the worker thread.
- Concurrently, the attacker removes the iframe from the DOM, freeing the UrlFilterReceiver.
- The worker's find() retrieves the dangling pointer.
- The attacker uses heap spraying to reclaim the freed memory with a forged object, leading to 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 background thread and the main thread both access the same list of pointers without coordination. One thread can read a pointer just after the object it points to has been deleted, so it uses freed memory. This can let an attacker 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.