Skip to content
Memory corruption Advisory Advanced CVE-2026-16418

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.cc
  • src/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

  1. Setup: An attacker defines a bound function: const CC = Function.prototype.call.bind(Function.prototype.call);. In an optimized function, a 2-way target Phi_A (cond ? Function.prototype.call : userFn) and a 6-way receiver Phi_B from a switch statement are created. The bound function is invoked: CC(Phi_A, Phi_B).

  2. JSBoundFunction Unwrapping: JSCallReducer::ReduceJSCall (src/compiler/js-call-reducer.cc:5186) unwraps the constant JSBoundFunction in-place. The node's Target and Receiver become Function.prototype.call (FPC), and the node is recursively reduced via ReduceFunctionPrototypeCall (:3468).

  3. Argument Shifting: Because the target is FPC, ReduceFunctionPrototypeCall shifts 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.

  4. Inlining Heuristic Snapshot: JSInliningHeuristic::Reduce (src/compiler/js-inlining-heuristic.cc:213) processes the node. CollectFunctions (:145) snapshots target = Phi_A (polymorphism of 2). This satisfies the snapshot-time bounds check value_input_count <= functions_size (:167). The candidate is deferred, and the node's ID is marked in seen_ (:227), blocking future re-snapshots.

  5. Target Collapse: During the GraphReducer fixpoint iterations, a higher-priority candidate is inlined first, folding the condition feeding Phi_A to true. DeadCodeElimination::ReduceLoopOrMerge simplifies Phi_A to its surviving constant input, Function.prototype.call.

  6. The Arity-0 Target Rewrite: JSCallReducer revisits the node. ReduceFunctionPrototypeCall runs again with arity == 0. It executes the if (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 receiver Phi). Crucially, because this rewrite manipulates inputs via ReplaceInput rather than property loads, no CheckMaps nodes are inserted into the effect chain. seen_ prevents the heuristic from re-snapshotting the node.

  7. Stale Candidate Finalization: JSInliningHeuristic::Finalize (:346) pops the stale candidate. Re-validation occurs (:360-361), but checks only IsInlineeOpcode and !IsDead(). InlineCandidate (:782) allocates fixed-size stack arrays based on kMaxCallPolymorphism (4):

    C++
    // src/compiler/js-inlining-heuristic.cc:805-806
    Node* calls[kMaxCallPolymorphism + 1];     // size 5
    Node* if_successes[kMaxCallPolymorphism];  // size 4
    
  8. TryReuseDispatch and Overflow: TryReuseDispatch (:493) extracts the live callee (Phi_B). Structural checks (:586-681) pass perfectly because the JSBoundFunction unwrapping bypassed CheckMaps insertions. 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, overflowing if_successes (size 4) and calls (size 5), clobbering adjacent compiler stack memory.

  9. 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 on candidate.can_inline_function[i] and candidate.bytecode[i] for indices $\geq 4$.

  10. Exploitation Impact: Under modern compilers (e.g., Clang with Stack Protector), arrays are typically packed adjacently. if_successes[4] reliably aliases calls[0]. Overwriting these arrays introduces corrupted Node* pointers into the compiler graph. Because these corrupted pointers are passed to inliner_.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:

C++
// 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): Enforces value_input_count <= functions_size and inserts seen_.insert(node->id());, blocking re-snapshot.
  • Finalize re-validation is opcode + IsDead only (:360-361): Checks IsInlineeOpcode and !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 no CHECK_LE against kMaxCallPolymorphism (4).
  • Fixed-size sinks (:805-806, 823, 833, 846, 858/866): Stack arrays are declared as Node* calls[kMaxCallPolymorphism + 1] and Node* if_successes[kMaxCallPolymorphism].
  • JSCallReducer GraphReducer integration (pipeline.cc:942-952, graph-reducer.cc:71-91): Reducers run in a fixpoint loop, allowing JSCallReducer to run on revisited nodes between consecutive JSInliningHeuristic::Finalize() iterations.
  • ReduceFunctionPrototypeCall Target Shift (js-call-reducer.cc:3494-3510): Shifts receiver to target via node->ReplaceInput(n.TargetIndex(), n.receiver()) when arity == 0. Opcode remains kJSCall, bypassing checks. No CheckMaps nodes are added by this rewrite (unlike property loads like t.call(r)), allowing TryReuseDispatch structural 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 by if_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.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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

  1. Define a bound function wrapping Function.prototype.call and invoke it with a two-way target Phi and a six-way receiver Phi.
  2. The call reducer unwraps the bound function and reduces it as a Function.prototype.call, shifting inputs until the arity reaches zero.
  3. The inlining heuristic snapshots the two-way target Phi, which passes the width check, and marks the node so it is not snapshotted again.
  4. Another candidate is inlined first, folding the condition so the target Phi collapses to a constant.
  5. The call reducer revisits the node at arity zero and replaces the target with the six-way receiver Phi, without inserting map checks.
  6. 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.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.