Out of bounds read in V8 (CVE-2026-11075)
A type narrowing bug in TurboFan's OperationTyper causes the compiler to compute an incorrectly narrow result type for additive safe integer operations, leading to wrong JavaScript results after algebraic simplification and branch elimination. An attacker could exploit this to cause incorrect program behaviour, potentially leading to out-of-bounds reads.
Originally disclosed on Chrome VRP
- Fix shipped in 58 days
VULNERABILITY DETAILS
Summary
A type narrowing bug in TurboFan's OperationTyper::SpeculativeAdditiveSafeIntegerAdd causes the compiler to compute an incorrectly narrow result type when the mathematical sum can exceed the kAdditiveSafeInteger range [-2^52, 2^52-1]. The function intersects the result type with kAdditiveSafeInteger when either input is in range (OR condition), but when both inputs are in range and their sum exceeds the range, the intersection clips the result to just 2 values instead of 2^32. After algebraic simplification of (x + C) - C -> x, the incorrect type Range(0, 1) persists on the result node, causing TypeNarrowingReducer to fold comparisons and ConstantFoldingReducer to eliminate reachable branches, producing wrong JavaScript results. The bug is reproducible on all 64-bit architectures with default V8 flags and no special command-line options.
Overview
The root cause is in OperationTyper::SpeculativeAdditiveSafeIntegerAdd (src/compiler/operation-typer.cc:721-728). The function intersects the addition result type with kAdditiveSafeInteger (range [-2^52, 2^52-1]) when either input type is a subset of kAdditiveSafeInteger (OR condition on line 723). This creates an incorrectly narrow result type when the mathematical sum can exceed the kAdditiveSafeInteger bounds, even though both inputs individually are within range.
When a subsequent subtraction of the same constant creates an algebraic identity (x + C) - C, the MachineOperatorReducer eliminates both operations and their runtime overflow checks. The incorrect type Range(0, 1) -- computed from the clipped intermediate -- persists on the result node, causing TypeNarrowingReducer to fold comparisons and ConstantFoldingReducer to eliminate branches, producing wrong JavaScript results.
Detail
The vulnerable code in OperationTyper::SpeculativeAdditiveSafeIntegerAdd:
// src/compiler/operation-typer.cc:721-728
Type OperationTyper::SpeculativeAdditiveSafeIntegerAdd(Type lhs, Type rhs) {
Type result = SpeculativeNumberAdd(lhs, rhs);
if (lhs.Is(cache_->kAdditiveSafeInteger) || // <-- OR condition: only ONE input needs to be in range
rhs.Is(cache_->kAdditiveSafeInteger)) {
return Type::Intersect(result, cache_->kAdditiveSafeInteger, zone()); // <-- clips result to [-2^52, 2^52-1]
}
return result;
}
And the corresponding subtraction:
// src/compiler/operation-typer.cc:730-738
Type OperationTyper::SpeculativeAdditiveSafeIntegerSubtract(Type lhs,
Type rhs) {
Type result = SpeculativeNumberSubtract(lhs, rhs);
if (lhs.Is(cache_->kAdditiveSafeInteger) ||
rhs.Is(cache_->kAdditiveSafeInteger)) {
return Type::Intersect(result, cache_->kAdditiveSafeInteger, zone());
}
return result;
}
How the miscompilation occurs (in pipeline execution order):
-
Incorrect Type Computation (Typer phase): For
ix(x >>> 0, Uint32 range[0, 2^32-1]) -- which is a subset ofkAdditiveSafeInteger-- adding constantBASE = 2^52 - 2producesSpeculativeNumberAddresultRange(4503599627370494, 4503603922337789). The OR condition triggers (both inputs are individually withinkAdditiveSafeInteger), and intersection withkAdditiveSafeIntegerclips this toRange(4503599627370494, 4503599627370495)-- just 2 possible values instead of 2^32. -
Type Propagation (Typer phase): The subtraction
sum - BASEis typed asRange(0, 1)bySpeculativeAdditiveSafeIntegerSubtract, because the subtraction ranger computesRange(4503599627370494, 4503599627370495) - Range(4503599627370494, 4503599627370494) = Range(0, 1). The actual mathematical range should be[0, 2^32-1]. -
Algebraic Simplification (LateOptimization phase): The
MachineOperatorReducer(src/compiler/machine-operator-reducer.cc:1179-1196) converts(x + C) - Cintox + C + (-C), then constant-foldsC + (-C) = 0viaReduceInt64Add(src/compiler/machine-operator-reducer.cc:1147-1155), resulting inx + 0 = x. This eliminates both the addition and subtraction operations along with theirCheckedAdditiveSafeIntegerAdd/Subruntime overflow checks. The incorrect typeRange(0, 1)from step 2 persists on the result node even though the actual runtime value is the unmodifiedx >>> 0. -
Comparison Folding (TypedOptimizations phase):
TypeNarrowingReducer(src/compiler/type-narrowing-reducer.cc:33-34) foldsidx < 2tosingleton_truebecauseRange(0, 1).Max() = 1 < 2:C++ // src/compiler/type-narrowing-reducer.cc:33-34 if (left_type.Max() < right_type.Min()) { new_type = op_typer_.singleton_true(); } -
Branch Elimination (TypedOptimizations phase):
ConstantFoldingReducer(src/compiler/constant-folding-reducer.cc:31-32) detects the singleton type and replaces the comparison with a constant, causing branch elimination to remove the reachable false branch:C++ // src/compiler/constant-folding-reducer.cc:31-32 } else if (type.Is(Type::PlainNumber()) && type.Min() == type.Max()) { result = jsgraph->ConstantNoHole(type.Min());
Trigger Conditions
- Target must be a 64-bit architecture (
additive_safe_int_feedbackflag istrueby default only on 64-bit;src/flags/flag-definitions.h:860-877) - The addition operand must be within
kAdditiveSafeIntegerrange (e.g.,x >>> 0produces Uint32, a subset) - The constant added must be close to
kMaxAdditiveSafeInteger(2^52 - 1) so that the sum can exceed the range - The addition must be paired with a subtraction of the same constant, enabling algebraic simplification
- The result of the add-sub pair must be used in a comparison that can be folded by TypeNarrowingReducer
- The function must be compiled by TurboFan (requires sufficient warmup or
%OptimizeFunctionOnNextCall)
Version
Reproduced Version
mainbranch latest commit (2026/04/06):01333f9ce95- V8 14.9.0
Bisect
The commit 0a1fae9e77c6d8e85d8197b4f4396815ec9194b9 introduces this bug.
commit 0a1fae9e77c6d8e85d8197b4f4396815ec9194b9
Author: Victor Gomes <[email protected]>
Date: Tue Feb 11 14:13:21 2025 +0100
[turbofan] Use AdditiveSafeInt feedback for faster int add/sub
Add Int53 addition feedback and use it during simplified lowering
to optimize integer addition and subtraction. When one of the inputs
is known to be within the Int53 range (since the check is relatively
expensive), we can use a shifted integer addition instead of floating
addition.
AdditiveSafeInteger (Int53) is used instead of SafeInteger because
the safe integer range (-2^53 + 1 to 2^53 -1) excludes -2^53.
Using SafeInteger directly would require an additional check after
the operation to ensure the result remains within the valid bounds.
This change does *not* implement Maglev-specific optimizations.
Bug: 384959125
Change-Id: I7b54d075c55ab7828e407cec03933a34be6247d5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6038008
Reviewed-by: Nico Hartmann <[email protected]>
Reviewed-by: Leszek Swirski <[email protected]>
Commit-Queue: Victor Gomes <[email protected]>
Cr-Commit-Position: refs/heads/main@{#98643}
The first V8 milestone branch that contains this commit is branch-heads/13.5 (Chrome M135). V8 branch-heads/13.4 does NOT contain the commit.
Reproduction Case
Release Build
out/x64.release/d8 --allow-natives-syntax poc.js
Result:
=== Wrong Result ===
[Interpreter] f(5) = 5
[TurboFan] f(5) = -1
Optimized: true
Debug Build
out/x64.debug/d8 --allow-natives-syntax poc.js
Result:
=== Wrong Result ===
[Interpreter] f(5) = 5
[TurboFan] f(5) = -1
Optimized: true
Also confirmed on ASAN release build (out/x64.release_asan/d8 --allow-natives-syntax poc.js) with identical results.
PoC Code
// Run: out/x64.release/d8 --allow-natives-syntax poc.js
const BASE = 4503599627370494; // 2^52 - 2
function f_interp(x) {
let ix = x >>> 0;
let idx = (ix + BASE) - BASE;
if (idx < 2) return -1;
return idx;
}
// Separate function to avoid feedback pollution from f_interp(5),
// which would record idx=5 and prevent AdditiveSafeInteger speculation.
function f_jit(x) {
let ix = x >>> 0;
let idx = (ix + BASE) - BASE;
if (idx < 2) return -1;
return idx;
}
// --- Interpreter ---
const interp = f_interp(5);
// --- TurboFan (train only with 0,1 so feedback stays AdditiveSafeInteger) ---
%PrepareFunctionForOptimization(f_jit);
for (let i = 0; i < 10000; i++) { f_jit(0); f_jit(1); }
%OptimizeFunctionOnNextCall(f_jit);
f_jit(0);
const opt = f_jit(5);
print("=== Wrong Result ===");
print("[Interpreter] f(5) = " + interp); // 5 (correct)
print("[TurboFan] f(5) = " + opt); // -1 (wrong)
print("Optimized: " + ((%GetOptimizationStatus(f_jit) & 32) !== 0));
Suggested Patch
src/compiler/operation-typer.cc
--- a/src/compiler/operation-typer.cc
+++ b/src/compiler/operation-typer.cc
@@ -721,7 +721,11 @@
Type OperationTyper::SpeculativeAdditiveSafeIntegerAdd(Type lhs, Type rhs) {
Type result = SpeculativeNumberAdd(lhs, rhs);
- if (lhs.Is(cache_->kAdditiveSafeInteger) ||
- rhs.Is(cache_->kAdditiveSafeInteger)) {
+ // Only narrow to kAdditiveSafeInteger when BOTH inputs are within range
+ // AND the computed result is already within range. With the OR condition,
+ // one input near the boundary plus any in-range value can produce a sum
+ // that exceeds the bounds, and the intersection clips the result type to
+ // a range that doesn't contain all possible values.
+ if (lhs.Is(cache_->kAdditiveSafeInteger) &&
+ rhs.Is(cache_->kAdditiveSafeInteger) &&
+ result.Is(cache_->kAdditiveSafeInteger)) {
return Type::Intersect(result, cache_->kAdditiveSafeInteger, zone());
}
return result;
@@ -730,8 +734,9 @@
Type OperationTyper::SpeculativeAdditiveSafeIntegerSubtract(Type lhs,
Type rhs) {
Type result = SpeculativeNumberSubtract(lhs, rhs);
- if (lhs.Is(cache_->kAdditiveSafeInteger) ||
- rhs.Is(cache_->kAdditiveSafeInteger)) {
+ if (lhs.Is(cache_->kAdditiveSafeInteger) &&
+ rhs.Is(cache_->kAdditiveSafeInteger) &&
+ result.Is(cache_->kAdditiveSafeInteger)) {
return Type::Intersect(result, cache_->kAdditiveSafeInteger, zone());
}
return result;
Explanation
The fix changes the OR condition (||) to AND (&&) with an additional guard that the computed result is already within kAdditiveSafeInteger. The intersection is now only applied when it is provably a no-op (i.e., when both inputs AND the result are within bounds), so it can never incorrectly clip the result type.
The original OR condition was wrong because two values that are individually within kAdditiveSafeInteger (e.g., Uint32 [0, 2^32-1] and constant 2^52 - 2) can sum to a value that exceeds the range. The intersection then clips the result to a range that excludes actually-reachable values, creating incorrect type information that persists through algebraic simplification and causes downstream miscompilation.
Note: CanSpeculateAdditiveSafeInteger in simplified-lowering.cc:1839 does not need fixing. Its OR condition only controls whether CheckedAdditiveSafeIntegerAdd/Sub operations (with runtime overflow checks) are emitted -- a lowering decision. The bug is solely in the typing of the result.
Credit Information
Reporter credit: Junyoung Park(@candymate) of KAIST Hacking Lab
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
The function intersects the addition result type with kAdditiveSafeInteger when either input is in range, but when both inputs are in range and their sum exceeds the range, the intersection clips the result to just 2 values instead of 2^32.
Impact
The miscompilation produces wrong JavaScript results, which could lead to out-of-bounds reads and potentially other security issues.
What the attacker needed
64-bit architecture; TurboFan compilation (warmup or %OptimizeFunctionOnNextCall); specific code pattern with add/sub of constant near 2^52
The fix
The fix changes the OR condition to AND with an additional guard that the computed result is already within kAdditiveSafeInteger, so the intersection is only applied when it is provably a no-op.
How it was found
- Compile a function with TurboFan that performs an addition of a constant near 2^52 to a Uint32 value, followed by subtraction of the same constant.
- The addition result type is incorrectly clipped to a narrow range, and the subtraction result type becomes Range(0,1).
- Algebraic simplification removes the addition and subtraction, but the incorrect type persists.
- A comparison using the result is folded to always true, eliminating a reachable branch.
- The optimized function returns a wrong value compared to the interpreter.
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.
This is a bug in V8, the JavaScript engine used in Chrome. The compiler made a mistake when figuring out the possible range of numbers, so it wrongly simplified some code and produced a wrong answer. An attacker could use this to make a program behave unexpectedly, which might lead to reading memory it shouldn't.
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.