-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## `Module._load` is not vm2's `require()`.\n\nThe pre-patch `lib/builtin.js` defined `BUILTIN_MODULES` as one line:\n\n```javascript\nconst BUILTIN_MODULES = (nmod.builtinModules\n || Object.getOwnPropertyNames(process.binding('natives')))\n .filter(s => !s.startsWith('internal/'));\n```\n\nOn Node 18 that resolves to 64 names. `child_process`, `cluster`, `fs`, `http`, `module`, `vm`, `worker_threads`, and 57 others. The same file's `addDefaultBuiltin` decided what each one would look like to the sandbox:\n\n```javascript\nfunction addDefaultBuiltin(builtins, key, hostRequire) {\n if (builtins.has(key)) return;\n const special = SPECIAL_MODULES[key];\n builtins.set(key, special ? special : vm => vm.readonly(hostRequire(key)));\n}\n```\n\n`SPECIAL_MODULES` covers three names: `events`, `buffer`, `util`. Each gets a sandbox-side reimplementation. The other 61 names fall through to `vm.readonly(hostRequire(key))`, which loads the builtin in the host realm and wraps the result in a Proxy whose handler is `ReadOnlyHandler` from `lib/bridge.js`.\n\nThe handler class in pre-patch source overrides exactly six traps: `set`, `setPrototypeOf`, `defineProperty`, `deleteProperty`, `isExtensible`, `preventExtensions`. Each refuses the mutation and returns. The `get` trap and the `apply` trap are not overridden. They fall through to `BaseHandler`, whose `apply` ends:\n\n```javascript\napply(target, context, args) {\n // ...\n return doApply(this, context, args);\n}\n```\n\nThe proxy reads a property and returns the host's value, wrapped for re-entry. The proxy receives a call and forwards the call to the host function, with arguments unwrapped across the bridge. `ReadOnly` is the name vm2 gives a wrapper that blocks writes. Method calls are not writes.\n\n`require('module')` enters this path. The user's `builtin: ['*', '-child_process']` enumerates the wildcard, encounters `module`, sees no `'-module'` exclusion in the user's array, and adds it. `module` is not in `SPECIAL_MODULES`. The default handler runs: `vm.readonly(hostRequire('module'))`. The sandbox receives a Proxy whose target is the host's `Module` constructor function.\n\n`Module._load(name)` is a property read followed by a call. The proxy returns the host's `Module._load`, wrapped. The wrapper's apply trap is `BaseHandler.apply`. The function is invoked. The function does what it always does: it consults the host's module cache, runs Node's resolver, loads `child_process` from the host's builtin registry, and returns the host `child_process` module.\n\nvm2's allowlist enforcement lives inside vm2's `require()` implementation. The sandbox did not call `require()`. The sandbox called the function that `require()` itself calls.\n\nThe full PoC is three lines:\n\n```javascript\nconst { NodeVM } = require('vm2');\nconst vm = new NodeVM({\n require: { builtin: ['*', '-child_process'], external: false },\n});\nconst out = vm.run(`\n const Module = require('module');\n const cp = Module._load('child_process');\n module.exports = cp.execSync('id').toString();\n`, 'poc.js');\nconsole.log(out.trim());\n```\n\n`-child_process` is honored. The user did not configure `child_process` to be reachable. `child_process` was loaded anyway, by a function the user did configure to be reachable.\n\n## The patch is a hardcoded list. The list is what the allowlist's grain could not see.\n\nvm2 3.11.0's `lib/builtin.js` adds two changes that together close every reachable variant of the same primitive. The first is a new constant above `BUILTIN_MODULES`:\n\n```javascript\nconst DANGEROUS_BUILTINS = new Set([\n 'module',\n 'worker_threads',\n 'cluster',\n 'vm',\n 'repl',\n 'inspector'\n]);\n\nconst BUILTIN_MODULES = (nmod.builtinModules\n || Object.getOwnPropertyNames(process.binding('natives')))\n .filter(s => !s.startsWith('internal/') && !DANGEROUS_BUILTINS.has(s));\n```\n\nThe wildcard no longer expands to these names. A user who writes `builtin: ['*', '-child_process']` after the patch gets 58 builtins instead of 63. The six are not in the iteration set.\n\nThe second change is inside `addDefaultBuiltin`:\n\n```javascript\nfunction addDefaultBuiltin(builtins, key, hostRequire) {\n if (builtins.has(key)) return;\n const special = SPECIAL_MODULES[key];\n if (!special && DANGEROUS_BUILTINS.has(key)) return;\n builtins.set(key, special ? special : vm => vm.readonly(hostRequire(key)));\n}\n```\n\nA user who writes `builtin: ['module']` explicitly, naming the builtin they want, gets nothing. The same denylist applies. `SPECIAL_MODULES` is the only escape hatch, and a developer who genuinely needs a `module` shim can register a sandbox-safe replacement under that key. The default loader is gone for these six names regardless of how the user names them.\n\nA separate commit on the same branch (`b3728f3`) added `trace_events` to the same set six days later, this time for a host-process abort: `trace_events.createTracing({categories: [...]})` asserts `args[0]->IsArray()` in V8 C++, and a sandbox-Proxy array fails the C++ check and aborts the entire host process. Same shape, different consequence. The denylist grew by one.\n\nThe maintainer's own commit message names the category the allowlist API does not have a word for:\n\n> Six Node builtins expose primitives whose primary capability is \"reach host code regardless of the sandbox boundary\".\n\nAnd the same commit's `docs/ATTACKS.md` addition names it more plainly:\n\n> They're *meta-builtins* that load other builtins by name. The generic `vm.readonly()` wrapper cannot make them safe because the sandbox-bypass primitive is the very thing the user is calling.\n\n`meta-builtin` is a category the allowlist API has no syntactic place for. The patch establishes the category in the source code where the API surface could not. The configuration the user reads is still a flat list of names. The category that determines whether a name is safe to grant is hardcoded one layer below the surface.\n\n## The minus syntax operates on names. Loaders are not a category of name.\n\nA user reading the pre-patch README chose `'-child_process'` because `child_process` is the name that appears in every Node tutorial about running untrusted code. The same user would have written `'-fs'` if they wanted to block filesystem access. The minus syntax filters by name match. It does what it says.\n\nIt cannot say \"every builtin that can load `child_process`,\" because the allowlist API has no vocabulary for \"loader.\" The user's mental model of `['*', '-child_process']` is \"every builtin minus the dangerous one.\" The mental model assumes every builtin is either a leaf (does its thing, returns) or fully blocked (refuses, returns nothing). `module` is neither. `module._load(name)` is the name resolution that `require()` itself uses. Calling it is calling the loader.\n\nNode's own documentation does not categorize its builtins as leaf or meta. The vm2 pre-patch README did not either. The only place the distinction now lives is the six-element Set in `lib/builtin.js`. The configuration surface the user writes against is still the same flat list. The patch is a hardcoded denylist underneath the configuration surface because the configuration surface cannot describe the category.\n\nThis is the [allowlist-grain-is-the-method](/patterns/allowlist-grain-is-the-method) shape one level up. The pattern's [first exhibit](/posts/grav-cve-2026-44738-toarray-was-on-grav-twig-sandbox-allowlist-for-thirteen-days) is Grav's Twig sandbox allowing `Config::toArray` at the method-name grain while the method's return value carries the merged secrets tree. The grain was wrong by one level: the allowlist could ask \"is this method permitted to be called,\" and the security question was \"is the data this method returns permitted to flow to this caller.\" Here the grain is wrong by the same level, with a different container: the allowlist can ask \"is this builtin permitted to be loaded,\" and the security question is \"is the data this builtin's methods return permitted to instantiate other builtins.\" Both fixes share a shape, replace the configured surface with a hardcoded layer underneath, because no allowlist whose grain is the container name can answer the data question.\n\n## A loader on the allowlist is a wildcard on the allowlist.\n\nThe six names in `DANGEROUS_BUILTINS`, each spelled out by what they grant:\n\n| Name | Primitive the proxy forwarded |\n|------|-------------------------------|\n| `module` | `Module._load(name)` loads any host builtin or external module. `Module._cache` is the host's cache. `createRequire(filename)` returns a new `require` bound to the host realm. |\n| `worker_threads` | `new Worker(src, { eval: true })` runs arbitrary JS in a fresh thread that has no vm2 sandbox attached. |\n| `cluster` | `cluster.fork()` spawns a host child process. The child runs the parent's entry script. |\n| `vm` | `vm.runInThisContext(src)` evaluates `src` in the host realm. The vm2 bridge is bypassed. |\n| `repl` | `repl.start({ eval, input, output })` constructs an interactive evaluator. The `eval` option is the evaluator function and accepts a sandbox closure that runs against host streams. |\n| `inspector` | `inspector.open()` attaches the V8 inspector protocol to the host process. `Session().post('Runtime.evaluate', { expression })` is host JS execution. |\n\nEach one is a single-line bypass under the pre-patch wildcard. `Module._load` is the documented PoC; the other five are alternates that produce the same outcome through different host primitives. The patch's denylist treats them identically because the question is identical: the wrapper that vm2 puts around the host builtin cannot remove the host capability the builtin's methods are designed to expose.\n\n## This is the allowlist-API variant of vm2's unpatchable primitive.\n\nvm2 v3.11.0 closed thirteen GitHub advisories on May 1, 2026. v3.11.1 cut forty-two minutes later closing one more. v3.11.2 closed three more on May 3. Eighteen advisories across three releases in three days. The CVE-2026-44007 post on the [`{ nesting: true, require: false }` configuration trap](/posts/vm2-cve-2026-44007-readme-is-the-patch-for-the-rest) walked the v3.11.1 entry; the CVE-2026-24120 post on the [Promise species lineage](/posts/vm2-cve-2026-24120-readme-already-admits) walked the V8-internal class.\n\nGHSA-947f-4v7f-x2v8 is a third variant of the same [unpatchable primitive](/patterns/unpatchable-primitive). The V8-internal variant lives inside V8's C++ implementations of language features (Promise species, `WebAssembly.JSTag`, `SuppressedError`, `%AsyncGeneratorPrototype%`); vm2's Proxy bridge cannot trap those reads, and the defense is a per-feature wrap added to `lib/setup-sandbox.js`. The configuration-trap variant lives inside vm2's own option semantics; the defense is a refusal of a specific option pair at the constructor. This variant lives inside the allowlist API's expressive capacity; the defense is a hardcoded category that the API surface cannot encode.\n\nThe CVE-2026-43999 patch is the smallest of the three at the source-code level: 48 lines added to one file. It is also the variant with the most direct user-visible regression. A vm2 customer running `builtin: ['*']` in production on v3.10.5 had the six meta-builtins reachable; on v3.11.0 they are not, and a sandbox that depended on `require('vm')` for nested compilation breaks at upgrade. The fix that closes the bypass is the fix that breaks the documented configuration. Six names disappear from a list the user did not know the names belonged to.\n\nvm2 is the [design-debt driver](/patterns/design-debt-driver) of the JavaScript sandboxing space and a working exhibit of [the-detector-is-the-target](/patterns/the-detector-is-the-target): when the substrate's job is containment, every CVE is the containment failing, and the surface a defender adopts in order to execute hostile code safely is the surface that ends up executing hostile code unsafely. The recurring shape across the eighteen advisories is the same: the substrate (in-process JavaScript isolation via Proxy bridge plus configurable allowlist) lets attacker-influenced code reach host primitives through paths the defense layer did not enumerate ahead of time. Each patch enumerates one more path. This patch enumerates six.\n\n## The vm2 README's recommendation is in the same release.\n\nvm2 3.11.0's README adds a new section above the `require.builtin` documentation:\n\n> ### Treat `require.builtin: ['*']` as a non-sandbox configuration\n>\n> The `'*'` wildcard expands to most Node built-ins, including `child_process`, `fs`, `dgram`, `net`, `http`, and `dns`. These are full host-capability primitives, `require('child_process').execSync('id')` is reachable from the sandbox under `'*'`. vm2's `'*'` semantics are intentional (some embedders run trusted-but-isolated code), but it should not be used as a default for untrusted code. Prefer an explicit allowlist of the smallest set of modules your sandbox actually needs.\n\nThe section enumerates `child_process`, `fs`, `dgram`, `net`, `http`, `dns`. The six names the same release's patch added to `DANGEROUS_BUILTINS` (`module`, `worker_threads`, `cluster`, `vm`, `repl`, `inspector`) do not appear in this list. They are not mentioned, because after the patch they are not reachable under `'*'` regardless of the user's exclusion list. The README's warning is about the configuration the user can write that vm2 will still honor. The patch's denylist is about the configuration the user can write that vm2 silently overrides. The two paragraphs are two parts of the same admission: the allowlist's expressive capacity is not what a vm2 caller writing untrusted-code defenses needs it to be. Use it for trusted-but-isolated code, or use isolated-vm.\n\nThe README's \"More Robust Alternatives\" section, three paragraphs further down, is the maintainer's running recommendation across every recent vm2 advisory: isolated-vm, Worker threads with restricted permissions, containers, managed services. Six names removed from the allowlist's effective coverage do not change the recommendation. The recommendation is the same because the substrate is the same.\n\nPoC: [GHSA-947f-4v7f-x2v8](https://github.com/advisories/GHSA-947f-4v7f-x2v8).","closing_line":"vm2's allowlist named modules. Six of the names named the rest.","hook_md":"The pre-patch `BUILTIN_MODULES` constant in `lib/builtin.js` was 64 names long. vm2's README documented `require.builtin: ['*']` as the \"allow everything\" configuration and pointed callers at the `-name` syntax for pruning it. The canonical pruning was `'-child_process'`. Six of the 64 names the wildcard expanded to were loaders that called Node's module system in the host realm without consulting vm2's allowlist. `module` was one. `Module._load('child_process')` was three lines of sandbox code. The 3.11.0 patch is a hardcoded list of six names the wildcard is no longer allowed to grant.","post_id":344,"slug":"vm2-cve-2026-43999-module-was-every-other-module","title":"CVE-2026-43999: vm2's Builtin Allowlist Granted `module`. `module` Granted The Rest.","type":"initial","unreadable_sentence":"vm2's allowlist enforcement lives inside vm2's `require()` implementation. The sandbox did not call `require()`. The sandbox called the function that `require()` itself calls."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCajWc+wAKCRDeZjl4jgkQ Jls3AQDHfEaYxpiDzgE18aXK+cgODNuGxmHIYtHqOhyv2jrOrgD+NxR3g8OhbkPS iZZ0D+CzRFTezQ+DCYIpgLLh18n//A8= =O8vK -----END PGP SIGNATURE-----