Sanitize host-Promise rejections under call/apply indirection

fix(GHSA-647f-g98j-qq25): sanitize host-Promise rejections under call/apply indirection
Sanitize host-Promise rejections under call/apply indirection315786-fix-sanitize-host-promise-rejections-under-call-apply-cve-2026-92937fixsanitize host promise rejections under call

Committed by patriksimek-bot

commit message
fix(GHSA-647f-g98j-qq25): sanitize host-Promise rejections under call/apply indirection

Patch bypass of the published GHSA-m283-3h24-438v fix. The apply-trap gate
that rebuilds capability-bearing host rejection values before a sandbox
onRejected callback runs identity-checked only the DIRECT apply target
(isHostPromiseThen(object) / isHostPromiseCatch(object)). Because the sandbox's
Function.prototype.call/.apply are connect()'d to the host's, registering the
handler through indirection -- p.then.call(p, undefined, cb), p.then.apply(...),
stacked p.then.call.call(...), and mixed call/apply -- made the apply target
host Function.prototype.call/.apply, the gate missed, no callback was wrapped,
and the raw host rejection reached the sandbox as a functional proxy:
err.detail = process -> e.detail.mainModule.require('child_process').execSync().
 
Fix (lib/bridge.js): replace the direct-target-only gate with
normalizeHostPromiseCallbacks. The apply trap is the single chokepoint every
sandbox-initiated host-function call passes through, so it reconstructs the
effective call: peel Function.prototype.call/.apply indirection in a bounded
loop (cached otherFunctionCall/otherFunctionApply, distinguished for their
differing arg shapes) via cached function identity (no attacker getter read;
TOCTOU-safe), and when the chain resolves to host then/catch, wrap the effective
onFulfilled/onRejected slots through the same m283 sanitizer. .apply nested arg
arrays are snapshotted into fresh getter-free storage (copyPromiseArgArray,
length>65535 bail); the peel is bounded (MAX_PROMISE_PEEL=64) and DENIES (throws
VMError) on exceed rather than forwarding an unwrapped callback (fail-closed).
bind and Reflect.apply already re-enter with the direct target and stay covered.
 
This restores Defense Invariant #3 (host-realm error carriers reaching sandbox
callbacks are sanitized) at the invocation layer rather than the direct
call-site layer.
 
Tests: test/ghsa/GHSA-647f-g98j-qq25/repro.js -- 6 indirection vectors + 3
mixed/stacked siblings + 4 already-safe controls + 3 over-block guards (16).
6 of the attack vectors escape without the patch.
 
Docs: ATTACKS.md gains Category 39 plus a matching row in the "How The Bridge
Defends" table. No package.json version bump (deferred to the release pass).
 
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

Editor assessment

This commit patches CVE-2026-92937. Excellent body on call/apply indirection: the direct-target-only gate missed handlers registered through p.then.call, stacked call.call and mixed forms, and the fix peels indirection in a bounded loop, snapshots apply arg arrays and fails closed beyond 64 hops. The header's only defect is the GHSA identifier used as a scope, which violates CCv1 scope semantics and caps the score. The technical explanation itself is complete and well tested. The 64-hop bound is a deliberate fail-closed choice; explaining why that number is safe would answer the main design question.

Browse categories

More fix examples · Back to search