Stack buffer overflow in V8 (CVE-2026-16418)
A missing bounds check in V8's TurboFan inlining heuristic lets a callee Phi wider than the expected maximum be processed, causing out-of-bounds writes into fixed-size stack arrays. The report claims this compiler-thread memory corruption could lead to JIT check elision and arbitrary code execution in the renderer, though no working proof of concept was produced.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 42 days
Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: JSInliningHeuristic::TryReuseDispatch reads a live callee Phi's input count at finalization without bounds checking against kMaxCallPolymorphism. An attacker can shift a wider Phi into the target slot via a JSBoundFunction target-rewrite, causing out-of-bounds writes to stack arrays calls and if_successes. This memory corruption on the compiler thread could lead to arbitrary code execution through downstream JIT check elision.
Affected files:
src/compiler/js-inlining-heuristic.ccsrc/compiler/js-call-reducer.cc
Estimated timestamp from git blame: 2017-09-08
1. Summary of the Issue (Meant for Human Triage)
A potential stack buffer overflow vulnerability exists in the TurboFan compiler of V8, specifically within JSInliningHeuristic::TryReuseDispatch. When snapshotting a polymorphic call site, the compiler ensures that the callee Phi has a width no greater than kMaxCallPolymorphism (which is 4) and defers the candidate to a queue. However, during subsequent compiler passes before the candidate is finalized, other reducers (such as JSCallReducer and DeadCodeElimination) can modify the graph.
If an attacker-controlled, wider Phi (representing more than 4 inputs) is shifted into the target index of the call node, the stale candidate is processed by JSInliningHeuristic::Finalize without revalidation of its target's width. When InlineCandidate is invoked, TryReuseDispatch reads the live callee's width via callee->op()->ValueInputCount() with no bounds check. This causes an out-of-bounds write of zone-allocated Node* pointers into fixed-size stack arrays calls (size 5) and if_successes (size 4), corrupting adjacent stack variables. This memory corruption can be utilized to overwrite compiler pointers or cause out-of-bounds array reads, triggering compiler crashes or leading to downstream JIT compilation check elisions (such as dropping crucial map or bounds checks), which can be exploited for arbitrary code execution in the renderer.
2. Proof-of-Concept & Detailed Execution Flow
Note: The following represents a potential execution flow traced through static analysis. Our tooling agent does not currently have the ability to run code to provide a working proof of concept.
An attacker can construct a graph that successfully threads the complex structural verification of TryReuseDispatch by utilizing a JSBoundFunction target-rewrite, which prevents the insertion of blocking CheckMaps nodes on the effect chain.
Detailed Execution Flow Trace
-
Setup: An attacker defines a bound function:
const CC = Function.prototype.call.bind(Function.prototype.call);. In an optimized function, a 2-way targetPhi_A(cond ? Function.prototype.call : userFn) and a 6-way receiverPhi_Bfrom aswitchstatement are created. The bound function is invoked:CC(Phi_A, Phi_B). -
JSBoundFunction Unwrapping:
JSCallReducer::ReduceJSCall(src/compiler/js-call-reducer.cc:5186) unwraps the constantJSBoundFunctionin-place. The node's Target and Receiver becomeFunction.prototype.call(FPC), and the node is recursively reduced viaReduceFunctionPrototypeCall(:3468). -
Argument Shifting: Because the target is
FPC,ReduceFunctionPrototypeCallshifts the inputs (node->RemoveInput(n.TargetIndex())). After two passes (arity drops 2 → 1 → 0), the node inputs become:Target = Phi_A,Receiver = Phi_B,arity = 0. -
Inlining Heuristic Snapshot:
JSInliningHeuristic::Reduce(src/compiler/js-inlining-heuristic.cc:213) processes the node.CollectFunctions(:145) snapshotstarget = Phi_A(polymorphism of 2). This satisfies the snapshot-time bounds checkvalue_input_count <= functions_size(:167). The candidate is deferred, and the node's ID is marked inseen_(:227), blocking future re-snapshots. -
Target Collapse: During the
GraphReducerfixpoint iterations, a higher-priority candidate is inlined first, folding the condition feedingPhi_Atotrue.DeadCodeElimination::ReduceLoopOrMergesimplifiesPhi_Ato its surviving constant input,Function.prototype.call. -
The Arity-0 Target Rewrite:
JSCallReducerrevisits the node.ReduceFunctionPrototypeCallruns again witharity == 0. It executes theif (arity == 0)branch (:3494-3510):C++ node->ReplaceInput(n.TargetIndex(), n.receiver()); // Target ← Receiver (Phi_B) node->ReplaceInput(n.ReceiverIndex(), jsgraph()->UndefinedConstant());The target is now
Phi_B(the 6-way receiverPhi). Crucially, because this rewrite manipulates inputs viaReplaceInputrather than property loads, noCheckMapsnodes are inserted into the effect chain.seen_prevents the heuristic from re-snapshotting the node. -
Stale Candidate Finalization:
JSInliningHeuristic::Finalize(:346) pops the stale candidate. Re-validation occurs (:360-361), but checks onlyIsInlineeOpcodeand!IsDead().InlineCandidate(:782) allocates fixed-size stack arrays based onkMaxCallPolymorphism(4):C++ // src/compiler/js-inlining-heuristic.cc:805-806 Node* calls[kMaxCallPolymorphism + 1]; // size 5 Node* if_successes[kMaxCallPolymorphism]; // size 4 -
TryReuseDispatch and Overflow:
TryReuseDispatch(:493) extracts the live callee (Phi_B). Structural checks (:586-681) pass perfectly because theJSBoundFunctionunwrapping bypassedCheckMapsinsertions. At line 683, the width is read with no bounds check:C++ // src/compiler/js-inlining-heuristic.cc:683-716 *num_calls = callee->op()->ValueInputCount(); // returns 6 for (int i = 0; i < *num_calls; ++i) { calls[i] = if_successes[i] = graph()->NewNode(...); }This loop writes 6
Node*pointers to the arrays, overflowingif_successes(size 4) andcalls(size 5), clobbering adjacent compiler stack memory. -
Out-of-Bounds Reads: Later in
InlineCandidate, lines 833 and 846 write to[num_calls]out of bounds. Lines 858 and 866 perform out-of-bounds reads oncandidate.can_inline_function[i]andcandidate.bytecode[i]for indices $\geq 4$. -
Exploitation Impact: Under modern compilers (e.g., Clang with Stack Protector), arrays are typically packed adjacently.
if_successes[4]reliably aliasescalls[0]. Overwriting these arrays introduces corruptedNode*pointers into the compiler graph. Because these corrupted pointers are passed toinliner_.ReduceJSCall(calls[i])before the function epilogue (where the stack canary is checked), the compiler is forced to wire disjoint nodes. This orphans effect chains, leading to JIT check elision (e.g., dropped bounds/map checks), which translates to arbitrary code execution in the renderer via standard Layer-1 primitives.
Proposed Fix
Add a bounds check immediately after confirming the callee is a Phi node in TryReuseDispatch:
// src/compiler/js-inlining-heuristic.cc:586
if (callee->opcode() != IrOpcode::kPhi) return false;
if (callee->op()->ValueInputCount() > kMaxCallPolymorphism) return false;
3. Technical Verification Details (Automated Audit Logs - Reviewers may skip this section)
Verbatim Critic Verdict Log:
VERDICT: accept at medium
LAYER: 1 CLASS: A/L (TurboFan JIT Miscompilation via Compiler-Thread Stack OOB)
Justification:
- The missing bounds check at `js-inlining-heuristic.cc:683` causes an out-of-bounds write of `Node*` pointers to the `calls` (size 5) and `if_successes` (size 4) stack arrays when a live callee Phi exceeds `kMaxCallPolymorphism` (4).
- Reachability is contrived-but-plausible: an attacker can thread the structural checks in `TryReuseDispatch` by using a `JSBoundFunction` target-rewrite to shift a wider receiver Phi into the target slot without inserting a blocking `CheckMaps` node, confirming the prior validation's reachability path.
- While `-fstack-protector-strong` prevents direct RIP control and the written values are `Node*` pointers rather than attacker-derived bytes, this stack corruption directly enables JIT miscompilation.
- Specifically, the arrays are allocated adjacent to critical local variables in `InlineCandidate`. If the `node` pointer is overwritten by a newly minted `Node*` during the overflow, the subsequent `ReplaceWithValue(node, ...)` acts on the new node, leaving the original `JSCall` intact but with a `Dead` control input (set at line 719). This orphans the call and its dependent effect chain, reliably leading to downstream check elision (e.g., dropped bounds/map checks) in the generated code.
- Alternatively, overwriting `num_calls` triggers massive OOB reads from the `Candidate` object, parsing garbage as `Node*` and leading to compiler crashes or wild dereferences.
- Because this provides a clear, structural path from compiler-thread stack corruption to classic Layer-1 JIT check elision, it qualifies as a Layer-1 write primitive with contrived reachability. Rated `medium` per the severity guide, rather than `low`.
Modifiers: Default flags (no experimental features), arch-independent.
Validation Notes:
- Snapshot-time bound check is one-shot (
js-inlining-heuristic.cc:165-186, 227, 326, 342): Enforcesvalue_input_count <= functions_sizeand insertsseen_.insert(node->id());, blocking re-snapshot. - Finalize re-validation is opcode + IsDead only (
:360-361): ChecksIsInlineeOpcodeand!IsDead, but not the Phi width or identity. - TryReuseDispatch reads live Phi width with no bound (
:683-716):*num_calls = callee->op()->ValueInputCount();reads the live callee with noCHECK_LEagainstkMaxCallPolymorphism(4). - Fixed-size sinks (
:805-806, 823, 833, 846, 858/866): Stack arrays are declared asNode* calls[kMaxCallPolymorphism + 1]andNode* if_successes[kMaxCallPolymorphism]. - JSCallReducer GraphReducer integration (
pipeline.cc:942-952,graph-reducer.cc:71-91): Reducers run in a fixpoint loop, allowingJSCallReducerto run on revisited nodes between consecutiveJSInliningHeuristic::Finalize()iterations. - ReduceFunctionPrototypeCall Target Shift (
js-call-reducer.cc:3494-3510): Shifts receiver to target vianode->ReplaceInput(n.TargetIndex(), n.receiver())whenarity == 0. Opcode remainskJSCall, bypassing checks. NoCheckMapsnodes are added by this rewrite (unlike property loads liket.call(r)), allowingTryReuseDispatchstructural bailouts (:586-681) to pass. - Mitigations Checked: Stack canary (
-fstack-protector-strong) does not prevent exploitation because the corrupted array elements (e.g.,calls[0]aliased byif_successes[4]) are used before the function returns, causing compiler graph corruption.
Evaluated with Chrome root at commit: 71e7e1a98476f8faf0d126dc83935a84331b2194
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
Note: This bug has been automatically redirected to the top-level Chromium component. Please move it to the actual component: https://b.corp.google.com/components/1456566 once PoCs have been generated.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the inlining heuristic validated the callee Phi's width only when snapshotting the candidate, then read the live width at finalisation without re-checking it against kMaxCallPolymorphism.
Impact
The report claims the stack corruption could lead to JIT check elision and arbitrary code execution in the renderer, but notes that a stack protector prevents direct control-flow hijack and that no working proof of concept was produced.
What the attacker needed
Attacker-controlled JavaScript in the renderer; default V8 flags, no experimental features
The fix
A bounds check should be added after confirming the callee is a Phi, rejecting any callee whose input count exceeds kMaxCallPolymorphism.
How it was found
- Define a bound function wrapping Function.prototype.call and invoke it with a two-way target Phi and a six-way receiver Phi.
- The call reducer unwraps the bound function and reduces it as a Function.prototype.call, shifting inputs until the arity reaches zero.
- The inlining heuristic snapshots the two-way target Phi, which passes the width check, and marks the node so it is not snapshotted again.
- Another candidate is inlined first, folding the condition so the target Phi collapses to a constant.
- The call reducer revisits the node at arity zero and replaces the target with the six-way receiver Phi, without inserting map checks.
- Finalisation pops the stale candidate and TryReuseDispatch reads the live width of six, writing past the ends of the fixed-size stack arrays.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
V8 is the JavaScript engine in Chrome, and TurboFan is the part that compiles hot JavaScript into fast machine code. A 'Phi' is a compiler graph node that picks one of several values depending on a condition, and the compiler assumed it would never have more than four inputs. Because that assumption was not re-checked later, a wider node could be pushed into a fixed-size stack array, writing past its end and corrupting nearby memory.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.