Executive brief
vm2 is a popular Node.js library used to run untrusted code in a restricted 'sandbox' environment to prevent it from accessing the host system. A critical flaw allows an attacker to bypass these restrictions and escape the sandbox. If exploited, an attacker can execute unauthorized commands on the underlying server, potentially leading to full system takeover and data theft.
Technical details
A sandbox breakout exists in vm2 due to improper control of dynamically-managed code resources (CWE-913) within the Promise constructor. Specifically, the 'localPromise' constructor fails to call 'resetPromiseSpecies' before invoking the 'then' method. An attacker can exploit this by hijacking the 'Symbol.species' protocol to provide a custom constructor, allowing them to capture V8's internal resolution capabilities. By combining this with a recursion-induced RangeError, the attacker can obtain a reference to a host-realm Error object and use its constructor to access the host's 'process' object and execute arbitrary commands via 'child_process'. This issue is patched in version 3.11.4.
Affected products
- patriksimek vm2 <= 3.11.3
Timeline
- 2026-05-17: patched: Fix committed to repository
- 2026-05-18: advisory: GitHub Security Advisory published
- 2026-06-12: disclosed: CVE published to NVD