Skip to content
Memory corruption Advisory Advanced CVE-2026-17807

Use after free in V8 (CVE-2026-17807)

A use-after-free exists in V8's inspector: when a page logs an object whose formatting runs page JavaScript, that JavaScript can destroy the inspector session, freeing the runtime agent while it is still being used. An attacker could then cause a virtual call through a pointer read from the freed object, potentially leading to code execution in the renderer, though only while DevTools is attached.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 2 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 without the Chrome Security team. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.

(Note from awillia: Our system dupes this bug to bug 511255112, but it's a separate issue. Raising this manually to bypass the duping).

Title: V8 Inspector: V8RuntimeAgentImpl UAF via session destruction during console.log→reportToFrontend re-entrancy (KeepSessionAliveScope missing on addMessage path)

Component: Blink>JavaScript>Inspector (or V8>Inspector)

Severity: S2 (renderer C++-heap UAF → vtable call on attacker-groomable freed chunk; DevTools-attached gating)


Summary

V8RuntimeAgentImpl::reportMessage (v8-runtime-agent-impl.cc:1222-1226) passes &m_frontend and m_session into reportToFrontend, which can run page JS via wrapArguments (custom formatters / Error-prototype accessors / @@hasInstance). If that JS destroys the session (not the storage), the agent — owned by unique_ptr<V8RuntimeAgentImpl> m_runtimeAgent inside the session — is freed mid-call. On return, frontend->consoleAPICalled(...) (v8-console-message.cc) makes a virtual call through a FrontendChannel* read from the freed agent, then reportMessage does m_frontend.flush() and m_session->contextGroupId() on freed this.

The KeepSessionAliveScope (a shared_ptr lock on the session, v8-inspector-session-impl.h:163-172) that prevents this is only applied at dispatchProtocolMessage:368 (CDP entry). The console.log path enters via V8ConsoleMessageStorage::addMessage → V8InspectorImpl::forEachSession → session->runtimeAgent()->messageAdded(), which never constructs the scope. forEachSession re-looks-up the session by ID between iterations but hands the lambda a raw V8InspectorSessionImpl* with no pin during one.

Why the bug 511255112 fix does not cover this

1dba9760bf9 + the addMessage:591 follow-up replaced hasConsoleMessageStorage(gid) with consoleMessageStorage(gid) != storage identity checks. But ~V8InspectorSessionImpl (v8-inspector-session-impl.cc:161-170) does not erase m_consoleStorageMap[gid] — only resetContextGroup does. So when the session is destroyed and the storage survives, the storage-identity check at v8-console-message.cc:370 returns false (unchanged) and execution continues into frontend->consoleAPICalled() on the freed agent.

Destruction path (Chrome)

  1. DevTools attached, Runtime.enable issued (default DevTools UI state).
  2. Page does console.log(obj) where obj makes wrapArguments run page JS:
    • obj is a NativeError subclass with a prototype name/message/stack getter — getErrorProperty falls through to object->Get (value-mirror.cc:281); or
    • Runtime.setCustomObjectFormatterEnabled(true) → devtoolsFormatters[i].header() (custom-preview.cc:312); or
    • doesAttributeHaveObservableSideEffectOnGet @@hasInstance callout (value-mirror.cc:1473-1508).
  3. The re-entrant JS enters a nested message loop (alert()/print()). During it, the host_remote_ Mojo disconnect handler fires (devtools_session.cc:188-190) — user closes DevTools, or a colluding extension calls chrome.debugger.detach. Detach() does v8_session_.reset() (devtools_session.cc:258) → shared_ptr refcount 0 → ~V8InspectorSessionImpl → m_runtimeAgent destroyed.
  4. wrapArguments returns. Storage-identity check at :370 passes (storage not erased). frontend->consoleAPICalled(...) reads frontend->frontend_channel_ from the freed V8RuntimeAgentImpl and makes a virtual SendProtocolNotification call.
  5. Back in reportMessage: m_frontend.flush() and m_inspector->hasConsoleMessageStorage(m_session->contextGroupId()) deref freed this.

(Same-process iframe.remove() does not trigger this in Chrome — only local-root frames own a WebDevToolsAgentImpl. Non-Chrome embedders using V8Inspector::connect() (unique_ptr, no m_weakThis) have no keep-alive at all; any synchronous embedder teardown from the JS callout suffices.)

Additional sinks (same root cause)

  • v8-console-message.cc:302 — second wrapArguments-loop iteration calls session->wrapObject(...) on freed session (loop only re-checks inspectedContext).
  • v8-console-message.cc:360 — kException branch frontend->exceptionThrown(...) after wrapException ran page JS, with no post-JS check at all.

Suggested fix

Pin the session across messageAdded. Either in forEachSession's callback wrapper, or in addMessage:

C++
// v8-console-message.cc, V8ConsoleMessageStorage::addMessage:
inspector->forEachSession(contextGroupId, [&message](V8InspectorSessionImpl* session) {
  V8InspectorSessionImpl::KeepSessionAliveScope keepAlive(*session);
  if (message->origin() == V8MessageOrigin::kConsole)
    session->consoleAgent()->messageAdded(message.get());
  session->runtimeAgent()->messageAdded(message.get());
});

(or hoist into V8InspectorImpl::forEachSession so every callback gets it).

Assumptions

  • Unconfirmed: host_remote_ disconnect handler dispatch inside an alert() nested loop (standard renderer nested-message-loop pattern; not traced to the exact SequencedTaskRunner).
  • Confirmed in source: KeepSessionAliveScope only at :368; ~V8InspectorSessionImpl does not erase console storage; forEachSession passes raw ptr without pin; Blink uses connectShared and Detach() does v8_session_.reset().

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 session keep-alive lock (KeepSessionAliveScope) is only applied on the protocol-message entry path, not on the console message path, so re-entrant page JavaScript can destroy the session and free the agent mid-call.

Impact

A renderer C++-heap use-after-free leading to a virtual call on an attacker-groomable freed chunk, which could allow code execution, but only when DevTools is attached.

What the attacker needed

DevTools attached to the page; Runtime domain enabled; Page runs attacker-influenced JavaScript; Session destroyed during the JS callout

The fix

The session should be pinned across messageAdded, either in the forEachSession callback wrapper or in addMessage, using the keep-alive scope.

How it was found

  1. Attach DevTools and enable the Runtime domain (the default DevTools UI state).
  2. Have the page log an object whose formatting runs page JavaScript, for example via a prototype getter, a custom formatter, or a hasInstance callout.
  3. The re-entrant JavaScript enters a nested message loop, during which the DevTools connection is torn down and the session is destroyed.
  4. When formatting returns, the storage-identity check passes and a virtual call is made through the freed agent.
  5. Control returns to reportMessage, which dereferences the freed object again.

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 you open the browser's developer tools, the page and the tools talk to each other. Here, the page could run its own code in the middle of that conversation and pull the rug out from under the tools, so the browser then uses memory that has already been freed. Using freed memory can crash the browser or, in the worst case, let an attacker run their own 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.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.