Use after free in DevTools (CVE-2026-87533)
A potential heap use-after-free and double-free exists in the browser process when clearing the attached sessions map in DevTools, because destroying a session can synchronously trigger reentrant erasure of sibling entries. An attacker with a trusted DevTools client could crash the browser or possibly achieve memory corruption.
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 potential high-severity heap use-after-free and double-free vulnerability exists in the browser process due to reentrancy in content::TargetHandler::Disable(). Synchronous destruction of target sessions during map clearance can trigger a recursive deletion cascade that modifies the same map mid-operation. This corrupts the underlying libc++ tree structure, leading to memory corruption without MiraclePtr protection.
Affected files:
content/browser/devtools/protocol/target_handler.cccontent/browser/devtools/protocol/target_handler.h
Estimated timestamp from git blame: 2017-07-20
Summary
There is a potential reentrancy-driven heap use-after-free (UAF) and double-free vulnerability in the browser process within content::TargetHandler::Disable(). When clearing attached_sessions_ (a std::map<std::string, std::unique_ptr<Session>>), the value destructor (~Session()) can run synchronously. Under specific teardown conditions (such as when a renderer process has crashed), this destruction triggers a recursive cascade that synchronously unlinks and deallocates sibling entries from the same map via S_Bi->AgentHostClosed() -> Detach(true).
Because libc++ __tree::clear() is not reentrancy-safe (it performs a recursive post-order traversal and caches the right-hand child node pointer before invoking the value destructor), the reentrant erase() call executes a search starting from the tree root. This results in Use-After-Free reads on already-freed tree node pointers and keys. Furthermore, if a sibling entry resides in the cached right subtree, the inner erase() deallocates it immediately, causing a Use-After-Free dereference, double-destruction of its unique_ptr payload, and a double-free of the node structure when the outer clear() loop subsequently attempts to visit it.
Affected Locations
content/browser/devtools/protocol/target_handler.cc(specifically withinTargetHandler::Disable(),~Session(), andSession::Detach()).content/browser/devtools/protocol/target_handler.h
Potential Trigger Mechanism
Note: The following are potential steps to trigger the issue, as our automated tooling does not currently have the capability to execute code or run a working Proof-of-Concept.
- Establish a trusted Chrome DevTools Protocol (CDP) client session
S1connected to the root browser session (e.g., via--remote-debugging-pipe). - Attach a child session
S_XviaTarget.attachToTargetwith theflatten: trueoption. This populatesT1->attached_sessions_and instantiates a headless sessionHDS_Xand headless handlerHT_X. - Through child session
sX, create several hidden targets $B_1 \dots B_n$ viaTarget.createTargetwithhidden: true. This places the hidden target IDs intoHT_X->hidden_web_contents_. - Attach all hidden targets $B_1 \dots B_n$ to the root session
S1usingTarget.attachToTarget(Bi). This stores sibling sessionsS_BialongsideS_XinT1->attached_sessions_. - Crash the renderer processes associated with the hidden targets $B_1 \dots B_n$, so that their respective main frames report
IsRenderFrameLive() == false. - Close the root pipe connection
S1. This triggersBrowserDevToolsAgentHost::DetachInternal(S1)on the UI thread, invokingT1->Disable()and callingattached_sessions_.clear(). - When the outer
__tree::clear()deletes nodeS_X, its destructor synchronously detaches the agent host. Because the renderers are dead, this triggers a synchronous fallback branch inRenderFrameHostImpl::ClosePagethat destroys the headless WebContents synchronously. - The WebContents destruction fires frame deletion notifications synchronously, reaching the other attached sessions $S_{Bi}$ on
T1viaAgentHostClosed() -> Detach(true). - This triggers
handler_->attached_sessions_.erase(id_SBi)reentrantly onT1, corrupting the__treeduring the outerclear()operation.
Suggested Fix
To eliminate this reentrancy vulnerability, attached_sessions_ should be swapped to a local map before clearance, or cleared in a reentrancy-safe loop. Swapping the map ensures that any reentrant deletion calls operate on an empty map rather than mutating a container currently undergoing destruction.
Response TargetHandler::Disable() {
SetAutoAttachInternal(false, false, false, base::DoNothing());
SetDiscoverTargets(false, {});
hidden_target_manager_.Clear();
auto_attached_sessions_.clear();
// Swap to local map to prevent reentrancy issues during clearance
std::map<std::string, std::unique_ptr<Session>> attached_sessions;
attached_sessions.swap(attached_sessions_);
attached_sessions.clear();
...
Evaluated with Chrome root at commit: 3947e01999a53d4e2382e39736cb79d79c7dffcf
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 map's clear operation is not reentrancy-safe: destroying a session synchronously triggers erasure of sibling entries from the same map while it is being cleared.
Impact
An attacker with a trusted DevTools client could crash the browser and potentially achieve memory corruption, though the report notes the trigger is only potential and no working proof-of-concept exists.
What the attacker needed
Trusted DevTools client access; ability to crash renderer processes; remote debugging pipe enabled
The fix
The map should be swapped to a local map before clearing, so reentrant deletions operate on an empty map rather than mutating the container being destroyed.
How it was found
- Establish a trusted DevTools client session connected to the root browser session.
- Attach a child session with flattening enabled, populating the attached sessions map.
- Create several hidden targets through the child session.
- Attach all hidden targets to the root session, adding sibling sessions to the map.
- Crash the renderer processes for the hidden targets so their frames are no longer live.
- Close the root pipe connection, triggering the disable routine and the reentrant map corruption.
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.
This is a memory safety bug in a web browser's developer tools. When the browser tries to clean up a list of debugging connections, one cleanup step can unexpectedly trigger another cleanup step on the same list, causing the browser to use memory it has already freed. This can crash the browser and, in theory, let an attacker run harmful code.
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.