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

Inappropriate implementation in V8 (CVE-2024-8905)

A crafted JavaScript file run in the V8 engine's d8 shell triggers an unexpected instance type, causing a crash. The report does not state what an attacker could achieve beyond the crash.

Ganjiang Zhou Follow

Originally disclosed on Chrome VRP

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

Steps to reproduce the problem

  1. ./d8 --expose-gc --omit-quit --allow-natives-syntax --fuzzing --jit-fuzzing poc.js

Problem Description

Unexpected instance type encountered

Summary

Unexpected instance type encountered

Custom Questions

Type of crash:

tab

Crash state:

==== JS stack trace =========================================

0: ExitFrame [pc: 0x7f6b1b3545bd]
1: StubFrame [pc: 0x7f6b1b91f378]
2: isCompatible [0xfd200301a5d] [/home/uuu/poc.js:698] [bytecode=0x30000c14d1 offset=4](this=0x0fd2002816fd <JSGlobalProxy>#0#,0)
3: /* anonymous */ [0xfd200301aa1] [/home/uuu/poc.js:193] [bytecode=0x30000c3e7d offset=21](this=0x0fd2002816fd <JSGlobalProxy>#0#)
4: findIndex [0xfd20028d151](this=0x0fd200300059 <JSArray[5]>#1#,0x0fd200301aa1 <JSFunction (sfi = 0xfd2002a0621)>#2#)
5: randomArgumentForReplacing [0xfd20007df45] [/home/uuu/poc.js:705] [bytecode=0x30000c141d offset=80](this=0x0fd20007dc19 <Object map = 0xfd2002be489>#3#,0,0x0fd200300021 <Arguments map = 0xfd200291d91>#4#)
6: exploreObject [0xfd200079ee5] [/home/uuu/poc.js:816] [bytecode=0x30000c29bd offset=186](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd200300021 <Arguments map = 0xfd200291d91>#4#)
7: exploreValue [0xfd200079fe1] [/home/uuu/poc.js:957] [bytecode=0x30000c22dd offset=12](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd20029b01d <String[3]: #v59>,0x0fd200300021 <Arguments map = 0xfd200291d91>#4#)
8: explore [0xfd20007a005] [/home/uuu/poc.js:1001] [bytecode=0x30000c21f1 offset=104](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd20029b01d <String[3]: #v59>,0x0fd200300021 <Arguments map = 0xfd200291d91>#4#,0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd200300059 <JSArray[5]>#1#,63201)
9: exploreWithErrorHandling [0xfd20007a029] [/home/uuu/poc.js:1019] [bytecode=0x30000c20f5 offset=21](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd20029b01d <String[3]: #v59>,0x0fd200300021 <Arguments map = 0xfd200291d91>#4#,0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd200300059 <JSArray[5]>#1#,63201)

10: f23 [0xfd2002a09bd] [/home/uuu/poc.js:1041] [bytecode=0x30000c43c9 offset=66](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd2002c01f1 <JSFunction js-to-wasm:n: (sfi = 0xfd2002c01c1)>#5#) 11: StubFrame [pc: 0x7f6b1b323850] 12: Wasm [wasm://wasm/31a10782], function #2 ('main'), pc=0x2171d6af38d5 (+0x95), pos=60 (+5) 13: JsToWasmFrame [pc: 0x7f6b1b32090a] 14: 2 [0xfd2002c01f1] [wasm://wasm/31a10782:~1] [pc=0x7f6b1b87a4c3](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd2002c01b1 <Other heap object (WASM_FUNC_REF_TYPE)>#6#) 15: /* anonymous */ [0xfd2002a07d1] [/home/uuu/poc.js:1052] [bytecode=0x3000000111 offset=320](this=0x0fd2002816fd <JSGlobalProxy>#0#) 16: InternalFrame [pc: 0x7f6b1afa1edc] 17: EntryFrame [pc: 0x7f6b1afa1c1f]

Additional Data

Category: Security
Chrome Channel: Stable
Regression: N/A

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

Context

This is a Chrome VRP report against V8, the JavaScript engine used by Chrome. The issue was classified as an inappropriate implementation in V8 and later published as CVE-2024-8905. The researcher is Ganjiang Zhou (@refrain_areu) of the ChaMd5-H1 team, the severity recorded by the program is medium, and the bounty was 8000.00 USD. The report was disclosed on 2024-10-01 and is an advisory rather than a full exploit narrative: it gives a reproduction command, a one-line problem description and a crash stack trace.

The crash is reported against the Stable Chrome channel, with regression marked N/A. The crash type is recorded as "tab".

Setup

The reproduction uses the V8 developer shell, d8, built with the flags needed for fuzzing and native syntax access. The report gives the exact invocation:

Bash
./d8 --expose-gc --omit-quit --allow-natives-syntax --fuzzing --jit-fuzzing poc.js

The flags do the following:

  • --expose-gc exposes the garbage collector to the script, so the proof of concept can force collection at chosen points.
  • --omit-quit removes the quit() builtin, so a script cannot terminate the shell early.
  • --allow-natives-syntax enables the %-prefixed native syntax used by V8 tests and fuzzers.
  • --fuzzing and --jit-fuzzing enable the fuzzing-oriented behaviour and JIT fuzzing support that the generated script expects.

The proof of concept itself is poc.js. The report does not include its contents, so the script cannot be reconstructed from this text; what follows is read from the stack trace it produced.

Finding it

The problem description is a single line: "Unexpected instance type encountered". That is the engine's own complaint when a value reaches code that expects one kind of object and finds another. The report does not explain which check fired or which instance type was unexpected; the stack trace is the only detail provided.

What the trace does show is the shape of the generated script. The frames reference a large poc.js with line numbers in the hundreds and over a thousand (frames at lines 193, 698, 705, 816, 957, 1001, 1019, 1041 and 1052), and the function names (explore, exploreValue, exploreObject, exploreWithErrorHandling, randomArgumentForReplacing, isCompatible) are those of a JavaScript fuzzer harness that walks object graphs and mutates arguments. The function names suggest a JavaScript fuzzer harness that walks object graphs and mutates arguments.

Exploitation

Step 1: run the proof of concept

The only step given is the command above, run against poc.js. The report lists two further numbered steps but leaves them empty, so there is no second action to describe.

Step 2: read the crash

The crash state is the JS stack trace. Reading it from the bottom up shows how the script reached the failing code:

The important parts of the trace:

  • Frame 15 is the entry point in the script, an anonymous function at poc.js:1052. It calls into a WebAssembly module.
  • Frames 14, 13 and 12 show the crossing into Wasm: a function reference of type WASM_FUNC_REF_TYPE is invoked, the engine pushes a JsToWasmFrame, and execution enters wasm://wasm/31a10782, function #2 named main, at position 60.
  • Frame 11 is a stub frame, and frame 10 is f23 at poc.js:1041, called with a js-to-wasm:n: function object. This is the Wasm module calling back into JavaScript.
  • Frames 9 to 5 are the fuzzer harness: exploreWithErrorHandling calls explore with the string #v59, an Arguments object and the array JSArray[5]; explore calls exploreValue; exploreObject walks the arguments; randomArgumentForReplacing at poc.js:705 runs with an Object as this and the Arguments object as an argument.
  • Frame 4 is a call to Array.prototype.findIndex on a five-element array, with the callback being the anonymous function at poc.js:193.
  • Frame 3 is that callback, and frame 2 is isCompatible at poc.js:698, called with this set to the global proxy and a single argument of 0.
  • Frames 1 and 0 are the stub and exit frames where the engine stopped.

So the path is: script entry, into Wasm, back out to JavaScript, through the fuzzer's object exploration code, into findIndex, into a compatibility check, and then the engine reports an unexpected instance type. The trace does not say which value had the wrong type, only that the failure happened at this point.

Root cause

The report classifies the weakness as an inappropriate implementation in V8 and gives no further analysis. The only technical statement is the engine message "Unexpected instance type encountered". The stack shows the crash occurring after a round trip from JavaScript into Wasm and back, inside a callback invoked by findIndex, but the report does not identify the specific check, the object involved or the code path in V8 that mishandled it. Any deeper explanation would be speculation, so it is left out here.

Impact

The report records the crash type as a tab crash on the Stable channel. The report does not describe a path from this crash to memory corruption, code execution or sandbox escape, and it does not state which sites or users would be affected. The severity assigned by the program is medium.

Fix

What is known from the advisory metadata is that the issue was tracked as CVE-2024-8905 and disclosed on 2024-10-01. The specific change to V8 is not part of this text.

Variants to test

Because the report gives no root cause, the only concrete lead is the shape of the crashing path. Things worth trying when fuzzing V8 builds:

  1. Round trips through Wasm. Have a JavaScript function call a Wasm export that calls back into JavaScript, and inside that callback exercise array iteration methods such as findIndex with callbacks that inspect argument objects. A positive result is an "Unexpected instance type encountered" abort or a similar type-check failure in the engine.
  2. Argument object mutation. Use a harness that walks arguments objects and replaces entries while an iteration callback is running, mirroring the randomArgumentForReplacing frame. A positive result is a crash or a debug assertion in the engine rather than a JavaScript exception.
  3. Function references across the boundary. Pass WASM_FUNC_REF_TYPE values into JavaScript callbacks and invoke them from inside iteration methods. A positive result is a type confusion report or a crash in the JIT or Wasm call machinery.
  4. Run under the same flags. Use --expose-gc --omit-quit --allow-natives-syntax --fuzzing --jit-fuzzing so that native syntax and forced GC are available, since the original crash was found under those conditions. A positive result is a reproducible crash with a stack trace that crosses JsToWasmFrame and a JavaScript callback.

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

What happened, in plain words

A security researcher found a way to make Chrome's JavaScript engine, the part of the browser that runs the code on web pages, crash. The engine is called V8. The crash was reported through Chrome's bug bounty programme, which pays people for finding and reporting security problems, and the researcher received 8000.00 USD. The problem was later given the public identifier CVE-2024-8905, which is a catalogue number used to track a specific security flaw. The programme rated the severity as medium, and the report was made public on 2024-10-01.

The report is short. It gives one command to run, a one-line description of the problem, and a long printout of what the engine was doing when it crashed. It does not include the actual test script, so we cannot rebuild the crash from this text alone. What we can do is read the printout and understand the path the engine took before it stopped.

The crash happened on the Stable channel, which is the ordinary Chrome that most people have installed, not a test or developer version. The report marks regression as N/A, meaning it does not say whether an older version of Chrome behaved differently. The crash type is recorded as "tab".

Setup

To reproduce the crash, the researcher used d8. This is a small command-line program that runs JavaScript using V8 directly, without the rest of Chrome around it. Think of it as a bare engine on a test bench, with no windows, no menus and no web page. Security researchers use it because it is fast and because it lets them switch on internal features that a normal browser keeps hidden.

The report gives the exact command used to start it:

Bash
./d8 --expose-gc --omit-quit --allow-natives-syntax --fuzzing --jit-fuzzing poc.js

Line by line:

  • ./d8 runs the d8 program from the current folder. The ./ just means "the file called d8 right here".
  • --expose-gc makes the garbage collector available to the script. The garbage collector is the part of the engine that automatically frees memory that is no longer in use. Normally a script cannot ask for it to run; this flag lets the script trigger it at chosen moments, which is useful when testing memory-related behaviour.
  • --omit-quit removes the built-in quit() function, so a script cannot end the program early.
  • --allow-natives-syntax turns on special syntax that starts with %. These are internal commands used by V8's own tests and fuzzers, not something a normal web page can use.
  • --fuzzing and --jit-fuzzing switch on behaviour meant for fuzzing. A fuzzer is a program that generates huge numbers of random or semi-random inputs and watches for crashes. JIT stands for just-in-time compilation, the technique where the engine turns JavaScript into machine code while it runs; the second flag enables fuzzing support around that machinery.
  • poc.js is the file containing the proof of concept, the script that triggers the bug.

The report does not include the contents of poc.js, so the script cannot be reconstructed from this text. Everything below is read from the stack trace it produced.

Finding it

The problem description is a single line: "Unexpected instance type encountered". That is the engine complaining that a value arrived somewhere expecting one kind of object, and it was a different kind. An instance type is the engine's internal label for what a value is: a string, an array, a function, a number and so on. When code checks that label and finds something it did not expect, it stops.

The report does not explain which check fired or which value had the wrong label. The stack trace is the only detail we have.

What the trace does show is the shape of the generated script. The line numbers in the trace run into the hundreds and past a thousand (lines 193, 698, 705, 816, 957, 1001, 1019, 1041 and 1052), and the function names (explore, exploreValue, exploreObject, exploreWithErrorHandling, randomArgumentForReplacing, isCompatible) look like the parts of a JavaScript fuzzer harness. A harness is the scaffolding a fuzzer uses: it walks through objects, looks at their contents and changes arguments to see what happens. The function names suggest the parts of a JavaScript fuzzer harness.

Exploitation

Step 1: run the proof of concept

The only step given is the command above, run against poc.js. The report lists two further numbered steps but leaves them empty, so there is no second action to describe.

Step 2: read the crash

The crash state is the JavaScript stack trace. A stack trace is a list of the function calls that were in progress at the moment of the crash, like a receipt showing every step that led to the failure. Reading it from the bottom up shows how the script reached the failing code:

Text
==== JS stack trace =========================================

    0: ExitFrame [pc: 0x7f6b1b3545bd]
    1: StubFrame [pc: 0x7f6b1b91f378]
    2: isCompatible [0xfd200301a5d] [/home/uuu/poc.js:698] [bytecode=0x30000c14d1 offset=4](this=0x0fd2002816fd <JSGlobalProxy>#0#,0)
    3: /* anonymous */ [0xfd200301aa1] [/home/uuu/poc.js:193] [bytecode=0x30000c3e7d offset=21](this=0x0fd2002816fd <JSGlobalProxy>#0#)
    4: findIndex [0xfd20028d151](this=0x0fd200300059 <JSArray[5]>#1#,0x0fd200301aa1 <JSFunction (sfi = 0xfd2002a0621)>#2#)
    5: randomArgumentForReplacing [0xfd20007df45] [/home/uuu/poc.js:705] [bytecode=0x30000c141d offset=80](this=0x0fd20007dc19 <Object map = 0xfd2002be489>#3#,0,0x0fd200300021 <Arguments map = 0xfd200291d91>#4#)
    6: exploreObject [0xfd200079ee5] [/home/uuu/poc.js:816] [bytecode=0x30000c29bd offset=186](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd200300021 <Arguments map = 0xfd200291d91>#4#)
    7: exploreValue [0xfd200079fe1] [/home/uuu/poc.js:957] [bytecode=0x30000c22dd offset=12](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd20029b01d <String[3]: #v59>,0x0fd200300021 <Arguments map = 0xfd200291d91>#4#)
    8: explore [0xfd20007a005] [/home/uuu/poc.js:1001] [bytecode=0x30000c21f1 offset=104](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd20029b01d <String[3]: #v59>,0x0fd200300021 <Arguments map = 0xfd200291d91>#4#,0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd200300059 <JSArray[5]>#1#,63201)
    9: exploreWithErrorHandling [0xfd20007a029] [/home/uuu/poc.js:1019] [bytecode=0x30000c20f5 offset=21](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd20029b01d <String[3]: #v59>,0x0fd200300021 <Arguments map = 0xfd200291d91>#4#,0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd200300059 <JSArray[5]>#1#,63201)
   10: f23 [0xfd2002a09bd] [/home/uuu/poc.js:1041] [bytecode=0x30000c43c9 offset=66](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd2002c01f1 <JSFunction js-to-wasm:n: (sfi = 0xfd2002c01c1)>#5#)
   11: StubFrame [pc: 0x7f6b1b323850]
   12: Wasm [wasm://wasm/31a10782], function #2 ('main'), pc=0x2171d6af38d5 (+0x95), pos=60 (+5)
   13: JsToWasmFrame [pc: 0x7f6b1b32090a]
   14: 2 [0xfd2002c01f1] [wasm://wasm/31a10782:~1] [pc=0x7f6b1b87a4c3](this=0x0fd2002816fd <JSGlobalProxy>#0#,0x0fd2002c01b1 <Other heap object (WASM_FUNC_REF_TYPE)>#6#)
   15: /* anonymous */ [0xfd2002a07d1] [/home/uuu/poc.js:1052] [bytecode=0x3000000111 offset=320](this=0x0fd2002816fd <JSGlobalProxy>#0#)
   16: InternalFrame [pc: 0x7f6b1afa1edc]
   17: EntryFrame [pc: 0x7f6b1afa1c1f]

Each line is one frame, meaning one function call that was still in progress. The number at the start is the frame number, lowest is the most recent call, highest is the oldest. The parts in angle brackets describe the values involved: JSGlobalProxy is the global object of the script, JSArray[5] is an array with five elements, Arguments is the special object that holds a function's arguments, and WASM_FUNC_REF_TYPE is a reference to a function inside a WebAssembly module. WebAssembly, or Wasm, is a second kind of code that runs in the browser alongside JavaScript, usually compiled from languages like C or Rust; it is faster and lower level, and JavaScript and Wasm can call each other.

The important parts of the trace:

  • Frame 15 is the entry point in the script, an anonymous function at poc.js:1052. It calls into a WebAssembly module.
  • Frames 14, 13 and 12 show the crossing into Wasm: a function reference of type WASM_FUNC_REF_TYPE is invoked, the engine pushes a JsToWasmFrame (a marker meaning "we are now entering Wasm from JavaScript"), and execution enters wasm://wasm/31a10782, function #2 named main, at position 60.
  • Frame 11 is a stub frame, a small piece of engine-generated code that bridges calls. Frame 10 is f23 at poc.js:1041, called with a js-to-wasm:n: function object. This is the Wasm module calling back into JavaScript.
  • Frames 9 to 5 are the fuzzer harness: exploreWithErrorHandling calls explore with the string #v59, an Arguments object and the array JSArray[5]; explore calls exploreValue; exploreObject walks the arguments; randomArgumentForReplacing at poc.js:705 runs with an Object as this and the Arguments object as an argument.
  • Frame 4 is a call to Array.prototype.findIndex on a five-element array, with the callback being the anonymous function at poc.js:193. findIndex is a standard JavaScript method that goes through an array and returns the position of the first element that matches a test you give it.
  • Frame 3 is that callback, and frame 2 is isCompatible at poc.js:698, called with this set to the global proxy and a single argument of 0.
  • Frames 1 and 0 are the stub and exit frames where the engine stopped.

So the path is: script entry, into Wasm, back out to JavaScript, through the fuzzer's object exploration code, into findIndex, into a compatibility check, and then the engine reports an unexpected instance type. The trace does not say which value had the wrong type, only that the failure happened at this point.

Root cause

The report classifies the weakness as an inappropriate implementation in V8 and gives no further analysis. "Inappropriate implementation" is a broad label meaning the code did not behave the way it was supposed to, as opposed to, say, a memory-safety bug where the program reads or writes memory it should not. The only technical statement is the engine message "Unexpected instance type encountered". The stack shows the crash occurring after a round trip from JavaScript into Wasm and back, inside a callback invoked by findIndex, but the report does not identify the specific check, the object involved or the code path in V8 that mishandled it. Any deeper explanation would be guesswork, so it is left out here.

Impact

The report records the crash type as a tab crash on the Stable channel. A renderer process is the isolated part of Chrome that handles a single tab's content; when it crashes, the tab goes down but the rest of the browser usually survives. The severity assigned by the programme is medium.

Fix

What is known from the advisory metadata is that the issue was tracked as CVE-2024-8905 and disclosed on 2024-10-01. The specific change to V8 is not part of this text.

Variants to test

Because the report gives no root cause, the only concrete lead is the shape of the crashing path. Things worth trying when fuzzing V8 builds:

  1. Round trips through Wasm. Have a JavaScript function call a Wasm export that calls back into JavaScript, and inside that callback exercise array iteration methods such as findIndex with callbacks that inspect argument objects. A positive result is an "Unexpected instance type encountered" abort or a similar type-check failure in the engine.
  2. Argument object mutation. Use a harness that walks arguments objects and replaces entries while an iteration callback is running, mirroring the randomArgumentForReplacing frame. A positive result is a crash or a debug assertion in the engine rather than a JavaScript exception.
  3. Function references across the boundary. Pass WASM_FUNC_REF_TYPE values into JavaScript callbacks and invoke them from inside iteration methods. A positive result is a type confusion report or a crash in the JIT or Wasm call machinery.
  4. Run under the same flags. Use --expose-gc --omit-quit --allow-natives-syntax --fuzzing --jit-fuzzing so that native syntax and forced garbage collection are available, since the original crash was found under those conditions. A positive result is a reproducible crash with a stack trace that crosses JsToWasmFrame and a JavaScript callback.

Glossary

  • V8: the JavaScript engine inside Chrome; it reads and runs the JavaScript on web pages.
  • CVE: a public catalogue number for a specific security flaw, used so people can refer to it unambiguously.
  • Bug bounty programme: a scheme where an organisation pays people for finding and reporting security problems.
  • Severity: a rating of how serious a flaw is, here medium.
  • Stable channel: the ordinary release of Chrome that most users have, as opposed to test or developer builds.
  • Regression: whether a flaw is new or existed in earlier versions; here marked N/A, meaning not stated.
  • Tab crash: a failure that takes down the browser tab (the renderer process) rather than the whole browser.
  • d8: a command-line program that runs JavaScript with V8 alone, without the rest of Chrome.
  • Garbage collector: the part of the engine that automatically frees memory no longer in use.
  • Fuzzer: a program that generates many random or semi-random inputs and watches for crashes.
  • Fuzzing harness: the scaffolding a fuzzer uses to walk objects, inspect them and change arguments.
  • JIT (just-in-time compilation): turning JavaScript into machine code while the program runs, for speed.
  • Native syntax: internal %-prefixed commands used by V8's own tests and fuzzers.
  • Proof of concept (poc): a small script or program that demonstrates a bug.
  • Instance type: the engine's internal label for what a value is, such as a string, array or function.
  • Stack trace: a list of the function calls in progress at the moment of a crash, newest first.
  • Frame: one entry in a stack trace, representing one function call.
  • WebAssembly (Wasm): a second kind of code that runs in the browser alongside JavaScript, usually compiled from other languages.
  • WASM_FUNC_REF_TYPE: a reference to a function inside a WebAssembly module.
  • JsToWasmFrame: a marker in the stack showing that execution is entering Wasm from JavaScript.
  • Stub frame: a small piece of engine-generated code that bridges calls between JavaScript and other code.
  • findIndex: a standard JavaScript array method that returns the position of the first element matching a test.
  • Arguments object: the special object holding a function's arguments.
  • Inappropriate implementation: a broad label meaning the code did not behave as it should, as opposed to a memory-safety bug.
  • Renderer process: the isolated part of Chrome that handles a single tab's content.
  • Sandbox escape: getting out of the isolation Chrome puts around a tab to reach the rest of the system.
  • Type confusion: a bug where the engine treats a value as one kind when it is actually another.

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.