Remote Code Execution (RCE) Affecting vm2 package, versions <3.11.7


Severity

Recommended
0.0
critical
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Remote Code Execution (RCE) vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-VM2-19513551
  • published3 Sept 2026
  • disclosed24 Aug 2026
  • creditabisheikM1, AbisheikMagesh, Den1al

Introduced: 24 Aug 2026

New CVE NOT AVAILABLE CWE-94  (opens in a new tab)

How to fix?

Upgrade vm2 to version 3.11.7 or higher.

Overview

vm2 is a sandbox that can run untrusted code with whitelisted Node's built-in modules.

Affected versions of this package are vulnerable to Remote Code Execution (RCE) in its external module loader, lib/resolver-compat.js (makeResolverFromLegacyOptions, CustomResolver.isPathAllowed, and CustomResolver.loadJS), where two unsafe defaults combine: when require.root is undefined isPathAllowed returns true for every path, and the context parameter defaults to 'host' so a resolved module is loaded through the real Node.js require() rather than through the sandbox. An attacker can execute arbitrary OS commands via child_process, read and write arbitrary files, and fully circumvent the outer sandbox by submitting sandboxed code that requires vm2's own installed package to obtain unwrapped classes, then instantiates an unrestricted nested NodeVM from them and runs host code inside it. This requires the application to enable require.external: true without setting require.root to exclude node_modules, and the exposure is not limited to an obviously misconfigured setup, because even the documented "Quick Examples" configuration of root: './' looks restrictive yet still resolves ./node_modules/vm2 and is therefore exploitable.

CVSS Base Scores

version 4.0
version 3.1