vm2 CLI sandbox escape via require(__filename)

Severity: high · CVSS 8.6 · Published 2026-09-17

vm2 is a Node.js library that executes untrusted JavaScript code in an isolated sandbox. The CLI tool runs scripts with insufficient sandbox isolation, allowing attackers to pass a malicious script file that escapes the sandbox and executes arbitrary code in the host Node.js process with full access to system modules like the file system and child processes.

Technologies: vm2 (npm), Patriksimek Vm2. Vendors: npm, Patriksimek.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
High severity, with a CVSS score of 8.6, published 17 September 2026.
Which products and versions are affected?
vm2 (npm) <= 3.11.6; Patriksimek Vm2 <= 3.11.6.
Is there a fix for This vulnerability?
A patch was published on 2026: Version 3.11.7 patches the vulnerability Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked with local access.
Am I affected?
Check whether you run vm2 (npm) or Patriksimek Vm2 at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

Technical details

The vm2 CLI invokes NodeVM.file() with require:{external:true} but without configuring require.root, require.context, or require.builtin. This allows any require() call within the sandboxed script to resolve through the host's require() function. An attacker supplies a script that calls require(__filename) to re-execute itself in the host realm, bypassing sandbox isolation and gaining access to host modules (fs, child_process, etc.). The vulnerability requires only supplying a malicious script file to the vm2 CLI with no additional preconditions.

Affected products

  • patriksimek vm2 <= 3.11.6

Timeline

  • 2026-08-24: disclosed
  • 2026: patched: Version 3.11.7 patches the vulnerability

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.