vm2 module allowlist bypass via prefix matching

Severity: medium · CVSS 4.2 · Published 2026-09-17

vm2 is a JavaScript virtual machine runtime that uses an allowlist to control which external modules can be loaded. A flaw in the allowlist check uses simple string prefix matching, allowing an attacker to access packages with names that share a prefix with allowlisted packages. An attacker who can run code in NodeVM can reach unauthorized packages and potentially access sensitive data or execute unintended code.

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?
Medium severity, with a CVSS score of 4.2, published 17 September 2026.
Which products and versions are affected?
vm2 (npm) <= 3.11.6; Patriksimek Vm2 before 3.11.7.
Is there a fix for This vulnerability?
A patch was published on 2026-08-24: Fix available 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.
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 isPathAllowedForModule function in lib/resolver-compat.js uses startsWith() for prefix matching instead of boundary-anchored comparison, allowing paths like node_modules/foo2 to match an allowlist entry for node_modules/foo. An attacker can exploit this by performing a relative require from an allowlisted package to reach a prefix-sharing sibling package when transitive loading is disabled. The fix requires path separator validation: checking for path equality or path + separator, not raw prefix matching.

Affected products

  • Patriksimek vm2 before 3.11.7

Timeline

  • 2026-08-24: disclosed: Original advisory GHSA-7q3f-wx44-378m published
  • 2026-09-17: advisory: Duplicate advisory GHSA-8mvv-mcc3-xwhh published
  • 2026-08-24: patched: Fix available in version 3.11.7

References

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