Use after free in Safebrowsing (CVE-2026-79012)
A use-after-free exists in Chrome's password protection modal warning on macOS because displaying the modal spins a nested run loop during which the WebContents can be destroyed, leaving a dangling pointer. An attacker could potentially achieve remote code execution in the browser process by closing the page while the warning is shown and spraying the heap.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 2 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) exists in the browser process on macOS within ChromePasswordProtectionService::ShowModalWarning. The vulnerability occurs because displaying a modal sheet synchronously spins a nested run loop, during which the WebContents can be destroyed and its memory freed, leaving a dangling stack pointer. This issue bypasses MiraclePtr protections and could potentially lead to Remote Code Execution.
Affected files:
chrome/browser/safe_browsing/chrome_password_protection_service.cc
Estimated timestamp from git blame: Unknown (Google3 checkout)
Summary
A potential Use-After-Free (UAF) vulnerability exists in ChromePasswordProtectionService::ShowModalWarning on macOS. The issue is caused by the interaction between the lifetime of a WebContents object and the synchronous nested run loop spun by AppKit when displaying a modal sheet.
If the WebContents is destroyed while the thread is blocked in this nested run loop, a raw stack pointer is left dangling. Because well-behaved observers clear their raw_ptr references during destruction, MiraclePtr's reference count drops to zero, unquarantining the memory. When the nested run loop finishes, the dangling pointer is dereferenced, potentially leading to Remote Code Execution (RCE) in the unsandboxed browser process.
Technical Details
In chrome/browser/safe_browsing/chrome_password_protection_service.cc, ShowModalWarning extracts a raw C++ pointer to a WebContents object:
void ChromePasswordProtectionService::ShowModalWarning(...) {
// ...
content::WebContents* web_contents = request_content->web_contents();
// ...
ShowPasswordReuseModalWarningDialog(web_contents, ...);
On macOS, ShowPasswordReuseModalWarningDialog eventually calls NativeWidgetNSWindowBridge::ShowAsModalSheet(). Because standard browser windows are in-process, this synchronously calls the AppKit API -[NSWindow beginSheet:completionHandler:].
As explicitly documented in Chromium's source (native_widget_ns_window_bridge.mm:2198), this native call blocks the UI thread and spins a nested run loop to handle the presentation animation:
// -[NSWindow beginSheet:completionHandler:] will block the UI thread while
// the animation runs...
While the C++ call stack is suspended inside ShowModalWarning, the browser's MessagePumpNSApplication continues to process incoming IPC messages within the nested run loop.
Potential Exploitation Scenario
(Note: These are suggested steps based on code analysis; a full PoC has not been executed).
- An attacker sets up a malicious site and induces a user to enter a saved password.
- Chrome's Safe Browsing detects the reuse and asynchronously calls
PasswordProtectionServiceBase::RequestFinishedon the UI thread, which callsShowModalWarning. - The UI thread becomes blocked in the macOS nested run loop inside
-[NSWindow beginSheet:]. - The attacker's webpage executes
window.close()via JavaScript (e.g., using a timer set before the warning triggered). - An IPC is sent to the browser, which processes it synchronously inside the nested run loop, invoking the
~WebContentsImpldestructor. - During destruction,
WebContentsImplnotifies observers.RequestCancelerContent::WebContentsDestroyed()is called, which cancels the pending password protection request. - The
PasswordProtectionRequestContentis destroyed. Crucially, allraw_ptr<WebContents>members observing the object (likerequest_canceler_->web_contents_) are cleared as the observers are destroyed.
MiraclePtr Bypass
MiraclePtr (BackupRefPtr) does not protect against this scenario.
First, the pointer held in ShowModalWarning is a raw stack pointer, which does not increment the BRP reference count. Second, because WebContentsImpl cleanly notifies its observers during destruction, all active raw_ptr instances pointing to it are safely cleared or destroyed. Consequently, the MiraclePtr reference count drops to zero, completely unquarantining the memory and returning it to the PartitionAlloc heap.
An attacker can then use IPCs (e.g., Blob URIs) to spray the heap and replace the freed WebContentsImpl object with malicious data containing a fake vtable.
The Crash / Hijack
When the modal sheet is eventually dismissed, the AppKit nested run loop terminates and -[NSWindow beginSheet:] returns. The C++ call stack unwinds back to ShowModalWarning.
The stack-allocated web_contents pointer is now a dangling pointer pointing to attacker-controlled memory. Execution proceeds to:
OnModalWarningShownForSavedPassword(web_contents, password_type, verdict_token);
Which calls:
void ChromePasswordProtectionService::UpdateSecurityState(..., content::WebContents* web_contents) {
// ...
const GURL url = web_contents->GetLastCommittedURL();
GetLastCommittedURL() is a pure virtual method. The CPU reads the attacker-supplied vtable pointer from the freed memory and executes the virtual call, diverting control flow to the attacker's payload and achieving RCE in the browser process.
Recommended Fix
Stack-allocated pointers to objects whose lifetime is not strictly guaranteed should not be held across calls that may spin a nested run loop.
The web_contents pointer in ShowModalWarning should be converted to a base::WeakPtr<content::WebContents>. After the call to ShowPasswordReuseModalWarningDialog (and ExitFullscreen), the code must verify the weak pointer is still valid before passing it to subsequent functions like OnModalWarningShownForSavedPassword.
auto weak_contents = web_contents->GetWeakPtr();
// ... call ShowPasswordReuseModalWarningDialog ...
if (!weak_contents) {
return;
}
// Safely proceed
Evaluated with Chrome root at commit: 65b3256311f3ab6fb9870eaa522de7e6dd2663bb
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 raw pointer to WebContents across a call that spins a nested run loop, allowing the WebContents to be destroyed and the pointer to dangle.
Impact
Could potentially lead to remote code execution in the unsandboxed browser process, though no full proof of concept has been executed.
What the attacker needed
MacOS; victim enters a saved password on attacker site; attacker can close the page via script
The fix
The web_contents pointer should be converted to a base::WeakPtr and checked for validity after the modal call before being used further.
How it was found
- An attacker sets up a malicious site and induces a user to enter a saved password.
- Chrome's Safe Browsing detects the reuse and asynchronously calls RequestFinished on the UI thread, which calls ShowModalWarning.
- The UI thread becomes blocked in the macOS nested run loop inside the modal sheet call.
- The attacker's webpage executes window.close() via JavaScript.
- An IPC is sent to the browser, which processes it synchronously inside the nested run loop, invoking the WebContentsImpl destructor.
- When the modal sheet is dismissed, the dangling pointer is dereferenced, leading to a virtual call on attacker-controlled memory.
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 Chrome shows a warning that a password was reused, it opens a modal dialog. On macOS, opening that dialog pauses the normal flow and lets other messages be processed, including a request from the page to close itself. If the page closes, the object the warning code still points to is freed, and later use of that pointer can crash or be exploited. This is called a use-after-free: using memory after it has been released.
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.