# CVE-2023-29017: Critical vm2 Sandbox Escape Leads to Host RCE

> Technical analysis of CVE-2023-29017 in the vm2 Node.js library. Learn how attackers escape the sandbox for remote code execution and how to patch.

- Published: 2026-05-06T20:36:13.000Z
- Severity: high
- Category: Vulnerabilities
- Tags: CVE-2023-29017, Vm2, Node Js, Sandbox Escape, RCE
- Author: Runtime Rebel Intel
- Primary source: https://www.bleepingcomputer.com/news/security/critical-vm2-sandbox-bug-lets-attackers-execute-code-on-hosts/
- Canonical: https://runtimerebel.com/blog/cve-2023-29017-critical-vm2-sandbox-escape-leads-to-host-rce

## Key points

- Attackers can achieve full host code execution by bypassing isolation in the widely used vm2 Node.js library.
- The vulnerability impacts all versions of vm2 up to 3.9.14 when processing untrusted JavaScript code.
- Developers must update the vm2 library to version 3.9.15 immediately to remediate this critical security flaw.

The vm2 library is a prominent Node.js module designed to execute untrusted code within a secure, isolated environment. With millions of weekly downloads, it is a foundational component for many platforms that allow users to run custom scripts or perform server-side data processing. However, the discovery of [CVE-2023-29017](https://nvd.nist.gov/vuln/detail/CVE-2023-29017) has highlighted a severe flaw in this isolation mechanism. According to [Bleeping Computer](https://www.bleepingcomputer.com/news/security/critical-vm2-sandbox-bug-lets-attackers-execute-code-on-hosts/), this [CVE](/glossary#cve) allows a remote attacker to escape the sandbox and execute arbitrary commands on the underlying host system, carrying a maximum [CVSS](/glossary#cvss) score of 10.0.

## Technical Analysis of CVE-2023-29017 Sandbox Escape

The vulnerability, discovered by security researcher SeungHyun Lee, resides in the way vm2 handles the `Error.prepareStackTrace` property when an asynchronous error occurs. In a standard Node.js environment, `Error.prepareStackTrace` is a function that can be customized to format stack traces. The vm2 library attempts to wrap and proxy various global objects to prevent them from leaking host-side functionality to the sandboxed code. 

However, by specifically manipulating how asynchronous errors are triggered, an attacker can bypass these proxy protections. The exploit involves overwriting the `prepareStackTrace` method and triggering an error that causes the host-side Error object to interact with the sandboxed version. This interaction allows the attacker to access the host's `process` object or other sensitive globals, facilitating a full [RCE](/glossary#rce). Because the escaped code runs with the same permissions as the Node.js process itself, this can lead to total system compromise, including unauthorized data access and [Lateral Movement](/glossary#lateral-movement) within the network.

### How to detect CVE-2023-29017 exploit

Security professionals and [SOC](/glossary#soc) teams should monitor for unusual child process spawning originating from Node.js applications that utilize the vm2 library. Patterns consistent with the [MITRE ATT&CK](/glossary#mitre-att-ck) technique T1203 (Exploitation for Client Execution) may be visible in system logs. Specifically, look for calls to `/bin/sh` or `cmd.exe` that are not part of the application's normal operational baseline. Since the exploit leverages the manipulation of error objects, high volumes of unhandled asynchronous errors in application logs may also serve as a preliminary [IoC](/glossary#ioc).

## Remediation and Mitigation Strategies

The primary and most effective remediation is to update the library to the latest version. The **Node.js vm2 library RCE fix** was introduced in version 3.9.15, which specifically addresses the handling of the stack trace formatting logic to prevent the sandbox escape. 

### vm2 3.9.14 sandbox escape mitigation

For organizations unable to update immediately, the following steps are recommended:

*   **Disable User Scripting:** If the functionality is not essential, disable the feature that allows users to submit or run custom JavaScript through vm2.
*   **Implement Strict Input Validation:** While difficult for complex scripts, validating the structure of submitted code to prevent the use of `Error.prepareStackTrace` can reduce the attack surface.
*   **Network Segmentation:** Ensure that the server running the vm2 instance has restricted network access to prevent an attacker from reaching internal management interfaces or [C2](/glossary#c2) servers after a successful escape.

Given the history of sandbox escapes in vm2 and similar libraries, developers should evaluate if a [Zero Trust](/glossary#zero-trust) approach to execution is required. In high-risk scenarios, moving isolation to a more robust level—such as using hardware-level virtualization or containers with restricted syscall access—may provide more durable security than software-based JavaScript sandboxing alone.

**Related:** [Google Gemini CLI Host Code Execution: Securing AI Developer Tools](/blog/google-gemini-cli-host-code-execution-securing-ai-developer-tools), [Google Antigravity RCE via Prompt Injection — Mitigation Guide](/blog/google-antigravity-rce-via-prompt-injection-mitigation-guide)

---

AI-generated analysis from the primary source above; not human-reviewed before publication — verify anything operational against the original (https://runtimerebel.com/editorial). Quote with attribution and a link to the canonical URL: https://runtimerebel.com/blog/cve-2023-29017-critical-vm2-sandbox-escape-leads-to-host-rce
