Type Confusion in V8 (CVE-2024-12053)
A type confusion flaw in V8 causes a crash when toString() is called on the return value of a WebAssembly function from JavaScript. The report only demonstrates a crash, not exploitation for code execution.
- Fix shipped in 20 days
VULNERABILITY DETAILS
It crashes when calling toString() on a wasm function's return value in javascript (the last line of the poc).
VERSION
v8 Version: commit 7a9e78e98f59b7adf79e6ead0459718e4ed249e7 (Nov 14 2024)
Operating System: Ubuntu Linux 5.4.0-167-generic
REPRODUCTION CASE
gn gen out/release
./out/release/d8 --jit-fuzzing ./poc.js
Note that the flag --jit-fuzzing is necessary for reproducing the crash.
ADDITIONAL INFORMATION
provided in the attached crash.log
What the report shows
The target is V8, the JavaScript and WebAssembly engine used by Chrome. The researcher found that calling toString() on the return value of a WebAssembly function, from JavaScript, crashes the engine. The proof of concept ends on that call, and the crash is the whole of the reported behaviour.
The build and reproduction steps are given exactly as follows. First the build directory is generated:
gn gen out/release
Then the proof of concept is run under the d8 shell:
./out/release/d8 --jit-fuzzing ./poc.js
The report stresses that the --jit-fuzzing flag is necessary to reproduce the crash.
The environment is recorded as V8 commit [redacted] (14 November 2024) on Ubuntu Linux 5.4.0-167-generic. A crash.log was attached to the report but its contents are not reproduced here.
The platform records the issue as a high severity type confusion in V8, credited to gal1ium and chluo, disclosed on 3 December 2024 with a bounty of 8,000 USD. The report text itself does not describe a fix or a patch.
Root cause
The platform records the issue as a type confusion in V8, and the crash occurs when toString() is called on a wasm function's return value. The report does not include the proof of concept source.
Impact
The observable effect in the report is a crash of the engine. The observable effect in the report is a crash of the engine, and the report makes no claim beyond it. The report states that the --jit-fuzzing flag is necessary to reproduce the crash.
How this kind of bug works
A type confusion arises when two parts of a program disagree about what a value is. In an optimising engine this usually means the optimiser has inferred one representation for a value, for example a tagged pointer to a particular object layout, while the code that produced the value built something else, such as a different object shape, a raw number where an object is expected, or a value from a foreign context such as WebAssembly. Once the two views diverge, a field read or a method dispatch uses the wrong offset or the wrong map, and the engine operates on memory it has misidentified.
JIT compilers make this class more likely because they specialise code on assumptions gathered at run time and then rely on those assumptions holding. Any path that can create a value the optimiser did not anticipate, especially a cross-boundary path like wasm to JS, is a candidate. Defences include strict map and type checks on every boundary crossing, deoptimisation when an assumption fails, and representation invariants enforced in debug and fuzzing builds so that a mismatch aborts loudly instead of silently corrupting memory.
How to test for it
- Identify boundaries where values cross between subsystems with different internal representations: wasm to JS, builtins to user code, one realm to another, or serialised data back into objects.
- Exercise the boundary with values of every shape the receiving side can handle: objects, primitives, null and undefined, arrays, typed arrays, proxies, and values returned from foreign functions.
- Force the optimiser to specialise on the path. Run the same operation many times with one type, then switch the type and observe whether the engine deoptimises cleanly or misbehaves.
- Run under fuzzing or debug configurations that enable extra assertions, since these turn silent corruption into a visible abort.
- A positive result is a crash, an assertion failure, or a wrong value observed after the type switch, reproducible with a minimal script and a stated build and flags.
Common false positives are crashes caused by resource exhaustion or by unsupported API use rather than by confused types, faults that only appear with an unusual flag and cannot be tied to a specific assumption, and non-deterministic failures that do not reproduce from a clean build. Confirm reproducibility and reduce the case before reporting.
How it is fixed
The report text does not describe a fix or a patch.
Hunting notes
Type confusion tends to hide at seams: interop layers, builtins that accept arbitrary values, deserialisation, and optimiser fast paths that assume a stable shape. Recon signals include recent changes to those seams, fuzzing configurations that expose extra assertions, and crash reports that mention map or representation checks. To get a report accepted, show a minimal reproducer, state the exact build and flags, explain which two views of the value disagree, and describe the worst realistic consequence rather than only the crash.
What happened, in plain words
Chrome runs JavaScript, the language that makes web pages interactive, using a piece of software called V8. V8 is the engine: it reads the code on a page and executes it. V8 also runs WebAssembly (often shortened to wasm), a faster, lower-level format that lets developers run heavy code, such as games or video tools, inside the browser.
The researcher found a way to make V8 crash. The trigger is a single operation: taking a value that a WebAssembly function hands back to JavaScript and calling toString() on it. toString() is a standard JavaScript method that turns a value into text, for example turning the number 5 into the string "5". Calling it on a wasm return value should be harmless. Here it brings the engine down.
The platform records this as a high severity type confusion in V8, credited to gal1ium and chluo, disclosed on 3 December 2024, with a bounty of 8,000 USD. The report text does not describe a fix or a patch.
The build and reproduction steps
The report gives the steps exactly as follows. First the build directory is generated:
gn gen out/release
gn is a tool that prepares the instructions for compiling a large program; this line creates a folder called out/release holding a release build configuration. It matters because the crash was observed in a specific build, and anyone trying to repeat the result needs the same starting point.
Then the proof of concept is run under the d8 shell:
./out/release/d8 --jit-fuzzing ./poc.js
d8 is a bare command-line shell for V8, without the rest of Chrome around it, which makes engine bugs easier to study. ./poc.js is the proof of concept script, the small file that triggers the fault. --jit-fuzzing is a flag, an option that changes how the engine behaves.
The report stresses that the --jit-fuzzing flag is necessary to reproduce the crash. JIT stands for just-in-time compilation: instead of interpreting code line by line every time, the engine translates hot code into fast machine code as it runs. Fuzzing means feeding a program large amounts of generated or unusual input to find faults. The flag turns on settings used for that kind of testing.
The environment is recorded as V8 commit [redacted] (14 November 2024) on Ubuntu Linux 5.4.0-167-generic. A commit is a saved snapshot of the source code, so the exact version can be rebuilt later. A crash.log was attached to the report, but its contents are not reproduced here.
Why it is called a type confusion
The platform records the issue as a type confusion in V8. A type confusion happens when two parts of a program disagree about what a value is. A simple comparison: one clerk files a parcel as a book, another clerk opens it expecting a book and finds a bottle. Each acted sensibly on their own information, but the mismatch causes trouble.
Calling toString() on a wasm function's return value crashes the engine. A map, in engine terms, is the internal description of an object's shape: which fields it has and where they sit in memory. The report does not include the proof of concept source.
What the impact is
The observable effect in the report is a crash of the engine. The observable effect in the report is a crash of the engine, and the report makes no claim beyond it. The report states that the --jit-fuzzing flag is necessary to reproduce the crash.
In general, how this kind of bug works
A type confusion arises when two parts of a program disagree about what a value is. In an optimising engine this usually means the optimiser has inferred one representation for a value, for example a tagged pointer to a particular object layout, while the code that produced the value built something else, such as a different object shape, a raw number where an object is expected, or a value from a foreign context such as WebAssembly. Once the two views diverge, a field read or a method dispatch uses the wrong offset or the wrong map, and the engine operates on memory it has misidentified.
JIT compilers make this class more likely because they specialise code on assumptions gathered at run time and then rely on those assumptions holding. Any path that can create a value the optimiser did not anticipate, especially a cross-boundary path like wasm to JS, is a candidate. Defences include strict map and type checks on every boundary crossing, deoptimisation when an assumption fails, and representation invariants enforced in debug and fuzzing builds so that a mismatch aborts loudly instead of silently corrupting memory.
How to test for it
- Identify boundaries where values cross between subsystems with different internal representations: wasm to JS, builtins to user code, one realm to another, or serialised data back into objects.
- Exercise the boundary with values of every shape the receiving side can handle: objects, primitives, null and undefined, arrays, typed arrays, proxies, and values returned from foreign functions.
- Force the optimiser to specialise on the path. Run the same operation many times with one type, then switch the type and observe whether the engine deoptimises cleanly or misbehaves.
- Run under fuzzing or debug configurations that enable extra assertions, since these turn silent corruption into a visible abort.
- A positive result is a crash, an assertion failure, or a wrong value observed after the type switch, reproducible with a minimal script and a stated build and flags.
Common false positives are crashes caused by resource exhaustion or by unsupported API use rather than by confused types, faults that only appear with an unusual flag and cannot be tied to a specific assumption, and non-deterministic failures that do not reproduce from a clean build. Confirm reproducibility and reduce the case before reporting.
How it is fixed
Hunting notes
Type confusion tends to hide at seams: interop layers, builtins that accept arbitrary values, deserialisation, and optimiser fast paths that assume a stable shape. Recon signals include recent changes to those seams, fuzzing configurations that expose extra assertions, and crash reports that mention map or representation checks. To get a report accepted, show a minimal reproducer, state the exact build and flags, explain which two views of the value disagree, and describe the worst realistic consequence rather than only the crash.
Glossary
- V8: the JavaScript and WebAssembly engine inside Chrome that reads and runs code from web pages.
- WebAssembly (wasm): a fast, low-level code format that runs inside the browser alongside JavaScript.
toString(): a standard JavaScript method that converts a value into text.- Type confusion: a bug where two parts of a program disagree about what type a value is, so memory is read or used the wrong way.
- JIT (just-in-time compilation): translating code into fast machine code while the program runs, instead of interpreting it every time.
- Fuzzing: feeding a program large amounts of generated or unusual input to find faults.
- Flag: a command-line option that changes how a program behaves.
d8: a bare command-line shell for V8, used to study the engine without the rest of Chrome.gn: a tool that prepares build instructions for a large program such as V8.- Commit: a saved snapshot of source code, identified by a long hash, so an exact version can be rebuilt.
- Map: the engine's internal description of an object's shape, meaning its fields and where they sit in memory.
- Optimiser: the part of the engine that rewrites code to run faster, based on assumptions gathered at run time.
- Deoptimisation: the engine discarding optimised code and falling back to a slower, safer path when an assumption no longer holds.
- Memory corruption: a state where a program writes to or reads memory it should not, which can lead to further exploitation.
- Renderer sandbox: the restricted environment in which a browser tab's code runs, meant to limit damage if that code is compromised.
- Proof of concept (poc): a small script or program that demonstrates a bug.
- Assertion: a check in code that stops the program loudly when an expected condition is false, common in debug and fuzzing builds.
- Regression test: a test added after a fix to make sure the same bug does not come back.