
Firefox SpiderMonkey use-after-free Value write: a non-strict this-boxing call lazily resolves a global constructor and reallocates the global's slots under a compiled store. Plain JS. Fixed in 158.
In non-strict JS, a primitive receiver flowing into this gets boxed: the engine wraps 1n in a BigIntObject so the callee sees an object. Warp compiles that as MBoxNonStrictThis, a fast path for receivers that are already objects and an out-of-line path that VM-calls BoxNonStrictThis down into js::PrimitiveToObject. To the compiler this is an inert conversion. It produces a wrapper object. It cannot change the shape of the world.
The people who wrote js::PrimitiveToObject knew something the optimizer did not. Boxing a primitive needs the wrapper constructor for its type, and if the global has never resolved that constructor, boxing resolves it: mid-script, from inside compiled code, it defines the BigInt property on the global object.
A call the optimizer treated as inert walks into the global and reallocates its slot array. That is the CVE.
The chain, end to end:
JSOp::FunctionThis to MBoxNonStrictThis. Receiver already an object: fast path. Primitive receiver: out-of-line path, VM call BoxNonStrictThis -> js::PrimitiveToObject.BigInt needs the BigInt wrapper constructor. If the global never resolved it, js::PrimitiveToObject resolves it lazily, which defines the BigInt property on the global object.MSlots is hoisted and CSE'd across the boxing call, because a boxing call cannot mutate the global. Except it just did.The PoC's core, evaluated inside a fresh compartment so the wrapper starts unresolved:
let numGlobalProps = Object.keys(globalThis).length;
let padding = target - numGlobalProps;
var value = 0;
function nonStrict() { return this; }
function assign(receiver) {
value = 1; // store A (before boxing call)
var r = nonStrict.call(receiver); // boxing: may resolve BigInt
if (r) {
value = 2; // store B: lost through stale slots
}
return r;
}
Three pieces of choreography make the miscompile visible:
newGlobal({newCompartment: true})) guarantees BigInt was never resolved there, so the boxing call has something to resolve.globalThis["property" + i] = i) tunes the global's property count to a dynamic-slots capacity boundary, so the BigInt definition is the one property addition that tips the array into reallocation.assign with the boxing path cold but present, then assign(1n) takes the out-of-line path for the first time.The script scans candidate boundaries (target from 966 to 1025) because the capacity step is not directly observable from JS.
155.0 release shell:
$ js --no-threads --fast-warmup poc-157-cve-2026-109722.js
UAF SLOT WRITE (vulnerable) at target=1003: value=1 after store, boxed this is a valid BigIntObject (truthy=true, String=1)
Nothing failed. The boxing call returned a perfectly valid, truthy BigIntObject. The if was taken. Store B executed. It landed in the freed slot array, and value is still 1: the store that ran is the store that is gone. An instrumented run says the same thing in more detail:
FAIL at target=1003 value=1 boxedThis: type=object truthy=true isBigIntObj=true String=1
On a fixed main the scan is clean: every boundary candidate stores and reads back correctly, and the script prints nothing.
This is a use-after-free write of a full tagged Value.
What occupies the freed array by the time store B lands is the obvious exploitation question. The PoC demonstrates the lost store; SpiderMonkey does not reclaim the allocation.