Inappropriate implementation in V8 (CVE-2024-3174)
A debug check in V8's mid-tier register allocator failed when compiling a WebAssembly module, causing a fatal error. The reporter does not demonstrate any security impact beyond the crash.
Originally disclosed on Chrome VRP
- Fix shipped in 37 days
VULNERABILITY DETAILS
Please provide a brief explanation of the security issue.
VERSION
Chrome Version: f2fe88605a0bcb2a31c69a8f6cf9d84c6e0383fd
Operating System: Ubuntu 23.04
gn gen out/libfuzzernosan '--args=use_libfuzzer=true is_ubsan=false is_msan=false is_asan=false is_tsan=false is_debug=false enable_nacl=false'
ninja -C out/libfuzzernosan/v8_wasm_compile_fuzzer
$ /home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer min
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 1788738389
INFO: Loaded 1 modules (1238938 inline 8-bit counters): 1238938 [0x55d664ef2d60, 0x55d6650214fa),
INFO: Loaded 1 PC tables (1238938 PCs): 1238938 [0x55d665021500,0x55d666308ea0),
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer: Running 1 inputs 1 time(s) each.
Running: min
Fatal error in ../../v8/src/compiler/backend/mid-tier-register-allocator.cc, line 583
Debug check failed: output_instr_index_ == definition_block->last_instruction_index() - 1 (19540 vs. 19551).
#FailureMessage Object: 0x7ffeb8b5cd30
==== C stack trace ===============================
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x536de2d) [0x55d664b36e2d]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x536c302) [0x55d664b35302]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x5344536) [0x55d664b0d536]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x5343ec5) [0x55d664b0cec5]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x43cb5b9) [0x55d663b945b9]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x43cb7d7) [0x55d663b947d7]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x43cd124) [0x55d663b96124]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x43cceab) [0x55d663b95eab]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x43d20b3) [0x55d663b9b0b3]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x43d4f65) [0x55d663b9df65]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x43d9cad) [0x55d663ba2cad]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x43d7ac1) [0x55d663ba0ac1]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x43daa4a) [0x55d663ba3a4a]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x47cb198) [0x55d663f94198]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x47c74da) [0x55d663f904da]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x47be599) [0x55d663f87599]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x47bfc91) [0x55d663f88c91]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x47c5d6a) [0x55d663f8ed6a]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x4a7b867) [0x55d664244867]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x3f86f5b) [0x55d66374ff5b]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x3f861b1) [0x55d66374f1b1]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x3feaafd) [0x55d6637b3afd]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x3dad796) [0x55d663576796]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x3dacfff) [0x55d663575fff]
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer(+0x511c9a0) [0x55d6648e59a0]
==28422== ERROR: libFuzzer: deadly signal
#0 0x55d661b32e84 in __sanitizer_print_stack_trace /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/ubsan/ubsan_diag_standalone.cpp:31:3
#1 0x55d661ba6a88 in fuzzer::PrintStackTrace() ../../third_party/libFuzzer/src/FuzzerUtil.cpp:210:5
#2 0x55d661b8d693 in fuzzer::Fuzzer::CrashCallback() ../../third_party/libFuzzer/src/FuzzerLoop.cpp:231:3
#3 0x7ff9e543c4af (/lib/x86_64-linux-gnu/libc.so.6+0x3c4af) (BuildId: bdb8aa3b1b60f9d43e1c70ba98158e05f765efdc)
#4 0x7ff9e5490ffa in __pthread_kill_implementation nptl/pthread_kill.c:43:17
#5 0x7ff9e5490ffa in __pthread_kill_internal nptl/pthread_kill.c:78:10
#6 0x7ff9e5490ffa in pthread_kill nptl/pthread_kill.c:89:10
#7 0x7ff9e543c405 in raise signal/../sysdeps/posix/raise.c:26:13
#8 0x7ff9e542287b in abort stdlib/abort.c:79:7
#9 0x55d664b303ab in v8::base::OS::Abort() ../../v8/src/base/platform/platform-posix.cc:701:3
#10 0x55d664b0d543 in V8_Fatal(char const*, int, char const*, ...) ../../v8/src/base/logging.cc:167:3
#11 0x55d664b0cec4 in v8::base::(anonymous namespace)::DefaultDcheckHandler(char const*, int, char const*) ../../v8/src/base/logging.cc:57:3
#12 0x55d663b945b8 in v8::internal::compiler::VirtualRegisterData::EnsureSpillRange(v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:582:7
#13 0x55d663b947d6 in v8::internal::compiler::VirtualRegisterData::AddSpillUse(int, v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:599:3
#14 0x55d663b96123 in SpillOperand ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:644:3
#15 0x55d663b96123 in v8::internal::compiler::RegisterState::Register::SpillPendingUses(v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:1104:15
#16 0x55d663b95eaa in v8::internal::compiler::RegisterState::Register::Spill(v8::internal::compiler::AllocatedOperand, v8::internal::compiler::InstructionBlock const*, v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:1055:3
#17 0x55d663b9b0b2 in Spill ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:1172:17
#18 0x55d663b9b0b2 in v8::internal::compiler::SinglePassRegisterAllocator::SpillRegister(v8::internal::compiler::RegisterIndex) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:2251:20
#19 0x55d663b9df64 in v8::internal::compiler::SinglePassRegisterAllocator::ReserveFixedRegister(v8::internal::compiler::UnallocatedOperand const*, int, v8::internal::MachineRepresentation, int, v8::internal::compiler::SinglePassRegisterAllocator::UsePosition) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:2647:5
#20 0x55d663ba2cac in ReserveFixedInputRegister ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:2617:3
#21 0x55d663ba2cac in v8::internal::compiler::MidTierRegisterAllocator::ReserveFixedRegisters(int) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:3202:12
#22 0x55d663ba0ac0 in v8::internal::compiler::MidTierRegisterAllocator::AllocateRegisters(v8::internal::compiler::InstructionBlock const*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:3024:5
#23 0x55d663ba3a49 in v8::internal::compiler::AllocateRegisters(v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:3273:15
#24 0x55d663f94197 in Run ../../v8/src/compiler/pipeline.cc:2588:5
#25 0x55d663f94197 in auto v8::internal::compiler::PipelineImpl::Runv8::internal::compiler::MidTierRegisterAllocatorPhase() ../../v8/src/compiler/pipeline.cc:1355:18
#26 0x55d663f904d9 in v8::internal::compiler::PipelineImpl::AllocateRegistersForMidTier(v8::internal::RegisterConfiguration const*, v8::internal::compiler::CallDescriptor*, bool) ../../v8/src/compiler/pipeline.cc:4550:3
#27 0x55d663f87598 in v8::internal::compiler::PipelineImpl::AllocateRegisters(v8::internal::compiler::CallDescriptor*, bool) ../../v8/src/compiler/pipeline.cc:4196:5
#28 0x55d663f88c90 in v8::internal::compiler::PipelineImpl::SelectInstructions(v8::internal::compiler::Linkage*) ../../v8/src/compiler/pipeline.cc:4106:10
#29 0x55d663f8ed69 in v8::internal::compiler::Pipeline::GenerateWasmCodeFromTurboshaftGraph(v8::internal::OptimizedCompilationInfo*, v8::internal::wasm::CompilationEnv*, v8::internal::compiler::WasmCompilationData&, v8::internal::compiler::MachineGraph*, v8::internal::wasm::FunctionBody const&, v8::internal::wasm::WasmFeatures*, v8::internal::compiler::CallDescriptor*) ../../v8/src/compiler/pipeline.cc:3807:7
#30 0x55d664244866 in v8::internal::compiler::turboshaft::ExecuteTurboshaftWasmCompilation(v8::internal::wasm::CompilationEnv*, v8::internal::compiler::WasmCompilationData&, v8::internal::wasm::WasmFeatures*) ../../v8/src/compiler/turboshaft/wasm-turboshaft-compiler.cc:51:8
#31 0x55d66374ff5a in v8::internal::wasm::WasmCompilationUnit::ExecuteFunctionCompilation(v8::internal::wasm::CompilationEnv*, v8::internal::wasm::WireBytesStorage const*, v8::internal::Counters*, v8::internal::wasm::WasmFeatures*) ../../v8/src/wasm/function-compiler.cc:158:18
#32 0x55d66374f1b0 in v8::internal::wasm::WasmCompilationUnit::ExecuteCompilation(v8::internal::wasm::CompilationEnv*, v8::internal::wasm::WireBytesStorage const*, v8::internal::Counters*, v8::internal::wasm::WasmFeatures*) ../../v8/src/wasm/function-compiler.cc:30:9
#33 0x55d6637b3afc in v8::internal::wasm::CompileLazy(v8::internal::Isolate*, v8::internal::Taggedv8::internal::WasmInstanceObject, int) ../../v8/src/wasm/module-compiler.cc:1211:48
#34 0x55d663576795 in v8::internal::__RT_impl_Runtime_WasmCompileLazy(v8::internal::RuntimeArgumentsWithoutHandles, v8::internal::Isolate*) ../../v8/src/runtime/runtime-wasm.cc:314:18
#35 0x55d663575ffe in v8::internal::Runtime_WasmCompileLazy(int, unsigned long*, v8::internal::Isolate*) ../../v8/src/runtime/runtime-wasm.cc:302:1
#36 0x55d6648e599f in Builtins_WasmCEntry setup-isolate-deserialize.cc
NOTE: libFuzzer has rudimentary signal handlers.
Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signal
CREDIT INFORMATION
Externally reported security bugs may appear in Chrome release notes. If
this bug is included, how would you like to be credited?
Reporter credit: Alan Goodman
Since my previous debug check report appeared to be well received, even if probably a duplicate here is another one. Looks like it might be turboshaft related again.
Context
This report concerns V8, the JavaScript and WebAssembly engine used by Google Chrome. The crash occurs in the mid-tier register allocator, reached while WebAssembly code is compiled through the Turboshaft pipeline. The report was filed through the Chrome Vulnerability Reward Program and the reporter asked to be credited as Alan Goodman.
The report itself is a debug-check failure found with libFuzzer, not a full exploit chain. The author notes that a previous debug check report of his appeared to be well received, and offers this one as probably a duplicate, suspecting it is Turboshaft related again.
Setup
The testing was done on Ubuntu 23.04 against a V8 checkout at commit [redacted]. The fuzzer was built with libFuzzer enabled and all sanitizers disabled, using the following GN arguments:
gn gen out/libfuzzernosan '--args=use_libfuzzer=true is_ubsan=false is_msan=false is_asan=false is_tsan=false is_debug=false enable_nacl=false'
The target binary is the WebAssembly compile fuzzer, built with ninja:
ninja -C out/libfuzzernosan/v8_wasm_compile_fuzzer
The crashing input is a file named min, run as a single input for one iteration:
$ /home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer min
Finding it
Running the fuzzer on the min input produced a fatal error rather than a memory-safety crash. libFuzzer reported the run parameters and then the V8 fatal error:
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 1788738389
INFO: Loaded 1 modules (1238938 inline 8-bit counters): 1238938 [0x55d664ef2d60, 0x55d6650214fa),
INFO: Loaded 1 PC tables (1238938 PCs): 1238938 [0x55d665021500,0x55d666308ea0),
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer: Running 1 inputs 1 time(s) each.
Running: min
#
# Fatal error in ../../v8/src/compiler/backend/mid-tier-register-allocator.cc, line 583
# Debug check failed: output_instr_index_ == definition_block->last_instruction_index() - 1 (19540 vs. 19551).
#
The failing check compares output_instr_index_ with definition_block->last_instruction_index() - 1. The two values differ: 19540 against 19551. The failing check compares output_instr_index_ with definition_block->last_instruction_index() - 1, and the two values differ: 19540 against 19551.
The stack trace shows the path that reached the check. The relevant frames, from the top of the V8 portion down, are:
#12 0x55d663b945b8 in v8::internal::compiler::VirtualRegisterData::EnsureSpillRange(v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:582:7
#13 0x55d663b947d6 in v8::internal::compiler::VirtualRegisterData::AddSpillUse(int, v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:599:3
#14 0x55d663b96123 in SpillOperand ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:644:3
#15 0x55d663b96123 in v8::internal::compiler::RegisterState::Register::SpillPendingUses(v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:1104:15
#16 0x55d663b95eaa in v8::internal::compiler::RegisterState::Register::Spill(v8::internal::compiler::AllocatedOperand, v8::internal::compiler::InstructionBlock const*, v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:1055:3
#17 0x55d663b9b0b2 in Spill ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:1172:17
#18 0x55d663b9b0b2 in v8::internal::compiler::SinglePassRegisterAllocator::SpillRegister(v8::internal::compiler::RegisterIndex) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:2251:20
#19 0x55d663b9df64 in v8::internal::compiler::SinglePassRegisterAllocator::ReserveFixedRegister(v8::internal::compiler::UnallocatedOperand const*, int, v8::internal::MachineRepresentation, int, v8::internal::compiler::SinglePassRegisterAllocator::UsePosition) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:2647:5
#20 0x55d663ba2cac in ReserveFixedInputRegister ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:2617:3
#21 0x55d663ba2cac in v8::internal::compiler::MidTierRegisterAllocator::ReserveFixedRegisters(int) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:3202:12
#22 0x55d663ba0ac0 in v8::internal::compiler::MidTierRegisterAllocator::AllocateRegisters(v8::internal::compiler::InstructionBlock const*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:3024:5
#23 0x55d663ba3a49 in v8::internal::compiler::AllocateRegisters(v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:3273:15
Above that, the pipeline frames show the compilation was triggered lazily for a WebAssembly function and went through Turboshaft:
#24 0x55d663f94197 in Run ../../v8/src/compiler/pipeline.cc:2588:5
#25 0x55d663f94197 in auto v8::internal::compiler::PipelineImpl::Run<v8::internal::compiler::MidTierRegisterAllocatorPhase>() ../../v8/src/compiler/pipeline.cc:1355:18
#26 0x55d663f904d9 in v8::internal::compiler::PipelineImpl::AllocateRegistersForMidTier(v8::internal::RegisterConfiguration const*, v8::internal::compiler::CallDescriptor*, bool) ../../v8/src/compiler/pipeline.cc:4550:3
#27 0x55d663f87598 in v8::internal::compiler::PipelineImpl::AllocateRegisters(v8::internal::compiler::CallDescriptor*, bool) ../../v8/src/compiler/pipeline.cc:4196:5
#28 0x55d663f88c90 in v8::internal::compiler::PipelineImpl::SelectInstructions(v8::internal::compiler::Linkage*) ../../v8/src/compiler/pipeline.cc:4106:10
#29 0x55d663f8ed69 in v8::internal::compiler::Pipeline::GenerateWasmCodeFromTurboshaftGraph(v8::internal::OptimizedCompilationInfo*, v8::internal::wasm::CompilationEnv*, v8::internal::compiler::WasmCompilationData&, v8::internal::compiler::MachineGraph*, v8::internal::wasm::FunctionBody const&, v8::internal::wasm::WasmFeatures*, v8::internal::compiler::CallDescriptor*) ../../v8/src/compiler/pipeline.cc:3807:7
#30 0x55d664244866 in v8::internal::compiler::turboshaft::ExecuteTurboshaftWasmCompilation(v8::internal::wasm::CompilationEnv*, v8::internal::compiler::WasmCompilationData&, v8::internal::wasm::WasmFeatures*) ../../v8/src/compiler/turboshaft/wasm-turboshaft-compiler.cc:51:8
#31 0x55d66374ff5a in v8::internal::wasm::WasmCompilationUnit::ExecuteFunctionCompilation(v8::internal::wasm::CompilationEnv*, v8::internal::wasm::WireBytesStorage const*, v8::internal::Counters*, v8::internal::wasm::WasmFeatures*) ../../v8/src/wasm/function-compiler.cc:158:18
#32 0x55d66374f1b0 in v8::internal::wasm::WasmCompilationUnit::ExecuteCompilation(v8::internal::wasm::CompilationEnv*, v8::internal::wasm::WireBytesStorage const*, v8::internal::Counters*, v8::internal::wasm::WasmFeatures*) ../../v8/src/wasm/function-compiler.cc:30:9
#33 0x55d6637b3afc in v8::internal::wasm::CompileLazy(v8::internal::Isolate*, v8::internal::Tagged<v8::internal::WasmInstanceObject>, int) ../../v8/src/wasm/module-compiler.cc:1211:48
#34 0x55d663576795 in v8::internal::__RT_impl_Runtime_WasmCompileLazy(v8::internal::RuntimeArgumentsWithoutHandles, v8::internal::Isolate*) ../../v8/src/runtime/runtime-wasm.cc:314:18
#35 0x55d663575ffe in v8::internal::Runtime_WasmCompileLazy(int, unsigned long*, v8::internal::Isolate*) ../../v8/src/runtime/runtime-wasm.cc:302:1
#36 0x55d6648e599f in Builtins_WasmCEntry setup-isolate-deserialize.cc
The crash is a libFuzzer: deadly signal raised through v8::base::OS::Abort() after V8_Fatal and the default DCHECK handler. libFuzzer notes that its signal handlers are rudimentary and suggests combining it with AddressSanitizer or similar for better crash reports.
Exploitation
There is no exploitation sequence in this report. The submission is a fuzzer-found debug check failure with the crashing input attached as min; the report does not describe a proof of concept that turns the failure into memory corruption or code execution.
Step 1: build the fuzzer
Generate the build with libFuzzer on and every sanitizer off, then build the WebAssembly compile fuzzer target:
gn gen out/libfuzzernosan '--args=use_libfuzzer=true is_ubsan=false is_msan=false is_asan=false is_tsan=false is_debug=false enable_nacl=false'
ninja -C out/libfuzzernosan/v8_wasm_compile_fuzzer
Step 2: run the input
$ /home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer min
The fuzzer loads the single input and runs it once. Compilation of a WebAssembly function is triggered lazily through Runtime_WasmCompileLazy, goes through ExecuteTurboshaftWasmCompilation, and reaches AllocateRegistersForMidTier. Inside the mid-tier register allocator, reserving a fixed input register forces a spill of a register that still has pending uses. Spilling those uses calls AddSpillUse, which calls EnsureSpillRange, and the debug check at line 583 fails because the recorded output instruction index (19540) is not one less than the definition block's last instruction index (19551).
Root cause
The report does not analyse the underlying code. What it establishes is the failing invariant: EnsureSpillRange in mid-tier-register-allocator.cc assumes that the spill range's output instruction is the instruction immediately before the last instruction of the definition block. When a fixed register is reserved and a register with pending uses is spilled, that assumption does not hold for this input, and the DCHECK fires. The author's own remark is that it looks like it might be Turboshaft related again, which is consistent with the stack going through GenerateWasmCodeFromTurboshaftGraph and ExecuteTurboshaftWasmCompilation.
Because the build has all sanitizers disabled, the run stops at the debug check rather than showing what would happen in a release build where the check is compiled out. The report does not say whether the mismatch would lead to incorrect register allocation or memory corruption.
Impact
Any real-world consequence would depend on whether the same mismatch can occur in a release build and what the allocator does with the inconsistent spill range, which this report does not establish.
Fix
The only actionable content is the crashing input and the exact build configuration needed to reproduce the check failure.
Variants to test
- Run the same
mininput against builds with AddressSanitizer or another sanitizer enabled, as libFuzzer itself suggests, to see whether the inconsistent spill range produces a memory-safety finding once the debug check is out of the way. - Build with
is_debug=trueand the same libFuzzer configuration to confirm the check fires reproducibly and to inspect the instruction block around indices 19540 and 19551. A positive result is the sameoutput_instr_index_ == definition_block->last_instruction_index() - 1failure with the same values. - Exercise the mid-tier register allocator with WebAssembly functions that force fixed input registers to be reserved while other registers still have pending uses, since that is the path in the stack (
ReserveFixedInputRegisterintoSpillRegisterintoSpillPendingUses). A positive result is any input that reachesEnsureSpillRangewith a spill range whose output instruction is not the penultimate instruction of its definition block. - Fuzz other WebAssembly compilation paths that go through Turboshaft, given the author's suspicion that the issue is Turboshaft related. A positive result is a similar debug check failure in the register allocator reached from
ExecuteTurboshaftWasmCompilation.
What happened, in plain words
A security researcher found a way to make Google Chrome's JavaScript and WebAssembly engine, called V8, crash in a controlled way while it was compiling a piece of WebAssembly code. The crash is not a normal crash that a user would see: it is a safety check inside the engine that fired because the engine's own internal assumptions did not hold. The researcher found it with an automated tool called a fuzzer, which throws large amounts of generated input at a program and watches for anything unusual.
The report was filed through the Chrome Vulnerability Reward Program, a scheme where Google pays people for reporting security problems in Chrome. The report was filed through the Chrome Vulnerability Reward Program and the reporter asked to be credited as Alan Goodman.
A few terms before we go further:
- V8 is the part of Chrome that reads and runs JavaScript (the language most web pages use) and WebAssembly (a faster, lower-level language that web pages can also run). Think of it as the kitchen where a restaurant turns a recipe (the code) into a finished dish (the running program).
- WebAssembly, often shortened to Wasm, is a binary format for code that runs in the browser. It is designed to be fast and compact, and it is often produced by compiling other languages such as C or Rust.
- A compiler is the program that translates code a human wrote into instructions the machine can run. V8 contains a compiler for WebAssembly.
- A register allocator is a part of a compiler that decides which of the processor's small, fast storage slots (registers) each value should live in while the code runs. Registers are scarce, so the allocator has to juggle them.
- A debug check, or DCHECK, is an assertion the developers put in the code to catch situations that should never happen. In a normal release build these checks are usually removed, so they cost nothing to users. In a debug or instrumented build they stop the program when the assumption is broken.
- A fuzzer is a program that generates many inputs and feeds them to a target program, looking for crashes. libFuzzer is one such tool, and it is the one used here.
- A sanitizer is a tool that adds extra checks to a program while it runs, to catch memory errors and similar problems. AddressSanitizer is a well-known example.
This report is a debug-check failure, not a full attack. The author says that a previous debug check report of his appeared to be well received, and offers this one as probably a duplicate, suspecting it is Turboshaft related again. Turboshaft is the name of a newer compiler pipeline inside V8, and the stack trace shows the code went through it.
Setting up the test
The testing was done on Ubuntu 23.04, a version of the Linux operating system, against a V8 checkout at a specific commit, [redacted]. A commit is a snapshot of the source code at a point in time, identified by a long string of characters. Pinning the exact commit matters because code changes constantly, and a bug may only exist in some versions.
The fuzzer was built with libFuzzer enabled and all sanitizers disabled. The build is configured with GN, a tool that generates build files, using these arguments:
gn gen out/libfuzzernosan '--args=use_libfuzzer=true is_ubsan=false is_msan=false is_asan=false is_tsan=false is_debug=false enable_nacl=false'
Line by line:
gn gen out/libfuzzernosantells GN to generate a build configuration in a folder calledout/libfuzzernosan. The folder name is just a label; here it hints at a libFuzzer build with no sanitizers.--args=...passes the build options.use_libfuzzer=trueturns on libFuzzer, so the resulting program can generate and run test inputs.is_ubsan=false,is_msan=false,is_asan=false,is_tsan=falseswitch off four sanitizers: UndefinedBehaviorSanitizer, MemorySanitizer, AddressSanitizer and ThreadSanitizer. Turning them off makes the build simpler and faster, and means the run will stop at V8's own debug checks rather than at a sanitizer report.is_debug=falsebuilds in a non-debug configuration, and the check still fired in this setup.enable_nacl=falsedisables Native Client, an older Chrome technology that is not needed here.
The target binary is the WebAssembly compile fuzzer, built with ninja, a build tool:
ninja -C out/libfuzzernosan/v8_wasm_compile_fuzzer
ninjais the build tool that actually compiles the code.-C out/libfuzzernosantells it to work inside that build folder.v8_wasm_compile_fuzzeris the name of the target: a fuzzer that feeds WebAssembly code to V8's compiler. The idea is to stress the part of V8 that turns Wasm into machine code.
The crashing input is a file named min, run as a single input for one iteration:
$ /home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer min
- The
$is the shell prompt, not part of the command. - The long path points to the fuzzer binary that was just built.
minis the name of the input file. The fuzzer is told to run that one file, once.
Finding it
Running the fuzzer on the min input produced a fatal error rather than a memory-safety crash. libFuzzer first reported its run parameters, then V8 stopped with a fatal error:
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 1788738389
INFO: Loaded 1 modules (1238938 inline 8-bit counters): 1238938 [0x55d664ef2d60, 0x55d6650214fa),
INFO: Loaded 1 PC tables (1238938 PCs): 1238938 [0x55d665021500,0x55d666308ea0),
/home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer: Running 1 inputs 1 time(s) each.
Running: min
#
# Fatal error in ../../v8/src/compiler/backend/mid-tier-register-allocator.cc, line 583
# Debug check failed: output_instr_index_ == definition_block->last_instruction_index() - 1 (19540 vs. 19551).
#
What each part means:
- The
INFOlines are libFuzzer telling you how it is running. The power schedule and seed control how it picks inputs; the seed is a number that makes a run reproducible. The counters and PC tables are instrumentation libFuzzer uses to know which parts of the code an input reaches. Running 1 inputs 1 time(s) eachconfirms it is running the single fileminonce.- The
Fatal errorline gives the file and line where V8 stopped:mid-tier-register-allocator.cc, line 583. The file name tells you this is the register allocator used in the middle tier of compilation. - The
Debug check failedline is the actual assertion. It compares two numbers:output_instr_index_anddefinition_block->last_instruction_index() - 1. The values in brackets, 19540 and 19551, are the two sides of the comparison. They differ, so the check fails.
In plain words: the check compares the spill range's output instruction index with the definition block's last instruction index minus one, and the two values differ. A spill range is the region of code over which a value that was pushed out of a register (spilled) has to be kept somewhere else, usually on the stack. The allocator assumed the output instruction would be the second-to-last instruction of the block, and it was not.
The stack trace shows the path that reached the check. A stack trace is a list of the function calls that were active when the program stopped, with the most recent call at the top. The relevant frames, from the top of the V8 portion down, are:
#12 0x55d663b945b8 in v8::internal::compiler::VirtualRegisterData::EnsureSpillRange(v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:582:7
#13 0x55d663b947d6 in v8::internal::compiler::VirtualRegisterData::AddSpillUse(int, v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:599:3
#14 0x55d663b96123 in SpillOperand ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:644:3
#15 0x55d663b96123 in v8::internal::compiler::RegisterState::Register::SpillPendingUses(v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:1104:15
#16 0x55d663b95eaa in v8::internal::compiler::RegisterState::Register::Spill(v8::internal::compiler::AllocatedOperand, v8::internal::compiler::InstructionBlock const*, v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:1055:3
#17 0x55d663b9b0b2 in Spill ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:1172:17
#18 0x55d663b9b0b2 in v8::internal::compiler::SinglePassRegisterAllocator::SpillRegister(v8::internal::compiler::RegisterIndex) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:2251:20
#19 0x55d663b9df64 in v8::internal::compiler::SinglePassRegisterAllocator::ReserveFixedRegister(v8::internal::compiler::UnallocatedOperand const*, int, v8::internal::MachineRepresentation, int, v8::internal::compiler::SinglePassRegisterAllocator::UsePosition) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:2647:5
#20 0x55d663ba2cac in ReserveFixedInputRegister ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:2617:3
#21 0x55d663ba2cac in v8::internal::compiler::MidTierRegisterAllocator::ReserveFixedRegisters(int) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:3202:12
#22 0x55d663ba0ac0 in v8::internal::compiler::MidTierRegisterAllocator::AllocateRegisters(v8::internal::compiler::InstructionBlock const*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:3024:5
#23 0x55d663ba3a49 in v8::internal::compiler::AllocateRegisters(v8::internal::compiler::MidTierRegisterAllocationData*) ../../v8/src/compiler/backend/mid-tier-register-allocator.cc:3273:15
Reading from the bottom up, because the bottom is the outermost call:
AllocateRegistersstarts the register allocation for a block of instructions.MidTierRegisterAllocator::AllocateRegistersandReserveFixedRegisterswork through the block, reserving registers that the code requires to be in specific places.ReserveFixedInputRegisterreserves a fixed register for an input to an instruction.ReserveFixedRegisterfinds that the register it needs is already in use, so it callsSpillRegisterto move the current value out of the way.SpillandSpillPendingUseshandle the uses of the spilled value that are still waiting to happen.SpillOperandandAddSpillUserecord that the value now lives in a spill slot.EnsureSpillRangesets up the range of instructions over which the spill is valid, and that is where the check at line 583 fails.
Above that, the pipeline frames show the compilation was triggered lazily for a WebAssembly function and went through Turboshaft:
#24 0x55d663f94197 in Run ../../v8/src/compiler/pipeline.cc:2588:5
#25 0x55d663f94197 in auto v8::internal::compiler::PipelineImpl::Run<v8::internal::compiler::MidTierRegisterAllocatorPhase>() ../../v8/src/compiler/pipeline.cc:1355:18
#26 0x55d663f904d9 in v8::internal::compiler::PipelineImpl::AllocateRegistersForMidTier(v8::internal::RegisterConfiguration const*, v8::internal::compiler::CallDescriptor*, bool) ../../v8/src/compiler/pipeline.cc:4550:3
#27 0x55d663f87598 in v8::internal::compiler::PipelineImpl::AllocateRegisters(v8::internal::compiler::CallDescriptor*, bool) ../../v8/src/compiler/pipeline.cc:4196:5
#28 0x55d663f88c90 in v8::internal::compiler::PipelineImpl::SelectInstructions(v8::internal::compiler::Linkage*) ../../v8/src/compiler/pipeline.cc:4106:10
#29 0x55d663f8ed69 in v8::internal::compiler::Pipeline::GenerateWasmCodeFromTurboshaftGraph(v8::internal::OptimizedCompilationInfo*, v8::internal::wasm::CompilationEnv*, v8::internal::compiler::WasmCompilationData&, v8::internal::compiler::MachineGraph*, v8::internal::wasm::FunctionBody const&, v8::internal::wasm::WasmFeatures*, v8::internal::compiler::CallDescriptor*) ../../v8/src/compiler/pipeline.cc:3807:7
#30 0x55d664244866 in v8::internal::compiler::turboshaft::ExecuteTurboshaftWasmCompilation(v8::internal::wasm::CompilationEnv*, v8::internal::compiler::WasmCompilationData&, v8::internal::wasm::WasmFeatures*) ../../v8/src/compiler/turboshaft/wasm-turboshaft-compiler.cc:51:8
#31 0x55d66374ff5a in v8::internal::wasm::WasmCompilationUnit::ExecuteFunctionCompilation(v8::internal::wasm::CompilationEnv*, v8::internal::wasm::WireBytesStorage const*, v8::internal::Counters*, v8::internal::wasm::WasmFeatures*) ../../v8/src/wasm/function-compiler.cc:158:18
#32 0x55d66374f1b0 in v8::internal::wasm::WasmCompilationUnit::ExecuteCompilation(v8::internal::wasm::CompilationEnv*, v8::internal::wasm::WireBytesStorage const*, v8::internal::Counters*, v8::internal::wasm::WasmFeatures*) ../../v8/src/wasm/function-compiler.cc:30:9
#33 0x55d6637b3afc in v8::internal::wasm::CompileLazy(v8::internal::Isolate*, v8::internal::Tagged<v8::internal::WasmInstanceObject>, int) ../../v8/src/wasm/module-compiler.cc:1211:48
#34 0x55d663576795 in v8::internal::__RT_impl_Runtime_WasmCompileLazy(v8::internal::RuntimeArgumentsWithoutHandles, v8::internal::Isolate*) ../../v8/src/runtime/runtime-wasm.cc:314:18
#35 0x55d663575ffe in v8::internal::Runtime_WasmCompileLazy(int, unsigned long*, v8::internal::Isolate*) ../../v8/src/runtime/runtime-wasm.cc:302:1
#36 0x55d6648e599f in Builtins_WasmCEntry setup-isolate-deserialize.cc
Again from the bottom up:
Builtins_WasmCEntryis the entry point from the running program into V8's WebAssembly support.Runtime_WasmCompileLazyand__RT_impl_Runtime_WasmCompileLazyare the runtime functions that trigger compilation of a Wasm function the first time it is called. This is what "lazy" means: the code is compiled on demand rather than all at once.CompileLazyand theWasmCompilationUnitfunctions set up the compilation of that one function.ExecuteTurboshaftWasmCompilationruns the Turboshaft pipeline, the newer compiler path.GenerateWasmCodeFromTurboshaftGraphturns the Turboshaft graph into machine code.SelectInstructions,AllocateRegistersandAllocateRegistersForMidTierare the pipeline stages that pick instructions and assign registers.Run<MidTierRegisterAllocatorPhase>runs the register allocator phase, which leads into the frames from the first trace.
The crash is a libFuzzer: deadly signal raised through v8::base::OS::Abort() after V8_Fatal and the default DCHECK handler. In plain words, V8 decided the situation was impossible, printed the message, and deliberately stopped the process. libFuzzer notes that its signal handlers are rudimentary and suggests combining it with AddressSanitizer or similar for better crash reports. A signal handler is the code that runs when the operating system tells a program something has gone wrong; libFuzzer's own handler is basic, so a sanitizer gives richer information.
Exploitation
There is no exploitation sequence in this report. The submission is a fuzzer-found debug check failure with the crashing input attached as min; the report does not describe a proof of concept that turns the failure into memory corruption or code execution. In other words, the researcher showed that the engine's internal assumption breaks, not that an attacker can use it to take over a browser.
Step 1: build the fuzzer
Generate the build with libFuzzer on and every sanitizer off, then build the WebAssembly compile fuzzer target:
gn gen out/libfuzzernosan '--args=use_libfuzzer=true is_ubsan=false is_msan=false is_asan=false is_tsan=false is_debug=false enable_nacl=false'
ninja -C out/libfuzzernosan/v8_wasm_compile_fuzzer
The first command writes the build configuration; the second compiles the fuzzer binary. Both are needed before any input can be run.
Step 2: run the input
$ /home/alan/chromium/src/out/libfuzzernosan/v8_wasm_compile_fuzzer min
The fuzzer loads the single input and runs it once. Compilation of a WebAssembly function is triggered lazily through Runtime_WasmCompileLazy, goes through ExecuteTurboshaftWasmCompilation, and reaches AllocateRegistersForMidTier. Inside the mid-tier register allocator, reserving a fixed input register forces a spill of a register that still has pending uses. Spilling those uses calls AddSpillUse, which calls EnsureSpillRange, and the debug check at line 583 fails because the recorded output instruction index (19540) is not one less than the definition block's last instruction index (19551).
Root cause
The report does not analyse the underlying code. What it establishes is the failing invariant: EnsureSpillRange in mid-tier-register-allocator.cc assumes that the spill range's output instruction is the instruction immediately before the last instruction of the definition block. An invariant is a rule the code expects to always be true. When a fixed register is reserved and a register with pending uses is spilled, that assumption does not hold for this input, and the DCHECK fires. The author's own remark is that it looks like it might be Turboshaft related again, which is consistent with the stack going through GenerateWasmCodeFromTurboshaftGraph and ExecuteTurboshaftWasmCompilation.
Because the build has all sanitizers disabled, the run stops at the debug check rather than showing what would happen in a release build where the check is compiled out. The report does not say whether the mismatch would lead to incorrect register allocation or memory corruption.
Impact
Any real-world consequence would depend on whether the same mismatch can occur in a release build and what the allocator does with the inconsistent spill range, which this report does not establish.
Fix
The only actionable content is the crashing input and the exact build configuration needed to reproduce the check failure.
Variants to test
- Run the same
mininput against builds with AddressSanitizer or another sanitizer enabled, as libFuzzer itself suggests, to see whether the inconsistent spill range produces a memory-safety finding once the debug check is out of the way. - Build with
is_debug=trueand the same libFuzzer configuration to confirm the check fires reproducibly and to inspect the instruction block around indices 19540 and 19551. A positive result is the sameoutput_instr_index_ == definition_block->last_instruction_index() - 1failure with the same values. - Exercise the mid-tier register allocator with WebAssembly functions that force fixed input registers to be reserved while other registers still have pending uses, since that is the path in the stack (
ReserveFixedInputRegisterintoSpillRegisterintoSpillPendingUses). A positive result is any input that reachesEnsureSpillRangewith a spill range whose output instruction is not the penultimate instruction of its definition block. - Fuzz other WebAssembly compilation paths that go through Turboshaft, given the author's suspicion that the issue is Turboshaft related. A positive result is a similar debug check failure in the register allocator reached from
ExecuteTurboshaftWasmCompilation.
Glossary
- AddressSanitizer: a tool that adds checks to a running program to catch memory errors such as reading or writing outside an allocated area.
- Assertion / debug check (DCHECK): a statement in the code that a condition must be true; if it is not, the program stops in a debug or instrumented build.
- Bounty: a payment made by a company to someone who reports a security problem.
- Build configuration: the set of options that determine how a program is compiled, such as which tools and checks are included.
- Chrome Vulnerability Reward Program: Google's scheme for paying people who report security issues in Chrome.
- Commit: a snapshot of a source code repository at a particular point in time, identified by a long string.
- Compiler: a program that translates code written in one language into instructions a machine can run.
- CVE: a public identifier for a known security vulnerability, assigned so people can refer to it unambiguously.
- Debug build: a build that keeps extra checks and information useful for finding problems, at the cost of speed.
- Definition block: a block of instructions in the compiled code within which a value is defined.
- Fuzzer: a program that generates many inputs and feeds them to a target program to find crashes.
- GN: a tool that generates build files for a project.
- Invariant: a rule or condition that the code expects to always hold.
- libFuzzer: a fuzzing tool that generates inputs and runs them against a target, reporting crashes.
- Memory corruption: a situation where a program writes to memory it should not, which can sometimes be exploited by an attacker.
- Mid-tier register allocator: the part of V8's compiler that assigns processor registers for the middle tier of compilation.
- Ninja: a build tool that compiles source code according to generated build files.
- Register: a small, fast storage slot inside a processor, used to hold values while code runs.
- Register allocator: the compiler component that decides which register each value should use.
- Release build: a build intended for normal use, usually without debug checks.
- Sanitizer: a tool that adds runtime checks to catch memory or behaviour errors.
- Seed: a number that makes a fuzzer's random choices reproducible.
- Signal handler: code that runs when the operating system sends a program a signal, such as a crash notification.
- Spill: moving a value out of a register into memory (usually the stack) because the register is needed for something else.
- Spill range: the region of code over which a spilled value must be kept in its spill location.
- Stack trace: a list of the function calls active when a program stopped, with the most recent call at the top.
- Turboshaft: a newer compiler pipeline inside V8.
- Ubuntu: a version of the Linux operating system.
- V8: the JavaScript and WebAssembly engine used by Google Chrome.
- WebAssembly (Wasm): a compact binary format for code that runs in the browser, often produced by compiling other languages.
- WebAssembly compile fuzzer: a fuzzer that feeds WebAssembly code to V8's compiler to look for crashes.