Remove WebAssembly JSPI surface from sandbox
fix(GHSA-6j2x-vhqr-qr7q): remove WebAssembly JSPI surface from sandbox
Remove WebAssembly JSPI surface from sandbox6915fa-fix-remove-webassembly-jspi-surface-from-sandbox-cve-2026-47210fixremove webassembly jspi surface sandbox ghsa
Committed by patriksimek
commit message
fix(GHSA-6j2x-vhqr-qr7q): remove WebAssembly JSPI surface from sandbox
`WebAssembly.promising` and `WebAssembly.Suspending` (Node 24 behind
`--experimental-wasm-jspi`, Node 26+ by default) return sandbox-visible
Promise objects whose `[[Prototype]]` chain points directly at the host
realm's `Promise.prototype` with no bridge proxy in between. Sandbox
property access on such a promise resolves `p.then`/`.catch`/`.finally`
to host-realm native methods via the cross-realm prototype walk,
bypassing:
- the sandbox-side `globalPromise.prototype.then|catch` overrides (the
JSPI promise's prototype is NOT `globalPromise.prototype`, so the
override is never reached),
- `resetPromiseSpecies` (only invoked from those overrides),
- the bridge `apply`-trap callback wrapping for host Promise methods
(which only fires for bridge-proxied host promises).
`Object.defineProperty(p, 'constructor', { get(){ return F }})` installs
directly on the raw JSPI promise. `p.finally(()=>{})` reaches host
`Promise.prototype.finally`; V8's host-realm `SpeciesConstructor` reads
F and `NewPromiseCapability(F)` stores F's raw sandbox closures as
`[[Resolve]]`/`[[Reject]]` with no bridge mediation. The eventual
host-realm `TypeError` (from `WebAssembly.compileStreaming(Promise.resolve(0))`)
is dispatched through F's reject closure raw, and
`e.constructor.constructor('return process')()` evaluates in the host
realm because `Function.[[Realm]]` is host.
Structural fix in `lib/setup-sandbox.js`: delete `WebAssembly.promising`
and `WebAssembly.Suspending` from the sandbox at bootstrap, mirroring
the existing `WebAssembly.JSTag` removal pattern. Without `Suspending`,
a wasm module cannot import a JS function as a suspending import;
without `promising`, sandbox cannot promote a wasm function into a JSPI
export. Removing either kills the attack class on its own; removing
both is belt-and-suspenders. The removal is `typeof`-guarded so the
same code path is a no-op on older Node versions where the constants
don't exist.
This articulates a previously-latent invariant — Defense Invariant #12:
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). 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.
Test surface:
- `test/ghsa/GHSA-6j2x-vhqr-qr7q/repro.js` — JSPI surface presence
test, defense verification (constructors deleted), and full PoC
reproduction (Node 26+ where JSPI is default-on).
Docs:
- `docs/ATTACKS.md` — Category 33 (WebAssembly JSPI Cross-Realm
Promise Prototype) with full Attack Flow, Canonical Example, Why It
Works, Mitigation, Detection Rules, and Considered Attack Surfaces;
Defense Invariant #12 articulated in the Defense Invariants
section; Compound Attack Pattern 25 added; "How The Bridge Defends"
table row for JSPI.
Restores Defense Invariants #4 and #12.Editor assessment
This commit patches CVE-2026-47210. The body explains why JSPI is special: WebAssembly.promising and Suspending return promises whose prototype chain hits host Promise.prototype with no bridge, so sandbox overrides, resetPromiseSpecies, and apply-trap wrapping are all skipped, and a species hijack reaches host-realm Function. It then states the fix—delete both members at bootstrap, mirroring JSTag removal, typeof-guarded—and articulates Defense Invariant #12 for future spec extensions. The invariant reasoning is the highlight. The extremely long sentences and the GHSA scope keep it at acceptable rather than exemplary.