Out of bounds memory access in V8 (CVE-2024-2173)
An out-of-bounds memory access occurred in V8's tier-up logic for the generic wasm-to-js wrapper because the code did not check the length of each WasmDispatchTable before accessing an entry by index. An attacker could trigger a crash or potentially read/write out of bounds by crafting a WebAssembly module with tables of different sizes.
5fceb6172bbf7e2c5a948183b53565b9 Follow
Originally disclosed on Chrome VRP
- Fix shipped in 16 days
Title:
Debug check failed: index < length() (2 vs. 1)
Component:
Blink>JavaScript>Runtime
Description:
While auditing codes related to the newly shipped generic wasm-to-js wrapper, I found this vulnerability in the tier-up logic.
This is an OOB vulnerability during getting the ref of indirect function from WasmDispatchTable in Runtime_TierUpWasmToJSWrapper.
Crashed lines: both 'https://source.chromium.org/chromium/chromium/src/+/main:v8/src/runtime/runtime-wasm.cc;l=617' and 'https://source.chromium.org/chromium/chromium/src/+/main:v8/src/runtime/runtime-wasm.cc;l=688'. Like:
if (WasmApiFunctionRef::CallOriginIsImportIndex(origin)) {
int func_index = WasmApiFunctionRef::CallOriginAsIndex(origin);
ImportedFunctionEntry entry(instance_object, func_index);
entry.set_target(wasm_code->instruction_start());
} else {
// Indirect function table index.
int entry_index = WasmApiFunctionRef::CallOriginAsIndex(origin);
int table_count = trusted_data->dispatch_tables()->length();
// We have to find the table which contains the correct entry.
for (int table_index = 0; table_index < table_count; ++table_index) {
Tagged<WasmDispatchTable> table =
trusted_data->dispatch_table(table_index);
if (table->ref(entry_index) == *ref) { // ---> [1]
table->SetTarget(entry_index, wasm_code->instruction_start());
// {ref} is used in at most one table.
break;
}
}
}
The main root cause is that in [1], Runtime_TierUpWasmToJSWrapper wants to use the entry_index to directly get the function ref from each WasmDispatchTable.
However, tables may have different sizes. If we use a large entry_index that exceeds the length of one WasmDispatchTable, the OOB will occur.
The for loop starts with the table that has a small index. So we may arrange two tables like that:
builder.addTable(kWasmFuncRef, 1, 1)
builder.addTable(kWasmFuncRef, 3, 3)
And then tier-up the 3rd function in the 2nd table.
As a result, the for loop will first get the 3rd function ref of the 1st table, whose length is 1. Thus an OOB will occur.
I wrote a testcase to stably trigger this vulnerability.
build on latest commit:
6d26d2b5f88fbb3e3ea7020c2ec16e47ed1aceb6
build command:
python3 tools\dev\gm.py x64.debug
run command (under v8, cause it needs the test/mjsunit/wasm/wasm-module-builder.js):
out\x64.debug\d8.exe --wasm-wrapper-tiering-budget=1 poc.js
Crash Log:
#
# Fatal error in ..\..\src\wasm\wasm-objects-inl.h, line 335
# Debug check failed: index < length() (2 vs. 1).
#
#
#
#FailureMessage Object: 0000001B533FD160
==== C stack trace ===============================
v8::base::debug::StackTrace::StackTrace [0x00007FF890FB5FF5+37]
v8::platform::`anonymous namespace'::PrintStackTrace [0x00007FF8B4F6AD29+57]
V8_Fatal [0x00007FF890F86ED7+295]
v8::base::`anonymous namespace'::DefaultDcheckHandler [0x00007FF890F868AC+44]
V8_Dcheck [0x00007FF890F86FC6+86]
v8::internal::WasmDispatchTable::ref [0x00007FF8015DA06A+154]
v8::internal::__RT_impl_Runtime_TierUpWasmToJSWrapper [0x00007FF803188A28+3624]
v8::internal::Runtime_TierUpWasmToJSWrapper [0x00007FF8031878FF+383]
Builtins_WasmCEntry [0x00007FF805C0EA75+181]
Builtins_WasmToJsWrapperCSA [0x00007FF805BD95F8+696]
(No symbol) [0x00000114643C18F4]
VERSION
Chrome Version: Tested on v8 12.3.0
Operating System: Tested on Windows 11
BISECT:
I think the commit that shipped the generic wasm-to-js wrapper is the latest bisect for this vulnerability.
Before this commit, we may need an experimental flag: --wasm-to-js-generic-wrapper.
https://chromium-review.googlesource.com/c/v8/v8/+/5259577
[wasm] Enable generic wasm-to-js wrapper by default
Bug: v8:14035, chromium:1489280
Change-Id: I6b45d6c1b88d76591be913a8798722ec0eadb4e2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5259577
Commit-Queue: Andreas Haas <[email protected]>
Reviewed-by: Clemens Backes <[email protected]>
Cr-Commit-Position: refs/heads/main@{#92183
But the root commit that introduced this vulnerability should be:
https://chromium-review.googlesource.com/c/v8/v8/+/4738319
Reland "[wasm] Wrapper tierup for the generic wasm-to-js wrapper"
This is a reland of commit 20c285f21c83ac2b37617d772618657e20beb0f8
Fixes:
The CL got reverted because of a failing isolate test. Like other
tier-up tests the new test does not work for isolate tests, therefore
I skip the test now for isolate tests.
Other changes:
I added one more flag guard, and I removed CHECKs which were actually
not necessary. Maybe this is what caused the performance regression?
...
Bug: v8:14035
Change-Id: Ia2965e1e6f95fd098c614fb44bda0a3cfd7d782c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4738319
Reviewed-by: Thibaud Michaud <[email protected]>
Commit-Queue: Andreas Haas <[email protected]>
Cr-Commit-Position: refs/heads/main@{#89310}
FIX PATCH:
Check the bound of the table first.
--- a/src/runtime/runtime-wasm.cc
+++ b/src/runtime/runtime-wasm.cc
@@ -614,7 +614,7 @@ RUNTIME_FUNCTION(Runtime_TierUpWasmToJSWrapper) {
for (int table_index = 0; table_index < table_count; ++table_index) {
Tagged<WasmDispatchTable> table =
trusted_data->dispatch_table(table_index);
- if (table->ref(entry_index) == *ref) {
+ if (entry_index < table->length() && table->ref(entry_index) == *ref) {
canonical_sig_index = table->sig(entry_index);
break;
}
@@ -685,7 +685,7 @@ RUNTIME_FUNCTION(Runtime_TierUpWasmToJSWrapper) {
for (int table_index = 0; table_index < table_count; ++table_index) {
Tagged<WasmDispatchTable> table =
trusted_data->dispatch_table(table_index);
- if (table->ref(entry_index) == *ref) {
+ if (entry_index < table->length() && table->ref(entry_index) == *ref) {
table->SetTarget(entry_index, wasm_code->instruction_start());
// {ref} is used in at most one table.
break;
CREDIT:
5fceb6172bbf7e2c5a948183b53565b9
Context
V8 is Chrome's JavaScript and WebAssembly engine. When WebAssembly code calls into JavaScript, the call passes through a wrapper. V8 shipped a generic wasm-to-js wrapper, and that wrapper has a tier-up mechanism: a wrapper that is called often enough is replaced by a faster version. The runtime function that performs this replacement is Runtime_TierUpWasmToJSWrapper, in v8/src/runtime/runtime-wasm.cc.
To find the function reference it needs to update, the runtime function walks the instance's WasmDispatchTable objects. A dispatch table holds function references and targets for indirect calls, and each table can have a different length. The bug is an out-of-bounds read while that walk uses an index taken from the call origin against every table, regardless of that table's size.
The issue was reported through the Chrome VRP as an out-of-bounds memory access in V8, rated high severity, with a bounty of 12,000 USD. It was disclosed on 6 March 2024 and tracked as CVE-2024-2173.
Setup
The researcher audited the code around the newly shipped generic wasm-to-js wrapper. The testcase was built from V8 commit:
[redacted]
with the build command:
python3 tools\dev\gm.py x64.debug
The proof of concept was run from the v8 directory, because it needs test/mjsunit/wasm/wasm-module-builder.js, with:
out\x64.debug\d8.exe --wasm-wrapper-tiering-budget=1 poc.js
The proof of concept was run with the --wasm-wrapper-tiering-budget=1 flag. The environment was Windows 11, and the engine version tested was V8 12.3.0.
Finding it
While auditing code related to the generic wasm-to-js wrapper, the researcher found the problem in the tier-up logic. The crash occurs at two places in runtime-wasm.cc, at line 617 and line 688. The relevant code looks like this:
if (WasmApiFunctionRef::CallOriginIsImportIndex(origin)) {
int func_index = WasmApiFunctionRef::CallOriginAsIndex(origin);
ImportedFunctionEntry entry(instance_object, func_index);
entry.set_target(wasm_code->instruction_start());
} else {
// Indirect function table index.
int entry_index = WasmApiFunctionRef::CallOriginAsIndex(origin);
int table_count = trusted_data->dispatch_tables()->length();
// We have to find the table which contains the correct entry.
for (int table_index = 0; table_index < table_count; ++table_index) {
Tagged<WasmDispatchTable> table =
trusted_data->dispatch_table(table_index);
if (table->ref(entry_index) == *ref) { // ---> [1]
table->SetTarget(entry_index, wasm_code->instruction_start());
// {ref} is used in at most one table.
break;
}
}
}
The root cause is at [1]. Runtime_TierUpWasmToJSWrapper takes entry_index, derived from the call origin, and uses it to read the function reference directly from each WasmDispatchTable in the loop. The code assumes the index is valid for every table, but tables may have different sizes. If entry_index is larger than the length of one of the tables, the read goes out of bounds.
Exploitation
Step 1: arrange tables of different sizes
The loop starts with the table that has the smallest index. If an instance has two tables, the first small and the second large, the loop will first read the large index from the small table. The researcher arranged them like this:
builder.addTable(kWasmFuncRef, 1, 1)
builder.addTable(kWasmFuncRef, 3, 3)
The first table has length 1 and the second has length 3.
Step 2: tier up the third function in the second table
With the tables in place, the testcase tiers up the third function in the second table.
Step 3: trigger the out-of-bounds read
The for loop starts at table index 0, the table of length 1. It calls table->ref(entry_index) with entry_index 2 on a table whose length is 1. The debug build catches this immediately and aborts with:
#
# Fatal error in ..\..\src\wasm\wasm-objects-inl.h, line 335
# Debug check failed: index < length() (2 vs. 1).
#
#
#
#FailureMessage Object: 0000001B533FD160
==== C stack trace ===============================
v8::base::debug::StackTrace::StackTrace [0x00007FF890FB5FF5+37]
v8::platform::`anonymous namespace'::PrintStackTrace [0x00007FF8B4F6AD29+57]
V8_Fatal [0x00007FF890F86ED7+295]
v8::base::`anonymous namespace'::DefaultDcheckHandler [0x00007FF890F868AC+44]
V8_Dcheck [0x00007FF890F86FC6+86]
v8::internal::WasmDispatchTable::ref [0x00007FF8015DA06A+154]
v8::internal::__RT_impl_Runtime_TierUpWasmToJSWrapper [0x00007FF803188A28+3624]
v8::internal::Runtime_TierUpWasmToJSWrapper [0x00007FF8031878FF+383]
Builtins_WasmCEntry [0x00007FF805C0EA75+181]
Builtins_WasmToJsWrapperCSA [0x00007FF805BD95F8+696]
(No symbol) [0x00000114643C18F4]
The stack shows the path: Builtins_WasmToJsWrapperCSA calls Builtins_WasmCEntry, which calls Runtime_TierUpWasmToJSWrapper, which reaches WasmDispatchTable::ref, where the debug check fails. The message index < length() (2 vs. 1) confirms the index 2 against a table of length 1. The researcher notes the testcase triggers the vulnerability stably.
Root cause
Runtime_TierUpWasmToJSWrapper receives an entry_index from the call origin and uses it to look up a function reference in every dispatch table of the instance. The loop exists because the reference may live in any one of the tables, and the code breaks as soon as it finds a match. The missing piece is a bounds check: table->ref(entry_index) is called without first confirming that entry_index is within that particular table's length. Because the loop starts with the lowest table index, a small table placed before a larger one is read with an index that belongs to the larger table, and the read goes past the end of the small table's storage.
In a debug build the DCHECK in WasmDispatchTable::ref turns this into a fatal error.
Impact
An instance with dispatch tables of differing sizes can cause the tier-up path to read out of bounds. The report does not describe a concrete exploit beyond the crash, so the practical consequences beyond the out-of-bounds access are not stated.
Fix
The fix checks the bound of the table before reading from it, in both places where the loop appears:
--- a/src/runtime/runtime-wasm.cc
+++ b/src/runtime/runtime-wasm.cc
@@ -614,7 +614,7 @@ RUNTIME_FUNCTION(Runtime_TierUpWasmToJSWrapper) {
for (int table_index = 0; table_index < table_count; ++table_index) {
Tagged<WasmDispatchTable> table =
trusted_data->dispatch_table(table_index);
- if (table->ref(entry_index) == *ref) {
+ if (entry_index < table->length() && table->ref(entry_index) == *ref) {
canonical_sig_index = table->sig(entry_index);
break;
}
@@ -685,7 +685,7 @@ RUNTIME_FUNCTION(Runtime_TierUpWasmToJSWrapper) {
for (int table_index = 0; table_index < table_count; ++table_index) {
Tagged<WasmDispatchTable> table =
trusted_data->dispatch_table(table_index);
- if (table->ref(entry_index) == *ref) {
+ if (entry_index < table->length() && table->ref(entry_index) == *ref) {
table->SetTarget(entry_index, wasm_code->instruction_start());
// {ref} is used in at most one table.
break;
The fix checks the bound of the table first, in both places where the loop appears.
Variants to test
- More than two tables. Build an instance with several dispatch tables of increasing size and tier up an entry in the last one. A positive result is the same debug check failing with an index that exceeds the length of an earlier table.
- Large index in the first table. Place a table of length 1 first and a much larger table second, then tier up an entry near the end of the second table. A positive result is a crash whose message shows the large index against length 1.
- Release build behaviour. Run the same testcase against a release build of the affected commit. A positive result is memory corruption or a crash rather than the clean DCHECK failure, which would confirm the out-of-bounds read is reachable without debug checks.
- Other tier-up paths. Look for other runtime functions that iterate over
WasmDispatchTableobjects with an index taken from a call origin. A positive result is another loop that callsref,sigorSetTargetwithout comparing the index totable->length()first.
Credit
[redacted]
What happened, in plain words
Chrome contains a piece of software called V8. V8 is the part of the browser that runs JavaScript, the programming language most web pages use, and WebAssembly, a faster, lower-level language that web pages can also run. When WebAssembly code wants to call a JavaScript function, the call does not happen directly. It goes through a small piece of glue code called a wrapper. V8 had recently started using a new, generic version of this wrapper, and that wrapper has a speed-up mechanism called tier-up: if a wrapper is used often enough, V8 swaps it for a faster version.
The function that performs this swap is called Runtime_TierUpWasmToJSWrapper. To do its job it has to find a particular function reference inside a list called a WasmDispatchTable. An instance can have several of these tables, and each table can be a different length. The bug is that the code used a position number (an index) taken from the call against every table, without first checking that the table was long enough to have that position. Reading past the end of a list is called an out-of-bounds read, and it is a classic security bug because the memory just past the end of a list may belong to something else.
The issue was reported through the Chrome VRP, Google's bug bounty programme for Chrome, as an out-of-bounds memory access in V8. It was rated high severity, paid a bounty of 12,000 USD, was disclosed on 6 March 2024 and is tracked as CVE-2024-2173. A CVE is a public catalogue number given to a known security flaw so people can refer to it unambiguously.
Setup
The researcher was reading through the code around the newly shipped generic wasm-to-js wrapper, looking for mistakes. This kind of reading is called an audit. The testcase was built from a specific V8 source code snapshot, identified by a long hexadecimal string called a commit hash:
[redacted]
A commit hash is like a fingerprint for one exact version of the source code, so anyone can check out the same code and reproduce the result.
The build command was:
python3 tools\dev\gm.py x64.debug
Line by line: python3 runs the Python interpreter; tools\dev\gm.py is a helper script inside the V8 source tree that drives the build; x64.debug asks for a 64-bit build with debug checks switched on. Debug builds are slower but they contain extra assertions, small self-checks that stop the program the moment something impossible happens. That is why the bug shows up here as a clean, loud crash instead of silent memory damage.
The proof of concept was run from inside the v8 directory, because the test file needs another file, test/mjsunit/wasm/wasm-module-builder.js, which lives there. The command was:
out\x64.debug\d8.exe --wasm-wrapper-tiering-budget=1 poc.js
Line by line: out\x64.debug\d8.exe is the freshly built V8 shell, a bare command-line program that runs JavaScript and WebAssembly without a browser window; --wasm-wrapper-tiering-budget=1 is a flag passed to the V8 shell; poc.js is the proof-of-concept script. The environment was Windows 11, and the engine version tested was V8 12.3.0.
Finding it
While auditing the code related to the generic wasm-to-js wrapper, the researcher found the problem in the tier-up logic. The crash happens at two places in runtime-wasm.cc, at line 617 and line 688. The relevant code looks like this:
if (WasmApiFunctionRef::CallOriginIsImportIndex(origin)) {
int func_index = WasmApiFunctionRef::CallOriginAsIndex(origin);
ImportedFunctionEntry entry(instance_object, func_index);
entry.set_target(wasm_code->instruction_start());
} else {
// Indirect function table index.
int entry_index = WasmApiFunctionRef::CallOriginAsIndex(origin);
int table_count = trusted_data->dispatch_tables()->length();
// We have to find the table which contains the correct entry.
for (int table_index = 0; table_index < table_count; ++table_index) {
Tagged<WasmDispatchTable> table =
trusted_data->dispatch_table(table_index);
if (table->ref(entry_index) == *ref) { // ---> [1]
table->SetTarget(entry_index, wasm_code->instruction_start());
// {ref} is used in at most one table.
break;
}
}
}
Line by line: the outer if asks whether the call came from an imported function, that is, a function brought in from outside the module. If so, the first branch looks up the imported function entry by its index and points it at the new, faster code. Otherwise, the else branch handles an indirect call, a call made through a table of function references. There, entry_index is read out of the call origin, the record of how the call was made. table_count is how many dispatch tables the instance has. The for loop then walks every table in turn, fetches it, and at the marked line [1] asks the table for the reference stored at entry_index. If it matches the reference being upgraded, the loop updates that table's target to the new code and stops, because a reference is used in at most one table.
The root cause is at [1]. Runtime_TierUpWasmToJSWrapper takes entry_index, derived from the call origin, and uses it to read the function reference directly from each WasmDispatchTable in the loop. The code assumes the index is valid for every table, but tables may have different sizes. If entry_index is larger than the length of one of the tables, the read goes out of bounds. A simple comparison: imagine a row of lockers of different heights, and a note that says "take item number 3 from every locker". If the first locker only has one shelf, reaching for shelf 3 means reaching into the wall.
Exploitation
Step 1: arrange tables of different sizes
The loop starts with the table that has the smallest index. If an instance has two tables, the first small and the second large, the loop will first read the large index from the small table. The researcher arranged them like this:
builder.addTable(kWasmFuncRef, 1, 1)
builder.addTable(kWasmFuncRef, 3, 3)
Line by line: builder is the helper object from wasm-module-builder.js that assembles a WebAssembly module piece by piece. addTable adds a table of function references. kWasmFuncRef says the table holds references to functions. The two numbers are the initial size and the maximum size, so the first table has length 1 and the second has length 3. The order matters: the small table is added first, so it gets the lower index and is visited first by the loop.
Step 2: tier up the third function in the second table
With the tables in place, the testcase tiers up the third function in the second table.
Step 3: trigger the out-of-bounds read
The for loop starts at table index 0, the table of length 1. It calls table->ref(entry_index) with entry_index 2 on a table whose length is 1. The debug build catches this immediately and aborts with:
#
# Fatal error in ..\..\src\wasm\wasm-objects-inl.h, line 335
# Debug check failed: index < length() (2 vs. 1).
#
#
#
#FailureMessage Object: 0000001B533FD160
==== C stack trace ===============================
v8::base::debug::StackTrace::StackTrace [0x00007FF890FB5FF5+37]
v8::platform::`anonymous namespace'::PrintStackTrace [0x00007FF8B4F6AD29+57]
V8_Fatal [0x00007FF890F86ED7+295]
v8::base::`anonymous namespace'::DefaultDcheckHandler [0x00007FF890F868AC+44]
V8_Dcheck [0x00007FF890F86FC6+86]
v8::internal::WasmDispatchTable::ref [0x00007FF8015DA06A+154]
v8::internal::__RT_impl_Runtime_TierUpWasmToJSWrapper [0x00007FF803188A28+3624]
v8::internal::Runtime_TierUpWasmToJSWrapper [0x00007FF8031878FF+383]
Builtins_WasmCEntry [0x00007FF805C0EA75+181]
Builtins_WasmToJsWrapperCSA [0x00007FF805BD95F8+696]
(No symbol) [0x00000114643C18F4]
Line by line: the first lines are the fatal error message, naming the file and line where the debug check lives, wasm-objects-inl.h line 335. The message Debug check failed: index < length() (2 vs. 1) says the check expected the index to be smaller than the length, but got index 2 against length 1. The hexadecimal number after FailureMessage Object is an internal address of the failure record. The stack trace is the list of function calls that were active at the moment of the crash, read from the bottom up: Builtins_WasmToJsWrapperCSA is the wrapper, which calls Builtins_WasmCEntry, which calls Runtime_TierUpWasmToJSWrapper, which reaches WasmDispatchTable::ref, where the check fails. The bracketed numbers are memory addresses and offsets, not values you need to interpret. The researcher notes the testcase triggers the vulnerability stably, meaning it does not depend on luck.
Root cause
Runtime_TierUpWasmToJSWrapper receives an entry_index from the call origin and uses it to look up a function reference in every dispatch table of the instance. The loop exists because the reference may live in any one of the tables, and the code breaks as soon as it finds a match. The missing piece is a bounds check: table->ref(entry_index) is called without first confirming that entry_index is within that particular table's length. Because the loop starts with the lowest table index, a small table placed before a larger one is read with an index that belongs to the larger table, and the read goes past the end of the small table's storage.
In a debug build the DCHECK in WasmDispatchTable::ref turns this into a fatal error. A DCHECK is a check that only exists in debug builds.
Impact
An instance with dispatch tables of differing sizes can cause the tier-up path to read out of bounds. The report does not describe a concrete exploit beyond the crash, so the practical consequences beyond the out-of-bounds access are not stated.
Fix
The fix checks the bound of the table before reading from it, in both places where the loop appears:
--- a/src/runtime/runtime-wasm.cc
+++ b/src/runtime/runtime-wasm.cc
@@ -614,7 +614,7 @@ RUNTIME_FUNCTION(Runtime_TierUpWasmToJSWrapper) {
for (int table_index = 0; table_index < table_count; ++table_index) {
Tagged<WasmDispatchTable> table =
trusted_data->dispatch_table(table_index);
- if (table->ref(entry_index) == *ref) {
+ if (entry_index < table->length() && table->ref(entry_index) == *ref) {
canonical_sig_index = table->sig(entry_index);
break;
}
@@ -685,7 +685,7 @@ RUNTIME_FUNCTION(Runtime_TierUpWasmToJSWrapper) {
for (int table_index = 0; table_index < table_count; ++table_index) {
Tagged<WasmDispatchTable> table =
trusted_data->dispatch_table(table_index);
- if (table->ref(entry_index) == *ref) {
+ if (entry_index < table->length() && table->ref(entry_index) == *ref) {
table->SetTarget(entry_index, wasm_code->instruction_start());
// {ref} is used in at most one table.
break;
Line by line: the lines starting with - are the old code and the lines starting with + are the new code. The change adds entry_index < table->length() && in front of the existing comparison. In plain words: only ask the table for the reference if the index is actually inside the table. The && means "and", so the second part is only evaluated when the first part is true. The fix checks the bound of the table first, in both places where the loop appears. The two hunks are the same fix applied at the two places where the loop appears.
Variants to test
- More than two tables. Build an instance with several dispatch tables of increasing size and tier up an entry in the last one. A positive result is the same debug check failing with an index that exceeds the length of an earlier table.
- Large index in the first table. Place a table of length 1 first and a much larger table second, then tier up an entry near the end of the second table. A positive result is a crash whose message shows the large index against length 1.
- Release build behaviour. Run the same testcase against a release build of the affected commit. A positive result is memory corruption or a crash rather than the clean DCHECK failure, which would confirm the out-of-bounds read is reachable without debug checks.
- Other tier-up paths. Look for other runtime functions that iterate over
WasmDispatchTableobjects with an index taken from a call origin. A positive result is another loop that callsref,sigorSetTargetwithout comparing the index totable->length()first.
Credit
[redacted]
Glossary
- V8: the JavaScript and WebAssembly engine inside Chrome, the part that actually runs the code on a web page.
- JavaScript: the programming language most web pages use for interactivity.
- WebAssembly: a fast, low-level language that web pages can run alongside JavaScript.
- Wrapper: a small piece of glue code that lets one kind of code call another, here WebAssembly calling JavaScript.
- Tier-up: automatically replacing a slow, general version of a piece of code with a faster, specialised one after it has been used enough times.
- Runtime function: an internal helper inside the engine that the generated code can call when it needs to do something complex.
WasmDispatchTable: a list inside a WebAssembly instance that holds function references and their targets, used for indirect calls.- Indirect call: a call to a function chosen at run time through a table, rather than named directly in the code.
- Index: a position number in a list, starting at zero.
- Out-of-bounds read: reading memory at a position past the end of a list or buffer, which can expose or corrupt unrelated data.
- Bounds check: a test that a position number is inside the allowed range before using it.
- DCHECK: a self-check that only exists in debug builds and stops the program when a condition is violated.
- Debug build: a version of the software compiled with extra checks and without speed optimisations, used for finding bugs.
- Release build: the normal, optimised version shipped to users, without debug checks.
- Commit hash: a long hexadecimal fingerprint identifying one exact version of the source code.
- Proof of concept (PoC): a small script or program that demonstrates a bug reliably.
- Flag: a command-line switch that changes how a program behaves.
- Stack trace: the list of function calls that were active when a program crashed, read from the innermost call outwards.
- CVE: a public catalogue number for a known security flaw.
- Chrome VRP: Google's bug bounty programme for Chrome, which pays researchers for reporting security bugs.
- Bounty: the money paid to a researcher for a valid security report.
- Audit: reading source code carefully, looking for mistakes.
- Memory corruption: damage to memory that a program did not intend to touch, often the step from a bug to an exploit.