Use after free in Views (CVE-2026-7343)
A use-after-free was identified in the Windows DPI-change handler, where a synchronous window operation can enter a nested message loop that processes a close task and destroys the handler while it is still on the call stack. An attacker could potentially trigger this to cause memory corruption and possibly arbitrary code execution in the browser process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 12 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 without the Chrome Security team. Please see go/chrome-ai-generated-security-bugs-faq for more information.
Overview: A potential use-after-free vulnerability exists in HWNDMessageHandler::OnDpiChanged on Windows. Synchronous window operations (like SetWindowPos) can enter a nested message loop, allowing an attacker to queue and execute a window close task. This destroys the HWNDMessageHandler while it is still on the call stack, leading to a UAF upon return.
Affected files:
ui/views/win/hwnd_message_handler.ccui/views/widget/desktop_aura/desktop_native_widget_aura.ccui/views/widget/desktop_aura/desktop_window_tree_host_win.ccui/views/win/hwnd_message_handler.h
Estimated timestamp from git blame: 2026-02-28
Summary
A potential Use-After-Free (UAF) vulnerability has been identified in HWNDMessageHandler::OnDpiChanged in the Chrome browser process on Windows. The issue occurs when the handler performs synchronous operations that trigger a native nested message loop. If application tasks are permitted in this loop, an attacker can destroy the handler while OnDpiChanged is still executing, leading to memory corruption.
Vulnerability Details
In ui/views/win/hwnd_message_handler.cc, the HWNDMessageHandler::OnDpiChanged function handles WM_DPICHANGED messages. During its execution, it calls SetBoundsInternal, which calls the Windows API ::SetWindowPos:
2015: display::win::GetScreenWin()->UpdateDisplayInfos();
2016: SetBoundsInternal(gfx::Rect(*reinterpret_cast<RECT*>(l_param)), false);
2017: delegate_->HandleWindowScaleFactorChanged(scaling_factor);
As noted in Chromium codebase comments (ui/views/win/hwnd_message_handler.cc:691), ::SetWindowPos can trigger a native nested message loop, especially during complex DPI transitions.
If the browser is already in a state that allows application tasks to run during native nested loops (e.g., during a drag-and-drop operation where base::CurrentThread::ScopedAllowApplicationTasksInNativeNestedLoop is active), the message pump will process incoming tasks while blocked inside ::SetWindowPos.
If an IPC task to close the window is processed during this nested loop, it posts a task to HWNDMessageHandler::CloseNow. This task is immediately picked up by the message pump and executed. CloseNow calls ::DestroyWindow, which synchronously destroys the HWNDMessageHandler instance (via WM_NCDESTROY and DesktopNativeWidgetAura::OnHostClosed).
When the nested loop finishes and ::SetWindowPos returns, execution continues in SetBoundsInternal (accessing background_fullscreen_hack_ at line 3816) and subsequently OnDpiChanged (accessing delegate_ at line 2017). Both accesses dereference the freed this pointer, resulting in a use-after-free. Because HandleWindowScaleFactorChanged is a virtual method, this can potentially lead to a controlled vtable indirect call and arbitrary code execution in the browser process.
Potential Attack Scenario
While we have not verified this with a working Proof of Concept, an attacker might trigger this path via the following steps:
- A compromised renderer opens a popup window.
- The attacker's script initiates an operation that enters a native nested loop with application tasks allowed (e.g., initiating a drag-and-drop).
- While the drag-and-drop loop is active, the attacker sends a
window.moveTo()IPC to move the popup across a DPI boundary. - This synchronously triggers
OnDpiChangedand the::SetWindowPoscall, which enters a second nested loop. - The attacker sends a
window.close()IPC targeting the popup. - The close task is processed by the second nested loop, destroying the window and the
HWNDMessageHandler. ::SetWindowPosreturns, and the freed handler is dereferenced.
Lack of Mitigations
- Missing WeakPtr Guards: While
SetBoundsInternaluses aWeakPtrafter notifying its delegate (line 3817), it does not protect the initial accesses immediately afterSetWindowPos.OnDpiChangedentirely lacks aWeakPtrguard. - MiraclePtr (BRP): The
raw_ptrprotection does not prevent this UAF because the implicitly capturedthispointer is a native C++ pointer and noraw_ptron the stack holds the object alive during this specific sequence to trigger quarantine.
Suggested Fix
Add base::WeakPtr guards in HWNDMessageHandler::OnDpiChanged and SetBoundsInternal to detect if the object has been destroyed during the SetWindowPos or UpdateDisplayInfos calls. For example, in OnDpiChanged:
base::WeakPtr<HWNDMessageHandler> ref(msg_handler_weak_factory_.GetWeakPtr());
display::win::GetScreenWin()->UpdateDisplayInfos();
SetBoundsInternal(gfx::Rect(*reinterpret_cast<RECT*>(l_param)), false);
if (!ref) return 0;
delegate_->HandleWindowScaleFactorChanged(scaling_factor);
Similar checks should be placed immediately after ::SetWindowPos in SetBoundsInternal.
Evaluated with Chrome root at commit: 661452647ddb2827305122ff3273bd5dea403f09
Results 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
Likely the handler lacks a weak-pointer guard after synchronous calls that can run a nested message loop and destroy the object.
Impact
This could potentially lead to a controlled vtable indirect call and arbitrary code execution in the browser process, though the attack has not been verified with a working proof of concept.
What the attacker needed
Compromised renderer; Windows OS; popup window; drag-and-drop operation
The fix
Add base::WeakPtr guards in HWNDMessageHandler::OnDpiChanged and SetBoundsInternal to detect if the object has been destroyed during the SetWindowPos or UpdateDisplayInfos calls.
How it was found
- A compromised renderer opens a popup window.
- The attacker's script initiates an operation that enters a native nested loop with application tasks allowed (e.g., initiating a drag-and-drop).
- While the drag-and-drop loop is active, the attacker sends a `window.moveTo()` IPC to move the popup across a DPI boundary.
- This synchronously triggers `OnDpiChanged` and the `::SetWindowPos` call, which enters a second nested loop.
- The attacker sends a `window.close()` IPC targeting the popup.
- The close task is processed by the second nested loop, destroying the window and the `HWNDMessageHandler`.
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 an object but keeps using it, like deleting a file and then trying to read it. Here, a window handler is destroyed during a nested loop, and the code then accesses the freed memory. This could let an attacker run their own code in the 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.