Skip to content
Memory corruption Disclosed report Advanced CVE-2026-8388

Ion Snapshot Recover Offset Truncation

Ion snapshot headers store the recover-stream offset in a 26-bit field, but the recover stream can grow past that limit; release builds silently truncate the high bits instead of failing. During bailout reconstruction the reader then decodes recover metadata from the wrong location, causing a crash and potentially out-of-bounds metadata reads or slot writes.

ggwhyp Follow

Originally disclosed on Mozilla

  • Fixed in 4 days
  • Paid in 16 days
  • Disclosed after 4 days

Created attachment 9583048 poc.js

Ion Snapshot Recover Offset Truncation

Summary

Ion snapshot metadata stores a recover-stream offset in a 26-bit field inside the snapshot header. The recover stream itself can grow beyond 1 << 26 bytes. When a snapshot is encoded after the recover stream crosses that boundary, debug builds abort in SnapshotWriter::startSnapshot; release builds truncate the high bits of the offset in the snapshot header.

During bailout reconstruction, RecoverReader then starts decoding recover metadata from the wrong location. In a local release build, this path is reproducible as a SIGSEGV.

Affected Component

  • SpiderMonkey JIT
  • Ion snapshot/recover metadata
  • Ion-to-Baseline bailout reconstruction

Impact

Confirmed impact:

  • Debug JS shell: assertion failure at js/src/jit/Snapshots.cpp:640
  • Release JS shell: SIGSEGV
  • Release GDB backtrace shows bailout recovery following the truncated recover offset and entering RObjectState::recover

Security relevance:

  • This is not only a debug assertion. In release builds, the recover offset is truncated and the runtime decodes the wrong byte sequence as recover metadata.
  • The current release PoC hits the fail-fast MOZ_RELEASE_ASSERT(val.isObject()) in SnapshotIterator::readObject.
  • The same decode path then performs an unchecked NativeObject cast and slot writes with debug-only slot range and shape consistency checks. With a different truncated-stream alignment, this can plausibly become an out-of-bounds metadata read or object slot write.
  • A fully controlled write primitive has not been established in this report.

Suggested severity: high, pending exploitability assessment.

Root Cause

SnapshotWriter::startSnapshot packs the bailout kind and recover offset into one compact unsigned value.

  • bailout kind: 6 bits
  • recover offset: 26 bits

Relevant source:

  • js/src/jit/Snapshots.cpp:519-532
  • js/src/jit/Snapshots.cpp:630-646

The only check that the recover offset fits is debug-only:

C++
MOZ_ASSERT(recoverOffset < (1 << SNAPSHOT_ROFFSET_BITS));

Release builds still pack the value:

C++
uint32_t bits = (uint32_t(kind) << SNAPSHOT_BAILOUTKIND_SHIFT) |
                (recoverOffset << SNAPSHOT_ROFFSET_SHIFT);

When recoverOffset >= 1 << 26, the high bits are lost.

The recover writer can create a recover stream much larger than the 26-bit snapshot field:

  • js/src/jit/Snapshots.h:481-499

The reader later trusts the truncated offset:

  • js/src/jit/Snapshots.cpp:585-593

Dangerous Decode Path

The release crash follows this path:

Text
BailoutIonToBaseline
  SnapshotIterator::initInstructionResults
    SnapshotIterator::computeInstructionResults
      RObjectState::recover
        SnapshotIterator::readObject

Relevant source:

  • js/src/jit/Recover.cpp:117-123
  • js/src/jit/Recover.cpp:2322-2342
  • js/src/jit/JSJitFrameIter.h:513-517
  • js/src/vm/NativeObject.h:1244-1248

In the observed release crash, the corrupted stream decodes as RObjectState and then attempts to read an object from the wrong snapshot allocation sequence.

Reproducer

Text
poc.js

Debug Reproduction

Command:

Bash
timeout 360s <debug-js-shell> poc.js

Result:

Text
status=139
Assertion failure: recoverOffset < (1 << SNAPSHOT_ROFFSET_BITS), at js/src/jit/Snapshots.cpp:640

Release Reproduction

Command:

Bash
timeout 360s <release-js-shell> poc.js

Result:

Text
status=139
Segmentation fault

GDB backtrace:

Text
Thread 1 "js" received signal SIGSEGV, Segmentation fault.
#1 js::jit::SnapshotIterator::readObject
#2 js::jit::RObjectState::recover
#3 js::jit::SnapshotIterator::computeInstructionResults
#4 js::jit::SnapshotIterator::initInstructionResults
#5 js::jit::BailoutIonToBaseline
#6 js::jit::Bailout

Expected Behavior

Ion compilation should do one of the following:

  • encode the full recover offset without truncation;
  • reject or abort compilation in release builds before writing a snapshot whose recover offset cannot be represented.

The runtime must not produce an IonScript with snapshot headers that point to the wrong recover-stream location.

Suggested Fix

Minimum fix:

  • Replace the debug-only recover-offset bound check with a release-enforced compile failure before packing the snapshot header.
  • Ensure the failure propagates as an Ion compile failure, not as a malformed IonScript.

More robust fix:

  • Widen the recover-offset field or encode it separately instead of packing it into the remaining 26 bits of the snapshot header.
  • Add reader-side validation that snapshot.recoverOffset() < recoversSize.
  • Validate that recover metadata decoding stays within the recover buffer.
  • Add a regression test that generates a recover stream crossing 1 << 26 and verifies that Ion compilation fails safely or encodes the offset correctly.

The original report as published on Mozilla's Bugzilla, by ggwhyp. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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 recover offset is packed into a 26-bit field with only a debug-only assertion guarding the bound, so release builds silently truncate offsets of 1<<26 or more.

Impact

Debug builds abort on an assertion and release builds crash with a segmentation fault; the author suggests a different truncated-stream alignment could plausibly lead to out-of-bounds metadata reads or object slot writes, though a controlled write primitive was not established.

What the attacker needed

Ability to run a JS shell build; recover stream exceeding 1<<26 bytes

The fix

The debug-only bound check should be enforced in release builds as a compile failure, and the offset field widened or validated on the reader side.

How it was found

  1. Run the provided proof-of-concept script in a debug JS shell and observe the assertion failure.
  2. Run the same script in a release JS shell and observe the segmentation fault.
  3. Inspect the backtrace to see bailout recovery following the truncated offset into object recovery.

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.

A JavaScript engine sometimes saves a snapshot of a running function so it can resume later. The snapshot records where to find extra data using a small fixed-size number, and when that data got too big the number was cut short instead of rejected. The engine then looked in the wrong place and crashed, and the author thinks a cleverer setup could corrupt 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 by ggwhyp

View all

4 more disclosed reports, best first.

More from Mozilla

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.