Use after free in DevTools (CVE-2026-7975)
A typographical error in TargetHandler::AutoAttacherDestroyed causes iteration over the member container throttles_ instead of a local copy. During the loop, elements are erased and synchronous callbacks can reallocate the container's backing buffer, leading to a use-after-free of the container's buffer and potential remote code execution in the browser process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 37 days
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: A typographical error in TargetHandler::AutoAttacherDestroyed causes iteration over the member container throttles_ instead of a local copy. During this loop, elements are erased, and synchronous callbacks can cause the container's backing buffer to be reallocated, leading to a Use-After-Free (UAF) of the container's buffer and potential Remote Code Execution in the browser process.
Affected files:
content/browser/devtools/protocol/target_handler.cccontent/browser/devtools/protocol/target_handler.h
Estimated timestamp from git blame: 2025-05-26
Vulnerability Summary
A logic error in TargetHandler::AutoAttacherDestroyed within content/browser/devtools/protocol/target_handler.cc leads to iterator invalidation and a potential Use-After-Free (UAF) in the browser process. While the code correctly creates a local copy of the throttles_ container (a base::flat_set), it mistakenly iterates over the member variable itself instead of the copy. During iteration, calling throttle->Clear() results in the current throttle being erased from the throttles_ set, invalidating the loop's iterators. Furthermore, synchronous callbacks during navigation resumption can cause the container's underlying buffer to be reallocated, leading to a UAF.
Technical Details
In TargetHandler::AutoAttacherDestroyed (line 964), the code attempts to safely clear throttles associated with a destroyed TargetAutoAttacher:
void TargetHandler::AutoAttacherDestroyed(TargetAutoAttacher* auto_attacher) {
auto throttles = throttles_; // [1] Local copy created
for (Throttle* throttle : throttles_) { // [2] TYPO: Iterates the member 'throttles_' instead of the copy 'throttles'
if (throttle->auto_attacher() == auto_attacher) {
throttle->Clear(); // [3] This eventually mutates 'throttles_'
}
}
// ...
}
At [1], a copy of throttles_ is created. However, at [2], the loop iterates over the member throttles_ itself. When throttle->Clear() is called at [3], it executes the following path:
Throttle::Clear()(line 676) callsCleanupPointers().Throttle::CleanupPointers()(line 658) callstarget_handler_->throttles_.erase(this).
Because throttles_ is a base::flat_set (internally a sorted std::vector), erasing an element invalidates all iterators to that element and any subsequent elements. This results in the loop's range-based iterator becoming invalid after the first erasure.
Re-entrancy and Use-After-Free
The impact is exacerbated because Throttle::Clear() also calls Resume() (line 682) if the throttle was deferring a navigation. NavigationThrottle::Resume() can trigger synchronous callbacks that start new navigations, which may in turn call TargetHandler::Throttle's constructor. This constructor inserts the new throttle into target_handler_->throttles_ (line 379), which can cause the underlying vector buffer to be reallocated.
When reallocation occurs, the range-based for loop's cached iterators and end() pointer in AutoAttacherDestroyed point to freed heap memory. Subsequent iterations will read from this freed buffer, resulting in a Use-After-Free. The intended safe pattern for iterating and clearing these throttles is demonstrated in TargetHandler::ClearThrottles (lines 854-859), where a copy is correctly utilized.
Impact and Exploitability
An attacker can exploit this issue to achieve a sandbox escape from a compromised renderer process or via a malicious website if a DevTools session is active (e.g., using Puppeteer or Selenium). By grooming the heap after the vector reallocation, an attacker can control the contents of the freed buffer. When the loop continues, it will read a malicious pointer from the freed buffer and call virtual methods (e.g., throttle->auto_attacher() or throttle->Clear()), leading to arbitrary code execution in the privileged browser process.
Notably, MiraclePtr (BRP) does not mitigate this vulnerability because the Use-After-Free occurs on the container's internal buffer of pointers, rather than on the objects pointed to by raw_ptr themselves. This allows for direct control of the program's execution flow if the heap can be sufficiently groomed.
Potential Reproduction Steps
These are suggested steps; our tooling agent doesn't yet have the ability to run code to produce a working exploit:
- Start Chrome with
--remote-debugging-port. - Attach a CDP client and send
Target.setAutoAttach {autoAttach:true, waitForDebuggerOnStart:true, flatten:true}to a page. - Have the page create multiple cross-origin iframes (OOPIFs). This creates multiple
TargetHandler::ResponseThrottleinstances that are in a deferred state. - Navigate the main frame to a different origin (e.g.,
location.href = 'https://other-origin.com'). This destroys theRenderFrameDevToolsAgentHostand itsAutoAttacher. - Observe the crash in
TargetHandler::AutoAttacherDestroyedas it iterates overthrottles_while they are being erased.
Suggested Fix
Change the loop variable in TargetHandler::AutoAttacherDestroyed to iterate over the local copy instead of the member variable:
--- a/content/browser/devtools/protocol/target_handler.cc
+++ b/content/browser/devtools/protocol/target_handler.cc
@@ -963,7 +963,7 @@
void TargetHandler::AutoAttacherDestroyed(TargetAutoAttacher* auto_attacher) {
auto throttles = throttles_;
- for (Throttle* throttle : throttles_) {
+ for (Throttle* throttle : throttles) {
if (throttle->auto_attacher() == auto_attacher) {
throttle->Clear();
}
Evaluated with Chrome root at commit: 876d480da1f794d87813cfa2e6ff4fcf9771e939
Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; 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 loop iterates over the member container throttles_ instead of the local copy, so erasing elements and reallocation during synchronous callbacks invalidate the loop's iterators.
Impact
An attacker could achieve a sandbox escape from a compromised renderer or via a malicious website if a DevTools session is active, and by grooming the heap after reallocation, could control the freed buffer and call virtual methods, leading to arbitrary code execution in the privileged browser process; MiraclePtr does not mitigate this because the use-after-free occurs on the container's internal…
What the attacker needed
Chrome started with remote debugging; A CDP client attached; DevTools session active; Page creates cross-origin iframes
The fix
The loop variable should be changed to iterate over the local copy instead of the member variable.
How it was found
- Start Chrome with --remote-debugging-port.
- Attach a CDP client and send Target.setAutoAttach with autoAttach, waitForDebuggerOnStart, and flatten set to true.
- Have the page create multiple cross-origin iframes (OOPIFs) to create multiple deferred TargetHandler::ResponseThrottle instances.
- Navigate the main frame to a different origin to destroy the RenderFrameDevToolsAgentHost and its AutoAttacher.
- Observe the crash in TargetHandler::AutoAttacherDestroyed as it iterates over throttles_ while they are being erased.
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 keeps using memory after it has been freed. Here, a loop goes over a list of objects, but while looping, the list is changed and its memory can be moved, so the loop ends up reading from freed memory. An attacker who can control that freed memory could make the browser run their 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.