Use after free in Cast Receiver (CVE-2026-13898)
A data race in the Cast Receiver component allows a worker thread to read a URL rewrite rules provider pointer after the main thread has freed it, leading to a use-after-free. The report claims this can be turned into an arbitrary atomic increment primitive in the renderer process, potentially leading to remote code execution.
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 without the Chrome Security team.
Overview: A data race exists in ContentRendererClientMixinsImpl where url_rewrite_rules_providers_ is accessed across threads without synchronization. Concurrent modification on the main thread and read from a worker thread leads to a Use-After-Free. This can be leveraged into an arbitrary atomic increment primitive in the renderer process.
Affected files:
components/cast_receiver/renderer/content_renderer_client_mixins_impl.cccomponents/cast_receiver/renderer/content_renderer_client_mixins_impl.hcomponents/cast_receiver/renderer/wrapping_url_loader_throttle_provider.cc
Estimated timestamp from git blame: 2023-11-07
Technical Details
A potential Use-After-Free (UAF) and data race vulnerability exists in the cast_receiver component, specifically in cast_receiver::ContentRendererClientMixinsImpl. This component manages URL rewrite rules for different frames using a base::flat_map<blink::LocalFrameToken, std::unique_ptr<UrlRewriteRulesProvider>> named url_rewrite_rules_providers_.
The url_rewrite_rules_providers_ map is modified on the renderer's main thread during frame creation (RenderFrameCreated calls emplace()) and destruction (OnRenderFrameRemoved calls erase()).
However, the map is read via GetUrlRewriteRulesProvider() which is called by WrappingURLLoaderThrottleProvider::CreateThrottles(). This method can execute on worker threads (for dedicated/shared worker subresource fetches) or background threads (when BackgroundResourceFetch is enabled). There is no locking mechanism protecting url_rewrite_rules_providers_ in ContentRendererClientMixinsImpl.
Potential Exploitation Steps
While we do not have a working Proof of Concept, code analysis suggests an attacker could exploit this via the following steps:
- Frame Setup: The attacker's webpage on the main thread creates a subframe (iframe).
- Worker Setup: The page spawns a Web Worker that will initiate subresource fetches.
- Fetch & Map Read: The worker thread executes a fetch. During throttle creation,
WrappingURLLoaderThrottleProvider::CreateThrottlescallsclient_->GetUrlRewriteRulesProvider(...). This performs a binary search on theflat_mapand returns a raw pointer to theUrlRewriteRulesProvider. This pointer is stored in a local stack variableprovider. - Race Condition: A context switch occurs back to the main thread. The attacker's script removes the subframe created in step 1.
- Destruction: Frame removal triggers
OnRenderFrameRemovedon the main thread, which callserase()on the map. Becausebase::flat_mapis backed by astd::vector, this shifts elements and destroys thestd::unique_ptrholding theUrlRewriteRulesProvider, freeing the object in the heap. - Heap Spray: The attacker sprays the heap from the main thread or another worker, reclaiming the freed memory with attacker-controlled data designed to mimic a
UrlRewriteRulesProviderobject. - Use-After-Free: Context switches back to the worker thread. The worker thread executes
auto rules = provider->GetCachedRules();using the now-danglingproviderpointer. - Atomic Increment:
GetCachedRules()internally reads ascoped_refptrfrom the attacker-controlled memory and returns it by value. Returning by value invokes the copy constructor, which callsAddRef()on the attacker-provided pointer. Because the target object inherits frombase::RefCountedThreadSafe, this provides the attacker with a highly reliable arbitrary atomic increment primitive.
This primitive can be used to corrupt reference counts of other objects, leading to further memory corruption and ultimately Remote Code Execution (RCE) in the sandboxed renderer process.
Note: MiraclePtr (BackupRefPtr) does not mitigate this specific UAF because the dangling provider pointer is held as a stack-local raw pointer rather than a class member.
Affected Files
components/cast_receiver/renderer/content_renderer_client_mixins_impl.hcomponents/cast_receiver/renderer/content_renderer_client_mixins_impl.cccomponents/cast_receiver/renderer/wrapping_url_loader_throttle_provider.cc
Suggested Fix
- Introduce a
base::LockinContentRendererClientMixinsImplto protect all accesses (reads and writes) tourl_rewrite_rules_providers_. - Instead of returning a raw pointer from
GetUrlRewriteRulesProvider(), the map should storescoped_refptr<url_rewrite::UrlRequestRewriteRules>directly, orGetUrlRewriteRulesProvider()should return thescoped_refptrby value while holding the lock. This ensures the rules stay alive for the duration of the worker thread's usage, even if the frame is destroyed.
Evaluated with Chrome root at commit: 096fc8fdbfacf2546485756d03f160a3d04fcc9b
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
The map of URL rewrite rules providers is accessed from multiple threads without any locking, so a worker thread can read a pointer to an object that the main thread has already erased and freed.
Impact
This could lead to further memory corruption and ultimately remote code execution in the sandboxed renderer process, though no working proof of concept is provided.
What the attacker needed
Victim visits attacker's webpage; browser runs Cast Receiver component; worker threads enabled
The fix
The map should be protected by a lock, and the provider should be returned as a reference-counted pointer by value so it stays alive during worker thread usage.
How it was found
- The attacker's webpage creates a subframe (iframe) on the main thread.
- The page spawns a Web Worker that will initiate subresource fetches.
- The worker thread executes a fetch, and during throttle creation it calls GetUrlRewriteRulesProvider, which returns a raw pointer to the provider.
- A context switch occurs back to the main thread, and the attacker's script removes the subframe.
- Frame removal triggers OnRenderFrameRemoved, which erases the map entry and frees the provider object.
- The attacker sprays the heap to reclaim the freed memory with controlled data, then the worker thread uses the dangling pointer to call GetCachedRules, causing an atomic increment on attacker-controlled memory.
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 pointer to memory after that memory has been freed, and then uses it again. Here, a background thread reads a pointer to an object that the main thread has already deleted, so the background thread ends up using memory that may now contain attacker-controlled data. This can let an attacker corrupt memory and possibly 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.