/

CVE-2026-43997

Severity:

CRITICAL RISK

(10.0)

Code Injection / Sandbox Escape in vm2 Node.js Sandbox

CVE-2026-43997

Modified

Vulnerability type

Category:

Code Injection / Sandbox Escape

CWE:

CWE-94, CWE-653

Impact:

Remote Code Execution via Sandbox Escape

Severity:

CRITICAL RISK

(10.0)

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

vm2, a popular sandboxing library for Node.js, allowed sandboxed code to obtain a reference to the host Object before version 3.11.0.

With access to the host Object, attackers can bypass isolation, inject arbitrary JavaScript, and potentially execute code on the host environment whenever untrusted code is run inside vm2.

Affected context

This vulnerability affects applications that:

  • Use vm2 as a sandbox to execute untrusted or semi-trusted JavaScript
  • Rely on vm2 isolation guarantees to protect the host Node.js process
  • Expose host utilities or objects to the sandboxed code, directly or indirectly

The risk is most pronounced in multi-tenant systems, online code runners, plugin architectures, or any environment where user-controlled code is evaluated in vm2.

Exploit preconditions

  • Attack surface: Any vm2 sandbox where untrusted or user-controlled JavaScript is executed.
  • Required access: Ability to run code inside the vm2 VM (e.g., via APIs that accept dynamic scripts, plugins, or expressions).
  • Trigger point: Execution of crafted sandboxed code that discovers and abuses the leaked host Object.
  • Why exploitation is possible: The sandbox exposes a reference to the host Object, breaking isolation boundaries and allowing the guest code to reach host-level APIs or symbols, which can then be leveraged to escape and inject arbitrary code.

Why this happens

The underlying issue stems from incomplete isolation between the sandbox environment and the host Node.js runtime.

vm2's security model assumes that sandboxed code has no direct references to host-level objects; however, due to an implementation flaw, the host Object became reachable from within the sandbox.

Once this reference is obtained, JavaScript's reflective and metaprogramming capabilities (such as introspection via Symbols or property descriptors) can be used to traverse back into privileged host APIs.

This aligns with CWE-94: Improper Control of Generation of Code (Code Injection), because untrusted code gains a path to inject and execute arbitrary logic in a context that was supposed to be isolated.

Potential impact

  • Execution of arbitrary JavaScript in the host Node.js process
  • Complete sandbox escape, nullifying isolation guarantees
  • Access to sensitive data and environment variables available to the host process
  • Lateral movement within the application by invoking internal services or APIs
  • Potential full compromise of the underlying server, depending on host privileges and integrations

General mitigation guidance

Mitigation strategies center on strengthening isolation boundaries and minimizing trust in sandboxing as a sole security control:

  • Treat sandboxing libraries as defense-in-depth, not the only barrier between untrusted code and the host.
  • Reduce the amount of untrusted code executed; prefer constrained, declarative configurations over dynamic code execution.
  • Avoid exposing host objects, utilities, or global references into the sandbox wherever possible.
  • Apply strict least-privilege policies to the host Node.js process (file system, network, and OS-level capabilities).
  • Use process-level or container-level isolation (e.g., separate OS processes, containers, or jails) for high-risk code execution workloads.
  • Regularly review sandbox configuration and ensure that any custom hooks or bridges do not leak host references.

How teams detect issues like this

Detection efforts can focus on both code-level patterns and runtime behavior:

  • Static analysis and code review:
  • Flag occurrences where user-supplied code or templates are executed within vm2.
  • Review any bridging code that passes host objects into the vm2 context.
  • Look for patterns exposing global objects, Symbols, or inspection utilities to sandboxed code.
  • Policy and configuration checks:
  • Enforce internal guidelines around safe sandbox use and restricted host interactions.
  • Require security review for any new feature that evaluates user-controlled scripts, plugins, or expressions.
  • Runtime monitoring:
  • Monitor for unusual behavior from processes running vm2, such as unexpected file system or network access.
  • Use logging around sandbox executions to track which inputs are executed and correlate with suspicious behavior.
  • Automated tools can assist by scanning repositories for dynamic code execution patterns and known unsafe sandbox usage, but should be combined with manual review for context.

Sources

SourceLink
github.comgithub.com/patriksimek/vm2/security/advisories/GHSA-47x8-96vw-5wg6
access.redhat.comaccess.redhat.com/errata/RHSA-2026:50850
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-43997
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2477203
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-43997.json

Frequently asked

questions

It is broadly exploitable in any application that lets users or external systems provide code running inside vm2. If you only execute fully trusted code, the practical risk is lower, but the structural isolation failure remains.

The attacker must be able to execute JavaScript inside the vm2 sandbox—typically through APIs that run user-defined scripts, plugins, or expressions. No direct access to the host environment is required beyond that.

The safest pattern is to ensure that sandboxed code cannot obtain references to host objects or privileged APIs at all. Combine this with additional isolation layers such as separate processes or containers for high-risk execution, and review any bridging logic for leaks.

To prevent similar issues, limit reliance on in-process sandboxes, enforce design reviews for any features evaluating untrusted code, and adopt a multi-layered isolation strategy. Regular security testing, threat modeling, and static analysis focused on dynamic execution paths can catch sandbox boundary weaknesses earlier.

Find out what's already
exploitable in your codebase.