Block host prototype mutation via apply-trap indirection
fix(GHSA-v6mx-mf47-r5wg): block host prototype mutation via apply-trap indirection
Block host prototype mutation via apply-trap indirection27c525-fix-block-host-prototype-mutation-via-apply-trap-cve-2026-47131fixblock host prototype mutation via apply
Committed by patriksimek
commit message
fix(GHSA-v6mx-mf47-r5wg): block host prototype mutation via apply-trap indirection
Two-layer structural fix in lib/bridge.js:
Layer A (write-side, primary): cache the identity of every host-realm
function that mutates [[Prototype]] (or could install code that mutates it)
— Object.prototype.__proto__ setter, Object.setPrototypeOf,
Reflect.setPrototypeOf, Object.{defineProperty,defineProperties},
Reflect.defineProperty, Object.prototype.__define{Setter,Getter}__ — and
refuse any sandbox-initiated apply-trap invocation reaching one. Peel one
layer of indirection for Function.prototype.{call,apply,bind} (re-check
unwrapped context) and Reflect.{apply,construct} (re-check unwrapped args[0]).
Layer B (read-side, defense-in-depth): cache-check mappingOtherToThis at
the top of thisEnsureThis, before the proto-chain walk. Any previously
bridged host value returns its existing proxy independent of subsequent
prototype tampering. Fall-through paths intentionally unchanged so
GHSA-9vg3-4rfj-wgcm (sandbox-realm null-proto via bridge from()) remains
closed.
The canonical PoC reached host Object.prototype.__proto__ setter via
Buffer.call.call({}.__lookupSetter__, Buffer, "__proto__") and called it
with a wrapped host NodeError.prototype as `this`. The apply trap
unwrapped context and forwarded to the host setter, severing the host
prototype chain. The next host TypeError from
`await WebAssembly.compileStreaming()` then walked back into sandbox code
through V8 async internals; thisEnsureThis's proto-walk failed to find
any registered mapping and returned the raw host error unwrapped, exposing
host Function via e.constructor.constructor.
Bumps version to 3.11.4.
Tests in test/ghsa/GHSA-v6mx-mf47-r5wg/. ATTACKS.md Category 30.Editor assessment
This commit patches CVE-2026-47131. Layer A and Layer B are clearly separated: one caches identities of host prototype mutators and peels Function.prototype call, apply, bind plus Reflect.apply and Reflect.construct indirection, the other adds a mapping check before the proto-chain walk. The body then walks the actual exploit—Buffer.call.call on __lookupSetter__ to reach Object.prototype.__proto__, severing the host chain, and a later TypeError leaking host Function through e.constructor.constructor. Version bump and ATTACKS.md category are recorded. The only real problem is the header: the advisory ID stands in as scope, and the subject is long. Strong content, capped framing.