/

CVE-2026-26332

Severity:

CRITICAL RISK

(9.8)

Sandbox Escape / Code Injection in vm2 for Node.js

CVE-2026-26332

Modified

Vulnerability type

Category:

Sandbox Escape / Code Injection

CWE:

CWE-94, CWE-693, CWE-653

Impact:

Remote Code Execution via Sandbox Escape

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A sandbox escape vulnerability in vm2 allows untrusted code to break out of the virtual machine and execute arbitrary JavaScript in the host Node.js process.

By abusing the handling of SuppressedError, an attacker can bypass vm2's isolation guarantees, turning supposedly sandboxed code execution into full remote code execution on the underlying environment.

Affected context

This issue affects applications that:

  • Use vm2 to execute untrusted or partially trusted JavaScript in a sandbox
  • Rely on vm2's isolation to prevent executed code from accessing the host environment
  • Run Node.js versions where SuppressedError behavior can be interacted with from sandboxed code

The risk is highest in multi-tenant or plugin-style architectures where external users, extensions, or configuration can influence code executed inside vm2.

Exploit preconditions

  • Attack surface: Any endpoint, plugin system, job runner, or API that feeds user-controlled or untrusted JavaScript into vm2.
  • Required access: Ability to supply or influence code or data executed within the vm2 sandbox (e.g., script uploads, templates, custom rules, or user-defined functions).
  • Trigger point: Execution of crafted code that interacts with SuppressedError inside the vm2 environment.
  • Why exploitation is possible: vm2's handling of SuppressedError fails to fully contain or scrub host-level objects and capabilities, allowing sandboxed code to pierce the isolation boundary and reach host execution context, mapping to CWE-94 (Improper Control of Code Generation) and compounded by CWE-693 (Protection Mechanism Failure).

Why this happens

The core issue lies in vm2's incomplete enforcement of isolation around the SuppressedError mechanism.

Error handling paths are part of the security boundary in a sandbox, and in this case, SuppressedError objects or related metadata exposed more capability than intended to sandboxed code.

This constitutes a protection mechanism failure (CWE-693) because the sandbox's isolation guarantees did not hold under certain error conditions.

Once exposed to more powerful host objects or references, an attacker can craft code that leverages these primitives to construct or execute new code in the host context, aligning with CWE-94: Improper Control of Generation of Code.

In abstract terms, the sandbox trusted that error-related objects were safe to expose, but their structure allowed re-entry into the host runtime.

Potential impact

  • Execution of arbitrary JavaScript in the host Node.js process, bypassing sandbox restrictions
  • Access to environment variables, filesystem APIs, network APIs, or process controls available to the Node.js host
  • Lateral movement within the application, including access to sensitive configuration, secrets, or backend services
  • Full compromise of the application's trust boundary, enabling data exfiltration or modification of other tenants' data in multi-tenant systems
  • Use of the compromised process as a stepping stone for broader infrastructure attacks, depending on host privileges

General mitigation guidance

Effective mitigation focuses on strengthening the isolation boundary and reducing trust in sandboxing as a singular control:

  • Prefer defense-in-depth: treat vm2 as one layer, not the sole barrier between untrusted code and sensitive resources.
  • Harden the host environment by enforcing least privilege for the Node.js process (minimal filesystem access, limited environment variables, restricted outbound network).
  • Use additional OS-level sandboxing (containers, seccomp, AppArmor, SELinux, or dedicated runtime sandboxes) around processes that execute untrusted code.
  • Isolate untrusted execution into separate processes or containers with narrow, well-defined communication channels instead of sharing the main application process.
  • Avoid exposing powerful host objects or error types directly to sandboxed code; validate and sanitize the interface between sandbox and host.
  • Establish clear boundaries for what untrusted code is allowed to do, and enforce them through configuration and architectural patterns rather than relying solely on library guarantees.

How teams detect issues like this

Organizations can approach detection and assurance by:

  • Reviewing code paths where vm2 is used to:
  • Identify where untrusted or user-controlled inputs are executed.
  • Map the privileges of the Node.js process and what a sandbox escape would expose.
  • Applying static analysis and secure code review to:
  • Flag uses of sandboxing libraries as "high-value" security review targets.
  • Ensure no privileged host objects, error classes, or global references are intentionally passed into the sandbox.
  • Implementing runtime monitoring:
  • Track unexpected filesystem access, environment variable usage, or network calls from processes that should be "restricted".
  • Alert on anomalous behaviors following execution of untrusted scripts or user-generated code.
  • Incorporating security testing:
  • Fuzz or penetration test sandboxed execution paths, focusing on error handling, prototype chains, and exposed APIs.
  • Use automated security scanners or SAST/DAST tools that highlight sandbox usage and potential breakout vectors.

Sources

SourceLink
github.comgithub.com/patriksimek/vm2/releases/tag/v3.11.0
github.comgithub.com/patriksimek/vm2/security/advisories/GHSA-55hx-c926-fr95
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-26332
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2466508
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-26332.json

Frequently asked

questions

It can be, if an attacker can supply or influence the code that is executed inside vm2. Any web endpoint, plugin framework, or automation feature that runs user-controlled JavaScript in vm2 may become a remote attack surface.

The attacker must have the ability to make their code or payload run inside the vm2 sandbox. This could be through uploading scripts, defining rules, customizing templates, or any other mechanism that results in execution within vm2.

Architecturally, the safest pattern is to isolate untrusted code execution into a strongly sandboxed process or container with minimal privileges and a narrow IPC interface, rather than relying solely on in-process libraries. Within the application code, ensure no powerful host capabilities, special error objects, or global references are exposed inside the sandbox boundary.

Treat sandbox boundaries as critical security mechanisms: design with the assumption that in-process sandboxes can fail, apply least privilege to the host process, add OS-level isolation where possible, and incorporate targeted security reviews and testing around all untrusted code execution paths. Regularly track security advisories for sandboxing libraries and plan for rapid remediation when isolation weaknesses are discovered.

Find out what's already
exploitable in your codebase.