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

Use after free in Network (CVE-2024-1077)

A use-after-free in Chromium's network service could occur when a data pipe is closed while a SourceStreamToDataPipe object is still alive, leading to a dangling pointer being used after the object frees itself. An attacker could potentially trigger a crash or memory corruption, though no reproduction case is provided.

Giulio Candreva Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 50 days

VULNERABILITY DETAILS
GWP-Asan running on Microsoft Edge caught an invalid free error happening on Chromium code.
There is no reproduction case since it was a crash happening on a user's machine.

Crash Callstack:

#0 msedge!gwp_asan::internal::GuardedPageAllocator::Deallocate at components\gwp_asan\client\guarded_page_allocator.cc:323
#1 msedge!network::SourceStreamToDataPipe::OnComplete at services\network\public\cpp\source_stream_to_data_pipe.cc:108
#2 msedge!base::internal::Invoker_base::internal::BindState_lambda at ..\..\content\browser\cache_storage\cache_storage_cache_entry_handler.cc:61:13',base::internal::UnretainedWrapper_content::(anonymous namespace)::DiskCacheStream,base::unretained_traits::MayNotDangle,0_,base::OnceCallback_void (int)_ _,void (int)_::RunOnce at base\functional\bind_internal.h:919 #3 msedge!base::internal::Invoker_base::internal::BindState_base::OnceCallback_void (int)_,net::Error_,void ()_::RunOnce at base\functional\bind_internal.h:919 #4 msedge!base::internal::TaskTracker::RunSkipOnShutdown at base\task\thread_pool\task_tracker.cc:635 #5 msedge!base::internal::TaskTracker::RunAndPopNextTask at base\task\thread_pool\task_tracker.cc:407 #6 msedge!base::internal::WorkerThread::RunWorker at base\task\thread_pool\worker_thread.cc:483 #7 msedge!base::internal::WorkerThread::RunPooledWorker at base\task\thread_pool\worker_thread.cc:359 #8 msedge!base::anonymous namespace'::ThreadFunc at base\threading\platform_thread_win.cc:126
#9 kernel32!BaseThreadInitThunk at clientcore\base\win32\client\thread.c:64
#10 ntdll!RtlUserThreadStart at minkernel\ntdll\rtlstrt.c:1153

Allocation stack size: 26
Allocation address: 44fc0034c000
Allocation size: 90
Error type: Free Invalid Address
Region start: 44fc00003000
Region size: 1041000
Allocator type: Malloc
Base address: 7ffaaa770000
Allocation Thread ID: 10496
Allocation Stack Trace:

0 0x7ffaad8a7c32 msedge!base::debug::CollectStackTrace at base/debug/stack_trace_win.cc:329
1 0x7ffaacf38bd6 msedge!gwp_asan::internal::GuardedPageAllocator::Allocate at components/gwp_asan/client/guarded_page_allocator.cc:299
2 0x7ffaabfc84d3 msedge!gwp_asan::internal::anonymous namespace'::AllocFn at components/gwp_asan/client/sampling_malloc_shims.cc:49 3 0x7ffaab6c5941 msedge!malloc at base/allocator/partition_allocator/shim/allocator_shim_override_ucrt_symbols_win.h:73 4 0x7ffaae999b4f msedge!operator new at vctools/crt/vcstartup/src/heap/new_scalar.cpp:35 5 0x7ffab045f727 msedge!content::anonymous namespace'::EntryReaderImpl::Read at content/browser/cache_storage/cache_storage_cache_entry_handler.cc:127
6 0x7ffaafa88ef7 msedge!storage::mojom::BlobDataItemReaderStubDispatch::AcceptWithResponder at out/Release_x64/gen/components/services/storage/public/mojom/blob_storage_context.mojom.cc:623
7 0x7ffab045feda msedge!storage::mojom::BlobDataItemReaderStub >::AcceptWithResponder at out/Release_x64/gen/components/services/storage/public/mojom/blob_storage_context.mojom.h:242
8 0x7ffaab565619 msedge!mojo::InterfaceEndpointClient::HandleIncomingMessageThunk::Accept at mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:363
9 0x7ffaab116f11 msedge!mojo::MessageDispatcher::Accept at mojo/public/cpp/bindings/lib/message_dispatcher.cc:43
10 0x7ffaab116bef msedge!mojo::InterfaceEndpointClient::HandleIncomingMessage at mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:701
11 0x7ffaab116977 msedge!mojo::internal::MultiplexRouter::ProcessIncomingMessage at mojo/public/cpp/bindings/lib/multiplex_router.cc:0
12 0x7ffaab114ede msedge!mojo::internal::MultiplexRouter::Accept at mojo/public/cpp/bindings/lib/multiplex_router.cc:724
13 0x7ffaab116f11 msedge!mojo::MessageDispatcher::Accept at mojo/public/cpp/bindings/lib/message_dispatcher.cc:43
14 0x7ffaab490077 msedge!mojo::Connector::DispatchMessageW at mojo/public/cpp/bindings/lib/connector.cc:560
15 0x7ffaab48f959 msedge!mojo::Connector::ReadAllAvailableMessages at mojo/public/cpp/bindings/lib/connector.cc:618
16 0x7ffaab48f842 msedge!base::internal::Invoker,base::internal::UnretainedWrapper >,void (unsigned int)>::Run at base/functional/bind_internal.h:935
17 0x7ffaaafeaeca msedge!base::RepeatingCallback::Run at base/functional/callback.h:336
18 0x7ffaab17e68b msedge!mojo::SimpleWatcher::OnHandleReady at mojo/public/cpp/system/simple_watcher.cc:278
19 0x7ffaab5e8881 msedge!base::internal::TaskTracker::RunSkipOnShutdown at base/task/thread_pool/task_tracker.cc:635
20 0x7ffaab5e5c63 msedge!base::internal::TaskTracker::RunAndPopNextTask at base/task/thread_pool/task_tracker.cc:407
21 0x7ffaaa9d07d3 msedge!base::internal::WorkerThread::RunWorker at base/task/thread_pool/worker_thread.cc:483
22 0x7ffaaaa6f3d8 msedge!base::internal::WorkerThread::RunPooledWorker at base/task/thread_pool/worker_thread.cc:359
23 0x7ffaaaa32004 msedge!base::`anonymous namespace'::ThreadFunc at base/threading/platform_thread_win.cc:126
24 0x7ffb18957614 kernel32!BaseThreadInitThunk at clientcore/base/win32/client/thread.c:64
25 0x7ffb1a9626b1 ntdll!RtlUserThreadStart at minkernel/ntdll/rtlstrt.c:1153

GWP-Asan reported a "Free Invalid Address" error, but the free'd address corresponds to a SourceStreamToDataPipe object which wasn't protected by GWP-Asan. Reading through GWPAsan source code, I suspect that this might be a double free with expired metadata.

Although I can't reproduce, I might have found a possible root cause detailed below.

SourceStreamToDataPipe is created in method EntryReaderImpl::Read [1] (cache_storage_entry_handler.cc). And its unique pointer is passed to a callback which will become the completion_callback_ member of the object iself. [2]

    auto stream = std::make_unique<DiskCacheStream>(  
        blob_entry_, disk_cache_index_, offset, length);  
    auto adapter = std::make_unique<network::SourceStreamToDataPipe>( /\* 1 \*/  
        std::move(stream), std::move(pipe));  /\* 3 \*/  
    auto\* adapter_raw = adapter.get();  
    adapter_raw->Start(base::BindOnce(  
        [](ReadCallback callback,  
           std::unique_ptr<network::SourceStreamToDataPipe> adapter,  
           int result) { std::move(callback).Run(result); },  
        std::move(callback), std::move(adapter)));   /\* 2 \*/  

This means that this object is self-owned and it will delete itself after reaching SourceStreamToDataPipe::OnComplete.

If you go through the code of SourceStreamToDataPipe, you will find out that a chain of tasks will be posted after calling the method Start and ending up into SourceStreamToDataPipe::OnComplete method.

You can notice at [3] that SourceStreamToDataPipe takes a MojoHandle argument that a producer end of a DataPipe.

During construction, a mojo::SimpleWatcher registers a handler callback for events happening on the pipe:
https://source.chromium.org/chromium/chromium/src/+/main:services/network/public/cpp/source_stream_to_data_pipe.cc;drc=9145b71e9ad5dee408605cf9841253ad30ccfd76;l=24

// In SourceStreamToDataPipe constructor  
  writable_handle_watcher_.Watch(  
      dest_.get(), MOJO_HANDLE_SIGNAL_WRITABLE,  
      base::BindRepeating(&SourceStreamToDataPipe::OnDataPipeWritable,  
                          base::Unretained(this))); /\* 4 \*/  

The problem here is that the dest_ pipe can be closed and that will trigger the posting of a task that holds a raw reference to this object (use of base::Unretained in [4]).

The task can get scheduled and executed after SourceStreamToDataPipe::OnComplete, resulting in UAF.

REPRODUCTION CASE
NA

The original report as published on the Chromium issue tracker, by Giulio Candreva with Microsoft Browser Security. 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 a callback registered with base::Unretained on a data pipe watcher can fire after the SourceStreamToDataPipe object has self-deleted in OnComplete, causing a use-after-free.

What the attacker needed

No reproduction provided

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 is a bug where a program keeps a pointer to memory after it has been freed, and then uses it again. Here, a callback registered on a data pipe could run after the object that owns it has already deleted itself, so the callback touches freed memory. This can crash the browser or, in theory, let an attacker run 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.