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

Type Confusion in V8 (CVE-2024-1938)

A commit that implemented encodeStringToUtf8Array for wasm imported strings introduced a type confusion, causing a debug check failure in the type canonicaliser. An attacker could trigger a crash in the V8 engine by running a crafted WebAssembly script with the experimental imported-strings feature enabled.

5f46f4ee2e17957ba7b39897fb376be8 Follow

Originally disclosed on Chrome VRP

Bounty$7,000 High View original
  • Fix shipped in 17 days

VULNERABILITY DETAILS

INTRODUCE

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

commit 08170169a305fab1dca42bc11d86d7400f25421e
Author: Jakob Kummerow <[email protected]>
Date:   Tue Feb 6 15:40:33 2024 +0100

    [wasm-imported-strings] Implement encodeStringToUtf8Array
    
    Contrary to the "Into" variant, this implicitly allocates an array
    of appropriate size.
    
    Bug: v8:14179
    Change-Id: I01974624683eef961f6c8b8c6cbe33aa65d2df6a
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5273182
    Reviewed-by: Matthias Liedtke <[email protected]>
    Commit-Queue: Jakob Kummerow <[email protected]>
    Auto-Submit: Jakob Kummerow <[email protected]>
    Cr-Commit-Position: refs/heads/main@{#92216}

CRASH LOG

  • Debug output
Bash
# CMD: /tmp/d8-linux32-debug-v8-component-92260/d8 --allow-natives-syntax --experimental-wasm-imported-strings poc.js
# OUTPUT ==============================================================


#
# Fatal error in ../../src/wasm/canonical-types.cc, line 131
# Debug check failed: !type.has_index().
#
#
#
#FailureMessage Object: 0xffed0a00
==== C stack trace ===============================

    /tmp/d8-linux32-debug-v8-component-92260/libv8_libbase.so(v8::base::debug::StackTrace::StackTrace()+0x1f) [0xf7f2d19f]
    /tmp/d8-linux32-debug-v8-component-92260/libv8_libplatform.so(+0x16274) [0xf7ed9274]
    /tmp/d8-linux32-debug-v8-component-92260/libv8_libbase.so(V8_Fatal(char const*, int, char const*, ...)+0xf7) [0xf7f0c5a7]
    /tmp/d8-linux32-debug-v8-component-92260/libv8_libbase.so(+0x26fa6) [0xf7f0bfa6]
    /tmp/d8-linux32-debug-v8-component-92260/libv8_libbase.so(V8_Dcheck(char const*, int, char const*)+0x31) [0xf7f0c5f1]
    /tmp/d8-linux32-debug-v8-component-92260/libv8.so(v8::internal::wasm::TypeCanonicalizer::AddRecursiveGroup(v8::internal::Signature<v8::internal::wasm::ValueType> const*)+0xda) [0xf68996ca]
    /tmp/d8-linux32-debug-v8-component-92260/libv8.so(+0x3153a0b) [0xf6753a0b]
    /tmp/d8-linux32-debug-v8-component-92260/libv8.so(v8::internal::Runtime_TierUpWasmToJSWrapper(int, unsigned int*, v8::internal::Isolate*)+0x7d) [0xf6752b4d]
    /tmp/d8-linux32-debug-v8-component-92260/libv8.so(+0x172590a) [0xf4d2590a]
    /tmp/d8-linux32-debug-v8-component-92260/libv8.so(+0x16f7a8a) [0xf4cf7a8a]
    [0x51d70442]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]
    [0x51d704dd]

Other

Please note to include the flags --allow-natives-syntax --experimental-wasm-imported-strings for clusterfuzz classification.

VERSION Tested on v8 version: 12.3.0 - 12.3.0

REPRODUCTION CASE

  1. Download debug v8 from: gs://v8-asan/linux32-debug/d8-linux32-debug-v8-component-92260.zip
  2. Run: d8 --allow-natives-syntax --experimental-wasm-imported-strings poc.js

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

CREDIT INFORMATION Reporter credit: Jerry

The original report as published on the Chromium issue tracker, by 5f46f4ee2e17957ba7b39897fb376be8. 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 a type confusion bug in V8, tracked as CVE-2024-1938, rated high severity with a bounty of 7,000 USD and disclosed on 27 February 2024. The affected component is V8, specifically the WebAssembly imported strings feature. The reporter is credited as Jerry.

The researcher bisected the regression to a single commit, 92216, which introduced encodeStringToUtf8Array for wasm imported strings. The commit message describes the change as allocating an array of appropriate size, in contrast to the existing "Into" variant. The full commit metadata is reproduced in the report:

Text
commit [redacted]
Author: Jakob Kummerow <[redacted]>
Date:   Tue Feb 6 15:40:33 2024 +0100

    [wasm-imported-strings] Implement encodeStringToUtf8Array

    Contrary to the "Into" variant, this implicitly allocates an array
    of appropriate size.

    Bug: v8:14179
    Change-Id: [redacted]
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5273182
    Reviewed-by: Matthias Liedtke <[redacted]>
    Commit-Queue: Jakob Kummerow <[redacted]>
    Auto-Submit: Jakob Kummerow <[redacted]>
    Cr-Commit-Position: refs/heads/main@{#92216}

The reproduction was run against a linux32 debug build of d8, tested on V8 version 12.3.0. The report gives the download location and the exact command line:

Bash
# CMD: /tmp/d8-linux32-debug-v8-component-92260/d8 --allow-natives-syntax --experimental-wasm-imported-strings poc.js

The report asks that both flags be included for ClusterFuzz classification. The crash is a debug check failure in src/wasm/canonical-types.cc at line 131, with the message Debug check failed: !type.has_index(). The stack trace runs from TypeCanonicalizer::AddRecursiveGroup through Runtime_TierUpWasmToJSWrapper, which places the failure on the tier-up path of a WebAssembly-to-JavaScript wrapper. The report lists the crash type as tab.

Root cause

The report does not explain the mechanism in prose; it identifies the introducing commit and the failing assertion.

Impact

The report records a debug-only assertion failure and a tab crash. It does not demonstrate memory corruption, code execution or a sandbox escape, and no exploitability claim is made. A type confusion in V8 is the kind of flaw that can, in principle, be developed further, but nothing in this report goes beyond the crash.

How this kind of bug works

Type confusion arises when code treats a value as one type while it is actually another. In an engine like V8, objects carry a map (hidden class) that determines layout and which operations are legal. If a path skips a check, a canonicalisation step or a conversion, a later stage can read fields at the wrong offsets, misinterpret a tagged value as a pointer, or pass a structure to code that assumes a different shape. The result ranges from an assertion failure in debug builds to out-of-bounds access in release builds.

In WebAssembly engines the risk concentrates around boundaries: JS-to-wasm wrappers, wasm-to-JS wrappers, tier-up transitions between baseline and optimised code, and the type canonicaliser that deduplicates function signatures. Each of these has invariants about which representation is valid at which point. A new feature that allocates or converts values, such as imported strings, adds new paths through those invariants, and a missed conversion is exactly where confusion appears.

Defences are structural: strong typing with explicit conversions at boundaries, assertions and debug checks that encode invariants, canonicalisation performed once and enforced afterwards, and fuzzing that exercises new features under tier-up and across wrapper boundaries.

How to test for it

  1. Identify recently landed features and their flags. Commit logs, release notes and experimental flag names are the map of new code paths.
  2. Build or obtain a debug or sanitizer build of the engine, since invariant violations surface there first as assertions rather than silent corruption.
  3. Write minimal programs that drive the feature across boundaries: call a wasm export from JS, pass strings and objects, and force tier-up by running the same call enough times to trigger optimisation.
  4. Vary the shapes involved: different signatures, mixed argument types, wrappers created and re-created, values that cross the JS/wasm line repeatedly.
  5. A positive result is a deterministic assertion failure, sanitizer report or crash whose stack points into the new feature's code. Reduce it to the smallest program and record the exact flags and build.

Common false positives: crashes caused by unsupported flag combinations, out-of-memory conditions, or bugs in the test harness rather than the engine. Confirm the crash reproduces on a clean build with only the documented flags, and check whether it also occurs without the experimental feature enabled.

How it is fixed

Fixes for this class usually insert the missing conversion or check at the boundary: ensuring a type is canonicalised before it reaches the canonicaliser, or rejecting indexed types on paths that require canonical ones. Maintainers often add or tighten debug assertions so the invariant is enforced in development builds, and add regression tests derived from the reproducer. Where a feature is experimental, the fix may also gate the path more strictly behind its flag until the invariants are proven.

Hunting notes

New engine features, especially those behind experimental flags, are fertile ground: imported strings, new wasm proposals, and any code that allocates or converts values at a language boundary. Recon signals include commit messages that mention allocation, conversion or canonicalisation, flag names that appear in fuzzing configurations, and changelogs that reference internal bug numbers.

To make a report land, reduce to a minimal reproducer, state the exact build, version and flags, include the full crash output and stack, and identify the introducing commit by bisection where possible. A deterministic assertion failure with a clear stack into the new code is far more persuasive than an unreduced crash, and it gives maintainers a direct pointer to the faulty invariant.

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

What happened, in plain words

This is a public bug bounty advisory from the Google Chrome programme, filed through the Chrome VRP (Vulnerability Reward Program). It describes a bug in V8, the JavaScript engine inside Chrome. V8 is the part of the browser that reads and runs the JavaScript code on every web page you visit. The bug is tracked as CVE-2024-1938, rated high severity, and the reporter is credited as Jerry. The report was disclosed on 27 February 2024.

The bug class is a type confusion. To understand that, imagine a post office where every parcel has a label saying what is inside. If a worker trusts the label without checking, and the label is wrong, they may handle a fragile glass item as if it were a book. Software works the same way: a value carries information about what kind of thing it is, and if one part of the program treats it as a different kind, things break. In a browser engine, that can range from a crash to, in the worst case, memory corruption.

The affected area is a V8 feature called WebAssembly imported strings. WebAssembly (often shortened to wasm) is a second language that browsers can run, alongside JavaScript. It is faster and lower level, and it is often used for games, video editors and other heavy web apps. "Imported strings" is a feature that lets wasm code and JavaScript code pass text between each other. The report concerns a specific function added to support that feature.

Finding the commit that introduced the bug

The researcher used a technique called bisection. If you know a version of the software where the bug happens and an older version where it does not, you can test the versions in between, halving the range each time, until you land on the single change that introduced the problem. It is the same idea as finding a broken link in a long chain by testing the middle link first.

Bisection pointed to commit 92216. A commit is a saved change to the source code, with a message explaining what it does. The report reproduces the commit details:

Text
commit [redacted]
Author: Jakob Kummerow <[redacted]>
Date:   Tue Feb 6 15:40:33 2024 +0100

    [wasm-imported-strings] Implement encodeStringToUtf8Array

    Contrary to the "Into" variant, this implicitly allocates an array
    of appropriate size.

    Bug: v8:14179
    Change-Id: [redacted]
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5273182
    Reviewed-by: Matthias Liedtke <[redacted]>
    Commit-Queue: Jakob Kummerow <[redacted]>
    Auto-Submit: Jakob Kummerow <[redacted]>
    Cr-Commit-Position: refs/heads/main@{#92216}

The message says the change implements encodeStringToUtf8Array, which turns a string into UTF-8 bytes (UTF-8 is the standard way of storing text as numbers). Unlike an existing "Into" variant, this one allocates a new array of the right size by itself. The commit is the starting point of the investigation: it is the change after which the crash began to appear.

Reproducing the crash

The researcher tested on a debug build of d8, version 12.3.0. d8 is V8's own command-line program for running JavaScript without a full browser, which makes testing much easier. A debug build is a version compiled with extra internal checks switched on, so mistakes that would pass silently in a normal build stop the program and print a message. The report gives the download location and the exact command:

Bash
# CMD: /tmp/d8-linux32-debug-v8-component-92260/d8 --allow-natives-syntax --experimental-wasm-imported-strings poc.js

Line by line: the first part is the path to the d8 program. --allow-natives-syntax is a flag (an option) that lets a test script use special internal functions that ordinary web pages cannot. --experimental-wasm-imported-strings switches on the imported strings feature, which is still experimental. poc.js is the proof-of-concept script, the small test file that triggers the bug. The report asks that both flags be included when the crash is classified by ClusterFuzz, Google's automated system for sorting crash reports.

The crash itself is a failed internal check in a file called src/wasm/canonical-types.cc, at line 131, with the message:

Text
Debug check failed: !type.has_index().

The check that failed is Debug check failed: !type.has_index(). The stack trace, the list of function calls that led to the failure, runs through TypeCanonicalizer::AddRecursiveGroup and Runtime_TierUpWasmToJSWrapper. The stack trace, the list of function calls that led to the failure, runs through TypeCanonicalizer::AddRecursiveGroup and Runtime_TierUpWasmToJSWrapper. The report lists the crash type as tab.

What the report does and does not claim

The report shows a crash in a debug build. It does not show memory corruption, code execution or any way to escape the browser's security sandbox, and it makes no claim that the bug can be exploited. A type confusion in V8 is the sort of flaw that could in principle be developed further, but this report stops at the crash.

In general, how this kind of bug works

A type confusion happens when one part of a program hands a value to another part that expects a different kind of value. In an engine like V8, every object carries a hidden description of its shape, which tells the engine where each field sits in memory and which operations are allowed. If a step is skipped, such as a check, a conversion or a normalisation step, later code can read the wrong bytes, mistake a number for a memory address, or pass a structure to code built for a different layout. In a debug build this usually ends in an assertion failure; in a release build it can become an out-of-bounds read or write.

In WebAssembly engines the risky places are the boundaries: calls from JavaScript into wasm, calls from wasm back into JavaScript, the switch from simple to optimised code, and the canonicaliser, the component that deduplicates function signatures so identical ones share a single representation. Each of these has rules about which form of a value is valid at which moment. A new feature such as imported strings adds new paths across those boundaries, and a missed conversion is exactly where confusion appears.

Defences are structural: explicit conversions at every boundary, assertions that encode the rules, canonicalisation done once and enforced afterwards, and fuzzing that exercises new features under tier-up and across wrapper boundaries.

In general, how to test for it

  1. Look at recently landed features and their flags. Commit logs, release notes and experimental flag names map out the new code paths.
  2. Obtain a debug or sanitizer build of the engine, because broken rules show up there first as clear assertions rather than silent corruption.
  3. Write small programs that drive the feature across boundaries: call a wasm export from JavaScript, pass strings and objects, and force tier-up by repeating the call enough times.
  4. Vary the shapes involved: different signatures, mixed argument types, wrappers created and recreated, values crossing the JavaScript/wasm line repeatedly.
  5. A positive result is a repeatable assertion failure, sanitizer report or crash whose stack points into the new feature. Reduce it to the smallest program and record the exact flags and build.

Watch for false positives: crashes from unsupported flag combinations, running out of memory, or faults in the test harness rather than the engine. Confirm the crash reproduces on a clean build with only the documented flags, and check whether it also happens with the experimental feature switched off.

In general, how it is fixed

Fixes for this class usually add the missing conversion or check at the boundary: making sure a type is canonicalised before it reaches the canonicaliser, or rejecting indexed types on paths that require canonical ones. Maintainers often tighten debug assertions so the rule is enforced during development, and add regression tests built from the reproducer. For an experimental feature, the fix may also gate the path more strictly behind its flag until the rules are proven.

In general, hunting notes

New engine features, especially those behind experimental flags, are fertile ground: imported strings, new wasm proposals, and any code that allocates or converts values at a language boundary. Useful signals include commit messages that mention allocation, conversion or canonicalisation, flag names that appear in fuzzing configurations, and changelogs that reference internal bug numbers.

To make a report land, reduce to a minimal reproducer, state the exact build, version and flags, include the full crash output and stack, and identify the introducing commit by bisection where possible. A repeatable assertion failure with a clear stack into the new code is far more persuasive than an unreduced crash, and it points maintainers straight at the broken rule.

Glossary

  • V8: the JavaScript engine inside Chrome, which reads and runs JavaScript code.
  • WebAssembly (wasm): a fast, low-level language that browsers can run alongside JavaScript.
  • Imported strings: a V8 feature that lets wasm code and JavaScript code exchange text.
  • Type confusion: a bug where a value of one kind is treated as a different kind, leading to wrong behaviour or memory errors.
  • CVE: a public identifier for a known security vulnerability.
  • Chrome VRP: Google's Vulnerability Reward Program, which pays researchers for reporting bugs in Chrome.
  • Bounty: the money paid to a researcher for a valid report.
  • Commit: a saved change to source code, with a message describing it.
  • Bisection: finding the change that introduced a bug by testing versions in the middle of a range and halving it repeatedly.
  • d8: V8's command-line program for running JavaScript without a full browser.
  • Debug build: a version of the software compiled with extra internal checks that stop the program when a rule is broken.
  • Flag: a command-line option that changes how a program runs.
  • Proof of concept (poc): a small script or program that demonstrates a bug.
  • ClusterFuzz: Google's automated system for sorting and classifying crash reports.
  • Assertion / debug check: an internal test in the code that stops the program if a rule is violated.
  • Stack trace: the list of function calls that led to a crash.
  • Tier-up: upgrading a function from a simple version to a faster optimised version after it has been used many times.
  • Wrapper: code that lets one language call into another, for example wasm calling JavaScript.
  • Canonicaliser: the component that deduplicates function signatures so identical ones share one representation.
  • UTF-8: the standard way of storing text as numbers.
  • Tab crash: the browser tab stops working.
  • Sandbox: the isolation that stops a compromised page from taking over the whole computer.
  • Fuzzing: feeding a program large amounts of generated input to find crashes automatically.
  • Sanitizer build: a build with extra tools that detect memory errors during a run.

More by 5f46f4ee2e17957ba7b39897fb376be8

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.