Executive brief
vm2 is a popular Node.js library used to safely execute untrusted JavaScript code in an isolated sandbox environment. The CLI tool shipped with vm2 fails to properly isolate sandboxed scripts, allowing an attacker to provide a malicious script file that breaks out of the sandbox and executes arbitrary code with full access to the host system, including filesystem and process execution capabilities.
Technical details
The vulnerability is a sandbox escape in the vm2 CLI tool (bin/vm2) caused by improper configuration of the NodeVM instance. The CLI invokes NodeVM.file() with require:{external:true} but fails to configure require.root, require.context, or require.builtin restrictions. This allows a sandboxed script to call require(__filename) to re-execute itself in the host realm via the resolver's loadJS() function, which performs the actual module load through the host require() function before wrapping results. An attacker supplying a script file to the documented vm2 ./script.js invocation can achieve arbitrary code execution in the host Node.js process with no preconditions or user interaction beyond running the tool. The vulnerability was patched in version 3.11.7.
Affected products
- vm2 vm2 before 3.11.7
Timeline
- 2026-08-24: disclosed: GitHub Security Advisory GHSA-jxxv-8r27-vm4p published
- 2026-09-17: advisory: CVE-2026-92950 and NVD entry published