vm2 allowlist bypass via substring matching in module resolver

Severity: critical · CVSS 9.9 · Published 2026-09-17

vm2 is a sandbox library that isolates untrusted JavaScript code running on Node.js. The library restricts which external npm packages sandboxed code can access using an allowlist. A flaw in the allowlist check uses substring matching instead of exact package name validation, allowing attackers to bypass the allowlist by loading similarly-named malicious packages (e.g., "evil-left-pad" when "left-pad" is allowlisted), resulting in arbitrary code execution in the host context.

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

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.9, published 17 September 2026.
Which products and versions are affected?
vm2 (npm) <= 3.11.6; Vm2 <= 3.11.6.
Is there a fix for This vulnerability?
A patch was published on 2026-08-24: Fixed in version 3.11.7 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 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 vulnerability exists in the external package allowlist pre-check logic, which generates an unanchored regular expression that performs substring matching on package names instead of full boundary validation. When NodeVM uses both require.external (allowlist) and a custom require.resolve callback, an attacker can supply a colliding package name containing an allowlisted substring. If the custom resolver can locate the malicious package in the host filesystem, vm2 loads it with host require() in 'host' context mode, executing the package code with full host privileges. The fix is to use anchored, exact-match validation of package names against the allowlist.

Affected products

  • vm2 <= 3.11.6

Timeline

  • 2026-08-24: disclosed
  • 2026-08-24: patched: Fixed in version 3.11.7

References

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