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

Use after free in V8 (CVE-2024-4949)

A use-after-free in V8's garbage collector caused a crash when running a JavaScript file with specific flags. An attacker could potentially exploit this to execute arbitrary code in the browser.

Ganjiang Zhou Follow

Originally disclosed on Chrome VRP

Bounty$7,000 Medium View original
  • Fix shipped in 3 months

Security Bug

Please READ THIS FAQ before filing a bug: https://chromium.googlesource.com/chromium/src/+/HEAD/docs/security/faq.md

Please see the following link for instructions on filing security bugs: https://www.chromium.org/Home/chromium-security/reporting-security-bugs

Reports may be eligible for reward payments under the Chrome VRP: https://g.co/chrome/vrp

NOTE: Security bugs are normally made public once a fix has been widely deployed.


VULNERABILITY DETAILS Hi, I found a crash which show malloc_consolidate(): unaligned fastbin chunk detected, I try to get stack info.

[Thread 0x7fabe0ffb6c0 (LWP 22913) exited] malloc_consolidate(): unaligned fastbin chunk detected

Thread 52 "WorkerThread" received signal SIGABRT, Aborted. [Switching to Thread 0x7fabe1ffd6c0 (LWP 22907)] 0x00007facbfc7756c in ?? () from /lib64/libc.so.6 #0 0x00007facbfc7756c in ?? () from /lib64/libc.so.6 #1 0x00007facbfc28602 in raise () from /lib64/libc.so.6 #2 0x00007facbfc114ed in abort () from /lib64/libc.so.6 #3 0x00007facbfc125a8 in ?? () from /lib64/libc.so.6 #4 0x00007facbfc80ee5 in ?? () from /lib64/libc.so.6 #5 0x00007facbfc81a2c in ?? () from /lib64/libc.so.6 #6 0x00007facbfc840a8 in ?? () from /lib64/libc.so.6 #7 0x00007facbfc85359 in malloc () from /lib64/libc.so.6 #8 0x0000555c6a2ab489 in operator_new_impl () at ../../third_party/libc++/src/src/new.cpp:33 #9 operator new () at ../../third_party/libc++/src/src/new.cpp:46 #10 0x0000555c6715cffd in __libcpp_operator_new<unsigned long> () at ../../third_party/libc++/src/include/new:271 #11 __libcpp_allocate () at ../../third_party/libc++/src/include/new:295 #12 allocate () at ../../third_party/libc++/src/include/__memory/allocator.h:125 #13 allocate () at ../../third_party/libc++/src/include/__memory/allocator_traits.h:281 #14 __add_back_capacity () at ../../third_party/libc++/src/include/deque:2169 #15 0x0000555c6715cdf2 in emplace_back<int, unsigned long&> () at ../../third_party/libc++/src/include/deque:1590 #16 0x0000555c6715caf5 in emplace<int, unsigned long&> () at ../../third_party/libc++/src/include/queue:411 #17 IndexGenerator () at ../../src/heap/index-generator.cc:13 #18 0x0000555c6719b2d9 in PointersUpdatingJob () at ../../src/heap/mark-compact.cc:4606 #19 make_unique<v8::internal::PointersUpdatingJob, v8::internal::Isolate*, v8::internal::MarkCompactCollector*, std::__Cr::vector<std::__Cr::unique_ptr<v8::internal::UpdatingItem, std::__Cr::default_deletev8::internal::UpdatingItem >, std::__Cr::allocator<std::__Cr::unique_ptr<v8::internal::UpdatingItem, std::__Cr::default_deletev8::internal::UpdatingItem > > > > () at ../../third_party/libc++/src/include/__memory/unique_ptr.h:597 #20 UpdatePointersAfterEvacuation () at ../../src/heap/mark-compact.cc:5097 #21 0x0000555c6717bddd in Evacuate () at ../../src/heap/mark-compact.cc:4536 #22 0x0000555c671747bd in CollectGarbage () at ../../src/heap/mark-compact.cc:418 #23 0x0000555c67078426 in MarkCompact () at ../../src/heap/heap.cc:2717 #24 0x0000555c67076c43 in PerformGarbageCollection () at ../../src/heap/heap.cc:2403 #25 0x0000555c670b5ffc in operator() () at ../../src/heap/heap.cc:1870 #26 0x0000555c6707002c in SetMarkerIfNeededAndCallback<(lambda at ../../src/heap/heap.cc:1834:40)> () at ../../src/heap/base/stack.h:64 #27 CollectGarbage () at ../../src/heap/heap.cc:1834 #28 0x0000555c67075c94 in CollectAllGarbage () at ../../src/heap/heap.cc:1514 #29 CollectGarbageForBackground () at ../../src/heap/heap.cc:2237 #30 0x0000555c67165a57 in ParkSlowPath () at ../../src/heap/local-heap.cc:231 #31 0x0000555c66d15ccf in Park () at ../../src/heap/local-heap.h:319 #32 ParkedScope () at ../../src/heap/parked-scope.h:24 #33 ParkAndExecuteCallback<(lambda at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:148:9)> () at ../../src/heap/local-heap-inl.h:64 #34 operator() () at ../../src/heap/local-heap-inl.h:85 #35 0x0000555c66d15c0e in void heap::base::Stack::SetMarkerAndCallbackImpl<v8::internal::LocalHeap::BlockMainThreadWhileParkedv8::internal::OptimizingCompileDispatcher::AwaitCompileTasks()::$_0(v8::internal::OptimizingCompileDispatcher::AwaitCompileTasks()::$_0)::{lambda()#1}>(heap::base::Stack*, void*, void const*) () at ../../src/heap/base/stack.h:95 #36 0x0000555c68ae5a97 in PushAllRegistersAndIterateStack () #37 0x0000555c66d13ad9 in SetMarkerIfNeededAndCallback<(lambda at ../../src/heap/local-heap-inl.h:85:7)> () at ../../src/heap/base/stack.h:60 #38 ExecuteWithStackMarker<(lambda at ../../src/heap/local-heap-inl.h:85:7)> () at ../../src/heap/local-heap-inl.h:95 #39 BlockMainThreadWhileParked<(lambda at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:148:9)> () at ../../src/heap/local-heap-inl.h:84 #40 BlockMainThreadWhileParked<(lambda at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:148:9)> () at ../../src/execution/local-isolate-inl.h:37 #41 AwaitCompileTasks () at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:147 #42 0x0000555c66d13e32 in FlushQueues () at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:163 #43 Stop () at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:179 #44 0x0000555c66ebd81a in Deinit () at ../../src/execution/isolate.cc:3832 #45 0x0000555c66ebd29e in Delete () at ../../src/execution/isolate.cc:3536 #46 0x0000555c66800915 in ExecuteInThread () at ../../src/d8/d8.cc:4778 #47 0x0000555c667ffeb7 in Run () at ../../src/d8/d8.cc:4538 #48 0x0000555c668bea99 in NotifyStartedAndRun () at ../../src/base/platform/platform.h:613 #49 ThreadEntry () at ../../src/base/platform/platform-posix.cc:1189 #50 0x00007facbfc7583c in ?? () from /lib64/libc.so.6 #51 0x00007facbfce7838 in ?? () from /lib64/libc.so.6

attachment file is full log

VERSION Chrome Version: [x.x.x.x] + [stable, beta, or dev] Operating System: [Please indicate OS, version, and service pack level]

REPRODUCTION CASE

run d8 with --expose-gc --omit-quit --allow-natives-syntax --fuzzing --jit-fuzzing --future --harmony --maglev-assert --optimize-for-size --stress-concurrent-allocation --stress-incremental-marking

PoC is 1.js file

FOR CRASHES, PLEASE INCLUDE THE FOLLOWING ADDITIONAL INFORMATION Type of crash: [tab, browser, etc.] Crash State: [see link above: stack trace with symbols, registers, exception record] Client ID (if relevant): [see link above]

CREDIT INFORMATION Externally reported security bugs may appear in Chrome release notes. If this bug is included, how would you like to be credited? Reporter credit: [goes here]

The original report as published on the Chromium issue tracker, by Ganjiang Zhou(@refrain_areu) of ChaMd5-H1 team. 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. 7 min read.

Context

V8 is the JavaScript engine used by Chrome and by the d8 developer shell. Its garbage collector includes a mark-compact phase that evacuates objects and then updates the pointers that referred to them. The report concerns a use-after-free in that machinery, tracked as CVE-2024-4949 and rated medium severity, with a bounty of 7000.00 USD under the Chrome VRP. It was disclosed on 2024-05-15 and credited to Ganjiang Zhou (@refrain_areu) of the ChaMd5-H1 team.

The bug was found in d8, not in a browser tab. The crash surfaces inside the heap's pointer-updating job, which runs on a worker thread during garbage collection.

Setup

The researcher ran d8 with a set of flags that stress the engine and its allocator:

Text
--expose-gc --omit-quit --allow-natives-syntax --fuzzing --jit-fuzzing --future --harmony --maglev-assert --optimize-for-size --stress-concurrent-allocation --stress-incremental-marking

These enable garbage collection from script (--expose-gc), native syntax for fuzzing, future and harmony features, Maglev assertions, size optimisation, and, importantly, concurrent allocation and incremental marking stress. The proof of concept is a single file, 1.js. The report does not include its contents.

Finding it

The researcher describes a crash that reports:

Text
malloc_consolidate(): unaligned fastbin chunk detected

That message comes from glibc's allocator: it means the heap metadata has been corrupted, typically because memory was written after it had been freed. The researcher then collected stack information to see where the corruption was detected.

Exploitation

Step 1: reproduce the crash

Run d8 with the flags above and the 1.js PoC. The process aborts with SIGABRT on a worker thread. The captured trace begins:

Text
[Thread 0x7fabe0ffb6c0 (LWP 22913) exited]
malloc_consolidate(): unaligned fastbin chunk detected

Thread 52 "WorkerThread" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fabe1ffd6c0 (LWP 22907)]
0x00007facbfc7756c in ?? () from /lib64/libc.so.6
#0  0x00007facbfc7756c in ?? () from /lib64/libc.so.6
#1  0x00007facbfc28602 in raise () from /lib64/libc.so.6
#2  0x00007facbfc114ed in abort () from /lib64/libc.so.6
#3  0x00007facbfc125a8 in ?? () from /lib64/libc.so.6
#4  0x00007facbfc80ee5 in ?? () from /lib64/libc.so.6
#5  0x00007facbfc81a2c in ?? () from /lib64/libc.so.6
#6  0x00007facbfc840a8 in ?? () from /lib64/libc.so.6
#7  0x00007facbfc85359 in malloc () from /lib64/libc.so.6
#8  0x0000555c6a2ab489 in operator_new_impl ()
    at ../../third_party/libc++/src/src/new.cpp:33
#9  operator new () at ../../third_party/libc++/src/src/new.cpp:46
#10 0x0000555c6715cffd in __libcpp_operator_new<unsigned long> ()
    at ../../third_party/libc++/src/include/new:271
#11 __libcpp_allocate () at ../../third_party/libc++/src/include/new:295
#12 allocate ()
    at ../../third_party/libc++/src/include/__memory/allocator.h:125
#13 allocate ()
    at ../../third_party/libc++/src/include/__memory/allocator_traits.h:281
#14 __add_back_capacity ()
    at ../../third_party/libc++/src/include/deque:2169
#15 0x0000555c6715cdf2 in emplace_back<int, unsigned long&> ()
    at ../../third_party/libc++/src/include/deque:1590
#16 0x0000555c6715caf5 in emplace<int, unsigned long&> ()
    at ../../third_party/libc++/src/include/queue:411
#17 IndexGenerator () at ../../src/heap/index-generator.cc:13
#18 0x0000555c6719b2d9 in PointersUpdatingJob ()
    at ../../src/heap/mark-compact.cc:4606
#19 make_unique<v8::internal::PointersUpdatingJob, v8::internal::Isolate*, v8::internal::MarkCompactCollector*, std::__Cr::vector<std::__Cr::unique_ptr<v8::internal::UpdatingItem, std::__Cr::default_delete<v8::internal::UpdatingItem> >, std::__Cr::allocator<std::__Cr::unique_ptr<v8::internal::UpdatingItem, std::__Cr::default_delete<v8::internal::UpdatingItem> > > > > ()
    at ../../third_party/libc++/src/include/__memory/unique_ptr.h:597
#20 UpdatePointersAfterEvacuation () at ../../src/heap/mark-compact.cc:5097
#21 0x0000555c6717bddd in Evacuate () at ../../src/heap/mark-compact.cc:4536
#22 0x0000555c671747bd in CollectGarbage ()
    at ../../src/heap/mark-compact.cc:418
#23 0x0000555c67078426 in MarkCompact () at ../../src/heap/heap.cc:2717
#24 0x0000555c67076c43 in PerformGarbageCollection ()
    at ../../src/heap/heap.cc:2403
#25 0x0000555c670b5ffc in operator() () at ../../src/heap/heap.cc:1870
#26 0x0000555c6707002c in SetMarkerIfNeededAndCallback<(lambda at ../../src/heap/heap.cc:1834:40)> () at ../../src/heap/base/stack.h:64
#27 CollectGarbage () at ../../src/heap/heap.cc:1834
#28 0x0000555c67075c94 in CollectAllGarbage ()
    at ../../src/heap/heap.cc:1514
#29 CollectGarbageForBackground () at ../../src/heap/heap.cc:2237
#30 0x0000555c67165a57 in ParkSlowPath ()
    at ../../src/heap/local-heap.cc:231
#31 0x0000555c66d15ccf in Park () at ../../src/heap/local-heap.h:319
#32 ParkedScope () at ../../src/heap/parked-scope.h:24
#33 ParkAndExecuteCallback<(lambda at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:148:9)> () at ../../src/heap/local-heap-inl.h:64
#34 operator() () at ../../src/heap/local-heap-inl.h:85
#35 0x0000555c66d15c0e in void heap::base::Stack::SetMarkerAndCallbackImpl<v8::internal::LocalHeap::BlockMainThreadWhileParked<v8::internal::OptimizingCompileDispatcher::AwaitCompileTasks()::$_0>(v8::internal::OptimizingCompileDispatcher::AwaitCompileTasks()::$_0)::{lambda()#1}>(heap::base::Stack*, void*, void const*) () at ../../src/heap/base/stack.h:95
#36 0x0000555c68ae5a97 in PushAllRegistersAndIterateStack ()
#37 0x0000555c66d13ad9 in SetMarkerIfNeededAndCallback<(lambda at ../../src/heap/local-heap-inl.h:85:7)> () at ../../src/heap/base/stack.h:60
#38 ExecuteWithStackMarker<(lambda at ../../src/heap/local-heap-inl.h:85:7)>
    () at ../../src/heap/local-heap-inl.h:95
#39 BlockMainThreadWhileParked<(lambda at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:148:9)> () at ../../src/heap/local-heap-inl.h:84
#40 BlockMainThreadWhileParked<(lambda at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:148:9)> ()
    at ../../src/execution/local-isolate-inl.h:37
#41 AwaitCompileTasks ()
    at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:147
#42 0x0000555c66d13e32 in FlushQueues ()
    at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:163
#43 Stop ()
    at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:179
#44 0x0000555c66ebd81a in Deinit () at ../../src/execution/isolate.cc:3832
#45 0x0000555c66ebd29e in Delete () at ../../src/execution/isolate.cc:3536
#46 0x0000555c66800915 in ExecuteInThread () at ../../src/d8/d8.cc:4778
#47 0x0000555c667ffeb7 in Run () at ../../src/d8/d8.cc:4538
#48 0x0000555c668bea99 in NotifyStartedAndRun ()
    at ../../src/base/platform/platform.h:613
#49 ThreadEntry () at ../../src/base/platform/platform-posix.cc:1189
#50 0x00007facbfc7583c in ?? () from /lib64/libc.so.6
#51 0x00007facbfce7838 in ?? () from /lib64/libc.so.6

The trace reads from the bottom up. A d8 worker thread (ExecuteInThread, Run) deletes its isolate (Delete, Deinit). During isolate teardown the optimising compile dispatcher is stopped (Stop, FlushQueues, AwaitCompileTasks), which parks the local heap and blocks the main thread while parked. Parking triggers a background garbage collection (CollectGarbageForBackground, CollectAllGarbage, CollectGarbage), which performs a mark-compact collection (MarkCompact, PerformGarbageCollection).

Inside that collection, Evacuate calls UpdatePointersAfterEvacuation, which constructs a PointersUpdatingJob (make_unique). The job's constructor builds an IndexGenerator (src/heap/index-generator.cc:13), which emplaces into a queue backed by a std::deque. Growing the deque calls __add_back_capacity, which allocates through libc++'s allocator and eventually malloc. It is inside malloc that glibc detects the corrupted fastbin chunk and aborts.

The abort is therefore the detection point, not the corruption point: the allocator notices that a chunk on its fastbin list has been tampered with while servicing an allocation for the deque inside IndexGenerator. The report does not identify which object was freed and later written to.

Step 2: capture the full log

The researcher attached the full log as a file; the excerpt above is the part quoted inline. The report does not include the attachment contents.

Root cause

The crash is classified as a use-after-free in V8. The allocator's unaligned fastbin chunk detected message indicates heap metadata corruption, consistent with a use-after-free, but the report does not describe the write itself. The stack places the detection during pointer updating after evacuation, in the PointersUpdatingJob and its IndexGenerator, while the isolate is being torn down on a worker thread and a background collection is running.

The report does not state the precise object or code path that holds the stale reference, so the exact root cause is not described in the text.

Impact

A use-after-free in V8 can in principle be exploitable, but the report only demonstrates a crash in d8 under fuzzing flags and does not show exploitation. The report itself only demonstrates a crash in d8 under fuzzing flags and does not show exploitation. The platform rates the issue medium severity.

Fix

The bug was disclosed on 2024-05-15, and the platform notes that security bugs are normally made public once a fix has been widely deployed.

Variants to test

  1. Run the same PoC under different stress combinations, for example with only --stress-concurrent-allocation or only --stress-incremental-marking, to see whether the crash depends on one of them. A positive result is the same malloc_consolidate(): unaligned fastbin chunk detected abort with a similar stack through PointersUpdatingJob.
  2. Exercise isolate teardown on worker threads while compilation tasks are outstanding, since the trace runs through OptimizingCompileDispatcher::Stop and AwaitCompileTasks. A positive result is a crash during Deinit rather than during normal script execution.
  3. Vary the allocation pattern around the IndexGenerator deque growth, for example by changing the number of updating items, to see whether the corruption depends on deque capacity changes. A positive result is the same allocator abort at __add_back_capacity.
  4. Run the PoC under a different allocator or with sanitizers to turn the silent corruption into an earlier, more precise report. A positive result is an ASan or similar report pointing at the write that follows the free, which would identify the object the report leaves unnamed.

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. 14 min read.

What happened, in plain words

A security researcher found a way to make a piece of software called V8 crash in a way that suggests a serious memory bug. V8 is the part of Google Chrome that reads and runs JavaScript, the programming language that makes web pages interactive. The same engine also ships in a small command-line tool called d8, which developers use to test V8 on its own, without a browser window.

The crash is a use-after-free. Imagine you borrow a library book, return it, and then someone else borrows the same book and writes notes in it. If you still have your old bookmark and try to read "your" page, you are reading a book that is no longer yours, and someone else's notes are now in it. In computer memory, a use-after-free means a program keeps a reference to a block of memory after it has handed that block back, and then reads or writes through the stale reference. That can corrupt whatever now lives in that memory.

The crash was reported to Google's Chrome bug bounty programme, the Chrome VRP, which pays people for finding security problems. It was tracked as CVE-2024-4949, rated medium severity, and paid a bounty of 7000.00 USD. It was disclosed on 2024-05-15 and credited to Ganjiang Zhou (@refrain_areu) of the ChaMd5-H1 team.

The report shows a crash inside V8's garbage collector, the part of the engine that automatically frees memory the program no longer needs. The crash happens while the collector is tidying up memory on a background worker thread. The report does not include the actual test file that triggers it, so we cannot see the exact JavaScript that causes the problem.

Background: the pieces involved

Before walking through the report, here are the main pieces, explained from scratch.

  • V8: the JavaScript engine inside Chrome. A browser engine is the part of a browser that turns code into actions on your screen. V8 takes JavaScript source and runs it.
  • d8: a developer shell that runs V8 by itself, outside a browser. Think of it as a laboratory bench where you can test the engine without the rest of Chrome around it. The researcher used d8, not a browser tab.
  • Garbage collector (GC): software that automatically reclaims memory. When your program stops using an object, the GC frees the memory so other things can use it. This saves programmers from having to free memory by hand, but it is complex, and bugs in it can be serious.
  • Mark-compact: one strategy a garbage collector uses. It first marks which objects are still reachable, then compacts memory by moving live objects together, like tidying a shelf by sliding all the books to one end. When objects move, any pointer (a reference to an object's location) that pointed at the old spot must be updated to the new spot.
  • Evacuation: the step where live objects are moved to a new area during compaction. After evacuation, the collector must update all the pointers that referred to the moved objects.
  • Worker thread: a second line of execution running alongside the main one. Browsers and engines use worker threads to do background work, such as garbage collection, without freezing the page.
  • Isolate: V8's term for an isolated instance of the engine, with its own memory and state. When a worker thread finishes, its isolate is torn down (deleted), and that teardown is where this crash occurs.
  • Allocator / malloc: the part of the system that hands out blocks of memory when a program asks for them. On Linux, the standard C library (glibc) provides malloc. It keeps bookkeeping data (metadata) about which blocks are free and which are in use.
  • Fastbin: a glibc data structure that keeps small freed memory blocks in a quick-access list. If that list's bookkeeping is corrupted, glibc notices and aborts the program rather than continuing with damaged memory.
  • CVE: a public identifier for a known security vulnerability, so people can refer to it unambiguously.
  • Chrome VRP: Google's Vulnerability Reward Program, which pays researchers for reporting security bugs in Chrome and related software.

Setup: how the researcher ran the test

The researcher ran d8 with a long list of command-line flags. Flags are switches that change how a program behaves when it starts. These particular flags turn on debugging features and deliberately stress the engine, making rare bugs easier to hit:

Text
--expose-gc --omit-quit --allow-natives-syntax --fuzzing --jit-fuzzing --future --harmony --maglev-assert --optimize-for-size --stress-concurrent-allocation --stress-incremental-marking

Line by line, in plain words:

  • --expose-gc: lets JavaScript code in the test file ask for garbage collection directly. Normally a page cannot do this; it is a testing convenience.
  • --omit-quit: changes how the shell handles a quit request, so the test can keep running.
  • --allow-natives-syntax: lets the test use special internal syntax that ordinary JavaScript cannot, useful for fuzzing (automated random testing).
  • --fuzzing and --jit-fuzzing: turn on behaviours meant for fuzzers, programs that throw lots of random input at software to find crashes.
  • --future and --harmony: enable JavaScript features that are still experimental or not yet standard.
  • --maglev-assert: turns on internal checks in Maglev, one of V8's compilers (the parts that translate JavaScript into fast machine code).
  • --optimize-for-size: tells the engine to prefer smaller memory use over raw speed.
  • --stress-concurrent-allocation: makes the engine allocate memory concurrently (at the same time as other work) much more aggressively than normal, to shake out timing bugs.
  • --stress-incremental-marking: makes the garbage collector's marking phase run in small increments, interleaved with other work, again to expose timing problems.

The PoC was run with all of these flags; the report does not say which ones are needed to reproduce the crash.

The proof of concept (PoC) is a single file called 1.js. A PoC is a minimal example that demonstrates a bug. The report does not include the contents of 1.js, so we cannot see the JavaScript that triggers the crash.

Finding it: the crash message

The researcher describes a crash that prints this message:

Text
malloc_consolidate(): unaligned fastbin chunk detected

This is a message from glibc, the standard C library on Linux. It means the allocator's internal bookkeeping has been damaged: a small freed memory block on its fastbin list has been tampered with. The allocator detects this while trying to service a new memory request and stops the program rather than carry on with corrupted data. In practice, this kind of message usually means some code wrote into memory after it had been freed.

The researcher then collected stack information to see where the corruption was detected. A stack trace is a list of the function calls that led to the current point, like a receipt showing every step that brought you to the till. It helps pinpoint where in the code the crash happened.

Exploitation

Step 1: reproduce the crash

To reproduce, run d8 with the flags above and the 1.js PoC. The process aborts with SIGABRT on a worker thread. SIGABRT is the signal a program sends itself when it decides it cannot continue safely; here, glibc raises it after detecting the corrupted memory. The captured trace begins:

Text
[Thread 0x7fabe0ffb6c0 (LWP 22913) exited]
malloc_consolidate(): unaligned fastbin chunk detected

Thread 52 "WorkerThread" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fabe1ffd6c0 (LWP 22907)]
0x00007facbfc7756c in ?? () from /lib64/libc.so.6
#0  0x00007facbfc7756c in ?? () from /lib64/libc.so.6
#1  0x00007facbfc28602 in raise () from /lib64/libc.so.6
#2  0x00007facbfc114ed in abort () from /lib64/libc.so.6
#3  0x00007facbfc125a8 in ?? () from /lib64/libc.so.6
#4  0x00007facbfc80ee5 in ?? () from /lib64/libc.so.6
#5  0x00007facbfc81a2c in ?? () from /lib64/libc.so.6
#6  0x00007facbfc840a8 in ?? () from /lib64/libc.so.6
#7  0x00007facbfc85359 in malloc () from /lib64/libc.so.6
#8  0x0000555c6a2ab489 in operator_new_impl ()
    at ../../third_party/libc++/src/src/new.cpp:33
#9  operator new () at ../../third_party/libc++/src/src/new.cpp:46
#10 0x0000555c6715cffd in __libcpp_operator_new<unsigned long> ()
    at ../../third_party/libc++/src/include/new:271
#11 __libcpp_allocate () at ../../third_party/libc++/src/include/new:295
#12 allocate ()
    at ../../third_party/libc++/src/include/__memory/allocator.h:125
#13 allocate ()
    at ../../third_party/libc++/src/include/__memory/allocator_traits.h:281
#14 __add_back_capacity ()
    at ../../third_party/libc++/src/include/deque:2169
#15 0x0000555c6715cdf2 in emplace_back<int, unsigned long&> ()
    at ../../third_party/libc++/src/include/deque:1590
#16 0x0000555c6715caf5 in emplace<int, unsigned long&> ()
    at ../../third_party/libc++/src/include/queue:411
#17 IndexGenerator () at ../../src/heap/index-generator.cc:13
#18 0x0000555c6719b2d9 in PointersUpdatingJob ()
    at ../../src/heap/mark-compact.cc:4606
#19 make_unique<v8::internal::PointersUpdatingJob, v8::internal::Isolate*, v8::internal::MarkCompactCollector*, std::__Cr::vector<std::__Cr::unique_ptr<v8::internal::UpdatingItem, std::__Cr::default_delete<v8::internal::UpdatingItem> >, std::__Cr::allocator<std::__Cr::unique_ptr<v8::internal::UpdatingItem, std::__Cr::default_delete<v8::internal::UpdatingItem> > > > > ()
    at ../../third_party/libc++/src/include/__memory/unique_ptr.h:597
#20 UpdatePointersAfterEvacuation () at ../../src/heap/mark-compact.cc:5097
#21 0x0000555c6717bddd in Evacuate () at ../../src/heap/mark-compact.cc:4536
#22 0x0000555c671747bd in CollectGarbage ()
    at ../../src/heap/mark-compact.cc:418
#23 0x0000555c67078426 in MarkCompact () at ../../src/heap/heap.cc:2717
#24 0x0000555c67076c43 in PerformGarbageCollection ()
    at ../../src/heap/heap.cc:2403
#25 0x0000555c670b5ffc in operator() () at ../../src/heap/heap.cc:1870
#26 0x0000555c6707002c in SetMarkerIfNeededAndCallback<(lambda at ../../src/heap/heap.cc:1834:40)> () at ../../src/heap/base/stack.h:64
#27 CollectGarbage () at ../../src/heap/heap.cc:1834
#28 0x0000555c67075c94 in CollectAllGarbage ()
    at ../../src/heap/heap.cc:1514
#29 CollectGarbageForBackground () at ../../src/heap/heap.cc:2237
#30 0x0000555c67165a57 in ParkSlowPath ()
    at ../../src/heap/local-heap.cc:231
#31 0x0000555c66d15ccf in Park () at ../../src/heap/local-heap.h:319
#32 ParkedScope () at ../../src/heap/parked-scope.h:24
#33 ParkAndExecuteCallback<(lambda at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:148:9)> () at ../../src/heap/local-heap-inl.h:64
#34 operator() () at ../../src/heap/local-heap-inl.h:85
#35 0x0000555c66d15c0e in void heap::base::Stack::SetMarkerAndCallbackImpl<v8::internal::LocalHeap::BlockMainThreadWhileParked<v8::internal::OptimizingCompileDispatcher::AwaitCompileTasks()::$_0>(v8::internal::OptimizingCompileDispatcher::AwaitCompileTasks()::$_0)::{lambda()#1}>(heap::base::Stack*, void*, void const*) () at ../../src/heap/base/stack.h:95
#36 0x0000555c68ae5a97 in PushAllRegistersAndIterateStack ()
#37 0x0000555c66d13ad9 in SetMarkerIfNeededAndCallback<(lambda at ../../src/heap/local-heap-inl.h:85:7)> () at ../../src/heap/base/stack.h:60
#38 ExecuteWithStackMarker<(lambda at ../../src/heap/local-heap-inl.h:85:7)>
    () at ../../src/heap/local-heap-inl.h:95
#39 BlockMainThreadWhileParked<(lambda at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:148:9)> () at ../../src/heap/local-heap-inl.h:84
#40 BlockMainThreadWhileParked<(lambda at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:148:9)> ()
    at ../../src/execution/local-isolate-inl.h:37
#41 AwaitCompileTasks ()
    at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:147
#42 0x0000555c66d13e32 in FlushQueues ()
    at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:163
#43 Stop ()
    at ../../src/compiler-dispatcher/optimizing-compile-dispatcher.cc:179
#44 0x0000555c66ebd81a in Deinit () at ../../src/execution/isolate.cc:3832
#45 0x0000555c66ebd29e in Delete () at ../../src/execution/isolate.cc:3536
#46 0x0000555c66800915 in ExecuteInThread () at ../../src/d8/d8.cc:4778
#47 0x0000555c667ffeb7 in Run () at ../../src/d8/d8.cc:4538
#48 0x0000555c668bea99 in NotifyStartedAndRun ()
    at ../../src/base/platform/platform.h:613
#49 ThreadEntry () at ../../src/base/platform/platform-posix.cc:1189
#50 0x00007facbfc7583c in ?? () from /lib64/libc.so.6
#51 0x00007facbfce7838 in ?? () from /lib64/libc.so.6

A stack trace is read from the bottom up: the lowest numbered frames are the most recent calls, and the highest are the oldest. Here is what the trace says, step by step, in plain words:

  1. A d8 worker thread starts (ThreadEntry, NotifyStartedAndRun, Run, ExecuteInThread). This is the thread doing the work.
  2. That thread deletes its isolate (Delete, Deinit). In other words, the engine instance is being shut down.
  3. During shutdown, the optimising compile dispatcher is stopped (Stop, FlushQueues, AwaitCompileTasks). The dispatcher is the part that manages background compilation of JavaScript into fast machine code. Stopping it means waiting for outstanding compile tasks to finish.
  4. Waiting parks the local heap and blocks the main thread while parked (BlockMainThreadWhileParked, Park, ParkedScope). Parking is a way of saying "this thread is idle for now, let the rest of the system proceed".
  5. Parking triggers a background garbage collection (CollectGarbageForBackground, CollectAllGarbage, CollectGarbage), which performs a mark-compact collection (MarkCompact, PerformGarbageCollection).
  6. Inside that collection, Evacuate moves live objects, then calls UpdatePointersAfterEvacuation to fix up the pointers that referred to them.
  7. That function constructs a PointersUpdatingJob (make_unique). A job is a unit of work, here the task of updating pointers.
  8. The job's constructor builds an IndexGenerator (src/heap/index-generator.cc:13). This object generates indices, numbers used to track items during the update.
  9. The IndexGenerator adds an item to a queue backed by a std::deque, a double-ended queue data structure. Growing the deque calls __add_back_capacity, which allocates memory through libc++'s allocator and eventually malloc.
  10. It is inside malloc that glibc detects the corrupted fastbin chunk and aborts.

The abort is therefore the detection point, not the corruption point. The allocator notices that a chunk on its fastbin list has been tampered with while servicing an allocation for the deque inside IndexGenerator. The report does not identify which object was freed and later written to.

Step 2: capture the full log

The researcher attached the full log as a file; the excerpt above is the part quoted inline. The report does not include the attachment contents.

Root cause

The crash is classified as a use-after-free in V8. The allocator's unaligned fastbin chunk detected message indicates heap metadata corruption, consistent with a use-after-free, but the report does not describe the write itself. The stack places the detection during pointer updating after evacuation, in the PointersUpdatingJob and its IndexGenerator, while the isolate is being torn down on a worker thread and a background collection is running.

The stress flags used (--stress-concurrent-allocation, --stress-incremental-marking) widen the window in which concurrent allocation and incremental marking interact with the collection, which is likely why the corruption is reproducible with this PoC.

Impact

A use-after-free in V8 can in principle be exploitable, but the report only demonstrates a crash in d8 under fuzzing flags and does not show exploitation. The renderer is the part of the browser that turns web content into what you see; if an attacker can run code there, they can do things the page should not be able to do. The report itself only demonstrates a crash in d8 under fuzzing flags and does not show exploitation. The platform rates the issue medium severity.

Fix

The bug was disclosed on 2024-05-15, and the platform notes that security bugs are normally made public once a fix has been widely deployed.

Variants to test

  1. Run the same PoC under different stress combinations, for example with only --stress-concurrent-allocation or only --stress-incremental-marking, to see whether the crash depends on one of them. A positive result is the same malloc_consolidate(): unaligned fastbin chunk detected abort with a similar stack through PointersUpdatingJob.
  2. Exercise isolate teardown on worker threads while compilation tasks are outstanding, since the trace runs through OptimizingCompileDispatcher::Stop and AwaitCompileTasks. A positive result is a crash during Deinit rather than during normal script execution.
  3. Vary the allocation pattern around the IndexGenerator deque growth, for example by changing the number of updating items, to see whether the corruption depends on deque capacity changes. A positive result is the same allocator abort at __add_back_capacity.
  4. Run the PoC under a different allocator or with sanitizers to turn the silent corruption into an earlier, more precise report. A sanitizer is a tool that adds extra checks to a program to catch memory errors as they happen. A positive result is an ASan (AddressSanitizer) or similar report pointing at the write that follows the free, which would identify the object the report leaves unnamed.

Glossary

  • V8: the JavaScript engine used by Chrome and by the d8 developer shell; it turns JavaScript code into actions.
  • d8: a command-line shell that runs V8 on its own, without a browser, used for testing and fuzzing.
  • JavaScript: the programming language that makes web pages interactive.
  • Garbage collector (GC): software that automatically frees memory the program no longer uses.
  • Mark-compact: a garbage collection strategy that marks live objects and then moves them together to reduce fragmentation.
  • Evacuation: the step in compaction where live objects are moved to a new area.
  • Pointer: a reference to the location of an object in memory.
  • Use-after-free: a bug where a program keeps using memory after it has been freed, which can corrupt whatever now occupies that memory.
  • Worker thread: a second line of execution running alongside the main one, often used for background work.
  • Allocator / malloc: the part of the system that hands out blocks of memory on request.
  • glibc: the standard C library on Linux, which provides malloc and related functions.
  • Fastbin: a glibc structure that keeps small freed memory blocks in a quick-access list.
  • Metadata: bookkeeping data that describes something, such as which memory blocks are free or in use.
  • Stack trace: a list of function calls that led to the current point in a program, used to locate a crash.
  • SIGABRT: the signal a program sends itself when it decides it cannot continue safely.
  • CVE: a public identifier for a known security vulnerability.
  • Bounty: a payment made for a valid security report.
  • Severity: a rating of how serious a vulnerability is.
  • Proof of concept (PoC): a minimal example that demonstrates a bug.
  • Fuzzing: automated testing that throws lots of random or semi-random input at software to find crashes.
  • Flag: a command-line switch that changes how a program behaves when it starts.
  • Compiler: software that translates code from one form into another, often into faster machine code.
  • Maglev: one of V8's compilers.
  • Optimising compile dispatcher: the part of V8 that manages background compilation of JavaScript into fast machine code.
  • Deque: a double-ended queue data structure that can grow at either end.
  • Sanitizer: a tool that adds extra checks to a program to catch memory errors as they happen.
  • ASan (AddressSanitizer): a widely used sanitizer that detects memory errors such as use-after-free.
  • Renderer: the part of a browser that turns web content into what you see and runs page code.

More by Ganjiang Zhou

View all

3 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.