vm2: NodeVM builtin allowlist bypass via node:test.run() execArgv allows sandbox escapeGHSA-qhwx-74w5-xhxq
CRITICALFix: patriksimek/vm2@415339fGHSA-qhwx-74w5-xhxq is a critical-severity (CVSS 9.9) CWE-693 vulnerability in vm2. A fix is available for vm2 — see the affected versions and patch details below.
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
- A successful exploit gives an attacker total control of the affected component, not partial access.
Exploitation and automatability from CISA’s SSVC triage for GHSA-qhwx-74w5-xhxq.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
vm2npmDescription
Summary
On Node.js 24 and newer, vm2 can expose the host node:test module to sandboxed NodeVM code when the embedder explicitly allows the node:test builtin. Sandbox code can reach that module through require('node:node:test') and call run() with attacker-controlled execArgv.
node:test.run() starts a separate Node process for process-isolated test execution and forwards the supplied execArgv values to that process. Supplying --eval=<JavaScript> therefore executes arbitrary JavaScript in an unrestricted host Node process, outside the NodeVM sandbox.
The PoC confirms that direct sandbox imports of fs, child_process, module, and process remain denied before the spawned process imports host fs and writes a harmless marker.
Affected versions and environment
- Package:
vm2 - Affected versions:
>=3.9.6, <=3.11.5 - Latest reproduced version:
3.11.5 - Reproduced runtime: Node.js
v24.18.0 - Exact path is not present on Node.js 22 because
module.builtinModulesdoes not expose the scheme-onlynode:testentry there - Configuration prerequisite:
require: {
builtin: ['node:test'],
external: false
}
The lower version boundary was tested directly: [email protected] blocks require('node:node:test'), while [email protected] permits the exploit path. Representative releases through 3.11.5 were also reproduced.
Root cause
The issue is a combination of builtin admission, generic host passthrough, and prefix normalization:
- On Node.js 24+,
module.builtinModulesincludes the scheme-only keynode:test. lib/builtin.jsbuildsBUILTIN_MODULESfrom that array. The family-basedDANGEROUS_BUILTINSprotection does not includetest, sonode:testremains eligible.- When the embedder explicitly allows
node:test,addDefaultBuiltin()stores it through the generic loader:
builtins.set(key, special ? special : vm => vm.readonly(hostRequire(key)));
- In
lib/setup-node-sandbox.js,requireImpl()strips onenode:prefix before builtin lookup:
if (localStringPrototypeStartsWith(filename, 'node:')) {
id = localStringPrototypeSlice(filename, 5);
nmod = loadBuiltinModule(id);
}
- Consequently, sandbox code requesting
node:node:testis normalized to the stored keynode:testand receives a readonly proxy to the host module. - The readonly proxy does not make
node:test.run()safe. Calls are forwarded to the host implementation, which accepts attacker-controlledexecArgvfor a newly spawned Node process. --eval=<attacker JavaScript>runs outside vm2 and has normal host builtin access.
The doubled prefix is the reachability mechanism, but the security boundary failure is broader: the generic host-passthrough loader treats the test builtin family as safe even though its run() API can launch unrestricted Node processes.
Proof of concept
From the poc directory:
npm ci --ignore-scripts --no-audit --no-fund
node repro.js
Expected successful result on Node.js 24+ includes:
{
"vm2Version": "3.11.5",
"nodeVersion": "v24.18.0",
"markerExists": true,
"childIsDistinctProcess": true,
"marker": {
"hostCodeExecution": true
}
}
The PoC writes only host-rce-marker.json in its own directory and does not invoke a shell, contact a network service, or access third-party data.
Impact
An attacker who is intentionally permitted to execute untrusted JavaScript in the affected NodeVM configuration can escape the sandbox and execute arbitrary JavaScript under the embedder's operating-system identity.
This provides the spawned process with the host user's filesystem, environment, network, and process-execution permissions. It can therefore result in complete confidentiality, integrity, and availability impact for the hosting service.
Suggested remediation
Treat the normalized test builtin family as dangerous before wildcard expansion and explicit builtin registration.
For example, add test to DANGEROUS_BUILTINS so the existing prefix and family checks reject both node:test and node:test/reporters:
const DANGEROUS_BUILTINS = new Set([
// existing entries
'test'
]);
If test helpers must be exposed, provide a sandbox-local wrapper through mock or override that does not expose run(), process isolation, execArgv, or other host process controls.
Recommended regression cases:
- explicit
builtin: ['node:test'] - wildcard builtin configurations
require('node:test')require('node:node:test')node:test/reportersand prefixed variants- direct low-level builtin registration
- attempts to pass
--eval,--require, or--importthrough test-runner process options vm2-node-test-ghsa-submission.zip
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | vm2 | ≥ 3.9.6&&< 3.11.7 | 3.11.7npm install vm2@3.11.7 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for vm2, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update vm2 to 3.11.7 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-qhwx-74w5-xhxq is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
An important-impact sandbox escape affects the vm2 JavaScript sandbox library as shipped in Red Hat Ansible Automation Platform 2.1 and 2.2 (automation-portal and bootc-automation-portal-rhel9 containers) and Red Hat Developer Hub 1.9 and 1.10 (rhdh-hub-rhel9 and the orchestrator and lightspeed backend plugin…
This flaw is only reachable when the NodeVM sandbox configuration explicitly allows the node:test built-in and the application runs on Node.js 24 or later. As a workaround, remove node:test from the allowed builtins in the vm2 sandbox configuration (for example, drop it from the require.builtin allowlist), or run the embedding application on a Node.js version where the scheme-only node:test entry is not exposed (the exploit path is not present on Node.js 22). If test functionality must be exposed to sandboxed code, provide a sandbox-local wrapper using vm2's mock or override options that does not expose run(), process isolation, execArgv, or other host process controls. Otherwise, update to…Source: Red Hat security advisory for GHSA-qhwx-74w5-xhxq (CC BY 4.0)
| Product | Fixed in | Advisory |
|---|---|---|
| Red Hat Ansible Automation Platform 2.1 | ansible-automation-platform/automation-portal:1791295379 | RHSA-2026:80603 |
| Red Hat Ansible Automation Platform 2.2 | ansible-automation-platform/automation-portal:1791293780 | RHSA-2026:80644 |
| Red Hat Ansible Automation Platform 2.2 | ansible-automation-platform/bootc-automation-portal-rhel9:1791865660 | RHSA-2026:82151 |
| Red Hat Developer Hub 1.10 | rhdh/red-hat-developer-hub-backstage-plugin-lightspeed-backend:1791242697 | RHSA-2026:76788 |
| Red Hat Developer Hub 1.10 | rhdh/rhdh-hub-rhel9:1791311495 | RHSA-2026:79088 |
| Red Hat Developer Hub 1.9 | rhdh/rhdh-hub-rhel9:1793117813 | RHSA-2026:91651 |
Frequently Asked Questions
Is GHSA-qhwx-74w5-xhxq in your dependencies?
Find it across npm, including transitive dependencies.