research
← All research

V8 sandbox escape via TurboFan formal-count mismatch

Description

TurboFan is able to create a single direct JavaScript call from two inconsistent snapshots of the callee signature. During optimization, an attacker can temporarily change the in-cage SharedFunctionInfo::formal_parameter_count from 2 to 4. Afterwards, JSTypedLowering::ReduceJSCall() trusts that value then inserts two undefined arguments, and sizes the call descriptor from it. Attacker code can restore the SFI before executing the optimized code, while the trusted JSDispatchTable has retained the authentic, original count of 2.

The arm64 backend accepts the call because it checks only that the generated argument count is, at least, the trusted count. The callee therefore returns using count 2 while the caller’s compiled frame model expects count 4, leaving SP at 16 bytes lower than expected. A later index reload aliases an attacker-controlled Float64 spill: its low 32 bits pass the bounds check, but the full 64-bit value feeds the final address calculation.

Root cause

JSTypedLowering::ReduceJSCall() uses modifiable SFI state for arguments padding and GetJSCallDescriptor(). The arm64 kArchCallJSFunction path reads the trusted JDT count instead, then accepts num_arguments >= expected_num_arguments. That difference doesn’t bind padding, descriptor shape, dispatch signature, or return-time stack cleanup to a given TurboFan signature instantiation.

Impact

The primitive is an exact native QWORD read/write outside the V8 sandbox. The video below shows how the proof of concept resolves the d8 image, isolate, trusted-pointer table, and live WasmTrustedInstanceData, and then overwrites only jump_table_start. WasmCompileLazy branches to a mov x1, x2; br x3 bridge with controlled arguments and reaches d8’s execvp stub, ending up on command execution.

Proof of concept

Fig. 1 - V8 sandbox escape on Chromium 152.0.7977.65 and V8 15.2.124.18

Fig. 2 - Arbitrary code execution via d8 on Chromium 152.0.7977.65