Type Confusion in V8 (CVE-2025-13227)
The WebAssembly GC type analyser wrongly treated a descriptor-based type check as always succeeding when the static types matched, so it marked the failing branch as unreachable. An attacker could use this to alias two unrelated Wasm struct types and turn the confusion into an arbitrary write inside the sandbox, and with a separate sandbox bypass, remote code execution.
Originally disclosed on Chrome VRP
- Fix shipped in 40 days
VULNERABILITY DETAILS
Summary
Wasm type confusion due to wrong reachability analysis on WasmGCTypeAnalyzer::ProcessBranchOnTarget() with descriptor checks. Analyzer wrongly assumes that same-type casts always succeed, although with custom descriptors exactly matching casts might still fail. This can be pivoted into arbitary Wasm type confusion.
Custom descriptors feature is exposed in the wild by default through Origin Trials from M141, which is currently at Beta and very soon reaches (Early) Stable. This bug is not caused by a recent code change and has existed from the very first feature implementation (approx. 6 months).
Details
WebAssembly Custom Descriptors proposal introduces descriptors, and descriptor-based type checks. These casts/checks require that the described struct has a descriptor that matches the given descriptor at runtime, regardless of whether the types match or not. However, WasmGCTypeAnalyzer::ProcessBranchOnTarget() fails to acknowledge this and assumes that any "upcasts", based purely on static types, always succeed:
void WasmGCTypeAnalyzer::ProcessBranchOnTarget(const BranchOp& branch,
const Block& target) {
DCHECK_EQ(current_block_, &target);
const Operation& condition = graph_.Get(branch.condition());
switch (condition.opcode) {
case Opcode::kWasmTypeCheck: {
const WasmTypeCheckOp& check = condition.Cast<WasmTypeCheckOp>();
if (branch.if_true == &target) {
// It is known from now on that the type is at least the checked one.
RefineTypeKnowledge(check.object(), check.config.to, branch);
} else {
DCHECK_EQ(branch.if_false, &target);
if (wasm::IsSubtypeOf(GetResolvedType(check.object()), check.config.to,
module_)) {
// The type check always succeeds, the target is impossible to be // [!] this is not true with custom descriptors.
// reached.
DCHECK_EQ(target.PredecessorCount(), 1);
block_is_unreachable_.Add(target.index().id()); // [!] this might actually be reachable at runtime.
TRACE(
"[b%uu] Block unreachable as #%u(%s) used in #%u(%s) is always "
"true\n",
target.index().id(), branch.condition().id(),
OpcodeName(condition.opcode), graph_.Index(branch).id(),
OpcodeName(branch.opcode));
}
}
} break;
case Opcode::kIsNull: {
// ...
} break;
default:
break;
}
}
Interestingly, WasmGCTypedOptimizationReducer does acknowledge this and avoids statically eliding the type check, fixed at commit e8bdb12b:
V<Word32> REDUCE_INPUT_GRAPH(WasmTypeCheck)(
V<Word32> op_idx, const WasmTypeCheckOp& type_check) {
// ...
if (type != wasm::ValueType()) {
// ...
bool to_nullable = type_check.config.to.is_nullable();
if (wasm::IsHeapSubtypeOf(type.heap_type(),
type_check.config.to.heap_type(), module_) &&
// When checking for a particular custom descriptor, static types
// cannot guarantee success.
!(IsCastToCustomDescriptor(type_check.config))) { // [!] acknowledges custom descriptor casts
if (to_nullable || type.is_non_nullable()) {
// The inferred type is guaranteed to be a subtype of the checked
// type.
return __ Word32Constant(1);
} else {
// The inferred type is guaranteed to be a subtype of the checked
// type if it is not null.
return __ Word32Equal(
__ IsNull(__ MapToNewGraph(type_check.object()), type), 0);
}
}
// ...
}
// ...
}
This leads to yet another bug where reachability analysis mistakenly marks a reachable code (false-side branch of the typecheck) as statically unreachable when the branch depends on an exact descriptor check.
Exploiting such reachability analysis bug has been shown to be possible in prior reports via loop reprocessing bypass, and thus is omitted. (b/372269618, b/373703277, b/374790906, b/377620832, ...)
Bisect
Bug introduced by WebAssembly Custom Descriptors, on Origin Trials from M141 and onwards. More specifically, it existed from commit 26b78962 which implements br_on_cast_desc, but likely has only been exposed after commit e8bdb12b which fixes the broken cast always succeeds/fails optimization on descriptor type cast/check (which itself would have been an exploitable bug).
VERSION
Chrome Version: M141~
Operating System: All
REPRODUCTION CASE
Attached as poc.js which exploits this issue to alias two unrelated struct types, then uses this type confusion to trigger an arbitrary caged write within the sandbox.
Also attached is rce.html which exploits this issue, together with the wrapper-wasmcpt-uaf v8sbx bypass, to gain RCE and print out /flag/flag to stdout.
You might want to pass --experimental-wasm-custom-descriptors on d8 or --enable-blink-features=WebAssemblyCustomDescriptors on Chrome to simulate Origin Trials behavior.
FOR CRASHES, PLEASE INCLUDE THE FOLLOWING ADDITIONAL INFORMATION
Type of crash: Renderer
Crash State: Crashes on arbitrary caged write attempt from JIT-compiled Wasm function with poc.js / RCE with rce.html
CREDIT INFORMATION
Reporter credit: Seunghyun Lee (@0x10n) of CMU CSD / CyLab
Context
This report concerns Google Chrome's V8 JavaScript and WebAssembly engine, specifically the WebAssembly Garbage Collection (WasmGC) type analysis used by the compiler. The feature at the centre of the bug is the WebAssembly Custom Descriptors proposal, which introduces descriptors and descriptor-based type checks. As the report explains, these casts and checks "require that the described struct has a descriptor that matches the given descriptor at runtime, regardless of whether the types match or not."
The researcher notes that the custom descriptors feature is exposed in the wild by default through Origin Trials from M141, which at the time of writing was at Beta and "very soon reaches (Early) Stable." The bug is not caused by a recent code change: the report states it has existed from the very first feature implementation, approximately 6 months.
The platform records this as a high severity Type Confusion in V8, disclosed on 2025-10-28, with a bounty of 55,000 USD. The report itself is an advisory-style write-up rather than a request/response walkthrough; it contains no HTTP traffic, no endpoints and no parameters.
Setup
The report gives the following conditions:
- Target: V8, as shipped in Chrome. Chrome Version: M141~, Operating System: All.
- Feature state: WebAssembly Custom Descriptors, on Origin Trials from M141 and onwards.
- Reproduction files:
poc.js, which exploits the issue to alias two unrelated struct types and then trigger an arbitrary caged write within the sandbox, andrce.html, which combines the issue with thewrapper-wasmcpt-uafv8sbx bypass to gain RCE and print/flag/flagto stdout. - Flags to simulate Origin Trials behaviour: the report suggests passing
--experimental-wasm-custom-descriptorson d8 or--enable-blink-features=WebAssemblyCustomDescriptorson Chrome.
--experimental-wasm-custom-descriptors
--enable-blink-features=WebAssemblyCustomDescriptors
The first flag enables the feature in the d8 shell; the second enables the corresponding Blink feature in Chrome so that the Origin Trials behaviour can be reproduced locally.
No accounts, roles or external services are involved. The only precondition is a build of V8 or Chrome in which the custom descriptors feature is enabled.
Finding it
The researcher's summary is that this is a Wasm type confusion caused by wrong reachability analysis in WasmGCTypeAnalyzer::ProcessBranchOnTarget() when descriptor checks are involved. The analyser wrongly assumes that same-type casts always succeed, although with custom descriptors exactly matching casts might still fail. The report states this can be pivoted into arbitrary Wasm type confusion.
The reasoning turns on the semantics of descriptor-based checks. A descriptor-based cast does not merely compare static types: at runtime the described struct must carry a descriptor that matches the given descriptor, regardless of whether the types match. The analyser, however, looks only at static types and concludes that an upcast always succeeds.
The relevant code is:
void WasmGCTypeAnalyzer::ProcessBranchOnTarget(const BranchOp& branch,
const Block& target) {
DCHECK_EQ(current_block_, &target);
const Operation& condition = graph_.Get(branch.condition());
switch (condition.opcode) {
case Opcode::kWasmTypeCheck: {
const WasmTypeCheckOp& check = condition.Cast<WasmTypeCheckOp>();
if (branch.if_true == &target) {
// It is known from now on that the type is at least the checked one.
RefineTypeKnowledge(check.object(), check.config.to, branch);
} else {
DCHECK_EQ(branch.if_false, &target);
if (wasm::IsSubtypeOf(GetResolvedType(check.object()), check.config.to,
module_)) {
// The type check always succeeds, the target is impossible to be // [!] this is not true with custom descriptors.
// reached.
DCHECK_EQ(target.PredecessorCount(), 1);
block_is_unreachable_.Add(target.index().id()); // [!] this might actually be reachable at runtime.
TRACE(
"[b%uu] Block unreachable as #%u(%s) used in #%u(%s) is always "
"true\n",
target.index().id(), branch.condition().id(),
OpcodeName(condition.opcode), graph_.Index(branch).id(),
OpcodeName(branch.opcode));
}
}
} break;
case Opcode::kIsNull: {
// ...
} break;
default:
break;
}
}
In the false branch of a type check, the analyser asks whether the object's resolved type is a subtype of the checked type. If it is, the code comments that "the type check always succeeds, the target is impossible to be reached" and adds the target block to block_is_unreachable_. The researcher's inline annotations mark the two places where this reasoning breaks with custom descriptors: the comment that the check always succeeds is "not true with custom descriptors," and the block marked unreachable "might actually be reachable at runtime."
The researcher also points out that another component does handle the case correctly. WasmGCTypedOptimizationReducer acknowledges custom descriptors and avoids statically eliding the type check, fixed at commit e8bdb12b:
V<Word32> REDUCE_INPUT_GRAPH(WasmTypeCheck)(
V<Word32> op_idx, const WasmTypeCheckOp& type_check) {
// ...
if (type != wasm::ValueType()) {
// ...
bool to_nullable = type_check.config.to.is_nullable();
if (wasm::IsHeapSubtypeOf(type.heap_type(),
type_check.config.to.heap_type(), module_) &&
// When checking for a particular custom descriptor, static types
// cannot guarantee success.
!(IsCastToCustomDescriptor(type_check.config))) { // [!] acknowledges custom descriptor casts
if (to_nullable || type.is_non_nullable()) {
// The inferred type is guaranteed to be a subtype of the checked
// type.
return __ Word32Constant(1);
} else {
// The inferred type is guaranteed to be a subtype of the checked
// type if it is not null.
return __ Word32Equal(
__ IsNull(__ MapToNewGraph(type_check.object()), type), 0);
}
}
// ...
}
// ...
}
The key line is the guard !(IsCastToCustomDescriptor(type_check.config)), with the comment that "when checking for a particular custom descriptor, static types cannot guarantee success." This reducer therefore refuses to fold the check to a constant when a custom descriptor is involved. The reachability analyser in ProcessBranchOnTarget() lacks the equivalent guard.
The consequence, as the researcher describes it, is that reachability analysis mistakenly marks reachable code, the false-side branch of the type check, as statically unreachable when the branch depends on an exact descriptor check.
Exploitation
The report does not include a step-by-step exploitation walkthrough. It states that exploiting such a reachability analysis bug has been shown to be possible in prior reports via loop reprocessing bypass, and that this is therefore omitted. It cites the prior reports b/372269618, b/373703277, b/374790906 and b/377620832 (and others).
What the report does describe is the outcome of the two attached files:
poc.jsexploits the issue to alias two unrelated struct types, then uses this type confusion to trigger an arbitrary caged write within the sandbox.rce.htmlexploits the issue together with thewrapper-wasmcptuafv8sbx bypass to gain RCE and print out/flag/flagto stdout.
The crash information section records the crash type as Renderer, with the crash state described as crashing on an arbitrary caged write attempt from a JIT-compiled Wasm function with poc.js, and RCE with rce.html.
Because the original does not include the contents of poc.js or rce.html, the exact Wasm module, the struct types aliased, the offsets used for the caged write, or the details of the wrapper-wasmcptuaf bypass cannot be reproduced here. The report does not say what those files contain beyond the outcomes above.
Root cause
The mistake is in WasmGCTypeAnalyzer::ProcessBranchOnTarget(). When the condition is a kWasmTypeCheck and the target is the false branch, the analyser checks wasm::IsSubtypeOf(GetResolvedType(check.object()), check.config.to, module_). If the static type of the object is a subtype of the checked type, it concludes the check can never fail and marks the false-branch block unreachable via block_is_unreachable_.Add(target.index().id()).
That conclusion is valid only when the check is a pure static type test. With custom descriptors, the check also requires the runtime descriptor of the described struct to match the given descriptor. Two types can be statically related, so that IsSubtypeOf returns true, while the runtime descriptor check still fails. The false branch is therefore reachable, but the analyser has already discarded it.
The report notes that WasmGCTypedOptimizationReducer acknowledges custom descriptors and avoids statically eliding the type check, fixed at commit e8bdb12b. The reachability analyser was not given the same treatment. The researcher adds that the broken cast always succeeds/fails optimisation fixed by e8bdb12b "itself would have been an exploitable bug."
On why existing defences did not stop it: the report does not discuss mitigations beyond the observation that the reducer had been fixed and the analyser had not.
Impact
Under the conditions in the report, an attacker who can run Wasm with custom descriptors enabled can turn the incorrect reachability analysis into a Wasm type confusion. The report states that poc.js uses this to alias two unrelated struct types and then trigger an arbitrary caged write within the sandbox, and that rce.html combines the bug with the wrapper-wasmcptuaf v8sbx bypass to gain RCE and print /flag/flag to stdout.
The exposure is tied to the feature being enabled. The report says custom descriptors are exposed in the wild by default through Origin Trials from M141, which was at Beta and about to reach (Early) Stable at the time of writing. The bug affects all operating systems (Operating System: All) and Chrome Version M141~. The report does not state which renderer process privileges or sandbox configuration are required beyond the caged write being "within the sandbox" and the RCE relying on a separate v8sbx bypass.
Fix
It identifies the faulty logic in WasmGCTypeAnalyzer::ProcessBranchOnTarget() and contrasts it with the already-fixed WasmGCTypedOptimizationReducer, which guards its static-success reasoning with !(IsCastToCustomDescriptor(type_check.config)). The implied fix is to apply the same descriptor awareness to the reachability analysis, so that a type check involving a custom descriptor is not treated as always succeeding and the false branch is not marked unreachable.
Variants to test
The report does not list variants. Based on the reasoning it presents, the following are concrete directions, each with the expected positive result:
- Other consumers of static subtype reasoning. Search the WasmGC pipeline for places that call
IsSubtypeOforIsHeapSubtypeOfand then assume a check cannot fail. A positive result is a path where a descriptor-based check is folded, elided or used to prune a block without anIsCastToCustomDescriptorstyle guard. - Reachability-driven optimisations. Look for other analyses that mark blocks unreachable based on type information, not only
ProcessBranchOnTarget(). A positive result is a block that the compiler treats as dead but that executes at runtime when the descriptor does not match. - Loop reprocessing. The report says prior work exploited reachability bugs via loop reprocessing bypass. Reproducing that pattern against a descriptor check, where the false branch is inside a loop, is a positive result if the discarded branch becomes live after reprocessing.
- Differential testing of the reducer and the analyser. Construct Wasm modules where
WasmGCTypedOptimizationReducercorrectly declines to fold a descriptor cast but the reachability analyser still prunes the false branch. A positive result is a module that behaves differently depending on which optimisation runs. - Feature-flag boundaries. Test builds with
--experimental-wasm-custom-descriptorson d8 and--enable-blink-features=WebAssemblyCustomDescriptorson Chrome to confirm the behaviour matches the Origin Trials configuration described in the report.
Each of these depends on the custom descriptors feature being enabled; without it, the descriptor mismatch that makes the false branch reachable cannot occur.
What happened, in plain words
Google Chrome is a web browser. Inside Chrome there is a piece of software called V8. V8 is the engine that reads the JavaScript and WebAssembly code that web pages contain and turns it into instructions the computer can actually run. Think of V8 as a very fast translator sitting between a web page and your computer's processor.
WebAssembly (often shortened to Wasm) is a second language that web pages can use, alongside JavaScript. It is designed to run quickly and is often used for heavy things like games, video editing or image processing in the browser. Wasm code is compiled ahead of time into a compact format, and V8 turns it into machine code when the page loads.
This report is about a mistake in V8's Wasm compiler. The mistake makes the compiler believe that a certain piece of code can never run, so it throws that code away. But in reality, that code can run. When a program's assumptions about which code can run are wrong, the program can be tricked into treating one kind of data as if it were a different kind. That is called a type confusion, and it is the class of bug recorded for this report.
The researcher who found it is Seunghyun Lee (@0x10n) of CMU CSD / CyLab. The platform records the report as a high severity Type Confusion in V8, disclosed on 2025-10-28, with a bounty of 55,000 USD. The report itself is an advisory-style write-up: it explains the bug and points to two attached files, but it contains no HTTP requests, no URLs, no endpoints and no parameters. Everything below comes from that text.
A quick note on how to read this article. The original report is written for people who already know how compilers and browser internals work. This version explains each idea from scratch, in the same order as the original, and keeps the same code blocks and flags. Where the original does not say something, this article says so plainly rather than guessing.
Context
The product: Chrome and V8
Chrome is the browser you use to open web pages. V8 is the part of Chrome that executes the code those pages contain. When you load a page, V8 reads the JavaScript and WebAssembly, and it works hard to make that code run as fast as possible. One of the ways it does that is by optimising: rewriting code so it does less work, as long as the rewrite produces the same result.
An engine in this sense is just the component that does the actual work of running code. A compiler is the component that translates code from one form into another. V8 contains both: it reads source code and produces machine code.
The feature: WebAssembly Custom Descriptors
The bug lives in a feature called the WebAssembly Custom Descriptors proposal. A "proposal" in this world is a design document for a new language feature that is being added to WebAssembly. Once a proposal is accepted and implemented, browsers can start shipping it.
What does the feature add? It introduces descriptors and descriptor-based type checks. A descriptor is a small piece of data attached to a value that says what kind of thing it is, in a way that can be checked while the program is running. A type check is an operation that asks "is this value of type X?" and answers yes or no.
The report states the key rule for these checks: they "require that the described struct has a descriptor that matches the given descriptor at runtime, regardless of whether the types match or not." In plain words: even if two things look like the same kind of thing on paper, the check at runtime also compares their descriptors, and if the descriptors do not match, the check fails.
A struct here is a bundle of named fields, like a small record. A runtime check is a check performed while the program is actually running, as opposed to a check performed earlier by the compiler based on what it can see in the code.
The exposure: Origin Trials
The report says the custom descriptors feature "is exposed in the wild by default through Origin Trials from M141, which is currently at Beta and very soon reaches (Early) Stable."
An Origin Trial is a mechanism Chrome uses to let real websites try a new feature before it is switched on for everyone. A site opts in, and Chrome enables the feature for that site. "M141" is a Chrome milestone number: Chrome releases are numbered, and M141 is one of those releases. "Beta" and "Stable" are release channels: Beta is the test channel, Stable is the channel most people run. So the feature was about to reach ordinary users.
The report also says the bug "is not caused by a recent code change and has existed from the very first feature implementation (approx. 6 months)." In other words, the mistake was there from the beginning of the feature, roughly six months before the report.
What the report is and is not
The platform records this as a high severity Type Confusion in V8, disclosed on 2025-10-28, with a bounty of 55,000 USD. A bounty is a payment a company makes to a researcher who reports a security bug through its programme. The programme here is the Chrome VRP (Vulnerability Reward Program).
The report is an advisory-style write-up. It explains the bug and points to two attached files, poc.js and rce.html. It does not contain HTTP traffic, endpoints or parameters.
Setup
What you need to reproduce it
The report gives these conditions:
- Target: V8, as shipped in Chrome. Chrome Version: M141~, Operating System: All.
- Feature state: WebAssembly Custom Descriptors, on Origin Trials from M141 and onwards.
- Reproduction files:
poc.js, which exploits the issue to alias two unrelated struct types and then trigger an arbitrary caged write within the sandbox, andrce.html, which combines the issue with thewrapper-wasmcpt-uafv8sbx bypass to gain RCE and print/flag/flagto stdout. - Flags to simulate Origin Trials behaviour: the report suggests passing
--experimental-wasm-custom-descriptorson d8 or--enable-blink-features=WebAssemblyCustomDescriptorson Chrome.
A few of those terms need unpacking before the flags make sense.
A flag (also called a command-line switch) is a word you add when starting a program to change its behaviour. For example, starting a program with an extra word might tell it to be more verbose or to enable an unfinished feature.
d8 is a small command-line program that runs V8 on its own, without the rest of Chrome. Researchers use it because it is much easier to test engine behaviour in d8 than inside a full browser. Blink is the part of Chrome that handles web page rendering and the web platform features exposed to pages; the second flag targets Blink rather than V8 directly.
A sandbox is a security boundary that limits what code can do if it goes wrong. Chrome puts web content inside a sandbox so that a bug in a page cannot directly read your files or take over your computer. A caged write is a write to memory inside a reserved region (the "cage") that the engine uses to keep its objects; the cage is a mitigation that constrains where memory accesses can land. RCE stands for remote code execution: an attacker getting their code to run on the target machine. A v8sbx bypass is a technique that gets around the V8 sandbox. The report names the bypass wrapper-wasmcptuaf but does not describe how it works.
The two flags are:
--experimental-wasm-custom-descriptors
This flag tells d8 to turn on the experimental WebAssembly custom descriptors feature. Without it, d8 would not accept or run Wasm that uses descriptors, so the bug could not be triggered.
--enable-blink-features=WebAssemblyCustomDescriptors
This flag tells Chrome to turn on the corresponding Blink feature, so that the Origin Trials behaviour can be reproduced locally. The first flag enables the feature in the d8 shell; the second enables the matching feature in Chrome.
No accounts, roles or external services are involved. The only precondition is a build of V8 or Chrome in which the custom descriptors feature is enabled.
Finding it
The summary in the researcher's words
The researcher's summary is that this is a Wasm type confusion caused by wrong reachability analysis in a function called WasmGCTypeAnalyzer::ProcessBranchOnTarget() when descriptor checks are involved. The analyser wrongly assumes that same-type casts always succeed, although with custom descriptors exactly matching casts might still fail. The report states this can be pivoted into arbitrary Wasm type confusion.
Two ideas need explaining here.
Reachability analysis is the compiler's job of working out which parts of a program can actually run. If a piece of code can never run, the compiler can delete it, which makes the program smaller and faster. Think of a road map where some roads are marked "closed": if the compiler is wrong about a road being closed, a driver following the map will be surprised. Here, the "road" is a branch of code, and the compiler wrongly marks it closed.
A cast is an operation that treats a value as a particular type. An upcast is a cast from a more specific type to a more general one, which is normally always safe: a dog is always an animal. The analyser assumes that an upcast always succeeds, which is normally true. With custom descriptors, the report says, "exactly matching casts might still fail", because the runtime descriptor check can fail even when the types line up.
Why the analyser is wrong
The reasoning turns on the semantics of descriptor-based checks. A descriptor-based cast does not merely compare static types: at runtime the described struct must carry a descriptor that matches the given descriptor, regardless of whether the types match. The analyser, however, looks only at static types and concludes that an upcast always succeeds.
Static types are the types the compiler can see by reading the code, without running it. Runtime means while the program is actually executing. The distinction matters because the compiler can only reason about what it can see; if the real answer depends on data that only exists at runtime, the compiler's conclusion can be wrong.
The relevant code is:
void WasmGCTypeAnalyzer::ProcessBranchOnTarget(const BranchOp& branch,
const Block& target) {
DCHECK_EQ(current_block_, &target);
const Operation& condition = graph_.Get(branch.condition());
switch (condition.opcode) {
case Opcode::kWasmTypeCheck: {
const WasmTypeCheckOp& check = condition.Cast<WasmTypeCheckOp>();
if (branch.if_true == &target) {
// It is known from now on that the type is at least the checked one.
RefineTypeKnowledge(check.object(), check.config.to, branch);
} else {
DCHECK_EQ(branch.if_false, &target);
if (wasm::IsSubtypeOf(GetResolvedType(check.object()), check.config.to,
module_)) {
// The type check always succeeds, the target is impossible to be // [!] this is not true with custom descriptors.
// reached.
DCHECK_EQ(target.PredecessorCount(), 1);
block_is_unreachable_.Add(target.index().id()); // [!] this might actually be reachable at runtime.
TRACE(
"[b%uu] Block unreachable as #%u(%s) used in #%u(%s) is always "
"true\n",
target.index().id(), branch.condition().id(),
OpcodeName(condition.opcode), graph_.Index(branch).id(),
OpcodeName(branch.opcode));
}
}
} break;
case Opcode::kIsNull: {
// ...
} break;
default:
break;
}
}
This is C++ code from V8. Here is what it does, line by line, in plain words.
void WasmGCTypeAnalyzer::ProcessBranchOnTarget(const BranchOp& branch, const Block& target) {declares a function that looks at a branch (a fork in the program's flow) and at the block of code the branch leads to. The::means the function belongs to a class calledWasmGCTypeAnalyzer.DCHECK_EQ(current_block_, &target);is a debug-only assertion: it checks that the block currently being analysed is the target block. Assertions are checks the programmer writes to catch their own mistakes during development; they are not part of the shipped behaviour.const Operation& condition = graph_.Get(branch.condition());fetches the operation that decides which way the branch goes. The program is represented as a graph of operations, and this line looks up the condition operation.switch (condition.opcode) {starts a decision: depending on what kind of operation the condition is, do different things.case Opcode::kWasmTypeCheck: {handles the case where the condition is a Wasm type check, that is, the question "is this value of type X?".const WasmTypeCheckOp& check = condition.Cast<WasmTypeCheckOp>();treats the condition as a type check operation so its details can be read.if (branch.if_true == &target) {asks: is the block we are analysing the one reached when the check is true?RefineTypeKnowledge(check.object(), check.config.to, branch);if so, record that from this point on the object is known to be at least the checked type. This is the normal, correct case.} else {otherwise, we are looking at the block reached when the check is false.DCHECK_EQ(branch.if_false, &target);another debug assertion: confirm this is indeed the false branch.if (wasm::IsSubtypeOf(GetResolvedType(check.object()), check.config.to, module_)) {asks whether the object's static type is a subtype of the checked type. A subtype is a more specific type: a dog is a subtype of animal. If the object is already known to be a subtype, the check would seem to always succeed.// The type check always succeeds, the target is impossible to be // [!] this is not true with custom descriptors.is a comment saying the check always succeeds. The researcher's inline annotation marks it: this is not true with custom descriptors.// reached.continues the comment: the target cannot be reached.DCHECK_EQ(target.PredecessorCount(), 1);asserts the target has exactly one predecessor, that is, only one way in.block_is_unreachable_.Add(target.index().id()); // [!] this might actually be reachable at runtime.records the target block as unreachable. The researcher's annotation marks it: this block might actually be reachable at runtime.TRACE(starts a debug trace message, which is logging output used during development."[b%uu] Block unreachable as #%u(%s) used in #%u(%s) is always "and"true\n",are the format string of the trace: it prints the block, the condition, the opcode names and the branch, saying the block is unreachable because the condition is always true.target.index().id(), branch.condition().id(),andOpcodeName(condition.opcode), graph_.Index(branch).id(),andOpcodeName(branch.opcode));supply the values for the trace.}closes the subtype check.}closes the else branch.} break;ends the type check case.case Opcode::kIsNull: {handles a different condition, a null check. The// ...means the body is omitted from the report.} break;ends that case.default:handles any other condition.break;does nothing for those.}closes the switch.}closes the function.
In the false branch of a type check, the analyser asks whether the object's resolved type is a subtype of the checked type. If it is, the code comments that "the type check always succeeds, the target is impossible to be reached" and adds the target block to block_is_unreachable_. The researcher's inline annotations mark the two places where this reasoning breaks with custom descriptors: the comment that the check always succeeds is "not true with custom descriptors," and the block marked unreachable "might actually be reachable at runtime."
The component that got it right
The researcher also points out that another component does handle the case correctly. WasmGCTypedOptimizationReducer acknowledges custom descriptors and avoids statically eliding the type check, fixed at commit e8bdb12b:
V<Word32> REDUCE_INPUT_GRAPH(WasmTypeCheck)(
V<Word32> op_idx, const WasmTypeCheckOp& type_check) {
// ...
if (type != wasm::ValueType()) {
// ...
bool to_nullable = type_check.config.to.is_nullable();
if (wasm::IsHeapSubtypeOf(type.heap_type(),
type_check.config.to.heap_type(), module_) &&
// When checking for a particular custom descriptor, static types
// cannot guarantee success.
!(IsCastToCustomDescriptor(type_check.config))) { // [!] acknowledges custom descriptor casts
if (to_nullable || type.is_non_nullable()) {
// The inferred type is guaranteed to be a subtype of the checked
// type.
return __ Word32Constant(1);
} else {
// The inferred type is guaranteed to be a subtype of the checked
// type if it is not null.
return __ Word32Equal(
__ IsNull(__ MapToNewGraph(type_check.object()), type), 0);
}
}
// ...
}
// ...
}
A reducer is a compiler component that simplifies operations: it takes an operation and, if it can prove the result in advance, replaces it with a simpler constant. "Eliding" a check means removing it because the compiler believes it is unnecessary. Here is the code in plain words.
V<Word32> REDUCE_INPUT_GRAPH(WasmTypeCheck)(declares a reducer for the Wasm type check operation.V<Word32>means it returns a 32-bit word value, which here is a yes/no result.V<Word32> op_idx, const WasmTypeCheckOp& type_check) {are the inputs: an index and the type check operation itself.// ...means some code is omitted from the report.if (type != wasm::ValueType()) {checks that a type was actually inferred for the object.// ...more omitted code.bool to_nullable = type_check.config.to.is_nullable();records whether the checked type allows null (the absence of a value).if (wasm::IsHeapSubtypeOf(type.heap_type(),starts a check that the inferred type is a subtype of the checked type.type_check.config.to.heap_type(), module_) &&completes that subtype check.// When checking for a particular custom descriptor, static typesand// cannot guarantee success.are comments explaining the next line.!(IsCastToCustomDescriptor(type_check.config))) { // [!] acknowledges custom descriptor castsis the crucial guard: if the check involves a custom descriptor, the whole condition is false, so the reducer does not fold the check. The researcher's annotation marks it as acknowledging custom descriptor casts.if (to_nullable || type.is_non_nullable()) {handles the case where the result is known to be true.// The inferred type is guaranteed to be a subtype of the checkedand// type.are comments.return __ Word32Constant(1);returns the constant 1, meaning "true", replacing the check entirely.} else {handles the case where the value might be null.// The inferred type is guaranteed to be a subtype of the checkedand// type if it is not null.are comments.return __ Word32Equal(starts building a comparison.__ IsNull(__ MapToNewGraph(type_check.object()), type), 0);compares whether the object is null with 0, producing a true/false result.}closes the else.}closes the subtype check.// ...more omitted code.}closes the outer if.// ...more omitted code.}closes the reducer.
The key line is the guard !(IsCastToCustomDescriptor(type_check.config)), with the comment that "when checking for a particular custom descriptor, static types cannot guarantee success." This reducer therefore refuses to fold the check to a constant when a custom descriptor is involved. The reachability analyser in ProcessBranchOnTarget() lacks the equivalent guard.
The consequence
The consequence, as the researcher describes it, is that reachability analysis mistakenly marks reachable code, the false-side branch of the type check, as statically unreachable when the branch depends on an exact descriptor check.
Exploitation
What the report does not include
The report does not include a step-by-step exploitation walkthrough. It states that exploiting such a reachability analysis bug has been shown to be possible in prior reports via loop reprocessing bypass, and that this is therefore omitted. It cites the prior reports b/372269618, b/373703277, b/374790906 and b/377620832 (and others).
The report names a loop reprocessing bypass but does not explain the technique further; it only says prior reports document it. The report does not explain the technique further; it only says prior reports document it. The identifiers starting with b/ are internal bug-tracking references, not public URLs.
What the two files do
What the report does describe is the outcome of the two attached files:
poc.jsexploits the issue to alias two unrelated struct types, then uses this type confusion to trigger an arbitrary caged write within the sandbox.rce.htmlexploits the issue together with thewrapper-wasmcptuafv8sbx bypass to gain RCE and print out/flag/flagto stdout.
To alias two types means to make the program treat a value of one type as if it were the other. That is the essence of type confusion. A proof of concept (the "poc" in poc.js) is a small program that demonstrates a bug without necessarily being a full attack. stdout is the standard output stream, the place where a program prints its normal text output; printing /flag/flag there means the exploit reads a file at that path and shows its contents.
The crash information section records the crash type as Renderer, with the crash state described as crashing on an arbitrary caged write attempt from a JIT-compiled Wasm function with poc.js, and RCE with rce.html.
A renderer is the Chrome process that handles a single web page; Chrome separates pages into processes so that one bad page cannot easily affect others. JIT stands for just-in-time: a JIT compiler translates code into machine code while the program is running, rather than ahead of time. So the crash happens inside Wasm code that V8 compiled on the fly.
Because the original does not include the contents of poc.js or rce.html, the exact Wasm module, the struct types aliased, the offsets used for the caged write, or the details of the wrapper-wasmcptuaf bypass cannot be reproduced here.
Root cause
Where the mistake is
The mistake is in WasmGCTypeAnalyzer::ProcessBranchOnTarget(). When the condition is a kWasmTypeCheck and the target is the false branch, the analyser checks wasm::IsSubtypeOf(GetResolvedType(check.object()), check.config.to, module_). If the static type of the object is a subtype of the checked type, it concludes the check can never fail and marks the false-branch block unreachable via block_is_unreachable_.Add(target.index().id()).
Why that conclusion is wrong here
That conclusion is valid only when the check is a pure static type test. With custom descriptors, the check also requires the runtime descriptor of the described struct to match the given descriptor. Two types can be statically related, so that IsSubtypeOf returns true, while the runtime descriptor check still fails. The false branch is therefore reachable, but the analyser has already discarded it.
An everyday comparison: imagine a bouncer with a guest list. The list says "members of the Jones family are allowed in." The bouncer sees someone whose surname is Jones and waves them through. But the venue's actual rule is "members of the Jones family who also carry the blue wristband." The guest list alone is not enough. The analyser is the bouncer who only read the list.
The fix that already existed elsewhere
The report notes that WasmGCTypedOptimizationReducer acknowledges custom descriptors and avoids statically eliding the type check, fixed at commit e8bdb12b. The reachability analyser was not given the same treatment. The researcher adds that the broken cast always succeeds/fails optimisation fixed by e8bdb12b "itself would have been an exploitable bug."
A commit is a recorded change to a codebase, identified by a short hash such as e8bdb12b. The report links to it but does not reproduce its contents beyond the code shown above.
On why existing defences did not stop it: the report does not discuss mitigations beyond the observation that the reducer had been fixed and the analyser had not.
Impact
What an attacker could do
Under the conditions in the report, an attacker who can run Wasm with custom descriptors enabled can turn the incorrect reachability analysis into a Wasm type confusion. The report states that poc.js uses this to alias two unrelated struct types and then trigger an arbitrary caged write within the sandbox, and that rce.html combines the bug with the wrapper-wasmcptuaf v8sbx bypass to gain RCE and print /flag/flag to stdout.
Who is exposed
The exposure is tied to the feature being enabled. The report says custom descriptors are exposed in the wild by default through Origin Trials from M141, which was at Beta and about to reach (Early) Stable at the time of writing. The bug affects all operating systems (Operating System: All) and Chrome Version M141~.
Fix
What the report says about the fix
It identifies the faulty logic in WasmGCTypeAnalyzer::ProcessBranchOnTarget() and contrasts it with the already-fixed WasmGCTypedOptimizationReducer, which guards its static-success reasoning with !(IsCastToCustomDescriptor(type_check.config)). The implied fix is to apply the same descriptor awareness to the reachability analysis, so that a type check involving a custom descriptor is not treated as always succeeding and the false branch is not marked unreachable.
Variants to test
Directions the reasoning suggests
The report does not list variants. Based on the reasoning it presents, the following are concrete directions, each with the expected positive result:
- Other consumers of static subtype reasoning. Search the WasmGC pipeline for places that call
IsSubtypeOforIsHeapSubtypeOfand then assume a check cannot fail. A positive result is a path where a descriptor-based check is folded, elided or used to prune a block without anIsCastToCustomDescriptorstyle guard. - Reachability-driven optimisations. Look for other analyses that mark blocks unreachable based on type information, not only
ProcessBranchOnTarget(). A positive result is a block that the compiler treats as dead but that executes at runtime when the descriptor does not match. - Loop reprocessing. The report says prior work exploited reachability bugs via loop reprocessing bypass. Reproducing that pattern against a descriptor check, where the false branch is inside a loop, is a positive result if the discarded branch becomes live after reprocessing.
- Differential testing of the reducer and the analyser. Construct Wasm modules where
WasmGCTypedOptimizationReducercorrectly declines to fold a descriptor cast but the reachability analyser still prunes the false branch. A positive result is a module that behaves differently depending on which optimisation runs. - Feature-flag boundaries. Test builds with
--experimental-wasm-custom-descriptorson d8 and--enable-blink-features=WebAssemblyCustomDescriptorson Chrome to confirm the behaviour matches the Origin Trials configuration described in the report.
Each of these depends on the custom descriptors feature being enabled; without it, the descriptor mismatch that makes the false branch reachable cannot occur.
Glossary
- API: a defined way for one piece of software to talk to another; here, the set of operations a program can call.
- Beta: a Chrome release channel used for testing features before they reach most users.
- Blink: the part of Chrome that handles web page rendering and web platform features.
- Bounty: a payment made by a company to a researcher who reports a security bug through its programme.
- Caged write: a write to memory inside a reserved region (the cage) that the engine uses to constrain memory accesses.
- Cast: an operation that treats a value as a particular type.
- Commit: a recorded change to a codebase, identified by a short hash.
- Compiler: a component that translates code from one form into another.
- d8: a small command-line program that runs V8 on its own, without the rest of Chrome.
- Descriptor: a small piece of data attached to a value that says what kind of thing it is, checkable at runtime.
- Elide: to remove a check or operation because the compiler believes it is unnecessary.
- Engine: the component that does the actual work of running code.
- Flag: a word added when starting a program to change its behaviour.
- JIT (just-in-time): a compiler that translates code into machine code while the program is running.
- Loop reprocessing bypass: a technique where the compiler processes a loop more than once and the second pass sees a different picture than the first.
- M141: a Chrome milestone number; Chrome releases are numbered.
- Origin Trial: a Chrome mechanism that lets real websites try a new feature before it is switched on for everyone.
- Proof of concept (poc): a small program that demonstrates a bug.
- RCE (remote code execution): an attacker getting their code to run on the target machine.
- Reducer: a compiler component that simplifies operations, replacing them with simpler constants when it can prove the result in advance.
- Renderer: the Chrome process that handles a single web page.
- Reachability analysis: the compiler's job of working out which parts of a program can actually run.
- Runtime: while the program is actually executing, as opposed to what the compiler can see in the code.
- Sandbox: a security boundary that limits what code can do if it goes wrong.
- Stable: the Chrome release channel most people run.
- Static type: the type the compiler can see by reading the code, without running it.
- stdout: the standard output stream, where a program prints its normal text output.
- Struct: a bundle of named fields, like a small record.
- Subtype: a more specific type; a dog is a subtype of animal.
- Type check: an operation that asks whether a value is of a given type and answers yes or no.
- Type confusion: a bug where a program treats one kind of data as if it were a different kind.
- Upcast: a cast from a more specific type to a more general one, normally always safe.
- V8: the JavaScript and WebAssembly engine inside Chrome.
- v8sbx bypass: a technique that gets around the V8 sandbox.
- VRP (Vulnerability Reward Program): the programme through which Chrome pays researchers for security bug reports.
- Wasm (WebAssembly): a second language web pages can use, designed to run quickly.
- WasmGC: WebAssembly Garbage Collection, the part of Wasm that manages memory automatically.
- WebAssembly Custom Descriptors proposal: a design document for a new Wasm feature that adds descriptors and descriptor-based type checks.