Use after free in Ozone (CVE-2026-15764)
A use-after-free was identified in WaylandWindow::OnDragSessionClose on Linux Wayland, where a synchronous drag-finished callback can destroy the window and the function then dereferences the freed object. An attacker could potentially trigger this by starting a drag and causing the source window to close during the drag, though the analysis is static only and no proof-of-concept was run.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 49 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 potential Use-After-Free (UAF) vulnerability exists in WaylandWindow::OnDragSessionClose on Linux Wayland. The function invokes a synchronous callback that can result in the immediate destruction of the WaylandWindow. Upon returning from the callback, the function dereferences the already deallocated window's member variables, resulting in a use-after-free.
Affected files:
ui/ozone/platform/wayland/host/wayland_window.cc
Estimated timestamp from git blame: 2024-06-05
Root Cause
In WaylandWindow::OnDragSessionClose (located in ui/ozone/platform/wayland/host/wayland_window.cc), the implementation invokes a synchronous callback and subsequently accesses member variables via the this pointer without verifying the window's liveness:
void WaylandWindow::OnDragSessionClose(DragOperation operation) {
if (!drag_finished_callback_) {
return;
}
std::move(drag_finished_callback_).Run(operation); // [1]
if (!connection()->data_drag_controller()->IsWindowDragSessionRunning()) { // [2]
connection()->event_source()->ReleasePressedPointerButtons(
this, EventTimeForNow());
}
std::move(drag_loop_quit_closure_).Run(); // [3]
}
- At
[1],drag_finished_callback_is executed synchronously. This invokesDesktopDragDropClientOzone::OnDragFinished, notifying drag-and-drop observers (such asTabDragController). - If an observer synchronously destroys the parent widget (for example, if the last tab is dragged out and the window closes via a synchronous
CloseNow()), the underlyingWaylandWindowis deleted immediately. This occurs becauseDesktopWindowTreeHostPlatform::OnClosed()callsSetPlatformWindow(nullptr), which deletes thestd::unique_ptr<ui::PlatformWindow>holding theWaylandWindowinstance. - Upon returning from the callback to
[2]and[3], the function dereferencesthis->connection_andthis->drag_loop_quit_closure_on the already-deletedWaylandWindowinstance, leading to a Use-After-Free.
Potential Trigger Path
Based on static analysis, an attacker could potentially trigger this vulnerability through the following steps:
- Initiate Drag: The user (or a renderer-initiated script) begins an outgoing drag-and-drop session.
- Store Callbacks:
WaylandWindow::StartDragspins a nestable run loop and registersdrag_finished_callback_anddrag_loop_quit_closure_. - Close Event: During the active drag session, a close task for the source window is queued or triggered.
- Drag Completion: The drag completes, which executes
WaylandWindow::OnDragSessionClose. - Synchronous Window Destruction: The synchronous execution of
drag_finished_callback_.Run()triggers observer cleanup, which processes the window close synchronously (e.g., viaCloseNow()), immediately destroyingWaylandWindow. - Use-After-Free: Execution resumes in
OnDragSessionCloseon the deletedthispointer, resulting in a UAF when dereferencingconnection()ordrag_loop_quit_closure_.
Note: Our analysis is currently based on static code review, as our tooling does not yet have the ability to run code or compile a functional proof-of-concept.
Proposed Fix
To remediate this issue, the lifetime of the WaylandWindow must be monitored using a WeakPtr. Additionally, the loop quit closure should be moved to a local variable prior to executing any client callbacks to ensure the nested run loop can be cleanly terminated even if the window is destroyed.
void WaylandWindow::OnDragSessionClose(DragOperation operation) {
if (!drag_finished_callback_) {
return;
}
// Move the callback and loop closure to local variables.
auto drag_finished_callback = std::move(drag_finished_callback_);
auto drag_loop_quit_closure = std::move(drag_loop_quit_closure_);
// Track the liveness of 'this' using a WeakPtr.
base::WeakPtr<WaylandWindow> weak_this = AsWeakPtr();
std::move(drag_finished_callback).Run(operation);
// If the window was destroyed during the callback, quit the nested loop safely and exit.
if (!weak_this) {
if (drag_loop_quit_closure) {
std::move(drag_loop_quit_closure).Run();
}
return;
}
if (!connection()->data_drag_controller()->IsWindowDragSessionRunning()) {
connection()->event_source()->ReleasePressedPointerButtons(
this, EventTimeForNow());
}
if (drag_loop_quit_closure) {
std::move(drag_loop_quit_closure).Run();
}
}
Evaluated with Chrome root at commit: b1520ef4a76878853a31f0943b565e42060edec8
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 function runs a synchronous callback that can delete the object, then continues to access its own members without checking whether it still exists.
Impact
An attacker could potentially cause a use-after-free in the browser process, which may lead to a crash or possibly code execution, but this is based on static analysis only and no exploit was demonstrated.
What the attacker needed
Linux with Wayland; user or script starts a drag; source window closes during drag
The fix
The lifetime of the window should be tracked with a WeakPtr and the loop-quit closure moved to a local variable before running any callbacks.
How it was found
- Start an outgoing drag-and-drop session from a window.
- The drag registers a finished callback and a loop-quit closure.
- A close task for the source window is queued or triggered during the drag.
- The drag completes and the close callback runs synchronously.
- The callback destroys the window, and the function then uses the freed object.
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 a drag-and-drop finishes, the browser runs some cleanup code. That cleanup can close the window the drag started from, which frees the window's memory. The original function then keeps using that freed memory, which is called a use-after-free and can crash the browser 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.