Use after free in Extensions (CVE-2026-87637)
A use-after-free exists in the browser process when the settings overridden dialog is shown on macOS, because a raw pointer to the dialog delegate is kept across a modal call that can run a nested event loop. An attacker could close the parent window during that loop, freeing the delegate, so the later dereference may cause memory corruption in the unsandboxed browser process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 57 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 the browser process when displaying the settings overridden dialog on macOS. Initiating the modal sheet can synchronously trigger a nested event-tracking run loop during which the parent window and dialog widget can be destroyed. This results in stack-local raw pointers being dereferenced upon return, leading to potential memory corruption in the unsandboxed browser process.
Affected files:
chrome/browser/ui/extensions/settings_overridden_dialog.cc
Estimated timestamp from git blame: 2022-08-09
Root Cause Analysis
In chrome/browser/ui/extensions/settings_overridden_dialog.cc, ShowSettingsOverriddenDialog retains a bare stack pointer to a SettingsOverriddenDialogDelegate whose ownership has been transferred to the ui::DialogModel:
void ShowSettingsOverriddenDialog(
std::unique_ptr<SettingsOverriddenDialogController> controller,
gfx::NativeWindow parent) {
...
auto dialog_delegate_unique =
std::make_unique<SettingsOverriddenDialogDelegate>(std::move(controller));
SettingsOverriddenDialogDelegate* dialog_delegate =
dialog_delegate_unique.get();
ui::DialogModel::Builder dialog_builder =
ui::DialogModel::Builder(std::move(dialog_delegate_unique));
...
ShowModalDialog(parent, dialog_builder.Build());
dialog_delegate->controller()->OnDialogShown();
}
On macOS, ShowModalDialog eventually calls NativeWidgetNSWindowBridge::ShowAsModalSheet in components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm. This synchronously executes -[NSWindow beginSheet:completionHandler:], which enters a synchronous, nested run loop to animate the sheet.
Because the nested run loop continues processing the browser's UI thread tasks and IPC messages, a queued close event (e.g., from a webpage closing its parent window or via extension APIs) can run and destroy the widget. Since the BubbleDialogModelHost and its underlying DialogModel are owned by the widget, this destruction chain deletes both the SettingsOverriddenDialogDelegate and its owned SettingsOverriddenDialogController.
Upon returning from the nested run loop, the stack-local dialog_delegate pointer is now dangling. Dereferencing it to call dialog_delegate->controller()->OnDialogShown() results in a Use-After-Free and an immediate virtual function dispatch through a potentially attacker-controlled vtable.
Potential Trigger Steps
Note: These are potential steps based on static code analysis; our automated tooling does not currently have the capability to execute proof-of-concept code.
- Install an extension that overrides the New Tab Page (NTP) on macOS.
- Programmatically open the NTP using
chrome.tabs.createor another page-opening mechanism to triggerShowSettingsOverriddenDialog. - While the sheet slide-down animation is executing (spinning the AppKit nested run loop), immediately close the window or tab (e.g., using
chrome.tabs.removefrom the extension's background script). - The window close IPC is processed during the nested run loop, destroying the widget and the dialog model host.
- Once the animation finishes and the nested loop terminates, control returns to
ShowSettingsOverriddenDialog, which attempts to invokeOnDialogShown()on the freed delegate/controller.
Suggested Fix
To prevent holding a dangling pointer across the potentially blocking ShowModalDialog call, retrieve a weak pointer to the controller prior to showing the dialog, and check its validity before invoking the notification:
// Inside ShowSettingsOverriddenDialog
base::WeakPtr<SettingsOverriddenDialogController> weak_controller = controller->AsWeakPtr();
ShowModalDialog(parent, dialog_builder.Build());
if (weak_controller) {
weak_controller->OnDialogShown();
}
Alternatively, if the design allows, notify the controller that the dialog was shown prior to calling ShowModalDialog.
Evaluated with Chrome root at commit: b5b015ea5f690560237d1f0cff1405844cd12b8d
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
Likely the code holds a bare stack pointer to a delegate owned by the dialog model across a modal call that can synchronously run a nested event loop and destroy the widget.
Impact
This could lead to memory corruption in the unsandboxed browser process, though the text notes the trigger steps are only potential and were not executed.
What the attacker needed
MacOS; an extension that overrides the New Tab Page; ability to close the window during the animation
The fix
The code should take a weak pointer to the controller before showing the dialog and check it before calling the notification, or notify the controller before the modal call.
How it was found
- Install an extension that overrides the New Tab Page on macOS.
- Open the New Tab Page programmatically to trigger the settings overridden dialog.
- While the sheet animation runs, close the window or tab from the extension.
- The close event is processed during the nested run loop, destroying the widget and dialog model host.
- After the loop ends, the code calls OnDialogShown on the freed delegate.
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 program frees an object but keeps a pointer to it and later uses that pointer, this is called a use-after-free. Here the browser shows a dialog, and while it is animating, another action can close the window and destroy the dialog's data; the code then touches the destroyed data. Because this happens in the browser's main process, which is not sandboxed, it could lead to memory corruption.
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.