Use after free in Input (CVE-2026-17719)
A base::WeakPtr created on the main thread is evaluated on the compositor thread in WidgetInputHandlerManager, and in release builds the sequence check is compiled out, so a TOCTOU race during destruction can leave the compositor thread using freed memory. The text claims an attacker could heap-spray the freed object and potentially achieve code execution in the renderer sandbox, though it states the tooling cannot run code and the path is theoretical.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 50 days
Flapjack, 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 data race exists in WidgetInputHandlerManager when a base::WeakPtr bound on the main thread is evaluated on the compositor thread. In release builds, this bypasses sequence validation and creates a Time-of-Check to Time-of-Use (TOCTOU) race condition during object destruction, leading to a potential Use-After-Free (UAF) that is not protected by MiraclePtr.
Affected files:
third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.cc
Estimated timestamp from git blame: 2025-06-25
Description
A potential Use-After-Free (UAF) vulnerability exists in WidgetInputHandlerManager due to the unsafe cross-thread usage of base::WeakPtr. WidgetInputHandlerManager manages input handling between the main thread and the compositor thread in the renderer process.
base::WeakPtr and its factory are thread-affine: they must be created, checked, and invalidated on the same sequence. WidgetInputHandlerManager creates its weak_ptr_factory_ on the main thread but passes WeakPtrs to tasks that execute on the compositor thread. Specifically, SetVizHost binds OnVizHostDisconnected to a disconnect handler using AsWeakPtr() and posts it to the compositor thread.
In release builds, DCHECK_CALLED_ON_VALID_SEQUENCE is compiled out. When a WeakPtr is evaluated, validity is determined solely by reading an atomic invalidated_ flag. If the WidgetInputHandlerManager is destructed on the main thread concurrently with the compositor thread evaluating the WeakPtr, a Time-of-Check to Time-of-Use (TOCTOU) data race occurs. The compositor thread can read invalidated_ as false just microseconds before the main thread destructor sets it to true and frees the object.
Crucially, base::WeakPtr internally uses RAW_PTR_EXCLUSION for the underlying raw pointer. This means the vulnerable freed pointer is completely invisible to MiraclePtr (BackupRefPtr), offering no mitigation against exploitation.
Potential Exploitation Scenario
While our tooling cannot run code, the following steps outline a theoretical exploit path for an attacker:
- Setup: The attacker embeds an iframe in a malicious webpage, initializing a
WidgetBaseandWidgetInputHandlerManageron the main thread. Mojo connections to the Viz and Browser processes are established. - Trigger: The attacker deliberately causes the GPU/Viz process to crash (e.g., via WebGL), triggering a Mojo disconnect on
viz_host_. The Mojo system schedules the boundOnVizHostDisconnectedtask to run on the renderer's compositor thread. - Race: Concurrently, the attacker uses JavaScript to remove the iframe (
iframe.remove()). This destroys theRenderWidgetHostImplon the browser side, which closes theWidgetInputHandlerpipe, causing the compositor thread to drop itsscoped_refptrto the manager. - Destruction: The iframe removal also posts a cleanup task to the main thread, dropping the final
scoped_refptrto the manager and invoking its destructor. - TOCTOU: The compositor thread begins evaluating the
WeakPtrfor theOnVizHostDisconnectedtask. It reads theinvalidated_flag as valid just before the main thread completes the manager's destructor and frees the memory. - UAF and Hijack: The attacker uses JavaScript on the main thread to heap spray the freed memory with a fake object payload. The compositor thread proceeds to invoke
OnVizHostDisconnectedusing the attacker-controlled memory as thethispointer. - RCE: Inside
OnVizHostDisconnected, callingviz_host_.reset()accesses a fakemojo::SharedRemotepointer from the sprayed memory. Dropping the reference count on this fake pointer triggers an attacker-controlled virtual destructor call, leading to arbitrary Remote Code Execution (RCE) in the sandboxed renderer.
Recommended Fix
Since WidgetInputHandlerManager inherits from ThreadSafeRefCounted, tasks posted across thread boundaries should capture a scoped_refptr<WidgetInputHandlerManager>(this) rather than a base::WeakPtr. This will ensure the object remains safely alive for the duration of the cross-thread task. Alternatively, CrossThreadWeakHandle should be used if the task must not extend the object's lifetime.
Evaluated with Chrome root at commit: 2155cb00003ec35716a76ed3246eae995f87b7ff
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
Likely the code passes a thread-affine base::WeakPtr to a task on another thread, and the release build removes the sequence assertion, so validity is decided by a plain atomic flag read that races with destruction.
Impact
The text claims this could lead to arbitrary code execution, but only inside the sandboxed renderer, and it is a theoretical path that the tooling could not run.
What the attacker needed
Victim loads attacker page; attacker can crash the GPU process; release build without sequence checks
The fix
Tasks posted across threads should hold a scoped_refptr to keep the manager alive, or use CrossThreadWeakHandle if the lifetime must not be extended.
How it was found
- Embed an iframe in a malicious page so the input handler manager is created on the main thread.
- Crash the GPU/Viz process to trigger a Mojo disconnect on the viz host.
- Remove the iframe with JavaScript so the manager is destroyed on the main thread.
- Let the compositor thread evaluate the weak pointer just before the destructor frees the object.
- Heap spray the freed memory from JavaScript so the callback runs on attacker-controlled data.
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.
Some programs split work across several threads, which are parallel streams of execution inside one process. A WeakPtr is a reference that is meant to notice when the object it points to has been deleted, but here it was created on one thread and checked on another, so the check and the use can happen at different moments. If the object is freed in between, the second thread reads memory that no longer belongs to it, which is called a use-after-free.
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.