Use after free in Views (CVE-2026-17752)
A use-after-free exists in SubmenuView::ShowAt when reusing an existing menu host, because synchronous window events on macOS can destroy the menu tree during ShowInactive(). An attacker could trigger a focus change at the right moment to make the function call methods on a freed object, potentially leading to remote code execution.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 4 months
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.
Overview: A potential Use-After-Free exists in SubmenuView::ShowAt when reusing an existing menu host. Synchronous window events on macOS can cause the menu tree to be destroyed during a call to ShowInactive(). Execution then continues, making virtual calls on the freed this pointer, which could lead to remote code execution.
Affected files:
ui/views/controls/menu/submenu_view.cc
Estimated timestamp from git blame: 2021-05-27
Description
A potential Use-After-Free (UAF) vulnerability exists in ui/views/controls/menu/submenu_view.cc within the SubmenuView::ShowAt method. This method is responsible for displaying a submenu.
When ShowAt is called, it checks if a MenuHost already exists. If it does not, it initializes a new one and crucially employs a base::WeakPtr check to ensure the SubmenuView survives the initialization process. However, if the host_ already exists (which occurs when a submenu is opened, hidden, and then re-opened), it takes the following branch:
if (host_) {
host_->SetMenuHostBounds(init_params.bounds);
host_->ShowMenuHost(init_params.do_capture);
} else {
// ... weak ptr check exists here ...
}
The call to host_->ShowMenuHost() invokes Widget::ShowInactive(). As noted in Chromium's codebase, calling ShowInactive() on macOS can trigger synchronous window events, such as focus or activation changes.
If a focus change event is processed synchronously inside this call, it can cause the menu system to cancel and close. The closing of the menu destroys the MenuRunnerImpl, which synchronously deletes the root MenuItemView, cascading down and synchronously deleting the SubmenuView.
When the stack unwinds and execution returns to SubmenuView::ShowAt just after host_->ShowMenuHost(), the implicit this pointer on the stack is now dangling. The function immediately proceeds to access member variables and call methods on this, including a virtual call to GetRowCount():
if (GetRowCount() == 0) {
// ...
}
This virtual call on a freed object provides a highly reliable primitive for a vtable hijack. Furthermore, because the dangling pointer is the implicit this pointer on the stack, it bypasses MiraclePtr (BackupRefPtr) protections, which primarily protect heap-allocated pointers.
Potential Trigger Steps
Note: These steps are theoretical, as our tooling agent cannot execute code to verify a live proof-of-concept.
- Setup: An attacker controls a webpage that uses a timer to trigger a focus change event (e.g., via
window.focus()or triggering an alert) precisely when the user is interacting with a browser menu. - Initial Interaction: The user opens a Views-based menu containing submenus (such as the browser App Menu or a Bookmarks folder).
- Caching the Host: The user hovers over a submenu to open it (creating the
MenuHost), then hovers away to another item. TheMenuControllerhides the submenu, but theMenuHostwidget is kept alive and cached inSubmenuView::host_. - Re-triggering: The user hovers back over the target submenu.
SubmenuView::ShowAtis invoked, entering theif (host_)branch. - Synchronous Destruction: During the resulting
Widget::ShowInactive()call, the attacker's background timer fires, triggering a focus change on macOS. The OS processes this synchronously, causing the menu to cancel and destroying theSubmenuView. - Exploitation: Execution returns to
SubmenuView::ShowAt. The freedthispointer is accessed, and a virtual call is made toGetRowCount(), allowing the attacker to hijack execution flow in the browser process.
Suggested Fix
The fix is straightforward. The if (host_) branch in SubmenuView::ShowAt should be protected with a base::WeakPtr check, exactly like the else branch already is.
base::WeakPtr<SubmenuView> weak_ptr = weak_ptr_factory_.GetWeakPtr();
if (host_) {
host_->SetMenuHostBounds(init_params.bounds);
host_->ShowMenuHost(init_params.do_capture);
} else {
host_ = new MenuHost(this);
// ... existing setup code ...
host_->InitMenuHost(new_init_params);
}
if (!weak_ptr) {
return;
}
Evaluated with Chrome root at commit: 096fc8fdbfacf2546485756d03f160a3d04fcc9b
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
The code path that reuses an existing menu host lacks a weak pointer check after calling ShowMenuHost(), which can synchronously destroy the SubmenuView and leave a dangling this pointer.
Impact
This could lead to remote code execution in the browser process, though the report notes the steps are theoretical and not verified with a live proof-of-concept.
What the attacker needed
MacOS; user interacts with a Views-based menu; attacker controls a webpage with a timer
The fix
The if (host_) branch should be protected with a base::WeakPtr check, exactly like the else branch already is.
How it was found
- An attacker controls a webpage that uses a timer to trigger a focus change event.
- The user opens a Views-based menu containing submenus.
- The user hovers over a submenu to open it, then hovers away, caching the MenuHost.
- The user hovers back over the submenu, invoking SubmenuView::ShowAt and entering the if (host_) branch.
- During Widget::ShowInactive(), the attacker's timer fires, causing a focus change that synchronously destroys the SubmenuView.
- Execution returns to SubmenuView::ShowAt, where the freed this pointer is accessed and a virtual call is made.
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 when a program keeps using memory after it has been freed. Here, opening a submenu can cause the menu to be destroyed while the code is still running, so it then uses the destroyed menu. An attacker might control when this happens to take over 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.