-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## Symmetry was the bug\n\nThe PoC in the GitHub Security Advisory database is six executable lines.\n\n```javascript\nconst {VM} = require(\"vm2\");\nconst vm = new VM();\nconsole.log(vm.run(`\n const o = {__proto__: null};\n try {\n throw o;\n } catch (e) {\n e.f = Buffer.prototype.inspect;\n o.f.constructor(\"return process\")().mainModule.require('child_process').execSync('touch pwned');\n }\n`));\n```\n\nThe sandbox creates an object with no prototype, throws it, catches it. Inside the catch, it writes `Buffer.prototype.inspect` (a sandbox-visible proxy of a host function) to a property on the caught value. Then it reads the same property through the *original* sandbox reference `o`, not the catch-clause binding `e`, and treats the result as a host-realm `Function` constructor's parent. `Function(\"return process\")()` returns the host `process` object. `child_process.execSync` is the next call.\n\nThat last step works because of what `handleException` did between the throw and the catch.\n\nvm2's bridge presents the sandbox with proxies of every host-realm object it can see. The sandbox treats `Buffer.prototype.inspect` as a proxy whose `get` and `apply` traps refuse any read that would surface a host-realm reference. Property access for `.constructor` on a host function returns a sandbox-realm sentinel; `.apply` is interposed; the prototype chain is rewritten on every read. The proxy is the membrane.\n\nWhen sandbox code throws, the value reaches every `catch` clause through the vm2 transformer's instrumentation: `catch (e) { e = handleException(e); ... }`. `handleException` is the chokepoint for \"every value entering a catch clause.\" Defense Invariant #2 in vm2's own `docs/ATTACKS.md`, in the same git tree:\n\n> All caught exceptions are sanitized. Every value entering a `catch` clause passes through `handleException`. Paths that bypass JS-level `catch` instrumentation (Wasm `try_table`, host-realm `Promise.then` rejection) are closed at the bridge.\n\nThe post-GHSA-mpf8 implementation of `handleException` honored that invariant by calling `from(e)`. `from` is the bridge's general-purpose cross-realm wrapper: given any value the bridge cannot find in its identity WeakMaps, return a new bridge proxy. For a host-realm null-proto value, this is correct. The wrapped proxy intercepts every read, refuses dangerous protocol gets, and returns sandbox-safe surrogates.\n\nFor a sandbox-realm null-proto value, `from` is the bug. The bridge has no WeakMap entry for the sandbox object and treats the missing entry as evidence that the value came from the other realm. It constructs a proxy around `o` itself with the bridge treating the underlying target as host-side. When sandbox code does `e.f = Buffer.prototype.inspect`, the proxy's `set` trap interprets the assignment as a write of a sandbox value onto a host object, and runs the trap's host-side-store path: it *unwraps* the incoming sandbox proxy of `Buffer.prototype.inspect` back to the raw host function before storing.\n\n`o.f` now holds the raw, unproxied host-realm `Buffer.prototype.inspect`.\n\nThe catch-clause binding `e` would still mediate the read through the proxy, and the read of `e.f` would re-wrap. The sandbox does not read through `e`. It reads through `o`, the original closure binding. `o.f` skips the trap entirely. `o.f.constructor` walks the raw host prototype chain to host `Function`. The host `Function` constructor compiles strings into functions executing in the host realm. The remainder of the PoC is the canonical pivot.\n\nThe patch's commit message names the path step by step:\n\n> `from()` builds a sandbox-side proxy whose target the bridge treats as host-realm; when called on a sandbox-realm null-proto value, the proxy's `set` trap unwraps incoming sandbox proxies of host references back to raw host originals and stores them on the underlying sandbox object. The original sandbox reference then yields the raw host fn → `.constructor` is host `Function` → RCE.\n\n## The chokepoint that cannot be one chokepoint\n\n`handleException` has three sandbox-side callers, all wired up in `lib/setup-sandbox.js`:\n\n1. The transformer-instrumented JS `catch` block: every `catch (e) { ... }` in user code becomes `catch (e) { e = handleException(e); ... }`.\n2. The sandbox-side `globalPromise.prototype.then` `onRejected` wrap.\n3. The `localPromise` executor's swallow tail, which runs `handleException` on errors thrown by the user-supplied executor.\n\nAll three deliver *sandbox-realm* values. The transformer instruments sandbox source; the Promise wraps run on sandbox-allocated Promises whose resolution values are sandbox objects by construction. Host-realm exceptions cross the bridge through a separate path entirely: the bridge's `apply`-trap interception of host `Promise.prototype.then`, which installs sanitizing wrappers at the boundary between host Promise machinery and sandbox callbacks.\n\nThat separation is what GHSA-mpf8 closed. The host-Promise `apply`-trap path was the asymmetry: rejection callbacks the sandbox registered on host-realm promises saw raw host rejection values. The fix added an install site, `bridge.setHostPromiseSanitizers(handleException, from)`, that wrapped both fulfillment and rejection callbacks through the same sanitizers used by the sandbox-realm Promise overrides. Then the follow-on commit, `b57ac2d`, propagated the choice of `from` from the install site *into* `handleException` itself, on the reasoning that the function should treat every value as potentially cross-realm regardless of which caller invoked it.\n\nThree months of advisories later, the propagation is reverted. The install site is rewritten so the cross-realm wrap happens *outside* `handleException`, at the one callsite where the value really is host-realm:\n\n```diff\n if (typeof bridge.setHostPromiseSanitizers === 'function') {\n- bridge.setHostPromiseSanitizers(handleException, from);\n+ bridge.setHostPromiseSanitizers(e => handleException(from(e)), from);\n }\n```\n\nThe `from()` call moves outside `handleException` and into a per-callsite closure. `handleException` itself becomes sandbox-realm-only. The chokepoint that was one function is now two contracts: every caller decides which realm its value comes from, and wraps accordingly. Defense Invariant #2 still reads \"every value entering a `catch` clause passes through `handleException`.\" Its enforcement is now spread across the bridge boundary rather than concentrated at the function.\n\n## The fix is a revert because the boundary cannot be symmetric\n\nThe thing the GHSA-mpf8 fix and the GHSA-9vg3 fix have in common is that both call `from()`. The thing they cannot have in common is *which* null-proto value `from()` should be called on. Sandbox-realm null-proto values and host-realm null-proto values are indistinguishable from inside `handleException`: both have null prototypes, both fail the bridge's identity-WeakMap lookups, both arrive as caught exceptions. The two fixes alternated on the same line because the same line could not tell them apart.\n\n`handleException` is a design-debt driver at the function level. A [prior post in this series](/posts/vm2-cve-2026-24120-readme-already-admits) counted five fixes that touched this function across thirty-two months, all closing the same general shape (a cross-realm reference reaching sandbox code through a caught exception) by tightening the wrap at one of three boundaries: the function itself, the bridge install site, or the in-sandbox catch transformer. The current commit is the sixth fix. It moves the wrap from the function to the install site. The next fix will move it to the transformer, or back, or to a new boundary that does not exist yet. The maintainer's source comment for the new patch cites the previous commit by hash and labels its hardening as the vulnerability it is reverting: `Reverts the b57ac2d \"GHSA-mpf8 symmetry\" change.` Naming the prior CVE inside the patch for the next one is the maintainer's own concession that the function is the debt, not any one of its bug instances.\n\nWhat no fix moves is the property the bridge's `set` trap exercises. The trap unwraps incoming sandbox proxies of host references when it believes its target is host-realm, because that is what `set` traps on bridge proxies are *for*. The trap does the right thing for every host-realm target. It does the wrong thing when an upstream chokepoint mislabels a sandbox-realm target. The fix is to stop mislabeling.\n\n## ATTACKS.md gains Category 26\n\nvm2 maintains a 3,161-line internal document at `docs/ATTACKS.md` titled \"Sandbox Escape Attack Patterns.\" Its preamble:\n\n> This document catalogs known attack patterns used to circumvent the vm2 sandbox. It is intended for AI agents and reviewers evaluating new code contributions. Each section describes a category of attack, provides canonical examples, explains why it is dangerous, and lists detection heuristics for spotting similar patterns in contributed code.\n\nThe document is the maintainer's working enumeration of the places the membrane has been or could be torn. There are 35 categories as of v3.11.5, organized into three tiers: Primitives (1 through 5), Techniques (6 through 15), Compound Attacks (16 and up). Each category cites the advisory that motivated it. The null-proto throw is Category 26. The 3.11.2 release that fixes it also adds Category 27 (computed-key probes of `globalThis` that surface bridge internal state) and Category 28 (sandbox-installed `Array.prototype[N]` setters that capture bridge saved state). Three release tags and two weeks later, the document is at Category 35.\n\nThe CHANGELOG documents the release cadence in vm2's own words:\n\n```\n[3.11.5] 2026-05-18 - two regression fixes\n[3.11.4] 2026-05-16 - ten advisories closed\n[3.11.3] 2026-05-13 - one advisory\n[3.11.2] 2026-05-03 - three advisories (this one)\n[3.11.1] 2026-04-22 - one advisory\n[3.11.0] 2026-04-15 - six advisories\n```\n\nTwenty-three CVEs in five weeks. The README, in the same git tree as the CHANGELOG, in the same release:\n\n> Despite our best efforts, researchers and security professionals continuously discover new ways to escape the vm2 sandbox.\n\nThat sentence is the project's release-cycle disclaimer. It is also a public admission about an *unpatchable primitive*: the bug class is the design's purpose, the thing producing CVEs is the same thing that makes the component work, and patches close instances while the primitive remains. The catalog of fix functions in `lib/setup-sandbox.js` (`resetPromiseSpecies`, `neutralizeArraySpeciesBatch`, the `WebAssembly.JSTag` deletion, the AsyncGenerator wrap, the SuppressedError recursion, and now the `handleException`/`setHostPromiseSanitizers` rearrangement) is the formal enumeration of places the proxy bridge has conceded it cannot generally reach. Each entry is a per-feature, reactive patch. The vocabulary grows by one entry per advisory.\n\n## The architectural reason, in the maintainer's words\n\n`docs/ATTACKS.md` opens its \"Realm Separation\" section with the design statement at the level the patches cannot reach:\n\n> vm2 runs untrusted code inside a V8 context created by Node.js's `vm` module. Host and sandbox share the **same V8 isolate**. They execute on the same thread, in the same heap. The sandbox gets its own set of global intrinsics (`Object`, `Function`, `Array`, `Error`, etc.), but these are all allocated from the same memory space as the host's intrinsics. There is no process boundary, no memory isolation, and no privilege separation at the OS level. If an attacker obtains a reference to any host-realm constructor, they can evaluate arbitrary code in the host context.\n\nThe bridge proxy model is the membrane. The membrane is a hand-written collection of Proxy traps with manually-maintained identity-preservation WeakMaps. Every trap is an attack surface. Every gap is a potential escape. The CVE record's description of GHSA-9vg3 is one gap of one method on one trap on one chokepoint where the chokepoint's realm-assumption could not match the value's actual realm.\n\nCVE-2026-44009 is the latest published advisory against a design whose maintainer's README, ATTACKS.md, and CHANGELOG all describe the same structural property: the design grants the primitive that produces the CVEs.\n\nPoC: [GHSA-9vg3-4rfj-wgcm](https://github.com/advisories/GHSA-9vg3-4rfj-wgcm). Patch: [c33c2bb](https://github.com/patriksimek/vm2/commit/c33c2bb19a822847f4e01d8d87b28dd5b2c86b3e). The prior fix it reverts: `b57ac2d` (GHSA-mpf8-4hx2-7cjg). Category 26 in [docs/ATTACKS.md](https://github.com/patriksimek/vm2/blob/master/docs/ATTACKS.md).","closing_line":"Some patches close a bug. The patch for CVE-2026-44009 closes the patch.","hook_md":"vm2 closed GHSA-mpf8-4hx2-7cjg in February 2026 by switching one line in `handleException` from `ensureThis(e)` to `from(e)`. The change cited symmetry: host-realm null-proto rejection values had been reaching sandbox callbacks unwrapped, the bridge had a tool for wrapping unmapped values into bridge proxies, the symmetric application of that tool to caught exceptions would close the asymmetry.\n\nCommit `c33c2bb`, signed by Patrik Simek on 2 May 2026, switches the same line back. `e = from(e);` becomes `e = ensureThis(e);`. The new comment names the change it reverts and labels it the vulnerability: *Reverts the b57ac2d \"GHSA-mpf8 symmetry\" hardening.* The advisory is GHSA-9vg3-4rfj-wgcm, CVE-2026-44009, CVSS 9.8.\n\nThe fix is a revert. The bug was the previous fix.","post_id":352,"slug":"vm2-cve-2026-44009-symmetry-was-the-bug","title":"CVE-2026-44009: vm2 Hardened handleException for Symmetry. Symmetry Was the Bug.","type":"initial","unreadable_sentence":"The two fixes alternated on the same line because the same line could not tell them apart."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCajwmSAAKCRDeZjl4jgkQ JkLXAP9eEaIYrcMFfhG7OQff2zh2NFLmoyuBst3NJUKVNHPa0AD/ejGlArgiS3nU Iv/uyzRn6na+KCnwYZBr1fZnYtGTRQo= =5cLW -----END PGP SIGNATURE-----