Close Promise species hijack in localPromise swallow tail
fix(GHSA-76w7-j9cq-rx2j): close Promise species hijack in localPromise swallow tail
Close Promise species hijack in localPromise swallow taila46265-fix-close-promise-species-hijack-in-localpromise-cve-2026-47208fixclose promise species hijack localpromise swallow
Committed by patriksimek
commit message
fix(GHSA-76w7-j9cq-rx2j): close Promise species hijack in localPromise swallow tail
The `localPromise` constructor (introduced in GHSA-hw58-p9xv-2mjh) attaches an
internal swallow tail to every sandbox-constructed Promise via the cached host
`Promise.prototype.then`:
apply(globalPromisePrototypeThen, this, [undefined, localPromiseSwallow]);
Host `then` resolves its downstream child via the species protocol — it reads
`this.constructor[Symbol.species]` and `Construct`s a new Promise with that
constructor. Every sibling call site (`.then`/`.catch` overrides,
`localReflect.apply` wrapper) already bookends host-then with
`resetPromiseSpecies(this)` so the species pin is `localPromise`. The
swallow-tail call site in the constructor body was the only one missing the
reset.
A sandbox subclass therefore hijacks the swallow-tail child:
class FakePromise extends Promise {
static get [Symbol.species]() { return ct; }
}
ct = function(executor) { executor(userResolve, userReject); };
new FakePromise(r => r());
V8 calls `new ct(internalExecutor)` with its internal `(resolve, reject)`
capability. `ct` re-invokes that executor with sandbox-controlled functions —
V8 now treats `userReject` as the child's reject. Combined with the deep
recursion + `e.stack` primitive (Category 29) to surface a host-realm
`RangeError` inside `PromiseResolveThenableJob`, the raw host Error lands in
sandbox via `userReject`. From there `ex.constructor.constructor("return
process")()` yields RCE.
Fix: add `resetPromiseSpecies(this)` immediately before the swallow-tail
`apply(globalPromisePrototypeThen, this, [undefined, localPromiseSwallow])`
call in `lib/setup-sandbox.js`. The species pin is now consistent across every
host-then call site the bridge controls, restoring Defense Invariant #4 (no
host built-in is invoked with a sandbox `this` whose species can be hijacked)
for this site.
Tests in `test/ghsa/GHSA-76w7-j9cq-rx2j/repro.js` cover:
- the canonical exploit (host RangeError reaches sandbox unwrapped),
- the bypass surface in isolation (species-hijack constructor call no longer
reaches a user-controlled `ct`),
- the regression surface (benign `class MyPromise extends Promise {}` and
`new Promise(r => r())` continue to work as before).
ATTACKS.md gains Category 31 (renumbered from the branch's Category 30 to
avoid collision with GHSA-v6mx-mf47-r5wg's Category 30 already on main), a
new Compound Attack Patterns entry #24, and an updated "How The Bridge
Defends" row for Promise species.Editor assessment
This commit patches CVE-2026-47208. The body is a full walkthrough: the localPromise constructor's swallow tail used host Promise.prototype.then without resetPromiseSpecies, so a FakePromise subclass could supply its own species constructor and re-enter V8's internal resolve and reject capability, eventually surfacing a host RangeError in sandbox via e.stack and userReject. It cites the exploit, states the one-line fix, and lists three test categories. It also explains the Category 30 renumbering collision. Excellent analysis, but the GHSA-as-scope header and the very long sentences mean the message is heavier than it needs to be.