A use-after-free was reported in the browser process: releasing mouse capture can synchronously close a transient widget, destroying the window, its host and the event handler, after which the code resumes and touches the freed objects. An attacker could potentially cause memory corruption, though the report is a theoretical code-flow analysis that was not executed or validated.
Overview: A potential Use-After-Free (UAF) vulnerability exists in the browser process due to a raw window pointer being used after a synchronous capture-release call. Releasing capture can cause transient widgets to synchronously close, destroying the window, the parent window tree host, and the rendering event handler. This results in potential memory corruption when the execution resumes and accesses these freed objects.
There is a potential Use-After-Free (UAF) vulnerability in WindowTreeHost::UnlockMouse and related event handlers. When window->ReleaseCapture() is called to unlock the mouse cursor, it synchronously dispatches capture change and mouse movement events. Under certain conditions (such as with transient widgets or popups designed to close upon capture loss), this dispatch can trigger synchronous widget and host destruction. When execution resumes, multiple components (WindowTreeHost, DesktopWindowTreeHostLinux, and RenderWidgetHostViewEventHandler) proceed to dereference members and execute virtual function calls on freed memory.
Synchronous Destruction Sink:
window->ReleaseCapture() dispatches a synchronous ui::EventType::kMouseCaptureChanged event to notify the window of capture loss. Views and widgets are explicitly permitted to self-destroy synchronously during capture loss (e.g., see the comment in Widget::OnMouseCaptureLost at ui/views/widget/widget.cc:2296: // Widget may be deleted upon the capture lost event.).
The Deallocation Chain:
If the widget is synchronously closed via CloseNow(), views::DesktopNativeWidgetAura::OnHostClosed() resets the unique pointer to the host (host_.reset();), which deletes the DesktopWindowTreeHostLinux instance. This in turn deletes the root window (delete window_;), which recursively deletes the child window_ and destroys the RenderWidgetHostViewAura (and its nested RenderWidgetHostViewEventHandler owner).
Post-Sink Use-After-Free Execution Paths:
In WindowTreeHost::UnlockMouse:
Resuming on line 445, root_window is now a dangling pointer. client::GetCursorClient(root_window) performs a property lookup on freed memory and can return the stale address of cursor_manager_ (which is deleted during root window teardown). Calling UnlockCursor() and ShowCursor() executes virtual functions on a freed object.
In DesktopWindowTreeHostLinux::UnlockMouse:
At ui/views/widget/desktop_aura/desktop_window_tree_host_linux.cc:530:
C++
DesktopWindowTreeHostPlatform::UnlockMouse(window);
if (SupportsMouseLock()) { // <--- UAF on `this`
auto* wayland_extension =
ui::GetWaylandToplevelExtension(*platform_window()); // <--- UAF on `this`
wayland_extension->LockPointer(false);
}
If the base class call destroys the host, the subsequent calls to SupportsMouseLock() and platform_window() are executed on a freed this pointer.
In RenderWidgetHostViewEventHandler::UnlockPointer:
At content/browser/renderer_host/render_widget_host_view_event_handler.cc:209-213:
C++
window_->GetHost()->UnlockMouse(window_);
window_->MoveCursorTo(...); // <--- UAF Read on `this->window_`
synthetic_move_position_ = ...; // <--- UAF Write to `this->synthetic_move_position_`
host_->LostPointerLock(); // <--- UAF Read on `this->host_` and virtual call
Since the event handler is deleted along with RenderWidgetHostViewAura, executing these lines results in UAF reads, a UAF write, and a virtual call via a deleted pointer.
Potential Trigger Path
Note: These steps are logical and theoretical based on code-flow analysis; our tooling does not currently have the capability to execute and validate runtime behavior.
A webpage or compromised renderer requests pointer lock on a transient widget/window (such as a dropdown menu or transient bubble) which has capture capabilities.
The browser grants pointer lock, causing the Aura window to acquire capture.
The renderer dispatches an IPC requesting to exit pointer lock.
The browser process receives this request and invokes RenderWidgetHostViewEventHandler::UnlockPointer(), which calls the capture-release sink.
During capture release, the transient widget processes capture loss and synchronously closes itself via CloseNow(), freeing the host, window, and event handler.
Control unwinds, leading to the UAF reads, writes, and virtual calls detailed above.
Suggested Fixes
To prevent execution on freed pointers, lifetime tracking must be introduced at each layer of the call chain:
In WindowTreeHost::UnlockMouse:
Utilize aura::WindowTracker to track both window and root_window before entering the release capture sink, and only proceed if they remain valid.
C++
void WindowTreeHost::UnlockMouse(Window* window) {
Window* root_window = window->GetRootWindow();
DCHECK(root_window);
aura::WindowTracker tracker;
tracker.Add(window);
tracker.Add(root_window);
if (window->HasCapture())
window->ReleaseCapture();
if (!tracker.Contains(root_window))
return;
auto* cursor_client = client::GetCursorClient(root_window);
if (cursor_client) {
cursor_client->UnlockCursor();
cursor_client->ShowCursor();
}
}
In DesktopWindowTreeHostLinux::UnlockMouse:
Guard the platform calls with the class's existing weak_factory_:
In RenderWidgetHostViewEventHandler::UnlockPointer:
Use a base::WeakPtr<RenderWidgetHostViewBase> to verify the view's lifetime before accessing members:
Evaluated with Chrome root at commit: b5b015ea5f690560237d1f0cff1405844cd12b8d
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.
The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 50 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the capture-release call synchronously dispatches events that let widgets destroy themselves, and the callers do not check that the window, host and event handler still exist before using them.
Impact
Could lead to memory corruption in the browser process, but the trigger is theoretical and was not executed or validated.
What the attacker needed
Pointer lock on a transient widget; renderer able to send the unlock IPC; widget closes itself on capture loss
The fix
The report suggests tracking object lifetimes with WindowTracker, a weak pointer factory and a weak pointer to the view, and returning early if the objects were destroyed; it does not say a fix was applied.
How it was found
A page or compromised renderer asks for pointer lock on a transient widget that can hold capture.
The browser grants pointer lock, so the Aura window takes capture.
The renderer sends an IPC asking to exit pointer lock.
The browser calls the unlock path, which releases capture.
The transient widget handles the capture-loss event and closes itself immediately, freeing the host, window and event handler.
Execution returns and the code reads, writes and makes virtual calls on the freed objects.
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.
Generating the AI write-up for this report.
This usually takes about 50 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
When a program frees a piece of memory but keeps using it, that is a use-after-free. Here, asking the browser to release the mouse pointer can make a small popup close itself immediately, which deletes several objects; the code then carries on and reads or calls those deleted objects, which can corrupt memory. The report is based on reading the code, not on running an exploit.
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.