Skip to content
Memory corruption Advisory Advanced CVE-2026-79150

Use after free in Views (CVE-2026-79150)

A use-after-free was reported in the macOS window bridge code: showing a window-modal sheet runs a nested event loop, and if the window is destroyed during that loop the method later dereferences freed objects. An attacker could potentially trigger this through a JavaScript-initiated modal dialog, causing memory corruption in the browser process, though the report is theoretical and no exploit was run.

Google Chrome

Originally disclosed on Chrome VRP

Critical View original
  • Fix shipped in 3 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. 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 NativeWidgetNSWindowBridge::SetVisibilityState() on macOS. When showing a window-modal sheet, the bridge synchronously spins a nested event run-loop during which the window (and its associated bridge/host objects) can be destroyed. Upon return from the nested loop, the method dereferences and executes virtual functions on the freed objects without a WeakPtr guard.

Affected files:

  • components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm

Estimated timestamp from git blame: Unknown (Google3 checkout)

Summary

A potential Use-After-Free (UAF) vulnerability has been identified in NativeWidgetNSWindowBridge::SetVisibilityState() within the macOS-specific remote cocoa/views implementation (components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm). Under certain conditions, showing a window modal dialog (such as a JavaScript-initiated app-modal dialog like alert(), confirm(), or prompt()) triggers a synchronous presentation animation that runs a nested event run-loop. If the window or its parent is destroyed during this nested run-loop, the underlying NativeWidgetNSWindowBridge and NativeWidgetMacNSWindowHost instances are synchronously deleted. When the nested loop exits and the stack unwinds, the execution flow proceeds to dereference members and make virtual calls on these freed objects, leading to a potential UAF in the browser process.

Potential Root Cause and Control Flow

In components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm:

C++
void NativeWidgetNSWindowBridge::SetVisibilityState(
    WindowVisibilityState new_state) {
  ...
  if (IsWindowModalSheet()) {
    ShowAsModalSheet();
    return;
  }
  ...
}

When a window-modal sheet is shown:

  1. SetVisibilityState() calls ShowAsModalSheet() (line 997).

  2. Because the window runs in-process in the browser, host_helper_->MustPostTaskToRunModalSheetAnimation() returns false, causing the block to run synchronously (line 2257):

    OBJC
    [parent_window beginSheet:window_
            completionHandler:^(NSModalResponse return_code) { ... }];
    
  3. This native AppKit call blocks the UI thread and synchronously runs a nested event run-loop to drive the presentation animation.

  4. If a task or event to close the window is processed during this nested loop, the destruction sequence is executed: -[ViewsNSWindowDelegate windowWillClose:] -> _parent->OnWindowWillClose() -> host_->OnWindowHasClosed() -> NativeWidgetMac::WindowDestroyed() -> ns_window_host_.reset() -> ~NativeWidgetMacNSWindowHost() -> in_process_ns_window_bridge_.reset() -> delete this.

As documented in components/remote_cocoa/app_shim/views_nswindow_delegate.mm line 311:

OBJC
  _parent->OnWindowWillClose();
  // |self| may be deleted here (it's NSObject, so who really knows).
  // |parent_| _will_ be deleted for sure.

And in native_widget_ns_window_bridge.mm line 1401:

C++
  host_->OnWindowHasClosed();
  // Note: |this| and its host will be deleted here.
  1. Once the nested loop exits, control returns to ShowAsModalSheet(), which immediately returns to SetVisibilityState(). At this point, the stack resumes execution. However, the this pointer (the bridge) and the host_ pointer have already been deleted. This results in a critical UAF dereference when the code subsequently calls ShouldRunCustomAnimationFor() or accesses host_->GetWidgetIsModal(). A similar UAF occurs in the host class caller NativeWidgetMacNSWindowHost::SetVisibilityState() at ui/views/cocoa/native_widget_mac_ns_window_host.mm:906 when calling GetWidget() on a deleted this pointer.

Note that our tooling agent does not have the ability to run functional exploit code, and these are potential/theoretical execution steps.

Suggested Fix

To prevent the UAF, a base::WeakPtr guard should be introduced to verify whether the bridge or host object has been destroyed during the synchronous nested loop execution. An identical lifetime guard pattern was previously introduced in FullscreenControllerTransitionComplete() (line 1643) and should be applied here:

In NativeWidgetNSWindowBridge::SetVisibilityState():

C++
  base::WeakPtr<NativeWidgetNSWindowBridge> weak_ptr = factory_.GetWeakPtr();
  if (IsWindowModalSheet()) {
    ShowAsModalSheet();
    return;
  }
  if (!weak_ptr) {
    return;
  }

Additionally, a similar base::WeakPtr check should be performed inside NativeWidgetMacNSWindowHost::SetVisibilityState() after calling GetNSWindowMojo()->SetVisibilityState(new_state) to avoid dereferencing this when calling GetWidget() if the host has been destroyed.

Evaluated with Chrome root at commit: fb72408a8493c46bc75fae1c70d03daec96b3040


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.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 method runs a synchronous nested event loop without a WeakPtr lifetime guard, so objects deleted during the loop are dereferenced afterwards.

Impact

A use-after-free in the browser process could potentially lead to memory corruption or a crash, but the report is theoretical and no working exploit was demonstrated.

What the attacker needed

MacOS build of Chromium; victim opens a page that shows a modal dialog; window closed during the sheet animation

The fix

A base::WeakPtr guard should be added after the nested loop so the code returns early if the object was destroyed, and the same check should be applied in the host class.

How it was found

  1. A window-modal sheet is shown, which calls ShowAsModalSheet().
  2. The AppKit beginSheet call runs a nested event loop synchronously on the UI thread.
  3. During that loop a close event is processed, deleting the bridge and host objects.
  4. When the loop exits, the code dereferences the freed objects, causing the use-after-free.

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's memory but keeps using it, that is a use-after-free: the data may now belong to something else, so the program can misbehave or crash. Here, showing a pop-up dialog on macOS pauses the code in a nested loop, and if the window is closed during that pause the objects are deleted, yet the code carries on using them. The report is a static-analysis finding, so nobody has actually demonstrated an attack.

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.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.