vm2: NodeVM builtin allowlist bypass via node:test.run() execArgv allows sandbox escape
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: vm2@3.9.5 blocks require('node:node:test'), while vm2@3.9.6 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
Betroffene Software
Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.
| Plattform | Paket | Anfällige Versionen | Behoben in |
|---|---|---|---|
| npm-Paket | vm2 | >= 3.9.6, < 3.11.7 | 3.11.7 |
Verweise
- https://github.com/patriksimek/vm2/security/advisories/GHSA-qhwx-74w5-xhxq
- https://nvd.nist.gov/vuln/detail/CVE-2026-92948
- https://github.com/patriksimek/vm2/commit/415339f698f0d52d3c5ad358b12b79c8072d5b4b
- https://github.com/patriksimek/vm2
- https://github.com/patriksimek/vm2/releases/tag/v3.11.7
- https://www.vulncheck.com/advisories/vm2-3.9.6-through-3.11.5-sandbox-escape-via-node-test
- CVSS-Vektor
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H- Schwäche (CWE)
CWE-693- Plattform
- npm
- Paket
vm2- Veröffentlicht
- 01.10.2026
- Aktualisiert
- 11.10.2026 10:22
Quellen und Lizenzen
OSV / GitHub Advisory Database - GHSA-qhwx-74w5-xhxq - CC BY 4.0
Schwachstellenhistorie: vm2
Alle veröffentlichten Schwachstellen dieses Pakets (npm-Paket), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.
- Einträge insgesamt
- 78
- Erste → letzte
- 10.2021 10.2026
- Ohne Fix
- 1
- In Angriffen ausgenutzt
- 0
Verteilung nach Schweregrad
- Kritisch 51
- Hoch 14
- Mittel 12
- Niedrig 1
Veröffentlichungen pro Jahr
- 2021: 1
- 2022: 4
- 2023: 7
- 2024: 0
- 2025: 0
- 2026: 66
-
vm2: NodeVM builtin allowlist bypass via node:test.run() execArgv allows sandbox escape dieser Eintrag
Erkennen Sie Schwachstellen in Ihrer Anwendung
Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.