Use after free in DevTools (CVE-2026-17896)
A code-analysis report claims a potential use-after-free in the DevTools virtual time policy handler, where unfreezing pending document loaders can synchronously run page scripts that spin a nested message loop. During that loop a navigation commit could add to the same loader vector, invalidating the loop's iterators and freeing memory still in use.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 42 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: During execution of InspectorEmulationAgent::setVirtualTimePolicy, unfreezing pending loaders can synchronously execute author scripts and spin a nested message loop via a scripted print request. If the virtual time budget expires during this nested loop, the policy reverts to Pause, allowing other concurrent navigation commits to mutate pending_document_loaders_. This results in vector reallocation and iterator invalidation, potentially leading to a Use-After-Free (UAF) in the renderer process.
Affected files:
third_party/blink/renderer/core/inspector/inspector_emulation_agent.ccthird_party/blink/renderer/core/inspector/inspector_emulation_agent.h
Estimated timestamp from git blame: 2020-11-11
Potential Use-After-Free (UAF) in InspectorEmulationAgent::setVirtualTimePolicy
Summary
There is a potential Use-After-Free (UAF) vulnerability in InspectorEmulationAgent::setVirtualTimePolicy due to synchronous script reentrancy and reentrant mutation of the pending_document_loaders_ vector during iteration.
Root Cause Analysis
In InspectorEmulationAgent::setVirtualTimePolicy (third_party/blink/renderer/core/inspector/inspector_emulation_agent.cc:603-605), the agent iterates over pending_document_loaders_ (a HeapVector<Member<DocumentLoader>>) directly with a range-based for loop:
for (DocumentLoader* loader : pending_document_loaders_)
loader->SetDefersLoading(LoaderFreezeMode::kNone);
pending_document_loaders_.clear();
When loader->SetDefersLoading(LoaderFreezeMode::kNone) is called on a loader, it propagates down to NavigationBodyLoader::SetDefersLoading which synchronously invokes OnReadable, reads from the Mojo data pipe, and triggers synchronous HTML parsing (kForceSynchronousParsing is enabled when virtual time is active).
This allows inline script blocks inside the parsing document to execute synchronously on the same stack. If this script spins a nested message loop, asynchronous tasks can run. If the virtual time budget expires inside the nested loop, VirtualTimeBudgetExpired is called and reverts virtual_time_policy_ to Pause.
When any concurrent navigation commit message is processed during the nested loop, InspectorEmulationAgent::WillCommitLoad is invoked. Because the policy was reverted to Pause, the loader is frozen and appended to pending_document_loaders_ via push_back:
void InspectorEmulationAgent::WillCommitLoad(LocalFrame*, DocumentLoader* loader) {
if (virtual_time_policy_.Get() != protocol::Emulation::VirtualTimePolicyEnum::Pause) return;
loader->SetDefersLoading(LoaderFreezeMode::kStrict);
pending_document_loaders_.push_back(loader);
}
This push_back mutates the active pending_document_loaders_ vector, potentially reallocating its backing store. When the nested loop exits and control returns to the range-based for loop, the loop's iterators are invalidated, resulting in a Use-After-Free of the Member<DocumentLoader> backing storage.
Note: Since our tooling agent currently lacks the ability to execute code, these are potential steps and findings derived from code flow analysis.
Suggested Potential Exploitation Steps
An attacker might attempt to exploit this potential vulnerability using the following path:
- Target page runs under a CDP automation session where virtual time is managed (e.g. headless tests).
- The CDP client pauses virtual time (
policy: "pause"), causing multiple frame navigations to freeze and append theirDocumentLoaders topending_document_loaders_. - The CDP client resumes virtual time (
policy: "advance") with a small budget. - During the iteration, the first unpaused loader synchronously parses an inline script containing
parent.print(). This script targets a fully loaded parent frame to bypassLocalDOMWindow::print's loading check, triggeringPrintRenderFrameHelper::RequestPrintPreview. - The scripted print request spins a nested
base::RunLoopwith nestable tasks allowed. - Inside the nested loop, the virtual time budget expires, reverting the policy to
Pause. - Also during the nested loop, a queued navigation commit dispatches, calling
WillCommitLoadand invokingpending_document_loaders_.push_back(), causing vector reallocation. - The print loop is terminated/dismissed, and the range-for resumes with invalidated iterators, leading to UAF.
Recommended Fix
To resolve this issue, adopt the pattern used to fix other reentrancy bugs in loader vectors (such as document_loader.cc:1946-1960) by snapshotting the collection before iterating. Move the elements out of pending_document_loaders_ using std::move or std::exchange before the loop, preventing any reentrant mutations from invalidating active iterators.
HeapVector<Member<DocumentLoader>> pending_loaders = std::move(pending_document_loaders_);
for (DocumentLoader* loader : pending_loaders)
loader->SetDefersLoading(LoaderFreezeMode::kNone);
Evaluated with Chrome root at commit: 75203b87cbf6681eb7c7dda8e1d0bf781538c76a
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
The code iterates the pending_document_loaders_ vector while a call inside the loop can synchronously re-enter and push_back into that same vector, invalidating the iterators.
Impact
The report claims this could lead to a use-after-free in the renderer process, but it is derived from code analysis only and has not been demonstrated; exploitation would require a page already running under a DevTools virtual time session.
What the attacker needed
Page under a CDP virtual time session; attacker-controlled page script; a fully loaded parent frame
The fix
The collection should be snapshotted or moved out before iterating so reentrant additions cannot invalidate the loop's iterators.
How it was found
- Run the target page under a DevTools automation session that manages virtual time.
- Pause virtual time so several frame navigations freeze and their loaders are added to the pending list.
- Resume virtual time with a small budget so the loop starts unfreezing loaders.
- The first unfrozen loader synchronously parses an inline script that requests printing of a fully loaded parent frame, spinning a nested message loop.
- Inside that loop the virtual time budget expires, the policy reverts to pause, and a queued navigation commit adds a loader to the vector.
- The print loop ends and the original loop resumes with invalidated iterators, leading to a 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 browser resumes a paused page, it walks a list of pending page loads and lets each one continue. Letting one continue can run code from the page straight away, and that code can trigger other browser work in the middle of the walk. If that other work adds an item to the same list, the list can be moved in memory while the walk is still using the old location, so the browser reads freed memory.
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.