Skip to content
Memory corruption Advisory Advanced CVE-2024-3168

Use after free in DevTools (CVE-2024-3168)

A use-after-free flaw in Chrome's DevTools inspector allows a crafted web page to crash the browser when DevTools is open. The attacker can trigger a heap-use-after-free by causing a rejected promise to be reported after the DevTools session has been detached.

Cassidy Kim Follow

Originally disclosed on Chrome VRP

Bounty$3,000 Medium View original
  • Fix shipped in 16 days

tested os: ubuntu 22.04 tested chrome version: stable & beta & dev

component:Platform>DevTools>JavaScript

repro steps:

  1. ~./chrome --user-data-dir=/tmp/xx1
  2. open the devtools.
  3. open page http://localhost:8880/crash.html

You should see the UAF crash in a few seconds.

==1==ERROR: AddressSanitizer: heap-use-after-free on address 0x50d0003a2078 at pc 0x560782104db6 bp 0x7f461763d470 sp 0x7f461763d468 READ of size 8 at 0x50d0003a2078 thread T35 (DedicatedWorker) #0 0x560782104db5 in v8_inspector::protocol::Runtime::Frontend::exceptionThrown(double, std::__Cr::unique_ptr<v8_inspector::protocol::Runtime::ExceptionDetails, std::__Cr::default_delete<v8_inspector::protocol::Runtime::ExceptionDetails>>) ./gen/v8/src/inspector/protocol/Runtime.cpp:498:10 #1 0x560782153749 in v8_inspector::V8ConsoleMessage::reportToFrontend(v8_inspector::protocol::Runtime::Frontend*, v8_inspector::V8InspectorSessionImpl*, bool) const ./../../v8/src/inspector/v8-console-message.cc:340:15 #2 0x56078221864e in reportMessage ./../../v8/src/inspector/v8-runtime-agent-impl.cc:1155:12 #3 0x56078221864e in v8_inspector::V8RuntimeAgentImpl::messageAdded(v8_inspector::V8ConsoleMessage*) ./../../v8/src/inspector/v8-runtime-agent-impl.cc:1150:18 #4 0x5607821e1607 in operator() ./../../third_party/libc++/src/include/__functional/function.h:711:12 #5 0x5607821e1607 in operator() ./../../third_party/libc++/src/include/__functional/function.h:978:10 #6 0x5607821e1607 in v8_inspector::V8InspectorImpl::forEachSession(int, std::__Cr::function<void (v8_inspector::V8InspectorSessionImpl*)> const&) ./../../v8/src/inspector/v8-inspector-impl.cc:430:40 #7 0x56078215736e in v8_inspector::V8ConsoleMessageStorage::addMessage(std::__Cr::unique_ptr<v8_inspector::V8ConsoleMessage, std::__Cr::default_delete<v8_inspector::V8ConsoleMessage>>) ./../../v8/src/inspector/v8-console-message.cc:567:14 #8 0x5607821e3366 in v8_inspector::V8InspectorImpl::exceptionThrown(v8::Localv8::Context, v8_inspector::StringView, v8::Localv8::Value, v8_inspector::StringView, v8_inspector::StringView, unsigned int, unsigned int, std::__Cr::unique_ptr<v8_inspector::V8StackTrace, std::__Cr::default_delete<v8_inspector::V8StackTrace>>, int) ./../../v8/src/inspector/v8-inspector-impl.cc:296:41 #9 0x56079948116b in blink::ThreadDebuggerCommonImpl::PromiseRejected(v8::Localv8::Context, WTF::String const&, v8::Localv8::Value, std::__Cr::unique_ptr<blink::SourceLocation, std::__Cr::default_deleteblink::SourceLocation>) ./../../third_party/blink/renderer/core/inspector/thread_debugger_common_impl.cc:146:28 #10 0x560797acb343 in blink::RejectedPromises::Message::Report() ./../../third_party/blink/renderer/bindings/core/v8/rejected_promises.cc:90:43 #11 0x560797ac919f in blink::RejectedPromises::ProcessQueueNow(WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message>, 0u, WTF::PartitionAllocator>) ./../../third_party/blink/renderer/bindings/core/v8/rejected_promises.cc:268:16 #12 0x560797acce79 in void base::internal::FunctorTraits<void (blink::RejectedPromises::)(WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message>, 0u, WTF::PartitionAllocator>)>::Invoke<void (blink::RejectedPromises::)(WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message>, 0u, WTF::PartitionAllocator>), scoped_refptrblink::RejectedPromises, WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message>, 0u, WTF::PartitionAllocator>>(void (blink::RejectedPromises::)(WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message>, 0u, WTF::PartitionAllocator>), scoped_refptrblink::RejectedPromises&&, WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message>, 0u, WTF::PartitionAllocator>&&) ./../../base/functional/bind_internal.h:710:12 #13 0x560797accc79 in MakeItSo<void (blink::RejectedPromises::)(WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message >, 0U, WTF::PartitionAllocator>), std::__Cr::tuple<scoped_refptrblink::RejectedPromises, WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message >, 0U, WTF::PartitionAllocator> > > ./../../base/functional/bind_internal.h:860:12 #14 0x560797accc79 in RunImpl<void (blink::RejectedPromises::)(WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message >, 0U, WTF::PartitionAllocator>), std::__Cr::tuple<scoped_refptrblink::RejectedPromises, WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message >, 0U, WTF::PartitionAllocator> >, 0UL, 1UL> ./../../base/functional/bind_internal.h:991:14 #15 0x560797accc79 in base::internal::Invoker<base::internal::BindState<void (blink::RejectedPromises::)(WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message>, 0u, WTF::PartitionAllocator>), scoped_refptrblink::RejectedPromises, WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_deleteblink::RejectedPromises::Message>, 0u, WTF::PartitionAllocator>>, void ()>::RunOnce(base::internal::BindStateBase*) ./../../base/functional/bind_internal.h:904:12 #16 0x56078c2e5a84 in Run ./../../base/functional/callback.h:156:12 #17 0x56078c2e5a84 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) ./../../base/task/common/task_annotator.cc:201:34 #18 0x56078c344a8f in RunTask<(lambda at ../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:480:11)> ./../../base/task/common/task_annotator.h:89:5 #19 0x56078c344a8f in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*) ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:478:23 #20 0x56078c343a89 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:343:41 #21 0x56078c34584a in non-virtual thunk to base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:0:0 #22 0x56078c1ded8c in base::MessagePumpDefault::Run(base::MessagePump::Delegate*) ./../../base/message_loop/message_pump_default.cc:40:55 #23 0x56078c34657f in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:646:12 #24 0x56078c27a10f in base::RunLoop::Run(base::Location const&) ./../../base/run_loop.cc:134:14 #25 0x560788b5d8bc in blink::scheduler::NonMainThreadImpl::SimpleThreadImpl::Run() ./../../third_party/blink/renderer/platform/scheduler/worker/non_main_thread_impl.cc:182:14 #26 0x56078c40add7 in base::(anonymous namespace)::ThreadFunc(void*) ./../../base/threading/platform_thread_posix.cc:103:13 #27 0x56077a897918 in asan_thread_start(void*) asan_rtl:28

0x50d0003a2078 is located 24 bytes inside of 144-byte region [0x50d0003a2060,0x50d0003a20f0) freed by thread T35 (DedicatedWorker) here: #0 0x56077a8ce0bd in operator delete(void*) asan_rtl:3 #1 0x5607821f26f8 in operator() ./../../third_party/libc++/src/include/__memory/unique_ptr.h:66:5 #2 0x5607821f26f8 in reset ./../../third_party/libc++/src/include/__memory/unique_ptr.h:266:7 #3 0x5607821f26f8 in ~unique_ptr ./../../third_party/libc++/src/include/__memory/unique_ptr.h:236:71 #4 0x5607821f26f8 in v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() ./../../v8/src/inspector/v8-inspector-session-impl.cc:169:1 #5 0x5607821f2d93 in v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() ./../../v8/src/inspector/v8-inspector-session-impl.cc:160:51 #6 0x5607995a0eac in operator() ./../../third_party/libc++/src/include/__memory/unique_ptr.h:66:5 #7 0x5607995a0eac in reset ./../../third_party/libc++/src/include/__memory/unique_ptr.h:266:7 #8 0x5607995a0eac in blink::DevToolsSession::Detach() ./../../third_party/blink/renderer/core/inspector/devtools_session.cc:215:15 #9 0x5607995ad042 in Invoke<void (blink::DevToolsSession::)(), const cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy> &> ./../../base/functional/bind_internal.h:710:12 #10 0x5607995ad042 in MakeItSo<void (blink::DevToolsSession::)(), std::__Cr::tuple<cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy> > > ./../../base/functional/bind_internal.h:881:5 #11 0x5607995ad042 in RunImpl<void (blink::DevToolsSession::)(), std::__Cr::tuple<cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy> >, 0UL> ./../../base/functional/bind_internal.h:991:14 #12 0x5607995ad042 in base::internal::Invoker<base::internal::BindState<void (blink::DevToolsSession::)(), cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy>>, void ()>::RunOnce(base::internal::BindStateBase*) ./../../base/functional/bind_internal.h:904:12 #13 0x56078d976002 in Run ./../../base/functional/callback.h:156:12 #14 0x56078d976002 in mojo::InterfaceEndpointClient::NotifyError(std::__Cr::optionalmojo::DisconnectReason const&) ./../../mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:744:31 #15 0x56078d99c676 in mojo::internal::MultiplexRouter::ProcessNotifyErrorTask(mojo::internal::MultiplexRouter::Task*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*) ./../../mojo/public/cpp/bindings/lib/multiplex_router.cc:1010:13 #16 0x56078d993b24 in mojo::internal::MultiplexRouter::ProcessTasks(mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*) ./../../mojo/public/cpp/bindings/lib/multiplex_router.cc:923:15 #17 0x56078d99da78 in mojo::internal::MultiplexRouter::LockAndCallProcessTasks() ./../../mojo/public/cpp/bindings/lib/multiplex_router.cc:1124:3 #18 0x56078d99f0e4 in Invoke<void (mojo::internal::MultiplexRouter::)(), scoped_refptrmojo::internal::MultiplexRouter > ./../../base/functional/bind_internal.h:710:12 #19 0x56078d99f0e4 in MakeItSo<void (mojo::internal::MultiplexRouter::)(), std::__Cr::tuple<scoped_refptrmojo::internal::MultiplexRouter > > ./../../base/functional/bind_internal.h:860:12 #20 0x56078d99f0e4 in RunImpl<void (mojo::internal::MultiplexRouter::)(), std::__Cr::tuple<scoped_refptrmojo::internal::MultiplexRouter >, 0UL> ./../../base/functional/bind_internal.h:991:14 #21 0x56078d99f0e4 in base::internal::Invoker<base::internal::BindState<void (mojo::internal::MultiplexRouter::)(), scoped_refptrmojo::internal::MultiplexRouter>, void ()>::RunOnce(base::internal::BindStateBase*) ./../../base/functional/bind_internal.h:904:12 #22 0x56078c2e5a84 in Run ./../../base/functional/callback.h:156:12 #23 0x56078c2e5a84 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) ./../../base/task/common/task_annotator.cc:201:34 #24 0x56078c344a8f in RunTask<(lambda at ../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:480:11)> ./../../base/task/common/task_annotator.h:89:5 #25 0x56078c344a8f in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*) ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:478:23 #26 0x56078c343a89 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:343:41 #27 0x56078c34584a in non-virtual thunk to base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:0:0 #28 0x56078c1ded8c in base::MessagePumpDefault::Run(base::MessagePump::Delegate*) ./../../base/message_loop/message_pump_default.cc:40:55 #29 0x56078c34668e in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:643:12 #30 0x56078c27a10f in base::RunLoop::Run(base::Location const&) ./../../base/run_loop.cc:134:14 #31 0x5607a31a7bf3 in content::(anonymous namespace)::NestedMessageLoopRunnerImpl::Run() ./../../content/child/blink_platform_impl.cc:88:14 #32 0x56079ad736e5 in blink::WorkerThread::PauseOrFreezeOnWorkerThread(blink::mojom::FrameLifecycleState, bool) ./../../third_party/blink/renderer/core/workers/worker_thread.cc:916:20 #33 0x5607802ff331 in v8::internal::Isolate::InvokeApiInterruptCallbacks() ./../../v8/src/execution/isolate.cc:1739:5 #34 0x56078036027c in v8::internal::StackGuard::HandleInterrupts(v8::internal::StackGuard::InterruptLevel) ./../../v8/src/execution/stack-guard.cc:371:15 #35 0x5607812d683f in __RT_impl_Runtime_StackGuard ./../../v8/src/runtime/runtime-internal.cc:354:34 #36 0x5607812d683f in v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) ./../../v8/src/runtime/runtime-internal.cc:343:1 #37 0x56078369ee75 in Builtins_CEntry_Return1_ArgvOnStack_NoBuiltinExit setup-isolate-deserialize.cc:0:0 #38 0x560783682026 in Builtins_SetPrototypeAdd setup-isolate-deserialize.cc:0:0 #39 0x5607836037db in Builtins_JSEntryTrampoline setup-isolate-deserialize.cc:0:0 #40 0x560783603506 in Builtins_JSEntry setup-isolate-deserialize.cc:0:0 #41 0x5607802bd85d in Call ./../../v8/src/execution/simulator.h:178:12 #42 0x5607802bd85d in v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) ./../../v8/src/execution/execution.cc:418:22 #43 0x5607802c074a in v8::internal::Execution::CallBuiltin(v8::internal::Isolate*, v8::internal::Handlev8::internal::JSFunction, v8::internal::Handlev8::internal::Object, int, v8::internal::Handlev8::internal::Object) ./../../v8/src/execution/execution.cc:526:10 #44 0x56077fe752f8 in v8::Set::Add(v8::Localv8::Context, v8::Localv8::Value) ./../../v8/src/api/api.cc:8502:20 #45 0x56078222d634 in v8_inspector::ValueMirror::getProperties(v8::Localv8::Context, v8::Localv8::Object, bool, bool, bool, v8_inspector::ValueMirror::PropertyAccumulator) ./../../v8/src/inspector/value-mirror.cc:1520:15

The original report as published on the Chromium issue tracker, by Cassidy Kim(@cassidy6564). Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

Context

This is a use after free in Chrome DevTools, tracked as CVE-2024-3168 and reported through the Chrome VRP. The affected component is listed as Platform > DevTools > JavaScript. The bug lives in the V8 inspector layer that DevTools uses to receive console and exception messages from a page, including from dedicated workers. When a worker throws or rejects a promise, the inspector builds a console message and reports it to every attached inspector session through v8_inspector::V8ConsoleMessage::reportToFrontend. If a session is torn down while such a message is still queued for delivery, the frontend pointer held by the message can outlive the session object it points into, and the later report dereferences freed memory.

The researcher is Cassidy Kim (@cassidy6564). The platform records the severity as medium and the bounty as 3000.00 USD, with disclosure on 2024-02-20. No CVSS score is recorded.

Setup

The report gives the following environment:

  • Tested OS: ubuntu 22.04
  • Tested Chrome version: stable & beta & dev
  • Component: Platform > DevTools > JavaScript

The repro requires DevTools to be open while the page is loaded. The page is served from a local HTTP server on port 8880, and the crashing document is named crash.html. The report does not include the contents of crash.html, so the exact JavaScript that triggers the worker rejection is not shown. The build used for the trace is an AddressSanitizer build, since the output is an ASan report.

Finding it

The researcher observed that loading the page with DevTools open produces a UAF crash within a few seconds. The crash is a heap-use-after-free reported by AddressSanitizer, and the stack shows the read happening on the worker thread while the object was freed earlier on the same thread during session teardown. The free stack goes through DevToolsSession::Detach, and the read happens later in the message delivery path.

Exploitation

Step 1: launch Chrome with a fresh profile

Bash
~./chrome  --user-data-dir=/tmp/xx1

This starts Chrome with a throwaway user data directory so the test is not affected by existing profile state. The report does not specify any other flags.

Step 2: open DevTools

With the browser running, open DevTools. Open DevTools, as the repro steps require.

Step 3: load the crashing page

HTTP
http://localhost:8880/crash.html

Navigate to the page served locally on port 8880. According to the report, the use after free crash appears within a few seconds. The report does not include the page source, so the specific worker code and promise rejection are not reproduced here.

The crash

The ASan report begins as follows:

Text
==1==ERROR: AddressSanitizer: heap-use-after-free on address 0x50d0003a2078 at pc 0x560782104db6 bp 0x7f461763d470 sp 0x7f461763d468
READ of size 8 at 0x50d0003a2078 thread T35 (DedicatedWorker)
    #0 0x560782104db5 in v8_inspector::protocol::Runtime::Frontend::exceptionThrown(double, std::__Cr::unique_ptr<v8_inspector::protocol::Runtime::ExceptionDetails, std::__Cr::default_delete<v8_inspector::protocol::Runtime::ExceptionDetails>>) ./gen/v8/src/inspector/protocol/Runtime.cpp:498:10
    #1 0x560782153749 in v8_inspector::V8ConsoleMessage::reportToFrontend(v8_inspector::protocol::Runtime::Frontend*, v8_inspector::V8InspectorSessionImpl*, bool) const ./../../v8/src/inspector/v8-console-message.cc:340:15
    #2 0x56078221864e in reportMessage ./../../v8/src/inspector/v8-runtime-agent-impl.cc:1155:12
    #3 0x56078221864e in v8_inspector::V8RuntimeAgentImpl::messageAdded(v8_inspector::V8ConsoleMessage*) ./../../v8/src/inspector/v8-runtime-agent-impl.cc:1150:18
    #4 0x5607821e1607 in operator() ./../../third_party/libc++/src/include/__functional/function.h:711:12
    #5 0x5607821e1607 in operator() ./../../third_party/libc++/src/include/__functional/function.h:978:10
    #6 0x5607821e1607 in v8_inspector::V8InspectorImpl::forEachSession(int, std::__Cr::function<void (v8_inspector::V8InspectorSessionImpl*)> const&) ./../../v8/src/inspector/v8-inspector-impl.cc:430:40
    #7 0x56078215736e in v8_inspector::V8ConsoleMessageStorage::addMessage(std::__Cr::unique_ptr<v8_inspector::V8ConsoleMessage, std::__Cr::default_delete<v8_inspector::V8ConsoleMessage>>) ./../../v8/src/inspector/v8-console-message.cc:567:14
    #8 0x5607821e3366 in v8_inspector::V8InspectorImpl::exceptionThrown(v8::Local<v8::Context>, v8_inspector::StringView, v8::Local<v8::Value>, v8_inspector::StringView, v8_inspector::StringView, unsigned int, unsigned int, std::__Cr::unique_ptr<v8_inspector::V8StackTrace, std::__Cr::default_delete<v8_inspector::V8StackTrace>>, int) ./../../v8/src/inspector/v8-inspector-impl.cc:296:41
    #9 0x56079948116b in blink::ThreadDebuggerCommonImpl::PromiseRejected(v8::Local<v8::Context>, WTF::String const&, v8::Local<v8::Value>, std::__Cr::unique_ptr<blink::SourceLocation, std::__Cr::default_delete<blink::SourceLocation>>) ./../../third_party/blink/renderer/core/inspector/thread_debugger_common_impl.cc:146:28
    #10 0x560797acb343 in blink::RejectedPromises::Message::Report() ./../../third_party/blink/renderer/bindings/core/v8/rejected_promises.cc:90:43
    #11 0x560797ac919f in blink::RejectedPromises::ProcessQueueNow(WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_delete<blink::RejectedPromises::Message>>, 0u, WTF::PartitionAllocator>) ./../../third_party/blink/renderer/bindings/core/v8/rejected_promises.cc:268:16

The read of size 8 happens in Runtime::Frontend::exceptionThrown, called from V8ConsoleMessage::reportToFrontend, which is reached from V8RuntimeAgentImpl::messageAdded while iterating sessions in V8InspectorImpl::forEachSession. The message itself originates from a rejected promise in a dedicated worker: blink::RejectedPromises::Message::Report calls ThreadDebuggerCommonImpl::PromiseRejected, which calls V8InspectorImpl::exceptionThrown, which stores the message and reports it to the frontend. The thread is identified as T35 (DedicatedWorker).

The allocation context and the free stack follow:

Text
0x50d0003a2078 is located 24 bytes inside of 144-byte region [0x50d0003a2060,0x50d0003a20f0)
freed by thread T35 (DedicatedWorker) here:
    #0 0x56077a8ce0bd in operator delete(void*) _asan_rtl_:3
    #1 0x5607821f26f8 in operator() ./../../third_party/libc++/src/include/__memory/unique_ptr.h:66:5
    #2 0x5607821f26f8 in reset ./../../third_party/libc++/src/include/__memory/unique_ptr.h:266:7
    #3 0x5607821f26f8 in ~unique_ptr ./../../third_party/libc++/src/include/__memory/unique_ptr.h:236:71
    #4 0x5607821f26f8 in v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() ./../../v8/src/inspector/v8-inspector-session-impl.cc:169:1
    #5 0x5607821f2d93 in v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() ./../../v8/src/inspector/v8-inspector-session-impl.cc:160:51
    #6 0x5607995a0eac in operator() ./../../third_party/libc++/src/include/__memory/unique_ptr.h:66:5
    #7 0x5607995a0eac in reset ./../../third_party/libc++/src/include/__memory/unique_ptr.h:266:7
    #8 0x5607995a0eac in blink::DevToolsSession::Detach() ./../../third_party/blink/renderer/core/inspector/devtools_session.cc:215:15
    #9 0x5607995ad042 in Invoke<void (blink::DevToolsSession::*)(), const cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy> &> ./../../base/functional/bind_internal.h:710:12
    #10 0x5607995ad042 in MakeItSo<void (blink::DevToolsSession::*)(), std::__Cr::tuple<cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy> > > ./../../base/functional/bind_internal.h:881:5
    #11 0x5607995ad042 in RunImpl<void (blink::DevToolsSession::*)(), std::__Cr::tuple<cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy> >, 0UL> ./../../base/functional/bind_internal.h:991:14
    #12 0x5607995ad042 in base::internal::Invoker<base::internal::BindState<void (blink::DevToolsSession::*)(), cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy>>, void ()>::RunOnce(base::internal::BindStateBase*) ./../../base/functional/bind_internal.h:904:12
    #13 0x56078d976002 in Run ./../../base/functional/callback.h:156:12
    #14 0x56078d976002 in mojo::InterfaceEndpointClient::NotifyError(std::__Cr::optional<mojo::DisconnectReason> const&) ./../../mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:744:31
    #15 0x56078d99c676 in mojo::internal::MultiplexRouter::ProcessNotifyErrorTask(mojo::internal::MultiplexRouter::Task*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*) ./../../mojo/public/cpp/bindings/lib/multiplex_router.cc:1010:13
    #16 0x56078d993b24 in mojo::internal::MultiplexRouter::ProcessTasks(mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*) ./../../mojo/public/cpp/bindings/lib/multiplex_router.cc:923:15
    #17 0x56078d99da78 in mojo::internal::MultiplexRouter::LockAndCallProcessTasks() ./../../mojo/public/cpp/bindings/lib/multiplex_router.cc:1124:3

The free happens in V8InspectorSessionImpl::~V8InspectorSessionImpl, reached from blink::DevToolsSession::Detach, which is invoked from a Mojo error notification (InterfaceEndpointClient::NotifyError). In other words, the inspector session is destroyed when the DevTools connection is torn down, and the console message that was queued for that session still holds a pointer into the freed session.

The free stack continues into the worker lifecycle:

Text
    #31 0x5607a31a7bf3 in content::(anonymous namespace)::NestedMessageLoopRunnerImpl::Run() ./../../content/child/blink_platform_impl.cc:88:14
    #32 0x56079ad736e5 in blink::WorkerThread::PauseOrFreezeOnWorkerThread(blink::mojom::FrameLifecycleState, bool) ./../../third_party/blink/renderer/core/workers/worker_thread.cc:916:20
    #33 0x5607802ff331 in v8::internal::Isolate::InvokeApiInterruptCallbacks() ./../../v8/src/execution/isolate.cc:1739:5
    #34 0x56078036027c in v8::internal::StackGuard::HandleInterrupts(v8::internal::StackGuard::InterruptLevel) ./../../v8/src/execution/stack-guard.cc:371:15
    #35 0x5607812d683f in __RT_impl_Runtime_StackGuard ./../../v8/src/runtime/runtime-internal.cc:354:34
    #36 0x5607812d683f in v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) ./../../v8/src/runtime/runtime-internal.cc:343:1

This shows the worker being paused or frozen (WorkerThread::PauseOrFreezeOnWorkerThread) and running a nested message loop, during which the Mojo disconnect is processed and the session is detached. The message that was already queued for the frontend is then delivered after the session is gone.

Root cause

A console message produced by a rejected promise in a dedicated worker is stored and then reported to every attached inspector session through V8InspectorImpl::forEachSession. The read happens in Runtime::Frontend::exceptionThrown after the session was freed. When the DevTools connection drops, blink::DevToolsSession::Detach destroys the V8InspectorSessionImpl, which frees the frontend. If the worker is paused or frozen at that moment and a nested message loop processes the Mojo disconnect, the pending message is delivered afterwards and Runtime::Frontend::exceptionThrown reads the freed frontend. The report does not describe the exact fix, so the specific lifetime change is not stated here.

Impact

The report demonstrates a renderer crash triggered by a page that produces a rejected promise in a dedicated worker while DevTools is open. The effect shown is a crash of the renderer while DevTools is open.

Fix

The fix would need to ensure that a queued console message does not report to a frontend whose session has been destroyed, for example by validating the session after the nested message loop or by holding a safe reference to the session for the duration of delivery. The report does not confirm which approach was taken.

Variants to test

  • Rejected promises in other worker types (shared workers, service workers) with DevTools attached: a positive result is an ASan heap-use-after-free in V8ConsoleMessage::reportToFrontend or Runtime::Frontend::exceptionThrown on the worker thread.
  • Other console message sources, such as console.error or uncaught exceptions in a worker, combined with pausing or freezing the worker: a positive result is the same free in V8InspectorSessionImpl::~V8InspectorSessionImpl followed by a read in the message delivery path.
  • Detaching DevTools while a worker is paused or frozen: a positive result is a crash whose free stack goes through DevToolsSession::Detach and whose read stack goes through forEachSession.
  • Multiple attached sessions where one is detached during message delivery: a positive result is a read of a freed frontend belonging to the detached session while another session remains attached.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 17 min read.

What happened, in plain words

Chrome has a built-in set of tools for web developers, called DevTools. You open it with a keyboard shortcut or from the browser menu, and it shows you things like the page's console messages, network requests and errors. To do that, DevTools attaches to the page and listens for messages from the part of Chrome that runs JavaScript, called V8.

This report describes a bug in that listening machinery. When a page runs JavaScript inside a background helper called a worker, and that worker produces an error that nobody catches (a rejected promise), the inspector builds a message about the error and tries to hand it to DevTools. If the DevTools session is torn down at the wrong moment, the message is still delivered afterwards, to memory that has already been freed. Reading memory that has already been freed is called a use after free, and it crashes the browser tab.

The bug is tracked as CVE-2024-3168. CVE stands for Common Vulnerabilities and Exposures: a public catalogue number given to a security flaw so people can refer to it unambiguously. It was reported through the Chrome VRP, the Chrome Vulnerability Reward Program, which pays researchers for finding and reporting bugs in Chrome. The researcher is Cassidy Kim (@cassidy6564). The platform records the severity as medium and the bounty as 3000.00 USD, with disclosure on 2024-02-20. No CVSS score is recorded. CVSS is a standard scoring system for the seriousness of a vulnerability; here it was simply not filled in.

The affected component is listed as Platform > DevTools > JavaScript. That is a path through Chrome's internal structure: the platform layer, then the DevTools feature, then the JavaScript engine part of it.

Setup

The report gives the following environment:

  • Tested OS: ubuntu 22.04
  • Tested Chrome version: stable & beta & dev
  • Component: Platform > DevTools > JavaScript

In plain terms: the researcher tried this on Ubuntu 22.04, a version of the Linux operating system, and on three release channels of Chrome (stable, beta and dev). The stable channel is the normal everyday Chrome; beta and dev are earlier, less polished builds that get changes sooner. The report lists stable, beta and dev as the tested versions.

The repro requires DevTools to be open while the page is loaded. The page is served from a local HTTP server on port 8880, and the crashing document is named crash.html. A local HTTP server is a small program on your own computer that hands out web pages over the HTTP protocol, the same language browsers use to talk to websites, but only to your own machine. Port 8880 is just a numbered door on that server; the browser connects to localhost (your own computer) on that door.

The report does not include the contents of crash.html, so the exact JavaScript that triggers the worker rejection is not shown. The build used for the trace is an AddressSanitizer build, since the output is an ASan report. AddressSanitizer, often shortened to ASan, is a special instrumented build of a program that watches memory use and shouts loudly when code reads or writes memory it should not. Normal Chrome builds do not print such reports; researchers use ASan builds to turn a silent memory mistake into a clear, detailed crash log.

Finding it

The researcher observed that loading the page with DevTools open produces a UAF crash within a few seconds. A dedicated worker is a background JavaScript thread that a page creates to do work without freezing the visible page; it belongs to that one page. A promise is JavaScript's way of representing a result that will arrive later; a rejected promise means that result failed, and if nothing handles the failure, the browser reports it as an error.

The renderer is the part of Chrome that turns a web page into what you see and runs its JavaScript. Each tab usually has its own renderer, which is why a crash here takes down the tab rather than the whole browser.

The crash is a heap-use-after-free reported by AddressSanitizer. The heap is the pool of memory a program uses for objects it creates while running; "use after free" means the program gave a piece of that memory back and then kept using it. The stack shows the read happening on the worker thread while the object was freed earlier on the same thread during session teardown. A stack (or stack trace) is the list of function calls that led to the moment of the crash, like a receipt showing every step that got you there. Session teardown means the inspector connection being closed and its objects destroyed.

The free stack goes through DevToolsSession::Detach, and the read happens later in the message delivery path. A lifetime bug is a mistake about how long an object is allowed to live: something is used after its life has ended. A race is when two things happen at nearly the same time and the result depends on the order; a benign race is one that does no harm. Here the harm is real: memory is genuinely freed and then read.

Exploitation

Step 1: launch Chrome with a fresh profile

Bash
~./chrome  --user-data-dir=/tmp/xx1

Line by line:

  • ~./chrome is how the report writes the command that starts the Chrome program. The ~ normally means your home folder, and ./chrome means "the file called chrome in the current folder"; the report writes them together, so treat this as the researcher's shorthand for launching their Chrome binary.
  • --user-data-dir=/tmp/xx1 is a command-line option that tells Chrome to keep all its profile data (history, settings, cookies, extensions) in the folder /tmp/xx1 instead of the normal profile folder. /tmp is a temporary folder on Linux, and xx1 is just a name the researcher chose.

Why this step: starting with a throwaway profile means the test is not affected by existing profile state, such as old settings or extensions, and it does not disturb the researcher's everyday Chrome. The report does not specify any other flags.

Step 2: open DevTools

With the browser running, open DevTools. Open DevTools, as the repro steps require. "Attached" means DevTools has connected to the page and is listening; "frontend" here is the DevTools side that receives messages. If DevTools is not open, there is nobody to deliver the message to, and this particular path is not exercised.

Step 3: load the crashing page

HTTP
http://localhost:8880/crash.html

Line by line:

  • http:// is the protocol, the set of rules for fetching a web page.
  • localhost means this computer, the one you are sitting at.
  • :8880 is the port number, the numbered door on the local server where the page is being served.
  • /crash.html is the path of the page on that server.

Why this step: the report says the UAF crash appears within a few seconds after loading this page. Navigate to it, and according to the report the use after free crash appears within a few seconds. The report does not include the page source, so the specific worker code and promise rejection are not reproduced here.

The crash

The ASan report begins as follows:

Text
==1==ERROR: AddressSanitizer: heap-use-after-free on address 0x50d0003a2078 at pc 0x560782104db6 bp 0x7f461763d470 sp 0x7f461763d468
READ of size 8 at 0x50d0003a2078 thread T35 (DedicatedWorker)
    #0 0x560782104db5 in v8_inspector::protocol::Runtime::Frontend::exceptionThrown(double, std::__Cr::unique_ptr<v8_inspector::protocol::Runtime::ExceptionDetails, std::__Cr::default_delete<v8_inspector::protocol::Runtime::ExceptionDetails>>) ./gen/v8/src/inspector/protocol/Runtime.cpp:498:10
    #1 0x560782153749 in v8_inspector::V8ConsoleMessage::reportToFrontend(v8_inspector::protocol::Runtime::Frontend*, v8_inspector::V8InspectorSessionImpl*, bool) const ./../../v8/src/inspector/v8-console-message.cc:340:15
    #2 0x56078221864e in reportMessage ./../../v8/src/inspector/v8-runtime-agent-impl.cc:1155:12
    #3 0x56078221864e in v8_inspector::V8RuntimeAgentImpl::messageAdded(v8_inspector::V8ConsoleMessage*) ./../../v8/src/inspector/v8-runtime-agent-impl.cc:1150:18
    #4 0x5607821e1607 in operator() ./../../third_party/libc++/src/include/__functional/function.h:711:12
    #5 0x5607821e1607 in operator() ./../../third_party/libc++/src/include/__functional/function.h:978:10
    #6 0x5607821e1607 in v8_inspector::V8InspectorImpl::forEachSession(int, std::__Cr::function<void (v8_inspector::V8InspectorSessionImpl*)> const&) ./../../v8/src/inspector/v8-inspector-impl.cc:430:40
    #7 0x56078215736e in v8_inspector::V8ConsoleMessageStorage::addMessage(std::__Cr::unique_ptr<v8_inspector::V8ConsoleMessage, std::__Cr::default_delete<v8_inspector::V8ConsoleMessage>>) ./../../v8/src/inspector/v8-console-message.cc:567:14
    #8 0x5607821e3366 in v8_inspector::V8InspectorImpl::exceptionThrown(v8::Local<v8::Context>, v8_inspector::StringView, v8::Local<v8::Value>, v8_inspector::StringView, v8_inspector::StringView, unsigned int, unsigned int, std::__Cr::unique_ptr<v8::StackTrace, std::__Cr::default_delete<v8::StackTrace>>, int) ./../../v8/src/inspector/v8-inspector-impl.cc:296:41
    #9 0x56079948116b in blink::ThreadDebuggerCommonImpl::PromiseRejected(v8::Local<v8::Context>, WTF::String const&, v8::Local<v8::Value>, std::__Cr::unique_ptr<blink::SourceLocation, std::__Cr::default_delete<blink::SourceLocation>>) ./../../third_party/blink/renderer/core/inspector/thread_debugger_common_impl.cc:146:28
    #10 0x560797acb343 in blink::RejectedPromises::Message::Report() ./../../third_party/blink/renderer/bindings/core/v8/rejected_promises.cc:90:43
    #11 0x560797ac919f in blink::RejectedPromises::ProcessQueueNow(WTF::Vector<std::__Cr::unique_ptr<blink::RejectedPromises::Message, std::__Cr::default_delete<blink::RejectedPromises::Message>>, 0u, WTF::PartitionAllocator>) ./../../third_party/blink/renderer/bindings/core/v8/rejected_promises.cc:268:16

Line by line, in plain words:

  • The first line says AddressSanitizer found a heap-use-after-free at a particular memory address. pc, bp and sp are the program counter, base pointer and stack pointer: internal registers that record where the processor was when the problem happened. You do not need to read the numbers; they are for engineers debugging the crash.
  • READ of size 8 means the program tried to read 8 bytes of memory. thread T35 (DedicatedWorker) says this happened on a background worker thread, not on the main page thread.
  • #0 is the innermost call, the exact place where the bad read happened: Runtime::Frontend::exceptionThrown, a function that reports an exception to the DevTools frontend.
  • #1 is the caller: V8ConsoleMessage::reportToFrontend, which takes a console message and hands it to a frontend.
  • #2 and #3 show reportMessage and V8RuntimeAgentImpl::messageAdded, the code that decides a new message has arrived and should be reported.
  • #4 to #6 show the loop over attached sessions, V8InspectorImpl::forEachSession, which visits each DevTools connection in turn.
  • #7 is V8ConsoleMessageStorage::addMessage, where the message is stored.
  • #8 is V8InspectorImpl::exceptionThrown, the entry point for reporting an exception.
  • #9 is ThreadDebuggerCommonImpl::PromiseRejected, called when a promise is rejected.
  • #10 and #11 show the rejected-promise queue being processed: RejectedPromises::Message::Report and RejectedPromises::ProcessQueueNow.

So the read of size 8 happens in Runtime::Frontend::exceptionThrown, called from V8ConsoleMessage::reportToFrontend, which is reached from V8RuntimeAgentImpl::messageAdded while iterating sessions in V8InspectorImpl::forEachSession. The message itself originates from a rejected promise in a dedicated worker: blink::RejectedPromises::Message::Report calls ThreadDebuggerCommonImpl::PromiseRejected, which calls V8InspectorImpl::exceptionThrown, which stores the message and reports it to the frontend. The thread is identified as T35 (DedicatedWorker).

The allocation context and the free stack follow:

Text
0x50d0003a2078 is located 24 bytes inside of 144-byte region [0x50d0003a2060,0x50d0003a20f0)
freed by thread T35 (DedicatedWorker) here:
    #0 0x56077a8ce0bd in operator delete(void*) _asan_rtl_:3
    #1 0x5607821f26f8 in operator() ./../../third_party/libc++/src/include/__memory/unique_ptr.h:66:5
    #2 0x5607821f26f8 in reset ./../../third_party/libc++/src/include/__memory/unique_ptr.h:266:7
    #3 0x5607821f26f8 in ~unique_ptr ./../../third_party/libc++/src/include/__memory/unique_ptr.h:236:71
    #4 0x5607821f26f8 in v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() ./../../v8/src/inspector/v8-inspector-session-impl.cc:169:1
    #5 0x5607821f2d93 in v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() ./../../v8/src/inspector/v8-inspector-session-impl.cc:160:51
    #6 0x5607995a0eac in operator() ./../../third_party/libc++/src/include/__memory/unique_ptr.h:66:5
    #7 0x5607995a0eac in reset ./../../third_party/libc++/src/include/__memory/unique_ptr.h:266:7
    #8 0x5607995a0eac in blink::DevToolsSession::Detach() ./../../third_party/blink/renderer/core/inspector/devtools_session.cc:215:15
    #9 0x5607995ad042 in Invoke<void (blink::DevToolsSession::*)(), const cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy> &> ./../../base/functional/bind_internal.h:710:12
    #10 0x5607995ad042 in MakeItSo<void (blink::DevToolsSession::*)(), std::__Cr::tuple<cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy> > > ./../../base/functional/bind_internal.h:881:5
    #11 0x5607995ad042 in RunImpl<void (blink::DevToolsSession::*)(), std::__Cr::tuple<cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy> >, 0UL> ./../../base/functional/bind_internal.h:991:14
    #12 0x5607995ad042 in base::internal::Invoker<base::internal::BindState<void (blink::DevToolsSession::*)(), cppgc::internal::BasicPersistent<blink::DevToolsSession, cppgc::internal::WeakPersistentPolicy, cppgc::internal::IgnoreLocationPolicy, cppgc::internal::DisabledCheckingPolicy>>, void ()>::RunOnce(base::internal::BindStateBase*) ./../../base/functional/bind_internal.h:904:12
    #13 0x56078d976002 in Run ./../../base/functional/callback.h:156:12
    #14 0x56078d976002 in mojo::InterfaceEndpointClient::NotifyError(std::__Cr::optional<mojo::DisconnectReason> const&) ./../../mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:744:31
    #15 0x56078d99c676 in mojo::internal::MultiplexRouter::ProcessNotifyErrorTask(mojo::internal::MultiplexRouter::Task*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*) ./../../mojo/public/cpp/bindings/lib/multiplex_router.cc:1010:13
    #16 0x56078d993b24 in mojo::internal::MultiplexRouter::ProcessTasks(mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*) ./../../mojo/public/cpp/bindings/lib/multiplex_router.cc:923:15
    #17 0x56078d99da78 in mojo::internal::MultiplexRouter::LockAndCallProcessTasks() ./../../mojo/public/cpp/bindings/lib/multiplex_router.cc:1124:3

Line by line:

  • The first line says the bad address sits 24 bytes inside a 144-byte block of memory. In other words, the object was a real, allocated thing, and the read landed inside it.
  • freed by thread T35 (DedicatedWorker) here says the same worker thread that later read the memory had already given it back.
  • #0 is operator delete, the low-level operation that returns memory to the system.
  • #1 to #3 show a unique_ptr being destroyed. A unique_ptr is a C++ object that owns a piece of memory and automatically frees it when it goes out of scope; it is like a key that deletes the room when you drop it.
  • #4 and #5 show V8InspectorSessionImpl::~V8InspectorSessionImpl, the destructor of the inspector session. A destructor is the cleanup function that runs when an object is destroyed.
  • #6 to #8 show blink::DevToolsSession::Detach, the function that disconnects the DevTools session.
  • #9 to #12 show the internal callback machinery that invokes Detach.
  • #13 and #14 show mojo::InterfaceEndpointClient::NotifyError. Mojo is Chrome's internal messaging system, used for parts of the browser to talk to each other; here it is reporting that the other end of a connection has gone away.
  • #15 to #17 show the Mojo router processing that error notification.

The free happens in V8InspectorSessionImpl::~V8InspectorSessionImpl, reached from blink::DevToolsSession::Detach, which is invoked from a Mojo error notification (InterfaceEndpointClient::NotifyError). In other words, the inspector session is destroyed when the DevTools connection is torn down, and the console message that was queued for that session still holds a pointer into the freed session. A pointer is simply a memory address that says "the object is over there"; once the object is freed, the pointer points at nothing valid.

The free stack continues into the worker lifecycle:

Text
    #31 0x5607a31a7bf3 in content::(anonymous namespace)::NestedMessageLoopRunnerImpl::Run() ./../../content/child/blink_platform_impl.cc:88:14
    #32 0x56079ad736e5 in blink::WorkerThread::PauseOrFreezeOnWorkerThread(blink::mojom::FrameLifecycleState, bool) ./../../third_party/blink/renderer/core/workers/worker_thread.cc:916:20
    #33 0x5607802ff331 in v8::internal::Isolate::InvokeApiInterruptCallbacks() ./../../v8/src/execution/isolate.cc:1739:5
    #34 0x56078036027c in v8::internal::StackGuard::HandleInterrupts(v8::internal::StackGuard::InterruptLevel) ./../../v8/src/execution/stack-guard.cc:371:15
    #35 0x5607812d683f in __RT_impl_Runtime_StackGuard ./../../v8/src/runtime/runtime-internal.cc:354:34
    #36 0x5607812d683f in v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) ./../../v8/src/runtime/runtime-internal.cc:343:1

Line by line:

  • #31 shows a nested message loop running. A message loop is the part of a program that waits for tasks and runs them one by one; a nested one runs inside another, so other tasks can be processed in the middle of what was already happening.
  • #32 shows WorkerThread::PauseOrFreezeOnWorkerThread, the code that pauses or freezes a worker, for example when the page is being put in the background.
  • #33 to #36 show V8's interrupt handling, the mechanism that lets the engine stop what it is doing and run a small piece of housekeeping code.

This shows the worker being paused or frozen (WorkerThread::PauseOrFreezeOnWorkerThread) and running a nested message loop, during which the Mojo disconnect is processed and the session is detached. The message that was already queued for the frontend is then delivered after the session is gone.

Root cause

A console message produced by a rejected promise in a dedicated worker is stored and then reported to every attached inspector session through V8InspectorImpl::forEachSession. The read happens in Runtime::Frontend::exceptionThrown after the session was freed. When the DevTools connection drops, blink::DevToolsSession::Detach destroys the V8InspectorSessionImpl, which frees the frontend. If the worker is paused or frozen at that moment and a nested message loop processes the Mojo disconnect, the pending message is delivered afterwards and Runtime::Frontend::exceptionThrown reads the freed frontend.

A useful comparison: imagine a receptionist holding a note for a visitor who has just left the building. The note still says "deliver to room 12", but room 12 has been cleared out and someone else may be using it. Delivering the note there is the use after free.

The report does not describe the exact fix, so the specific lifetime change is not stated here.

Impact

The report demonstrates a renderer crash triggered by a page that produces a rejected promise in a dedicated worker while DevTools is open. Code execution would mean running the attacker's own program on the machine; data disclosure would mean reading information the user did not intend to share; a sandbox escape would mean getting out of the restricted environment Chrome puts web pages in. None of those is shown here.

The practical effect shown is denial of service against the browser tab: the tab stops working, which is a denial of service because the service (the page) is made unavailable. It requires the user to have DevTools attached to the page.

Fix

The fix would need to ensure that a queued console message does not report to a frontend whose session has been destroyed, for example by validating the session after the nested message loop or by holding a safe reference to the session for the duration of delivery. The report does not confirm which approach was taken.

Variants to test

These are follow-up experiments a researcher might try, to see whether the same mistake appears elsewhere. For each, a positive result means the same kind of crash shows up again.

  • Rejected promises in other worker types (shared workers, service workers) with DevTools attached: a positive result is an ASan heap-use-after-free in V8ConsoleMessage::reportToFrontend or Runtime::Frontend::exceptionThrown on the worker thread. Shared workers can be used by several pages at once; service workers sit between the page and the network and can keep running in the background.
  • Other console message sources, such as console.error or uncaught exceptions in a worker, combined with pausing or freezing the worker: a positive result is the same free in V8InspectorSessionImpl::~V8InspectorSessionImpl followed by a read in the message delivery path. console.error is the JavaScript call that prints an error to the console; an uncaught exception is an error nobody handled.
  • Detaching DevTools while a worker is paused or frozen: a positive result is a crash whose free stack goes through DevToolsSession::Detach and whose read stack goes through forEachSession.
  • Multiple attached sessions where one is detached during message delivery: a positive result is a read of a freed frontend belonging to the detached session while another session remains attached. Several DevTools windows or debugging connections can be attached to the same page at once.

Glossary

  • AddressSanitizer (ASan): an instrumented build of a program that detects memory errors such as reading freed memory and prints a detailed report.
  • API: a defined way for one piece of software to ask another for something, like a menu of allowed requests.
  • Attached (DevTools): the state where DevTools is connected to a page and receiving its messages.
  • Beta / dev channel: earlier, less polished Chrome builds that receive changes before the stable release.
  • Blink: the part of Chrome that renders pages and runs their JavaScript.
  • Bounty: a payment made by a company to a researcher who reports a valid security bug.
  • Chrome VRP: the Chrome Vulnerability Reward Program, Google's scheme for rewarding Chrome bug reports.
  • Console message: a message a page or worker produces for the developer console, such as an error or a log line.
  • CVE: Common Vulnerabilities and Exposures, a public catalogue number for a security flaw.
  • CVSS: a standard scoring system for the severity of a vulnerability.
  • Dedicated worker: a background JavaScript thread created by, and belonging to, a single page.
  • Denial of service: making a service or program unavailable, here by crashing the tab.
  • Destructor: the cleanup function that runs when an object is destroyed.
  • DevTools: the developer tools built into Chrome for inspecting pages, console output, network traffic and more.
  • Frontend (inspector): the DevTools side that receives messages from the inspected page.
  • Heap: the pool of memory a program uses for objects it creates while running.
  • HTTP: the protocol browsers and servers use to exchange web pages and other resources.
  • Inspector session: the connection between DevTools and a page, through which messages flow.
  • Localhost: the name for your own computer in a network address.
  • Medium (severity): a middle rating on a scale of how serious a vulnerability is.
  • Mojo: Chrome's internal messaging system that lets different parts of the browser talk to each other.
  • Nested message loop: a message loop running inside another one, so other tasks can be processed in the middle of current work.
  • Pointer: a memory address that refers to an object stored elsewhere.
  • Port: a numbered door on a computer that a network service listens on.
  • Promise: JavaScript's way of representing a result that will arrive later; a rejected promise means it failed.
  • Renderer: the part of Chrome that turns a page into what you see and runs its JavaScript, usually one per tab.
  • Sandbox escape: getting out of the restricted environment a browser puts web pages in.
  • Service worker: a background script that sits between a page and the network and can keep running when the page is closed.
  • Shared worker: a background script that several pages can use at once.
  • Stable channel: the normal, everyday release of Chrome.
  • Stack (stack trace): the list of function calls that led to a particular moment, like a receipt of every step.
  • Thread: a sequence of instructions a program runs; a program can run several at once.
  • Unique_ptr: a C++ object that owns a piece of memory and frees it automatically when it goes out of scope.
  • Use after free: a bug where a program keeps using memory after it has been given back, which can crash it or worse.
  • V8: the JavaScript engine inside Chrome that runs page scripts.
  • Worker: a background JavaScript thread that runs alongside a page.

More by Cassidy Kim

View all

29 more disclosed reports, best first.

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.