vm2 Sandbox Breakout Vulnerability Allowing Remote Code Execution

Vulnerability

A sandbox breakout vulnerability has been identified in vm2, an open-source virtual machine/sandbox for Node.js, affecting versions through 3.11.2. This vulnerability allows attackers to escape the vm2 sandbox and execute arbitrary commands on the host system. The issue arises from the ability to catch host exceptions using the yield* expression within an async generator. When the generator is closed with the return function, the awaited value can include exceptions thrown, which are then passed to the yield* iterator as the next value. This behavior can be exploited to execute unauthorized commands on the host.

Impact

Exploitation of this vulnerability allows for remote code execution on the host system, with the executed code running in the context of the vm2 sandbox, but with the potential to escape the sandbox and affect the host.

Reproduction

To reproduce this vulnerability, create a vm2 instance and run a script that utilizes an async generator. The script should include a function that throws an error, such as a RangeError, which can be caught and processed in a way that escapes the sandbox. The provided proof-of-concept code demonstrates this exploitation by throwing a RangeError, catching it, and then using the error to execute a command on the host system.

Remediation

Users can upgrade to vm2 version 3.11.3 or later to address this vulnerability.

Added: May 13, 2026, 7:45 PM
Updated: May 13, 2026, 7:45 PM

Vulnerability Rating

Custom Algorithm
spread
6.6
impact
10.0
exploitability
5.5
remediation
7.7
relevance
8.2
threat
6.4
urgency
2.9
incentive
0.0

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.