Use after free in Views (CVE-2026-19142)
A use-after-free exists in the browser process because the capture controller does not re-check that the new capture window is still alive after reentrant event dispatch. An attacker who can trigger a reentrant destruction of that window could leave a dangling pointer that is later dereferenced on mouse movement, potentially leading to code execution in the unsandboxed 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 Use-After-Free vulnerability exists in the browser process due to a missing liveness check for a window acquiring mouse capture during reentrant event dispatch. If the new capture window is destroyed reentrantly, a dangling pointer is assigned to WindowEventDispatcher members, bypassing MiraclePtr protections. This can potentially lead to arbitrary code execution in the unsandboxed browser process.
Affected files:
ui/wm/core/capture_controller.ccui/aura/window_event_dispatcher.ccui/aura/window_event_dispatcher.h
Estimated timestamp from git blame: 2022-07-18
Root Cause Analysis
A potential Use-After-Free (UAF) vulnerability exists in wm::CaptureController::SetCapture and aura::WindowEventDispatcher::UpdateCapture. When changing mouse capture, the system iterates through multiple CaptureDelegate (WindowEventDispatcher) objects to update their state.
In ui/wm/core/capture_controller.cc, the SetCapture method specifically re-checks the liveness of the old_capture_window after each delegate call using a base::WeakPtr. However, it neglects to perform a similar check for the new_capture_window:
for (const auto& it : delegates) {
it.second->UpdateCapture(old_capture_window, new_capture_window);
if (old_capture_window && !old_capture_window_weak)
old_capture_window = nullptr;
// Missing: liveness check for new_capture_window
}
During the call to UpdateCapture, the dispatcher may synchronously dispatch events (like kMouseCaptureChanged) and execute callbacks (like OnCaptureLost). These callbacks can trigger reentrant UI logic—such as cancelling a menu—that destroys the window intended to receive the new capture.
MiraclePtr Bypass Mechanism
This vulnerability potentially bypasses MiraclePtr (BackupRefPtr). When new_capture_window is destroyed during the reentrant portion of UpdateCapture, the Aura architecture ensures that all raw_ptr<Window> references (in CaptureController, WindowEventDispatcher, etc.) are cleared via observers. If no other raw_ptr references exist, the MiraclePtr refcount hits zero and the memory is immediately freed.
Upon returning from the reentrant call, UpdateCapture continues using a stack-based bare pointer (new_capture) which is now dangling. It proceeds to assign this dangling address to the mouse_moved_handler_ member (a raw_ptr<Window>). Since the assignment occurs after the free, MiraclePtr cannot prevent the UAF.
Potential Attack Scenario
- An attacker triggers a capture change to a specific window (e.g., by interacting with a complex menu or widget).
- During the synchronous
OnCaptureLostcallback for the previous capture window, the attacker-controlled logic triggers a reentrant menu cancellation or widget destruction that targets thenew_capture_window. - The
new_capture_windowis destroyed and its memory is freed because allraw_ptrreferences are cleared reentrantly. - The original
UpdateCapturecall resumes and assigns the dangling pointer tomouse_moved_handler_. - A subsequent mouse move event dereferences
mouse_moved_handler_inDispatchMouseEnterOrExit, potentially leading to control flow hijacking in the browser process.
Suggested Fix
Add a liveness check for new_capture_window inside the delegate loop in CaptureController::SetCapture using the existing new_capture_window_weak tracker:
for (const auto& it : delegates) {
it.second->UpdateCapture(old_capture_window, new_capture_window);
if (old_capture_window && !old_capture_window_weak)
old_capture_window = nullptr;
if (new_capture_window && !new_capture_window_weak)
new_capture_window = nullptr;
}
Evaluated with Chrome root at commit: 29093e11cf509e3593f6229e4b1b075cca356049
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 delegate loop in CaptureController::SetCapture re-checks the old capture window's liveness after each UpdateCapture call but not the new capture window's, so a reentrant destruction leaves a dangling stack pointer that is then stored in a raw_ptr member.
Impact
This could potentially lead to arbitrary code execution in the unsandboxed browser process, though the report presents it as a potential issue rather than a demonstrated exploit.
What the attacker needed
Attacker can influence UI state; reentrant destruction of the new window; subsequent mouse movement
The fix
A liveness check for the new capture window should be added inside the delegate loop using the existing weak pointer tracker, mirroring the check already done for the old capture window.
How it was found
- Trigger a capture change to a specific window, for example through a complex menu or widget.
- During the synchronous OnCaptureLost callback for the previous capture window, cause a reentrant menu cancellation or widget destruction that targets the new capture window.
- The new capture window is destroyed and its memory freed because all raw_ptr references were cleared reentrantly.
- The original UpdateCapture call resumes and assigns the dangling pointer to mouse_moved_handler_.
- A subsequent mouse move event dereferences mouse_moved_handler_ in DispatchMouseEnterOrExit.
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 the browser changes which window is receiving mouse input, it runs some code that can trigger other code to run immediately. That other code can destroy the window that was about to receive the input, leaving the browser holding a pointer to memory that has already been freed. Later, when the mouse moves, the browser may use that stale pointer, which can crash it or, in theory, let an attacker 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.