{"id":"CVE-2026-92935","aliases":["CVE-2026-92935","GHSA-8hr7-r645-pc6w"],"related":[],"kind":"vulnerability","state":"published","title":"vm2 NodeVM Remote Code Execution via Array-Shaped Require","summary":"vm2 is a sandbox for running untrusted Node.js code. In versions >= 3.11.4 and <= 3.11.6, the NodeVM constructor computes `hasRealRequireConfig` with `typeof requireOpts === 'object' && requireOpts !== null`, so an array-shaped `require` value (for example `require: []`) satisfies the guard that is meant to reject nesting without an explicit require configuration. `makeResolverFromLegacyOptions()` then destructures the array into undefined option fields and returns a resolver containing only `NESTING_OVERRIDE.vm2`. As a result, an attacker who can supply JavaScript executed by a NodeVM configured with truthy `nesting` and an array-shaped `require` (e.g. `new NodeVM({nesting: true, require: []})`) can require the host `vm2` module, create an inner NodeVM with an attacker-chosen builtin allowlist (such as `child_process`), and execute arbitrary commands with the privileges of the host Node.js process, escaping the sandbox. Outer builtin restrictions do not constrain the attacker-created inner NodeVM. This issue is fixed in vm2 3.11.7.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"vm2 is a sandbox for running untrusted Node.js code. In versions >= 3.11.4 and <= 3.11.6, the NodeVM constructor computes `hasRealRequireConfig` with `typeof requireOpts === 'object' && requireOpts !== null`, so an array-shaped `require` value (for example `require: []`) satisfies the guard that is meant to reject nesting without an explicit require configuration. `makeResolverFromLegacyOptions()` then destructures the array into undefined option fields and returns a resolver containing only `NESTING_OVERRIDE.vm2`. As a result, an attacker who can supply JavaScript executed by a NodeVM configured with truthy `nesting` and an array-shaped `require` (e.g. `new NodeVM({nesting: true, require: []})`) can require the host `vm2` module, create an inner NodeVM with an attacker-chosen builtin allowlist (such as `child_process`), and execute arbitrary commands with the privileges of the host Node.js process, escaping the sandbox. Outer builtin restrictions do not constrain the attacker-created inner NodeVM. This issue is fixed in vm2 3.11.7.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nThe `NodeVM` constructor computes `hasRealRequireConfig` using `typeof requireOpts === 'object' && requireOpts !== null`, so `require: []` bypasses the guard intended to reject `nesting` without an explicit require configuration. `makeResolverFromLegacyOptions()` then destructures the array to undefined option fields and returns a resolver containing only `NESTING_OVERRIDE.vm2`. Any attacker whose JavaScript is executed by a downstream `NodeVM` configured with `{nesting: true, require: []}` can load the host `vm2` module, create an inner `NodeVM` with an attacker-selected builtin allowlist, and execute commands as the host process. No equivalent plain-object validation exists in `makeResolverFromLegacyOptions()`.\n\nArray is converted into the vm2-only resolver:\nhttps://github.com/patriksimek/vm2/blob/54b54b74a382577f0bcd0538c5bf99acdcd7f53b/lib/resolver-compat.js#L205-L226\n\nNesting loader returns the host VM constructors:\nhttps://github.com/patriksimek/vm2/blob/54b54b74a382577f0bcd0538c5bf99acdcd7f53b/lib/nodevm.js#L640-L645\n\n## Proof of Concept\n\nPreconditions:\n\n- The host creates `NodeVM` with truthy `nesting` and array-shaped `require`.\n- The attacker can supply JavaScript executed by that `NodeVM`.\n\n```javascript\n'use strict';\n\nconst {NodeVM} = require('./index.js');\n\nconst outer = new NodeVM({nesting: true, require: []});\nconst result = outer.run(`\n\tconst {NodeVM} = require('vm2');\n\tconst inner = new NodeVM({require: {builtin: ['child_process']}});\n\tmodule.exports = inner.run(\n\t\t\"module.exports = require('child_process').execSync('id').toString()\"\n\t);\n`);\n\nconsole.log(result);\n```\n\n```text\nuid=1000(lohar) gid=1000(lohar) groups=1000(lohar)\n```\n\nThe `hasRealRequireConfig` guard fails open because it returns `true` for arrays, although arrays are not `VMRequire` configuration objects. `makeResolverFromLegacyOptions()` applies object destructuring to the array, obtains undefined `builtin` and `external` values, merges `NESTING_OVERRIDE`, and returns before any external-module control is relevant. Outer builtin restrictions do not constrain the attacker-created inner `NodeVM`, whose `require` configuration is selected inside the sandbox.\n\nFailed shape check:\nhttps://github.com/patriksimek/vm2/blob/54b54b74a382577f0bcd0538c5bf99acdcd7f53b/lib/nodevm.js#L304-L307\n\n## Impact\n\nAn attacker can execute arbitrary commands with the host Node.js process privileges, including reading secrets, modifying files, and accessing the host network. GHSA-m4wx-m65x-ghrr covers the same nesting primitive but does not cover array-shaped `require` values and incorrectly identifies 3.11.4 as patched. \n\n> Exploitation is limited to downstream applications that enable `nesting` and pass the malformed array configuration.","format":"markdown","source":"ghsa"}],"published":"2026-09-17T13:46:00.854Z","modified":"2026-10-01T15:45:06.195Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H","score":9.5,"rating":"CRITICAL"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H","score":9.5,"rating":"CRITICAL"},{"scorer":"VulnCheck","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H","score":9,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H","score":9,"rating":"CRITICAL"}],"cwes":["CWE-913"],"affected":[{"ranges":[{"type":"semver","introduced":"3.11.4","fixed":"3.11.7","status":"affected"},{"type":"semver","version":"3.11.7","status":"unaffected"}],"vendor":"patriksimek","product":"vm2","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"3.11.4","status":"affected","fixed":"3.11.7"}],"ecosystem":"npm","package":"vm2","purl":"pkg:npm/vm2","source":"ghsa"}],"references":[{"url":"https://github.com/patriksimek/vm2/security/advisories/GHSA-8hr7-r645-pc6w","tags":["vendor-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/patriksimek/vm2/commit/54b54b74a382577f0bcd0538c5bf99acdcd7f53b","tags":["patch","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.vulncheck.com/advisories/vm2-nodevm-remote-code-execution-via-array-shaped-require","tags":["third-party-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-92935","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/patriksimek/vm2/commit/05894eca1dc6a2b1a986f312c88255288a983d22","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/patriksimek/vm2","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/patriksimek/vm2/releases/tag/v3.11.7","tags":["web"],"sources":["ghsa"]}],"credits":["lexdotdev"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-09-17T18:57:25.525Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-92935","url":"https://www.cve.org/CVERecord?id=CVE-2026-92935","licence":"CVE Terms of Use","modified":"2026-09-17T19:21:04.162Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-8hr7-r645-pc6w","url":"https://github.com/advisories/GHSA-8hr7-r645-pc6w","licence":"CC-BY-4.0","modified":"2026-10-01T15:45:06.195Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-92935","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-92935","licence":"Public domain","modified":"2026-09-17T20:18:59.093Z"}],"updatedAt":"2026-11-25T22:59:39.241Z","epss":{"score":0.00636,"percentile":0.51823,"date":"2026-12-01T12:00:22.000Z"}}