Critical vm2 flaws let attackers escape Node.js sandboxes and run host commands


Multiple critical vulnerabilities in the vm2 Node.js sandbox library can let attackers break out of the sandbox and execute commands on the host system. The flaws affect applications that use vm2 to run untrusted JavaScript, including code runners, plugin systems, workflow tools, testing platforms, and internal automation services.

The newest safe upgrade target is vm2 version 3.11.2. The release includes security fixes for the latest sandbox escape issues, including flaws tied to null-prototype exception handling and Array species behavior.

The risk is serious because vm2 runs inside the same Node.js process as the host application. If sandboxed code escapes, it may reach host objects, load restricted modules, access the process object, and run operating system commands.

Why these vm2 vulnerabilities matter

vm2 is designed to run untrusted JavaScript with restrictions. Developers use it when they need to let users, plugins, scripts, or automated systems execute code without exposing the main application.

The new advisories show that this security boundary can fail in several ways. Some issues abuse JavaScript prototype behavior, Promise species handling, exception logic, WebAssembly behavior, or module loading rules.

In practical terms, an attacker who can submit code into a vulnerable vm2 sandbox may escape into the host environment. From there, they may run commands with the privileges of the Node.js process.

At a glance

DetailWhat it means
Affected packagevm2 for Node.js
Main impactSandbox escape and arbitrary command execution on the host
High-risk use casesCode execution platforms, plugin systems, CI tools, automation platforms, and multi-tenant services
Latest fixed version3.11.2
Recommended actionUpdate immediately and add stronger isolation around untrusted code

Which vm2 flaws were disclosed

The disclosed issues include several critical sandbox escapes with CVSS scores reaching 10.0. Affected versions vary by vulnerability, but older releases before 3.11.2 should be treated as risky in environments that execute untrusted code.

One issue, CVE-2026-24118, abuses __lookupGetter__ behavior to reach host-side objects and execute commands. Another, CVE-2026-24120, bypasses a previous Promise species fix and can again lead to command execution.

Other flaws involve inspect handling, SuppressedError behavior, prototype traversal, restricted module loading, prototype pollution, null-prototype exceptions, and Array species handling. CVE-2026-26956 is also notable because it involves WebAssembly behavior and was confirmed in a Node.js 25 environment.

Key CVEs and patch status

CVEIssue typeFixed in
CVE-2026-24118Sandbox breakout through __lookupGetter__3.11.0
CVE-2026-24120Promise species sandbox escape3.10.5
CVE-2026-24781Sandbox escape through inspect behavior3.11.0
CVE-2026-26332Sandbox escape through SuppressedError behavior3.11.0
CVE-2026-26956WebAssembly-related sandbox escape3.10.5
CVE-2026-43997Code injection leading to host object access3.11.0
CVE-2026-43999NodeVM built-in allowlist bypass3.11.0
CVE-2026-44005Sandbox escape and prototype pollution3.11.0
CVE-2026-44006BaseHandler.getPrototypeOf code injection3.11.0
CVE-2026-44007Improper access control sandbox escape3.11.1
CVE-2026-44008Array species sandbox escape3.11.2
CVE-2026-44009Null-prototype exception sandbox escape3.11.2

How attackers can abuse these flaws

The attack path depends on where vm2 sits in an application. If a service lets users submit JavaScript for execution, an attacker may send crafted code that triggers one of the sandbox escape paths.

After the escape, the attacker may reach the host Function constructor or process object. That can allow access to Node.js internals and restricted modules such as child_process.

Once command execution works, the impact depends on the permissions of the Node.js process. A poorly isolated service could expose files, environment variables, access tokens, cloud credentials, internal network access, or build secrets.

Who should act first

  • Services that run user-submitted JavaScript
  • Online code editors and coding challenge platforms
  • Plugin systems that execute third-party scripts
  • CI/CD tools that evaluate scripts dynamically
  • Low-code and workflow automation platforms
  • Multi-tenant SaaS products that rely on JavaScript sandboxing
  • Internal tools that run scripts from tickets, dashboards, or user input

Updating vm2 is not the full fix

Developers should update to vm2 3.11.2 immediately. This reduces exposure to the newly disclosed flaws and brings the package to the latest security-fixed release.

Still, the vm2 project warns that in-process JavaScript sandboxing has limits. Its own documentation now explains that JavaScript is highly dynamic and that new bypasses may continue to appear.

For high-risk workloads, teams should not rely on vm2 as the only security layer. Running untrusted code in a separate process, container, microVM, or managed isolation environment gives defenders a stronger boundary than an in-process JavaScript sandbox.

Practical steps for developers

  • Upgrade vm2 to version 3.11.2 across all projects.
  • Search package-lock.json, pnpm-lock.yaml, yarn.lock, and SBOM files for older vm2 versions.
  • Check transitive dependencies that may still pull vulnerable vm2 releases.
  • Disable execution of untrusted code until the update is deployed.
  • Run sandbox workloads with least-privilege user accounts.
  • Move high-risk execution to containers, microVMs, or separate processes.
  • Restrict filesystem, network, and environment variable access for sandbox workers.
  • Rotate exposed secrets if suspicious sandbox execution occurred.

Why stronger isolation matters

The core lesson is simple: a JavaScript-only sandbox can reduce risk, but it should not define the entire security boundary for hostile code. Attackers only need one bypass to move from sandboxed code to the host process.

Containers and microVMs are not perfect, but they create a separate operating system boundary. That gives defenders more places to enforce limits, monitor behavior, and contain damage.

Teams that run untrusted JavaScript should treat vm2 as one layer in a larger design. The safer architecture limits what the sandboxed process can read, where it can connect, and which credentials it can access.

FAQ

Are all older vm2 versions unsafe?

Older versions should be treated as risky in systems that execute untrusted code. Different CVEs affect different versions, but 3.11.2 is the current safe upgrade target.

Which vm2 version should developers install?

Developers should update to vm2 3.11.2, which is the newest release with the latest security fixes.

What is the main risk from these vulnerabilities?

The main risk is sandbox escape. An attacker who can run code inside a vulnerable vm2 sandbox may escape and execute commands on the host system.

What is vm2?

vm2 is a Node.js sandbox library that runs untrusted JavaScript with restrictions. It supports use cases where applications need controlled code execution.

Readers help support VPNCentral. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help VPNCentral sustain the editorial team Read more

User forum

0 messages