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

Out of bounds read in V8 (CVE-2024-2884)

An out-of-bounds read in V8's Turboshaft compiler was triggered by a specific JavaScript file when run with certain flags. An attacker could potentially cause a crash or read out-of-bounds memory, but the report only demonstrates a crash.

Zhenghang Xiao Follow

Originally disclosed on Chrome VRP

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

VULNERABILITY DETAILS

INTRODUCE

After bisect, it was determined that following commit caused this problem.

commit bde0ed46a0fd612b6126988c54c1100c56a80b7a
Author: Nico Hartmann <[email protected]>
Date:   Wed Nov 22 12:23:35 2023 +0100

    [turboshaft] Re-enable parts of the disabled CSA pipeline changes (1)

    Bug: v8:12783, chromium:1489500
    Change-Id: I072787c3353dabfb8aae74c5eae93b25d0e65e09
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5053297
    Reviewed-by: Darius Mercadier <[email protected]>
    Auto-Submit: Nico Hartmann <[email protected]>
    Commit-Queue: Nico Hartmann <[email protected]>
    Commit-Queue: Darius Mercadier <[email protected]>
    Cr-Commit-Position: refs/heads/main@{#91113}

commit 0aec2b50a0c5b600470d6c20858d69d20d58e374
Author: Darius M <[email protected]>
Date:   Tue Oct 31 16:06:05 2023 +0100

    Reland "[turboshaft] Implement Loop Peeling"
    
    This is a reland of commit 3b084cc30429bb01329715c8ef043ebbc7a776c5
    
    This CL was reverted because of binary size increase. This is expected
    since it adds a new phase to Turboshaft.
    We'll look into reducing Turboshaft binary-size in the mid-term
    future, but for now we have to live with some binary size increases.
    
    Original change's description:
    > [turboshaft] Implement Loop Peeling
    >
    > Bug: v8:12783
    > Change-Id: I95a1bd80adec0433cae8a50bc4d671de29413744
    > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4935413
    > Commit-Queue: Darius Mercadier <[email protected]>
    > Reviewed-by: Nico Hartmann <[email protected]>
    > Cr-Commit-Position: refs/heads/main@{#90693}
    
    Bug: v8:12783
    Change-Id: I0032121aef723c0564184f4f1c281e74d082cf80
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4999945
    Commit-Queue: Darius Mercadier <[email protected]>
    Auto-Submit: Darius Mercadier <[email protected]>
    Reviewed-by: Nico Hartmann <[email protected]>
    Commit-Queue: Nico Hartmann <[email protected]>
    Cr-Commit-Position: refs/heads/main@{#90703}

CRASH LOG

  • Debug output
Bash
# CMD: /tmp/d8-linux-debug-v8-component-91829/d8 --allow-natives-syntax --turboshaft-loop-peeling --stress-gc-during-compilation poc.js
# OUTPUT ==============================================================
102 102
Received signal 11 SEGV_ACCERR 122e626f6f65

Other

Please note to include the flags --allow-natives-syntax --turboshaft-loop-peeling --stress-gc-during-compilation for clusterfuzz classification.

VERSION Tested on v8 version: 12.1.0 - 12.2.0

REPRODUCTION CASE

  1. Download debug v8 from: gs://v8-asan/linux-debug/d8-linux-debug-v8-component-91829.zip
  2. Run: d8 --allow-natives-syntax --turboshaft-loop-peeling --stress-gc-during-compilation poc.js

FOR CRASHES, PLEASE INCLUDE THE FOLLOWING ADDITIONAL INFORMATION Type of crash: tab

CREDIT INFORMATION Reporter credit: Zhenghang Xiao (@Kipreyyy)

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

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 4 min read.

What the report shows

This is a Chrome VRP advisory for an out of bounds read in V8, credited to Zhenghang Xiao (@Kipreyyy). The platform records it as medium severity with a bounty of 8,000 USD, disclosed on 30 January 2024. The affected component is V8, and the report itself is a crash report rather than a full exploit narrative.

The researcher bisected the regression to two commits. The first, at version 91113, is [redacted], titled [turboshaft] Re-enable parts of the disabled CSA pipeline changes (1). The second, at version 90703, is [redacted], a reland of [turboshaft] Implement Loop Peeling. Both commits are in the Turboshaft compiler pipeline, and the second one adds loop peeling as a new phase.

The reproduction is a debug build of d8, V8's shell, run with three flags: --allow-natives-syntax, --turboshaft-loop-peeling and --stress-gc-during-compilation. The crash log shows the command and its output:

Bash
# CMD: /tmp/d8-linux-debug-v8-component-91829/d8 --allow-natives-syntax --turboshaft-loop-peeling --stress-gc-during-compilation poc.js
# OUTPUT ==============================================================
102 102
Received signal 11 SEGV_ACCERR 122e626f6f65

The program prints 102 102 and then dies with a segmentation fault (SEGV_ACCERR) at address 122e626f6f65. The report does not include the contents of poc.js, so the exact JavaScript that triggers the fault is not shown here.

The reproduction steps are:

  1. Download the debug V8 build from gs://v8-asan/linux-debug/d8-linux-debug-v8-component-91829.zip.
  2. Run d8 --allow-natives-syntax --turboshaft-loop-peeling --stress-gc-during-compilation poc.js.

The researcher asks that the same three flags be used for ClusterFuzz classification, and states the bug was tested on V8 versions 12.1.0 to 12.2.0. The crash type is recorded as a tab crash.

Root cause

The report points to the Turboshaft loop peeling phase and the re-enabled CSA pipeline changes as the source of the regression, since bisection lands on those two commits. The report does not analyse the faulting address or the mechanism further.

Impact

An out of bounds read in the JIT compiler can crash the renderer, as it does here. Whether it can be turned into something more, such as leaking memory contents or influencing generated code, is not established in the report. The report only demonstrates a crash in a debug build under specific flags.

How this kind of bug works

Compilers that build an intermediate representation of a function and then transform it (inlining, loop peeling, branch elimination) must keep every node's type and bounds information consistent with the code they emit. When a transformation assumes a value is within a range that no longer holds, or when it reuses a buffer or node index after a phase has changed the graph, the generated machine code can index past the end of an array, a string or a heap object. The read itself may not crash immediately; it crashes when the address falls outside a mapped page, which is why stress flags that perturb allocation and garbage collection make such bugs easier to hit.

Defences include bounds checks that the optimiser cannot prove away incorrectly, typed representations that are revalidated after each phase, and fuzzing with stress flags that vary GC timing and heap layout.

How to test for it

  1. Identify the compiler or JIT path in scope: for a JavaScript engine, the optimising compiler and its newer pipeline phases are the interesting surface.
  2. Look for recently landed or relanded optimisation phases, especially ones that restructure loops or re-enable previously disabled pipeline stages.
  3. Build or obtain a debug or ASan build of the engine, since out of bounds reads often only fault under instrumentation.
  4. Write small programs that exercise the phase in question: loops with unusual bounds, loops whose trip count depends on values the optimiser may misjudge, and code that allocates heavily so garbage collection runs during compilation.
  5. Run them with stress flags that force GC during compilation and that enable the specific phase, and watch for segmentation faults, sanitizer reports or assertion failures.
  6. A positive result is a deterministic crash whose stack points into the compiler phase you targeted, ideally reproducible on a release build too.

Common false positives are crashes caused by the stress flags themselves, by debug-only assertions, or by unrelated engine bugs; bisecting to a specific commit, as done here, separates those from a real regression.

How it is fixed

Hunting notes

Compiler bugs tend to hide in newly added or re-enabled optimisation phases, in code paths that only run under stress flags, and in interactions between phases that each look correct alone. Recon signals include commit messages mentioning relands, re-enabled pipeline parts, or binary size trade-offs, and bug tracker entries referencing the same phase. To show impact, provide a minimal reproducer, the exact flags, the bisected commit range, and a crash log with the faulting address, so the triager can classify and reproduce it quickly.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 7 min read.

What happened, in plain words

This is a public bug report from Google's Chrome Vulnerability Reward Program (VRP), a scheme that pays people for finding and reporting security problems in Chrome. The report describes an out of bounds read in V8, the JavaScript engine inside Chrome. In plain terms, V8 is the part of the browser that reads and runs the JavaScript code on every web page. An out of bounds read means a program asks for data at a position outside the area it is allowed to look at, like reading a line past the end of a printed page and picking up whatever happens to be on the next sheet.

The researcher, Zhenghang Xiao (@Kipreyyy), is credited with the find. The platform records it as medium severity, with a bounty of 8,000 USD, disclosed on 30 January 2024. The report is a crash report: it shows how to make the engine fall over, not a full attack.

Finding the cause with a bisect

A bisect is a way of finding which change introduced a bug. You take a known-good version and a known-bad version and repeatedly test the middle point, halving the range each time, much like guessing a number between 1 and 100 by always asking about the midpoint. The researcher bisected the problem to two commits. A commit is a saved change to the source code, with a message describing it.

The first commit is at version 91113, with the identifier [redacted], titled [turboshaft] Re-enable parts of the disabled CSA pipeline changes (1). Turboshaft is a newer part of V8's optimising compiler, the component that rewrites JavaScript into faster machine code. The second commit is at version 90703, [redacted], a reland of [turboshaft] Implement Loop Peeling. A reland is a change that was landed, then undone, then landed again. Loop peeling is an optimisation that takes the first pass through a loop and writes it out separately, so the rest of the loop can run without re-checking conditions every time.

Both commits sit in the Turboshaft compiler pipeline, and the second adds loop peeling as a new phase. That matters because a compiler phase is a step that transforms the program's internal representation; a new or re-enabled step is a natural place for a mistake to hide.

Reproducing the crash

The reproduction uses d8, V8's standalone command-line shell, in a debug build. A debug build is a version compiled with extra checks and information to help developers. The command and its output are:

Bash
# CMD: /tmp/d8-linux-debug-v8-component-91829/d8 --allow-natives-syntax --turboshaft-loop-peeling --stress-gc-during-compilation poc.js
# OUTPUT ==============================================================
102 102
Received signal 11 SEGV_ACCERR 122e626f6f65

Line by line: the first line is the command that was run. --allow-natives-syntax lets the test script use special internal functions that ordinary web JavaScript cannot call. --turboshaft-loop-peeling switches on the loop peeling phase. --stress-gc-during-compilation forces garbage collection, the automatic cleanup of unused memory, to happen while code is being compiled, which shakes up memory layout and makes timing-dependent bugs easier to hit. poc.js is the proof-of-concept script.

The output shows the program printing 102 102, then Received signal 11 SEGV_ACCERR 122e626f6f65. Signal 11 is a segmentation fault: the program tried to touch memory it is not allowed to touch, and the operating system stopped it. SEGV_ACCERR is the specific reason, an access error, and 122e626f6f65 is the address involved. The report does not include the contents of poc.js, so the exact JavaScript that triggers the fault is not shown.

The reproduction steps are:

  1. Download the debug V8 build from gs://v8-asan/linux-debug/d8-linux-debug-v8-component-91829.zip.
  2. Run d8 --allow-natives-syntax --turboshaft-loop-peeling --stress-gc-during-compilation poc.js.

The researcher asks that the same three flags be used when the crash is classified by ClusterFuzz, Google's automated fuzzing and crash-triage system, so the automated tooling reproduces the same conditions. The bug was tested on V8 versions 12.1.0 to 12.2.0, and the crash type is recorded as a tab crash, meaning the browser tab running the code goes down.

Why it happens

The report points to the loop peeling phase and the re-enabled pipeline changes as the source of the regression, because the bisect lands on those two commits. The report does not analyse the mechanism further.

Impact

An out of bounds read in a just-in-time (JIT) compiler, the part that turns JavaScript into machine code while the page runs, can crash the renderer, as it does here. Whether it can be turned into something more, such as leaking memory contents or influencing the generated code, is not established in the report. What is demonstrated is a crash in a debug build under specific flags.

In general, how this kind of bug works

Compilers that build an intermediate representation of a function and then transform it, through inlining, loop peeling or branch elimination, must keep every node's type and bounds information consistent with the code they emit. When a transformation assumes a value is within a range that no longer holds, or reuses a buffer or node index after a phase has changed the graph, the generated machine code can index past the end of an array, a string or a heap object. The read may not crash immediately; it crashes when the address falls outside a mapped page, which is why stress flags that perturb allocation and garbage collection make such bugs easier to hit.

Defences include bounds checks that the optimiser cannot prove away incorrectly, typed representations that are revalidated after each phase, and fuzzing with stress flags that vary GC timing and heap layout.

How to test for it

  1. Identify the compiler or JIT path in scope: for a JavaScript engine, the optimising compiler and its newer pipeline phases are the interesting surface.
  2. Look for recently landed or relanded optimisation phases, especially ones that restructure loops or re-enable previously disabled pipeline stages.
  3. Build or obtain a debug or ASan build of the engine, since out of bounds reads often only fault under instrumentation. ASan is AddressSanitizer, a tool that adds checks around memory accesses.
  4. Write small programs that exercise the phase in question: loops with unusual bounds, loops whose trip count depends on values the optimiser may misjudge, and code that allocates heavily so garbage collection runs during compilation.
  5. Run them with stress flags that force GC during compilation and that enable the specific phase, and watch for segmentation faults, sanitizer reports or assertion failures.
  6. A positive result is a deterministic crash whose stack points into the compiler phase you targeted, ideally reproducible on a release build too.

Common false positives are crashes caused by the stress flags themselves, by debug-only assertions, or by unrelated engine bugs; bisecting to a specific commit, as done here, separates those from a real regression.

How it is fixed

Hunting notes

Compiler bugs tend to hide in newly added or re-enabled optimisation phases, in code paths that only run under stress flags, and in interactions between phases that each look correct alone. Recon signals include commit messages mentioning relands, re-enabled pipeline parts, or binary size trade-offs, and bug tracker entries referencing the same phase. To show impact, provide a minimal reproducer, the exact flags, the bisected commit range, and a crash log with the faulting address, so the triager can classify and reproduce it quickly.

Glossary

  • V8: the JavaScript engine inside Chrome that reads and runs page scripts.
  • Out of bounds read: reading data at a position outside the area a program is allowed to access.
  • Chrome VRP: Chrome Vulnerability Reward Program, which pays for security reports.
  • Bisect: halving a range of versions to find the change that introduced a bug.
  • Commit: a saved change to source code with a descriptive message.
  • Turboshaft: a newer part of V8's optimising compiler.
  • Compiler pipeline: the sequence of transformation steps a compiler applies to code.
  • Loop peeling: an optimisation that writes out the first pass of a loop separately.
  • Reland: a change that was landed, reverted, then landed again.
  • d8: V8's standalone command-line shell for running JavaScript.
  • Debug build: a version compiled with extra checks and diagnostic information.
  • Flag: a command-line switch that changes how a program runs.
  • Garbage collection (GC): automatic cleanup of memory no longer in use.
  • Segmentation fault (signal 11): the operating system stopping a program that touched memory it may not access.
  • SEGV_ACCERR: the specific reason for a segmentation fault, an access error.
  • ASCII: the standard numbering that maps characters to numbers.
  • Heap object: a piece of data stored in the area of memory the program manages dynamically.
  • JIT compiler: a compiler that turns code into machine code while the program runs.
  • Renderer: the browser process that draws a page and runs its scripts.
  • ClusterFuzz: Google's automated fuzzing and crash-triage system.
  • ASan (AddressSanitizer): a tool that adds checks around memory accesses to catch errors.
  • False positive: a reported problem that turns out not to be the bug being hunted.
  • Backport: applying a fix to older supported release branches.
  • Triager: the person who reviews and classifies incoming bug reports.

More by Zhenghang Xiao

View all

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