Use after free in Printing (CVE-2026-95319)
A use-after-free vulnerability exists in PrintViewManager when initiating a print preview, because showing the preview dialog exits fullscreen and spins a nested message loop during which the tab can be closed, destroying the object. An attacker could potentially exploit this to achieve control-flow hijacking and remote code execution in the browser process.
Google Chrome
Originally disclosed on Chrome VRP
- 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 Use-After-Free vulnerability exists in PrintViewManager when initiating a print preview. Showing the preview dialog forces the tab out of HTML fullscreen, which on Windows and macOS spins a nested message loop; closing the tab during this loop destroys the PrintViewManager, leading to a virtual function call on the freed object upon return.
Affected files:
chrome/browser/printing/print_view_manager.cc
Estimated timestamp from git blame: 2021-09-27
Description
A potential Use-After-Free (UAF) vulnerability has been identified in PrintViewManager::OnRequestPrintPreviewCallback (chrome/browser/printing/print_view_manager.cc).
When a renderer requests a print preview, PrintViewManager calls PrintPreviewDialogController::PrintPreview to display the modal preview dialog. Showing a modal dialog requires dropping HTML Fullscreen mode to ensure the user has context. To do this, BrowserWindowModalDialogDelegate::SetWebContentsBlocked calls web_contents->ExitFullscreen(true).
On Windows (via ::SetWindowPos) and macOS (via [NSWindow toggleFullScreen:]), exiting fullscreen spins a native nested message loop. If an attacker closes the tab while this nested loop is running, the WebContents and its associated WebContentsUserData (including the PrintViewManager instance) are synchronously destroyed.
When the nested loop finishes, the stack unwinds back to PrintViewManager::OnRequestPrintPreviewCallback. The function then calls PrintPreviewAllowedForTesting() using the implicit this pointer. Because this is a raw pointer on the execution stack, it is not protected by MiraclePtr (BackupRefPtr). Since the object has been destroyed, this results in a virtual method call on a freed object, which can be exploited for Control-Flow Hijacking and Remote Code Execution (RCE) in the Browser Process.
Potential Steps to Trigger
- An attacker-controlled renderer opens two tabs (Tab A and Tab B) in the same window.
- In Tab A, the attacker uses JavaScript to enter HTML Fullscreen (
document.documentElement.requestFullscreen()). - Tab A sends a
mojom::PrintManagerHost::RequestPrintPreviewIPC. The browser binds aWeakPtrand invokesPrintViewManager::OnRequestPrintPreviewCallback. - Inside the callback, the raw
thispointer is extracted from theWeakPtrto execute the method. The code callsdialog_controller->PrintPreview(). - The UI framework attempts to show the modal dialog, which triggers
web_contents->ExitFullscreen(true). - The platform-specific
ExitFullscreenimplementation spins a nested message loop. - During the nested loop, Tab B sends a
ClosePageIPC to close Tab A. Tab A'sWebContentsandPrintViewManagerare destroyed. - The attacker performs heap spraying (e.g., via other IPCs) to replace the freed
PrintViewManagerobject in memory with a fake vtable. - The nested loop finishes. The stack unwinds.
- Note: The code bypasses a
CHECKinTabStripModel::SetTabBlockedduring unwinding because Tab B is still open, keeping the stale tab index within bounds. - Note: The code bypasses a
CHECK(weak_widget)inShowWebModalDialogViewsbecause the native dialog widget is closed asynchronously and still exists during the unwind.
- Note: The code bypasses a
- Execution returns to
OnRequestPrintPreviewCallback. The code callsPrintPreviewAllowedForTesting()on the freedthispointer. - The virtual call uses the attacker's fake vtable. On Windows, Control Flow Guard (CFG) only verifies that the target is a valid function start, allowing the attacker to jump to an arbitrary ROP gadget and achieve RCE.
(Note: These are suggested steps based on code analysis; our tooling agent does not have the ability to run code to verify an exploit end-to-end.)
Suggested Fix
Unlike OnScriptedPrintPreviewCallback, which checks print_preview_state_ and explicitly handles ExitFullscreen with a WeakPtr guard, OnRequestPrintPreviewCallback lacks these protections.
The fix should guard the execution after PrintPreview() returns by checking if this is still valid. You can acquire a WeakPtr before the call and check it afterward:
auto weak_this = weak_factory_.GetWeakPtr();
dialog_controller->PrintPreview(web_contents(), *params);
if (!weak_this) {
return;
}
PrintPreviewAllowedForTesting();
Alternatively, verify print_preview_state_ before proceeding, similar to how OnScriptedPrintPreviewCallback operates.
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 calls a method on a raw `this` pointer after a nested message loop without checking if the object was destroyed, because it lacks a WeakPtr guard.
Impact
The vulnerability could allow an attacker to achieve control-flow hijacking and remote code execution in the browser process, though the report notes that the steps are suggested based on code analysis and have not been verified end-to-end.
What the attacker needed
Attacker-controlled renderer; two tabs in same window; JavaScript to enter fullscreen; ability to send IPC messages
The fix
The fix should guard the execution after PrintPreview() returns by checking if `this` is still valid using a WeakPtr, or by verifying print_preview_state_ before proceeding.
How it was found
- An attacker-controlled renderer opens two tabs in the same window.
- In Tab A, the attacker uses JavaScript to enter HTML Fullscreen.
- Tab A sends a RequestPrintPreview IPC, invoking PrintViewManager::OnRequestPrintPreviewCallback.
- The callback calls dialog_controller->PrintPreview(), which triggers ExitFullscreen and spins a nested message loop.
- During the nested loop, Tab B sends a ClosePage IPC to close Tab A, destroying the WebContents and PrintViewManager.
- The attacker performs heap spraying to replace the freed object with a fake vtable, then execution returns and calls PrintPreviewAllowedForTesting() on the freed pointer.
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 in memory but then keeps using it, like deleting a file and then trying to open it. Here, showing a print preview forces the browser out of fullscreen, which briefly pauses the normal flow and allows other actions to happen. If the tab is closed during that pause, the object is destroyed, but the code later tries to use it, which can let an attacker take control.
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.