Use after free in Views (CVE-2026-7910)
A use-after-free flaw exists in the Linux/Ozone implementation of DesktopWindowTreeHostPlatform::OnActivationChanged, where a synchronous call can destroy the object and then ScheduleRelayout() is called on the freed pointer. A compromised renderer could potentially exploit this to achieve remote code execution in the browser process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 38 days
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: A potential Use-After-Free (UAF) vulnerability exists in DesktopWindowTreeHostPlatform::OnActivationChanged on Linux/Ozone. Synchronous widget destruction during activation handling can free the this pointer, which is subsequently accessed when calling ScheduleRelayout(). This could potentially allow a compromised renderer to achieve Remote Code Execution (RCE) in the browser process.
Affected files:
ui/views/widget/desktop_aura/desktop_window_tree_host_platform.ccui/views/widget/desktop_aura/desktop_window_tree_host_platform.h
Estimated timestamp from git blame: 2024-05-31
Summary
A potential Use-After-Free (UAF) vulnerability has been identified in the browser process on Linux (Ozone platform) within DesktopWindowTreeHostPlatform::OnActivationChanged. The issue occurs because a synchronous call to desktop_native_widget_aura_->HandleActivationChanged(active) can trigger a cascade of events that results in the destruction of the DesktopWindowTreeHostPlatform instance. Upon returning from this call, the method unconditionally invokes ScheduleRelayout() on the now-freed this pointer.
Technical Details
In ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc, OnActivationChanged is implemented as follows:
void DesktopWindowTreeHostPlatform::OnActivationChanged(bool active) {
// ...
is_active_ = active;
aura::WindowTreeHostPlatform::OnActivationChanged(active);
desktop_native_widget_aura_->HandleActivationChanged(active);
ScheduleRelayout();
}
The call to HandleActivationChanged(active) notifies WidgetObservers and focus listeners of the activation change. A specifically crafted UI interaction (or observer behavior) could respond to this notification by synchronously calling Widget::CloseNow().
This triggers the following synchronous destruction path:
Widget::CloseNow()callsnative_widget_->CloseNow(), which routes toDesktopWindowTreeHostPlatform::CloseNow().DesktopWindowTreeHostPlatform::CloseNow()callsplatform_window()->Close().- On Ozone/X11 or Wayland, the platform window synchronously notifies its delegate via
OnClosed(). DesktopWindowTreeHostPlatform::OnClosed()callsDesktopNativeWidgetAura::OnHostClosed().
Inside DesktopNativeWidgetAura::OnHostClosed() (desktop_native_widget_aura.cc:378):
// WindowEventDispatcher owns |desktop_window_tree_host_|.
desktop_window_tree_host_ = nullptr;
// Delete host after resetting `desktop_window_tree_host_` and
// `content_window_` to avoid accessing the stale instance during deletion.
host_.reset();
First, the raw_ptr tracking the host object (desktop_window_tree_host_) is set to nullptr. This explicitly drops the reference count before destruction, meaning MiraclePtr (BackupRefPtr) will not quarantine the memory for this specific pointer.
Second, host_.reset() destroys the DesktopWindowTreeHostPlatform object (this). The memory is returned to PartitionAlloc.
When the stack unwinds back to OnActivationChanged, the code unconditionally calls ScheduleRelayout() on the freed this pointer.
Inside ScheduleRelayout():
void DesktopWindowTreeHostPlatform::ScheduleRelayout() {
if (!native_widget_delegate_) {
return;
}
Widget* widget = native_widget_delegate_->AsWidget();
// ...
The code reads native_widget_delegate_ (a base::WeakPtr) from the freed memory and subsequently calls AsWidget(), a pure virtual function. If the memory has been reallocated and controlled by an attacker, this virtual function call can be hijacked.
Potential Exploitation Steps
Note: These are potential steps, as our tooling agent doesn't yet have the ability to run code to confirm a working PoC.
- An attacker compromises a renderer process (e.g., via a v8 bug).
- The attacker uses the compromised renderer to open two popup windows (Popup A and Popup B).
- The attacker programmatically closes Popup A, causing the OS window manager (Wayland/X11) to deliver an activation change notification to Popup B's platform window.
DesktopWindowTreeHostPlatform::OnActivationChanged(true)is invoked for Popup B.- During
HandleActivationChanged(true), a synchronous UI event or observer cascade triggersWidget::CloseNow(). - The
DesktopWindowTreeHostPlatforminstance is destroyed viahost_.reset(), and its memory is freed. - Concurrently, the attacker sprays the browser process heap via IPC messages to reallocate the freed memory chunk with attacker-controlled data.
- The attacker forges the
base::WeakPtr(native_widget_delegate_) within the sprayed memory to appear valid and points it to a fake object. - Control returns to
OnActivationChanged, andScheduleRelayout()is executed. - The forged
WeakPtrcheck passes, and the virtual methodAsWidget()is called on the attacker-controlled pointer, granting Remote Code Execution (RCE) in the browser process.
Suggested Fix
The call to ScheduleRelayout() in DesktopWindowTreeHostPlatform::OnActivationChanged must be guarded to ensure the this pointer has not been destroyed during the synchronous call to HandleActivationChanged(). A base::WeakPtr check should be used.
void DesktopWindowTreeHostPlatform::OnActivationChanged(bool active) {
// ...
is_active_ = active;
aura::WindowTreeHostPlatform::OnActivationChanged(active);
auto weak_this = close_widget_factory_.GetWeakPtr();
desktop_native_widget_aura_->HandleActivationChanged(active);
if (!weak_this) {
return;
}
ScheduleRelayout();
}
A similar fix was previously applied to the Windows equivalent (ui/views/win/hwnd_message_handler.cc) but is missing in the Linux/Ozone implementation.
Evaluated with Chrome root at commit: a9cbf6e8b275fe4147435aa905f3b7f5a656f5f0
Results from so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; 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 calls ScheduleRelayout() on the this pointer without checking whether the preceding synchronous call to HandleActivationChanged() destroyed the object.
Impact
A compromised renderer could potentially achieve remote code execution in the browser process, though the report notes these are potential steps and no working proof-of-concept was confirmed.
What the attacker needed
Compromised renderer process; Linux/Ozone platform
The fix
The call to ScheduleRelayout() should be guarded with a base::WeakPtr check to ensure the this pointer has not been destroyed during the synchronous call to HandleActivationChanged().
How it was found
- Compromise a renderer process.
- Open two popup windows, Popup A and Popup B.
- Close Popup A to trigger an activation change notification to Popup B.
- OnActivationChanged(true) runs for Popup B and during HandleActivationChanged(true) a synchronous event triggers Widget::CloseNow().
- The DesktopWindowTreeHostPlatform instance is destroyed and its memory freed.
- Spray the heap via IPC to reallocate the freed chunk with attacker-controlled data and forge the WeakPtr to point to a fake 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.
A use-after-free happens when a program frees memory but then keeps using it, like deleting a file and then trying to open it. Here, a function frees an object and then calls another function on that same object, which can let an attacker who controls the freed memory run their own code. This is serious because it could let someone who has already taken over a web page take over the whole browser.
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.