Use after free in DevTools (CVE-2026-79266)
A DevTools agent in the renderer kept a bare pointer to a V8 inspector session that could be freed while a nested message loop was running, leaving a dangling pointer. If the session was detached during that pause, the agent could make a virtual call on freed memory when it resumed.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 36 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: A potential Use-After-Free (UAF) vulnerability exists in the renderer process within InspectorDOMDebuggerAgent due to the use of a bare pointer to a V8InspectorSession that can be destroyed during a nested message loop. If the debugger session is detached while inside this nested loop, the session is freed, potentially leading to a virtual call on the freed memory upon resuming. This occurs because Blink-domain Chrome DevTools Protocol (CDP) dispatches lack a session-pinning scope.
Affected files:
third_party/blink/renderer/core/inspector/inspector_dom_debugger_agent.ccthird_party/blink/renderer/core/inspector/inspector_dom_debugger_agent.hthird_party/blink/renderer/core/inspector/devtools_session.ccthird_party/blink/renderer/core/inspector/devtools_session.h
Estimated timestamp from git blame: 2016-04-27
Detailed Description
A potential Use-After-Free (UAF) vulnerability has been identified in InspectorDOMDebuggerAgent. The agent holds a bare (non-raw_ptr) pointer to a v8_inspector::V8InspectorSession object. During the dispatch of certain Blink-domain Chrome DevTools Protocol (CDP) commands, virtual methods are called on this session inside loops that can re-enter page JavaScript via custom object formatters. If the DevTools session is detached while JavaScript execution is paused in a nested message loop, the underlying V8InspectorSession is deleted, leaving the agent with a dangling pointer when execution resumes.
Root Cause
-
Lack of Pinning Scope on Blink Dispatch Path: When a CDP command is executed,
DevToolsSession::DispatchProtocolCommandImplchecks whether the command can be handled by V8. If so, it uses V8's dispatch path which implicitly instantiates aKeepSessionAliveScope(keeping the session's reference count > 0). If it is a Blink-domain command (such asDOMDebugger.getEventListeners), it is dispatched directly viainspector_backend_dispatcher_->Dispatch(dispatchable)without any pinning scope on the stack. -
Bare Pointer Usage:
InspectorDOMDebuggerAgentstoresv8_session_as a bare raw pointer:C++ // third_party/blink/renderer/core/inspector/inspector_dom_debugger_agent.h v8_inspector::V8InspectorSession* v8_session_;Unlike other agents (e.g.,
InspectorDOMAgent),InspectorDOMDebuggerAgentdoes not overrideDispose()to nullifyv8_session_upon detachment. -
Nested Pause and Teardown: In
InspectorDOMDebuggerAgent::BuildObjectForEventListener,v8_session_->wrapObjectis called on the event listener's handler function. If custom formatters are enabled, this triggers V8'sgenerateCustomPreviewwhich runs user-supplied formatter JavaScript. If adebugger;statement is encountered during formatting, the debugger pauses and enters a nested message loop (base::RunLoop(kNestableTasksAllowed).Run()).While paused in this nested loop, a detach request (such as closing DevTools or calling
chrome.debugger.detach()) will triggerDevToolsSession::Detach(). This resets the strongstd::shared_ptr<v8_inspector::V8InspectorSession>reference to0, freeing the object. When the pause loop terminates and the stack unwinds,InspectorDOMDebuggerAgentattempts to execute the next statement:C++ value->setOriginalHandler(v8_session_->wrapObject(context, info.handler, object_group_id, false));This results in a virtual method call on the freed
v8_session_pointer.
Suggested Potential Steps to Reproduce
Note: These steps are suggested/potential based on static code analysis; our automated tooling does not have the capability to execute code.
-
Load a target page containing multiple event listeners registered on
document.body. -
Configure a custom object formatter on the page's global scope:
JavaScript window.devtoolsFormatters = [{ header() { debugger; return null; } }]; -
Attach a
chrome.debuggerextension to the page and enable custom formatters viaRuntime.setCustomObjectFormatterEnabled(true). -
Request the event listeners for
document.bodyusing theDOMDebugger.getEventListenerscommand, passing a non-emptyobjectGroupID. -
Once V8 hits the programmatic breakpoint inside the custom formatter, it enters a nested message loop on pause.
-
Have the extension call
chrome.debugger.detach()to disconnect the session. -
Resume/quit the pause loop. The agent resumes execution in
BuildObjectForEventListenerand attempts to perform a virtual call tov8_session_->wrapObjectusing the freed pointer.
Suggested Fix
To prevent this issue, InspectorDOMDebuggerAgent should align with the design pattern of other agents (such as InspectorDOMAgent and InspectorPageAgent) by implementing a Dispose() override to clear the v8_session_ pointer upon session teardown, and adding null-checks before referencing it:
-
In
InspectorDOMDebuggerAgent:C++ void InspectorDOMDebuggerAgent::Dispose() override { v8_session_ = nullptr; InspectorBaseAgent::Dispose(); } -
Add checks to verify that
v8_session_is non-null before invoking any methods on it withingetEventListenersandBuildObjectForEventListener.
Evaluated with Chrome root at commit: bf775e5d75cb9e1767e2cd02cc93efa0077d14a5
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 Blink-domain CDP dispatch path lacked a session-pinning scope, and the agent stored the V8 inspector session as a bare pointer without clearing it on detach.
Impact
A virtual call on freed memory could crash the renderer and, in principle, may be exploitable, though the text only describes a potential issue found by static analysis and does not demonstrate code execution.
What the attacker needed
A debugger extension attached; custom object formatters enabled; page runs attacker-influenced formatter code
The fix
The agent should override Dispose() to clear the session pointer on teardown and check it for null before use, matching other agents.
How it was found
- Load a page with several event listeners on the document body.
- Set a custom object formatter on the page that hits a debugger statement.
- Attach a debugger extension and enable custom object formatters.
- Request the body's event listeners with a non-empty object group.
- When the breakpoint pauses execution, detach the debugger session.
- Resume the pause so the agent uses the freed session 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.
When a program frees a piece of memory but keeps a reference to it, that reference is called a dangling pointer. If the program later uses it, it may read or call whatever now occupies that memory, which can crash the browser or, in the worst case, let an attacker run their own code. Here the browser's developer tools code kept such a reference while it paused to run page-supplied formatting 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.