Use after free in Chromecast (CVE-2026-130943)
JavaScript bindings exposed through the cast.__platform__ object used an unretained pointer to their owning C++ object, so a same-origin parent frame could keep a bound function alive after the subframe was removed. Invoking that stashed function after heap spraying could dereference attacker-controlled memory and potentially achieve code execution in the renderer.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 6 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. 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 vulnerability exists in the Chromecast renderer where JavaScript bindings for cast.__platform__ features use base::Unretained(this) for callbacks. These bindings can outlive their owning CastBinding object if a reference is kept by a same-origin parent frame. Removing the subframe synchronously destroys the CastBinding object, leaving a dangling pointer that can lead to remote code execution.
Affected files:
chromecast/renderer/native_bindings_helper.hchromecast/renderer/native_bindings_helper.ccchromecast/renderer/cast_window_manager_bindings.ccchromecast/renderer/cast_demo_bindings.ccchromecast/renderer/settings_ui_bindings.ccchromecast/renderer/assistant_bindings.ccchromecast/renderer/feature_manager.cc
Estimated timestamp from git blame: 2021-10-12
Description
The Chromecast renderer exposes C++ functionality to JavaScript via the cast.__platform__ object using CastBinding subclasses (e.g., CastWindowManagerBindings, CastDemoBindings, SettingsUiBindings, AssistantBindings). These bindings are created in InstallBinding (chromecast/renderer/native_bindings_helper.h) using gin::CreateFunctionTemplate and bind C++ methods using base::Unretained(this).
Root Cause Analysis
CastBinding inherits from content::RenderFrameObserver and manages its own lifetime by synchronously calling delete this; during OnDestruct() when the associated RenderFrame is detached.
However, the V8 gin::CallbackHolder created by InstallBinding is kept alive by V8 as long as the generated JavaScript function remains reachable. If a same-origin parent frame stashes a reference to a subframe's bound function, the V8 function outlives the CastBinding object. When the subframe is removed from the DOM, the CastBinding object is destroyed, leaving the base::Unretained(this) pointer inside the gin::CallbackHolder dangling.
Exploitation Vector
BackupRefPtr (MiraclePtr) is explicitly disabled by default in Chromecast renderer processes (both on CastOS and Android). Because the memory is not quarantined, an attacker can reliably spray the heap to reclaim the freed CastBinding object's memory slot with controlled data.
When the stashed JavaScript function is subsequently invoked, methods like CastWindowManagerBindings::SetCanGoBack are executed on the attacker-controlled memory block. This method reads the render_frame_ pointer from this and invokes a virtual method (render_frame()->GetBrowserInterfaceBroker()), leading to a classic vtable hijack and potential Remote Code Execution (RCE) within the sandboxed renderer.
Potential Reproduction Steps
Please note: These are suggested/potential steps based on source code analysis. Our tooling agent does not currently have the ability to run code or provide a working proof of concept.
- Load a Cast application with affected features enabled in its configuration (e.g.,
system_gestures). - From the main frame, create a same-origin
<iframe>and append it to the DOM. - Stash a reference to one of the iframe's bound functions from the parent frame. For example:
let stashed_func = iframe.contentWindow.cast.__platform__.windowManager.canGoBack; - Remove the iframe using
iframe.remove();. This triggers synchronous frame detachment, invokingCastBinding::OnDestruct()and freeing the bindings object. - Execute a heap grooming/spraying payload to reclaim the freed memory with a forged object containing a forged
render_frame_pointer and a forged vtable. - Invoke the stashed function:
stashed_func(true);. - The C++ callback executes on the reclaimed memory, dereferences the forged vtable during the
GetBrowserInterfaceBroker()call, and hijacks the instruction pointer.
Suggested Fix
Do not use base::Unretained(this) when exposing C++ methods to JavaScript via gin::CreateFunctionTemplate.
Modify CastBinding and its subclasses to use base::WeakPtrFactory. Update the InstallBinding template to accept and bind base::WeakPtr instead of base::Unretained. Alternatively, integrate the bindings with gin::Wrappable to ensure the object's lifetime is properly managed and synchronized with the V8 garbage collector.
Evaluated with Chrome root at commit: eca8648a4e1cdfdda68c495a6003059fed641955
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 bindings passed base::Unretained(this) into V8 callbacks while the owning CastBinding deleted itself synchronously on frame detachment, so a JavaScript reference could outlive the C++ object.
Impact
Because pointer protection is disabled in Chromecast renderer processes, an attacker could reliably reclaim the freed object and potentially hijack execution within the sandboxed renderer, though the report is based on source analysis without a working proof of concept.
What the attacker needed
Cast app with affected features enabled; same-origin iframe; ability to run script in the parent frame
The fix
The bindings should use base::WeakPtrFactory and bind weak pointers instead of base::Unretained, or be integrated with gin::Wrappable so their lifetime follows the garbage collector.
How it was found
- Load a Cast application with the affected features enabled.
- Create a same-origin iframe from the main frame and add it to the page.
- Keep a reference to one of the iframe's bound functions in the parent frame.
- Remove the iframe, which synchronously destroys the bindings object.
- Spray the heap to reclaim the freed memory with a forged object and vtable.
- Call the stashed function so the callback runs on the reclaimed 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 web page can hold on to a function that belongs to a smaller embedded page (an iframe) even after that iframe is deleted. The browser code behind the function was freed at the same moment, so calling it later touches memory that no longer belongs to it. If an attacker fills that freed memory with their own data, the browser may follow their instructions instead of the original ones.
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.