vm2 NodeVM path bypass in custom resolution

Severity: critical · CVSS 9 · Published 2026-09-27

vm2 is a Node.js virtual machine library that runs untrusted code in a sandboxed environment. When using a custom module resolver with host-context permissions, an attacker can bypass the external module allowlist by exploiting incomplete path boundary checking, allowing them to load and execute arbitrary files with host-process privileges, achieving a complete sandbox escape.

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?
Critical severity, with a CVSS score of 9, published 27 September 2026.
Which products and versions are affected?
vm2 (npm) < 3.12.2; Patriksimek Vm2 <3.12.2.
Is there a fix for This vulnerability?
Yes: fixed in 3.12.2. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network, in a software library.
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.

How to fix

  • Fixed in: 3.12.2

Technical details

The vulnerability exists in LegacyResolver.customResolve (lib/resolver-compat.js), which stores allowlisted module paths as a regular expression without enforcing path separators or string boundaries; an attacker can require a sibling module whose path merely shares the prefix of an allowlisted module (e.g., "foo2" after "foo" is allowlisted), and it will pass the isPathAllowedForModule check. The module then loads through hostRequire, executing its top-level code in the host process before vm.readonly wrapping, resulting in arbitrary code execution. This requires the embedder to use context: 'host' with a custom resolver.

Affected products

  • patriksimek vm2 <3.12.2

Timeline

  • 2026-09-08: disclosed
  • 2026-09-27: advisory
  • 2026-10-05: other: advisory withdrawn as duplicate of GHSA-5h3f-q97h-ccvc

References

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