Object corruption in V8 (CVE-2024-3832)
A logic flaw in V8's WebAssembly feature installation allowed an attacker to create a corrupted object with duplicate properties by manipulating the global WebAssembly object. This could lead to a renderer crash and potentially memory corruption.
Originally disclosed on Chrome VRP
- Fix shipped in 36 days
VULNERABILITY DETAILS
It appears that mechanisms introduced to prevent issues like 40056206 (CVE-2021-30561) is insufficient. In InstallConditionalFeatures, a check is introduced to check that the webassembly object does not have the relevant property before adding it to the object:
void WasmJs::InstallConditionalFeatures(Isolate* isolate,
Handle<NativeContext> context) {
...
MaybeHandle<Object> maybe_wasm =
JSReceiver::GetProperty(isolate, global, "WebAssembly"); //<-------- 1.
...
if (isolate->IsWasmJSPIEnabled(context)) {
isolate->WasmInitJSPIFeature();
Handle<String> suspender_string = v8_str(isolate, "Suspender");
if (!JSObject::HasRealNamedProperty(isolate, webassembly, suspender_string) //<----- 2.
.FromMaybe(true)) {
InstallSuspenderConstructor(isolate, context);
}
// Install Wasm type reflection features (if not already done).
Handle<String> function_string = v8_str(isolate, "Function");
if (!JSObject::HasRealNamedProperty(isolate, webassembly, function_string)
.FromMaybe(true)) {
InstallTypeReflection(isolate, context);
}
}
}
In the above, the object that is used in the check is the global property WebAssembly (1. and 2.) However, when the property is installed using InstallSuspenderConstructor, the object that is used is context->wasm_webassembly_object() (3.), which may not be the same as the WebAssembly global property.
void WasmJs::InstallSuspenderConstructor(Isolate* isolate,
Handle<NativeContext> context) {
Handle<JSObject> webassembly(context->wasm_webassembly_object(), isolate); //<------ 3.
Handle<JSFunction> suspender_constructor = InstallConstructorFunc(
isolate, webassembly, "Suspender", WebAssemblySuspender);
context->set_wasm_suspender_constructor(*suspender_constructor);
SetupConstructor(isolate, suspender_constructor, WASM_SUSPENDER_OBJECT_TYPE,
WasmSuspenderObject::kHeaderSize, "WebAssembly.Suspender");
}
By first setting the Suspender property on the WebAssembly object and then set the global WebAssembly to a different object, the property name check will be performed on the newly assigned WebAssembly object while the property will be added in the context->wasm_assembly_object(), which already had a Suspender object. This then creates a corrupted object with a duplicated Suspender property. This also affects the InstallTypeReflection function when the Function property is installed.
This is somewhat related to 331383939 though with a rather different root cause, so I opened a different ticket, but please feel to merge the issues if you see fit.
Thank you very much for your help and please let me know if there is anything I can help. As with 40056206, the bug depends on origin trial and only affects Chrome version 123 onwards after the JSPI origin trial started.
VERSION Chromium version 123.0.6312.58 OS: Ubuntu 22.04 LTS
REPRODUCTION CASE
To simulate origin trial token locally, apply the patch trial-token.patch to accept the token from the test cases. Then open wasm_suspender.html in Chrome. In a debug build, the renderer should crash with a DCHECK failure when duplicated properties are added.
CREDIT INFORMATION Reporter credit: Man Yue Mo of GitHub Security Lab
Context
V8 is Chrome's JavaScript and WebAssembly engine. The WebAssembly JavaScript API exposes a global WebAssembly object, and V8 installs parts of that API lazily through WasmJs::InstallConditionalFeatures, which runs when a context is set up and adds constructors and namespaces to the WebAssembly object only when the relevant features are enabled.
One of those features is JSPI (JavaScript Promise Integration), which was being shipped behind an origin trial. When JSPI is enabled, InstallConditionalFeatures installs a WebAssembly.Suspender constructor and, if not already present, the type reflection features including WebAssembly.Function. The report concerns the way those installers decide whether a property already exists, and which object they then write to.
The researcher notes that this is somewhat related to an earlier issue, 331383939, but with a rather different root cause, and filed it as a separate ticket. The bug depends on the origin trial, as did 40056206 (CVE-2021-30561), and only affects Chrome version 123 onwards, after the JSPI origin trial started.
Setup
- Target: V8 inside Google Chrome, Chromium version 123.0.6312.58.
- OS: Ubuntu 22.04 LTS.
- Precondition: the JSPI origin trial must be active for the context, because the vulnerable installation path only runs when
isolate->IsWasmJSPIEnabled(context)is true. - To reproduce locally, the researcher applied a patch,
trial-token.patch, that makes the build accept the origin trial token from the test cases, then openedwasm_suspender.htmlin Chrome. - A debug build is useful for observing the failure: the renderer should crash with a
DCHECKfailure when duplicated properties are added.
Finding it
The researcher's starting point was the earlier fix for 40056206 (CVE-2021-30561). Mechanisms introduced to prevent issues of that kind were, in his assessment, insufficient. In InstallConditionalFeatures, a check was added so that the webassembly object is inspected for the relevant property before that property is added:
void WasmJs::InstallConditionalFeatures(Isolate* isolate,
Handle<NativeContext> context) {
...
MaybeHandle<Object> maybe_wasm =
JSReceiver::GetProperty(isolate, global, "WebAssembly"); //<-------- 1.
...
if (isolate->IsWasmJSPIEnabled(context)) {
isolate->WasmInitJSPIFeature();
Handle<String> suspender_string = v8_str(isolate, "Suspender");
if (!JSObject::HasRealNamedProperty(isolate, webassembly, suspender_string) //<----- 2.
.FromMaybe(true)) {
InstallSuspenderConstructor(isolate, context);
}
// Install Wasm type reflection features (if not already done).
Handle<String> function_string = v8_str(isolate, "Function");
if (!JSObject::HasRealNamedProperty(isolate, webassembly, function_string)
.FromMaybe(true)) {
InstallTypeReflection(isolate, context);
}
}
}
The object used in the check is the global property WebAssembly, fetched at step 1 and tested at step 2. But when the property is actually installed by InstallSuspenderConstructor, the object written to is context->wasm_webassembly_object(), at step 3, which may not be the same object as the global WebAssembly property:
void WasmJs::InstallSuspenderConstructor(Isolate* isolate,
Handle<NativeContext> context) {
Handle<JSObject> webassembly(context->wasm_webassembly_object(), isolate); //<------ 3.
Handle<JSFunction> suspender_constructor = InstallConstructorFunc(
isolate, webassembly, "Suspender", WebAssemblySuspender);
context->set_wasm_suspender_constructor(*suspender_constructor);
SetupConstructor(isolate, suspender_constructor, WASM_SUSPENDER_OBJECT_TYPE,
WasmSuspenderObject::kHeaderSize, "WebAssembly.Suspender");
}
The mismatch between the object that is checked and the object that is modified is the core of the finding. The same pattern applies to InstallTypeReflection when the Function property is installed.
Exploitation
Step 1: put a Suspender property on the real WebAssembly object
Set the Suspender property on the WebAssembly object first. This means the context's internal WebAssembly object already carries a Suspender property.
Step 2: replace the global WebAssembly with a different object
Assign a different object to the global WebAssembly. The name check in InstallConditionalFeatures now runs against this newly assigned object, not against the object that will be modified.
Step 3: trigger the conditional installation
When the JSPI installation path runs, the check on the substituted global object passes because that object has no Suspender property, so InstallSuspenderConstructor proceeds. It then adds Suspender to context->wasm_webassembly_object(), which already had one. The result is a corrupted object with a duplicated Suspender property. The same sequence applies to Function through InstallTypeReflection.
Step 4: observe the corruption
Open wasm_suspender.html in Chrome with the trial token patch applied. In a debug build, the renderer crashes with a DCHECK failure when the duplicated properties are added, which confirms the corruption.
Root cause
The installer checks one object and writes to another. InstallConditionalFeatures reads the global WebAssembly property and tests it with JSObject::HasRealNamedProperty, but InstallSuspenderConstructor and InstallTypeReflection operate on context->wasm_webassembly_object(). Because the global can be reassigned by script, an attacker can make the checked object differ from the modified object, so the guard that was meant to prevent duplicate installation is evaluated against the wrong target. The earlier mitigation for 40056206 (CVE-2021-30561) therefore does not cover this path.
Impact
The immediate, demonstrated effect is object corruption: a WebAssembly object ends up with a duplicated Suspender property, and a debug build trips a DCHECK. The report does not describe a full exploit chain beyond that corruption. The bug requires the JSPI origin trial to be enabled for the context and affects Chrome 123 onwards, from the point the trial started. The report's credit section names Man Yue Mo of GitHub Security Lab as the reporter.
Fix
The report does not describe the patch that was applied. The direction implied by the analysis is to make the existence check and the installation operate on the same object, so that the guard cannot be bypassed by reassigning the global WebAssembly property.
Variants to test
- Other lazy installers that read a global by name and then write to a context-held object. A positive result is a property installed twice on the internal object after the global is swapped.
- The
Functionpath throughInstallTypeReflection, using the same substitution of the globalWebAssembly. A positive result is a duplicatedFunctionproperty and aDCHECKin a debug build. - Any feature gated by an origin trial whose installation path runs conditionally at context setup. A positive result is a state change that survives the trial check being evaluated against attacker-controlled input.
What happened, in plain words
Chrome runs JavaScript and WebAssembly code using a component called V8. WebAssembly is a way to run fast, compiled code inside a web page, and V8 gives web pages a global object called WebAssembly that holds the tools for using it. V8 does not build all of that object at once: it adds pieces only when a feature is switched on, and it does so lazily, meaning at the moment the page needs them.
One of those features is JSPI (JavaScript Promise Integration), which was being tested in Chrome through an origin trial. An origin trial is a way for a website to opt in to an unfinished browser feature early, by presenting a special token. When JSPI is on, V8 adds a WebAssembly.Suspender constructor and, if it is not already there, type reflection features including WebAssembly.Function.
The bug is a mix-up about which object is being looked at. Before adding a property, V8 checks whether the property already exists, but it checks the global WebAssembly object that a page can see and replace. When it actually adds the property, it writes to a different, internal object kept by the browser context. A page can make those two objects different, so the check passes on one object while the write lands on another that already had the property. The result is an object with a duplicated property, which is a corrupted object. In a debug build of Chrome, this corruption makes the renderer process crash with a DCHECK failure.
The researcher, Man Yue Mo of GitHub Security Lab, notes that this is somewhat related to an earlier issue, 331383939, but with a rather different root cause, so he filed it as a separate ticket. The bug depends on the origin trial, as did 40056206 (CVE-2021-30561), and only affects Chrome version 123 onwards, after the JSPI origin trial started.
The pieces involved
Before the details, here are the main ideas in everyday terms.
- V8 is the engine inside Chrome that reads and runs JavaScript and WebAssembly. Think of it as the kitchen where the browser cooks the code a page sends it.
- WebAssembly is a format for code that runs very fast in the browser. The
WebAssemblyobject is the toolbox a page uses to load and work with that code. - A global object is a name that every script on a page can see and use, like a shared noticeboard in a building. A page can also replace what is pinned to that noticeboard with something else.
- A constructor is a function used to create new objects, for example
new WebAssembly.Suspender(...). Adding a constructor to an object means giving that object a new tool. - Lazy installation means the browser does not build every tool up front. It waits until a feature is enabled and then adds the tool, like a shop that only puts an item on the shelf when a customer asks for it.
- An origin trial is an early-access programme. A website includes a special token to say "I want to try this unfinished feature", and the browser then switches the feature on for that site.
- A context is the browser's private workspace for one page or frame. It keeps its own internal copies of things, separate from what the page can see.
- Object corruption means an object ends up in a state it was never meant to be in, here with the same property added twice. It is like a form that has two boxes with the same label, so different parts of the system disagree about what is in it.
- A DCHECK is a sanity check that only runs in debug builds of Chrome. When it fails, the browser stops on purpose so developers can see that something impossible happened.
The setup
The researcher worked with these conditions:
- Target: V8 inside Google Chrome, Chromium version 123.0.6312.58.
- OS: Ubuntu 22.04 LTS.
- Precondition: the JSPI origin trial must be active for the context, because the vulnerable installation path only runs when
isolate->IsWasmJSPIEnabled(context)is true. In plain words, the special code that adds the tools only runs when the trial has switched JSPI on for that page. - To reproduce locally, he applied a patch,
trial-token.patch, that makes the build accept the origin trial token from the test cases, then openedwasm_suspender.htmlin Chrome. The patch makes the local build accept the origin trial token used by the test cases. - A debug build is useful for observing the failure: the renderer should crash with a
DCHECKfailure when duplicated properties are added. A debug build is a version of Chrome built with extra internal checks turned on.
Finding it
The starting point was the earlier fix for 40056206 (CVE-2021-30561). Mechanisms introduced to prevent issues of that kind were, in the researcher's assessment, insufficient. In InstallConditionalFeatures, a check was added so that the webassembly object is inspected for the relevant property before that property is added:
void WasmJs::InstallConditionalFeatures(Isolate* isolate,
Handle<NativeContext> context) {
...
MaybeHandle<Object> maybe_wasm =
JSReceiver::GetProperty(isolate, global, "WebAssembly"); //<-------- 1.
...
if (isolate->IsWasmJSPIEnabled(context)) {
isolate->WasmInitJSPIFeature();
Handle<String> suspender_string = v8_str(isolate, "Suspender");
if (!JSObject::HasRealNamedProperty(isolate, webassembly, suspender_string) //<----- 2.
.FromMaybe(true)) {
InstallSuspenderConstructor(isolate, context);
}
// Install Wasm type reflection features (if not already done).
Handle<String> function_string = v8_str(isolate, "Function");
if (!JSObject::HasRealNamedProperty(isolate, webassembly, function_string)
.FromMaybe(true)) {
InstallTypeReflection(isolate, context);
}
}
}
Line by line, in plain words:
void WasmJs::InstallConditionalFeatures(...)declares a function that adds optional WebAssembly features to a context. It receives the engine (isolate) and the context (context).MaybeHandle<Object> maybe_wasm = JSReceiver::GetProperty(isolate, global, "WebAssembly");looks up the global property namedWebAssembly. This is step 1 in the comments. The result is the object the page can see, which a page is allowed to replace.if (isolate->IsWasmJSPIEnabled(context)) {asks whether the JSPI feature is enabled for this context, for example through the origin trial. Everything inside only runs when it is.isolate->WasmInitJSPIFeature();prepares the JSPI feature inside the engine.Handle<String> suspender_string = v8_str(isolate, "Suspender");creates the nameSuspenderto look for.if (!JSObject::HasRealNamedProperty(isolate, webassembly, suspender_string).FromMaybe(true)) {checks whether the object calledwebassemblyalready has a real property namedSuspender. This is step 2. If the answer cannot be determined,.FromMaybe(true)treats it as "already present". If the property is not present, the code inside theifruns.InstallSuspenderConstructor(isolate, context);adds theSuspenderconstructor. The important detail is which object it adds it to, shown next.- The
Functionblock does the same for the type reflection feature: it creates the nameFunction, checks whether the object already has it, and callsInstallTypeReflectionif not.
The object used in the check is the global property WebAssembly, fetched at step 1 and tested at step 2. But when the property is actually installed by InstallSuspenderConstructor, the object written to is context->wasm_webassembly_object(), at step 3, which may not be the same object as the global WebAssembly property:
void WasmJs::InstallSuspenderConstructor(Isolate* isolate,
Handle<NativeContext> context) {
Handle<JSObject> webassembly(context->wasm_webassembly_object(), isolate); //<------ 3.
Handle<JSFunction> suspender_constructor = InstallConstructorFunc(
isolate, webassembly, "Suspender", WebAssemblySuspender);
context->set_wasm_suspender_constructor(*suspender_constructor);
SetupConstructor(isolate, suspender_constructor, WASM_SUSPENDER_OBJECT_TYPE,
WasmSuspenderObject::kHeaderSize, "WebAssembly.Suspender");
}
Line by line:
void WasmJs::InstallSuspenderConstructor(...)declares the function that installs theSuspenderconstructor.Handle<JSObject> webassembly(context->wasm_webassembly_object(), isolate);takes the internal WebAssembly object stored in the context. This is step 3, and it is the object that will be modified.Handle<JSFunction> suspender_constructor = InstallConstructorFunc(isolate, webassembly, "Suspender", WebAssemblySuspender);adds a property namedSuspenderto that internal object, pointing at theWebAssemblySuspenderfunction.context->set_wasm_suspender_constructor(*suspender_constructor);remembers the new constructor in the context.SetupConstructor(...)finishes setting up the constructor with its internal type and size information.
The mismatch between the object that is checked and the object that is modified is the core of the finding. The same pattern applies to InstallTypeReflection when the Function property is installed.
Exploitation
Step 1: put a Suspender property on the real WebAssembly object
Set the Suspender property on the WebAssembly object first. This means the context's internal WebAssembly object already carries a Suspender property. In everyday terms, you put a label on the internal toolbox before the browser gets a chance to check it.
Step 2: replace the global WebAssembly with a different object
Assign a different object to the global WebAssembly. The name check in InstallConditionalFeatures now runs against this newly assigned object, not against the object that will be modified. This is the trick: the guard looks at the noticeboard, but the work happens in the back room.
Step 3: trigger the conditional installation
When the JSPI installation path runs, the check on the substituted global object passes because that object has no Suspender property, so InstallSuspenderConstructor proceeds. It then adds Suspender to context->wasm_webassembly_object(), which already had one. The result is a corrupted object with a duplicated Suspender property. The same sequence applies to Function through InstallTypeReflection.
Step 4: observe the corruption
Open wasm_suspender.html in Chrome with the trial token patch applied. In a debug build, the renderer crashes with a DCHECK failure when the duplicated properties are added, which confirms the corruption. The renderer is the part of Chrome that runs the page's code.
Root cause
The installer checks one object and writes to another. InstallConditionalFeatures reads the global WebAssembly property and tests it with JSObject::HasRealNamedProperty, but InstallSuspenderConstructor and InstallTypeReflection operate on context->wasm_webassembly_object(). Because the global can be reassigned by script, an attacker can make the checked object differ from the modified object, so the guard that was meant to prevent duplicate installation is evaluated against the wrong target. The earlier mitigation for 40056206 (CVE-2021-30561) therefore does not cover this path.
The list and the room are two different places, and the guard only watches one of them.
Impact
The immediate, demonstrated effect is object corruption: a WebAssembly object ends up with a duplicated Suspender property, and a debug build trips a DCHECK. The report does not describe a full exploit chain beyond that corruption. The bug requires the JSPI origin trial to be enabled for the context and affects Chrome 123 onwards, from the point the trial started. The report's credit section names Man Yue Mo of GitHub Security Lab as the reporter.
Fix
The report does not describe the patch that was applied. The direction implied by the analysis is to make the existence check and the installation operate on the same object, so that the guard cannot be bypassed by reassigning the global WebAssembly property.
Variants to test
- Other lazy installers that read a global by name and then write to a context-held object. A positive result is a property installed twice on the internal object after the global is swapped.
- The
Functionpath throughInstallTypeReflection, using the same substitution of the globalWebAssembly. A positive result is a duplicatedFunctionproperty and aDCHECKin a debug build. - Any feature gated by an origin trial whose installation path runs conditionally at context setup. A positive result is a state change that survives the trial check being evaluated against attacker-controlled input.
Glossary
- V8: the engine inside Chrome that runs JavaScript and WebAssembly code.
- WebAssembly: a fast, compiled code format that runs inside the browser; the
WebAssemblyobject is the toolbox pages use to work with it. - JavaScript: the programming language most web pages use for interactivity.
- Global object: a name every script on a page can see and use, which a page can also replace.
- Property: a named entry on an object, like a labelled box holding a value or a function.
- Constructor: a function used to create new objects, for example with
new. - Lazy installation: adding a feature only when it is needed or enabled, rather than building everything up front.
- Origin trial: an early-access programme where a website presents a token to switch on an unfinished browser feature.
- Token: a short piece of data that proves something, here that a site is allowed to take part in the trial.
- Context: the browser's private workspace for one page or frame, holding its own internal objects.
- Isolate: V8's term for an independent engine instance that runs code and manages memory.
- JSPI (JavaScript Promise Integration): a WebAssembly feature that lets code wait on asynchronous JavaScript operations; it was behind an origin trial.
- Type reflection: a WebAssembly feature that lets code inspect the types of functions; it includes
WebAssembly.Function. - Object corruption: an object ending up in an invalid state, here with a property added twice.
- DCHECK: a sanity check that only runs in debug builds; when it fails, the process stops on purpose.
- Debug build: a version of Chrome built with extra internal checks switched on.
- Renderer: the part of Chrome that runs a page's code; a crash there breaks the tab.
- CVE: a public identifier for a known security vulnerability.
- Guard / check: code that verifies a condition before doing something, here checking whether a property already exists.
- Patch: a change to source code, here one that makes a local build accept a trial token.