Use after free in Ozone (CVE-2026-13854)
A use-after-free exists in X11Window::DispatchUiEvent when a synchronous XCB call to fetch window bounds triggers callbacks that destroy the grabber window, leaving a dangling raw pointer. An attacker who compromises a renderer could potentially exploit this to achieve remote code execution in the browser process and escape the sandbox.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 18 days
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 (UAF) vulnerability exists in X11Window::DispatchUiEvent when translating coordinates for a located event grabber. A synchronous XCB call to fetch window bounds can trigger callbacks that destroy the grabber window, leaving a raw stack pointer dangling. MiraclePtr does not quarantine the memory because all raw_ptr references are cleared during destruction, potentially allowing a sandbox escape.
Affected files:
ui/ozone/platform/x11/x11_window.cc
Estimated timestamp from git blame: 2025-03-06
Description
A Use-After-Free (UAF) vulnerability has been identified in ui/ozone/platform/x11/x11_window.cc within X11Window::DispatchUiEvent. The issue occurs when an event is routed to a window that currently holds the event grab (the located_events_grabber).
The code fetches the grabber window as a raw pointer and stores it in a local stack variable. It then attempts to translate the event coordinates by calling GetBoundsInPixels() on the grabber window. If the window's geometry is not cached, this call will block and dispatch a synchronous request to the X server (geometry_future_.DispatchNow()).
During this synchronous wait, XCB replies are processed out-of-order. Processing the geometry response triggers an OnBoundsChanged callback cascade that reaches the UI layer (e.g., TabDragController). Depending on the state, the UI layer can synchronously close and destroy the widget and its underlying X11Window.
MiraclePtr Bypass
When the X11Window is destroyed, the X11WindowManager clears its raw_ptr<X11Window> reference to the grabber. Because all raw_ptr fields pointing to the object are cleared, PartitionAlloc's BackupRefPtr reference count drops to zero. Consequently, the memory is not quarantined by MiraclePtr and is immediately freed.
Execution then returns to DispatchUiEvent. The local located_events_grabber variable is a raw C++ pointer and is not updated. It now points to freed memory. The code subsequently dereferences this pointer (located_events_grabber->DispatchUiEvent(...)), resulting in a UAF.
Potential Exploit Scenario (Suggested Steps)
Note: These steps trace a theoretical path through the codebase; a working Proof of Concept has not yet been executed.
- An attacker compromises a renderer process.
- Using the
content.mojom.WidgetInputHandlerHostIPC, the attacker forces a specific browser window (e.g., a detached tab) to acquire mouse capture, making it thelocated_events_grabber. - The attacker injects synthetic mouse events via the
content.mojom.InputInjectorIPC. - When the event reaches
X11Window::DispatchUiEvent, the code fetches the raw pointer to the grabber window. - The code calls
GetBoundsInPixels(), blocking on the X server. - The out-of-order processing of the X11 reply triggers a bounds change notification to
TabDragController, which (based on carefully timed attacker input) synchronously closes the widget. - The
X11Windowis destroyed and its memory freed. - The attacker sprays the browser process heap via IPC, replacing the freed window object with malicious data.
DispatchUiEventresumes and calls a method on the dangling pointer.- The hijacked object provides a fake
platform_window_delegate(), leading to a virtual function call hijack whenDispatchEventFromNativeUiEventexecutes. - This results in arbitrary Remote Code Execution (RCE) in the browser process, escaping the sandbox.
Suggested Fix
Use a base::WeakPtr<X11Window> to track the grabber window across the potentially blocking GetBoundsInPixels() call.
auto* located_events_grabber = window_manager->located_events_grabber();
if (event->IsLocatedEvent() && located_events_grabber &&
located_events_grabber != this) {
base::WeakPtr<X11Window> weak_grabber = located_events_grabber->GetWeakPtr();
if (event->IsMouseEvent() || ...) {
const gfx::Point target_origin = located_events_grabber->GetBoundsInPixels().origin();
// Check both the current window AND the grabber window
if (!weak_this || !weak_grabber) {
return;
}
// ...
}
return weak_grabber->DispatchUiEvent(event, xev);
}
Alternatively, retrieve window_manager->located_events_grabber() again after coordinate translation to verify it hasn't changed or been destroyed.
Evaluated with Chrome root at commit: 65b3256311f3ab6fb9870eaa522de7e6dd2663bb
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
The code stores a raw pointer to the event grabber window and then makes a blocking call that can synchronously destroy that window, leaving the pointer dangling.
Impact
This could allow an attacker to achieve arbitrary remote code execution in the browser process, escaping the sandbox, though a working proof of concept has not yet been executed.
What the attacker needed
Compromised renderer process; ability to send IPC messages; X11 environment
The fix
The grabber window should be tracked with a base::WeakPtr across the potentially blocking GetBoundsInPixels() call, or the grabber should be re-fetched after coordinate translation to verify it has not been destroyed.
How it was found
- An attacker compromises a renderer process.
- Using the WidgetInputHandlerHost IPC, the attacker forces a browser window to acquire mouse capture, making it the located_events_grabber.
- The attacker injects synthetic mouse events via the InputInjector IPC.
- When the event reaches X11Window::DispatchUiEvent, the code fetches the raw pointer to the grabber window.
- The code calls GetBoundsInPixels(), blocking on the X server.
- The out-of-order processing of the X11 reply triggers a bounds change notification to TabDragController, which synchronously closes the widget, destroying the X11Window and freeing its 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 is a bug where a program keeps using a piece of memory after it has been freed, which can let an attacker control what happens next. Here, a window object is destroyed while the code is still holding a pointer to it, and the code then calls a method on that freed object. If an attacker can control the freed memory, they might run their own code inside the browser process.
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.