/

CVE-2026-24781

Severity:

CRITICAL RISK

(9.8)

Code Injection / Sandbox Escape in vm2 inspect Function for

CVE-2026-24781

Modified

Vulnerability type

Category:

Code Injection / Sandbox Escape

CWE:

CWE-94, CWE-693, CWE-653

Impact:

Remote Code Execution and 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 breakout vulnerability in vm2's inspect functionality allows attacker-controlled code running inside the VM to escape the sandbox boundaries.

Under certain conditions, a malicious script executed within vm2 can leverage inspect behavior to execute arbitrary commands on the host system, effectively bypassing isolation guarantees.

Affected context

This vulnerability affects Node.js applications that rely on vm2 as a security boundary for running untrusted or semi-trusted JavaScript.

Specifically, it involves code paths where:

  • vm2 is used to execute user-supplied or dynamically generated code
  • the inspect functionality or related introspection mechanisms are available inside the sandbox
  • the host trusts vm2 to prevent that code from interacting with the underlying system or process environment

The risk manifests when developers treat vm2 as a strong isolation layer rather than as a defense-in-depth measure.

Exploit preconditions

  • Attack surface: Application endpoints or features that evaluate untrusted or partially trusted JavaScript within a vm2 sandbox (e.g., plugins, user-defined functions, custom rules, or scripting consoles).
  • Required access: Ability to supply or influence the code that is executed inside vm2; this may be anonymous, authenticated, or via internal integration points.
  • Trigger point: Execution of crafted code inside the vm2 instance that triggers the inspect-related behavior enabling the breakout.
  • Why exploitation is possible: The inspect function exposes or manipulates internal references in a way that breaks vm2's isolation model, ultimately allowing access to host objects and command-execution primitives, contrary to the intended sandbox restrictions.

Why this happens

At its core, this issue is a sandbox integrity failure rooted in CWE-94: Improper Control of Generation of Code and reinforced by CWE-693: Protection Mechanism Failure.

The vm2 library dynamically executes JavaScript supplied from outside the application's trusted code base and attempts to constrain it within a virtualized context.

The inspect mechanism, however, was not fully hardened against adversarial inputs and allowed constructed code to reach privileged objects or APIs that should have been inaccessible.

This insecure interaction meant that attacker-controlled code could influence execution flows and object graphs beyond the intended boundary, leading to arbitrary code execution on the host environment.

Potential impact

  • Execution of arbitrary system commands on the host running the Node.js process
  • Complete compromise of the Node.js application runtime and its data
  • Lateral movement to other internal services or infrastructure reachable from the compromised host
  • Exfiltration or tampering of sensitive data processed or stored by the application
  • Abuse of the compromised host to launch further attacks (e.g., supply chain, cryptomining, phishing infrastructure)

General mitigation guidance

Because this vulnerability undermines the core isolation guarantees of vm2, mitigations should focus on both technical hardening and architectural assumptions:

  • Treat vm2 and similar sandboxes as defense-in-depth, not as the sole security boundary for untrusted code execution.
  • Avoid giving sandboxed code access to powerful reflection, debugging, or inspection utilities that can reveal or manipulate host objects.
  • Restrict the features available within the sandbox (e.g., whitelisting safe APIs, disabling unnecessary modules and global objects).
  • Separate high-risk code execution environments from critical infrastructure using OS-level isolation such as containers, separate processes, or dedicated hosts with minimal privileges.
  • Apply least-privilege to the Node.js process: limit filesystem, network, and system command access so that a breakout yields minimal capabilities.
  • Perform threat modeling for any untrusted code execution path to clarify assumptions about isolation and to design layered controls around it.

How teams detect issues like this

Detection strategies can combine code-level analysis, configuration review, and runtime monitoring:

  • Static analysis and code review:
  • Flag use of vm2 or similar sandboxes as high-risk components, especially where they execute user-controlled or dynamically generated code.
  • Review sandbox configuration for exposed introspection features, debugging hooks, or non-essential APIs that increase breakout risk.
  • Identify code paths where vm2 is treated as a hard security boundary instead of being wrapped in additional isolation layers.
  • Security testing:
  • Incorporate targeted fuzzing and penetration tests for endpoints that accept user-defined scripts, rules, or plugins.
  • Use security testing tools that understand JavaScript sandbox patterns and attempt known sandbox escape techniques.
  • Runtime monitoring:
  • Monitor for unexpected child processes, shell command execution, or filesystem/network access originating from the Node.js process that hosts vm2.
  • Establish anomaly detection around endpoints that execute untrusted code (e.g., sudden spikes in CPU, suspicious command invocations).
  • Automated code scanning tools can be configured to flag use of vm2 versions with known sandbox escape issues and highlight risky patterns around untrusted code execution.

Sources

SourceLink
github.comgithub.com/patriksimek/vm2/commit/8d30d93213c1898b3e035298b89a814970dd1189
github.comgithub.com/patriksimek/vm2/commit/bdd3d15e57bc4ec5e70365cd79f7cb0256e5f88c
github.comgithub.com/patriksimek/vm2/commit/fd266d084e0a3322d0f71ba2a8dc4c96cd030228
github.comgithub.com/patriksimek/vm2/releases/tag/v3.11.0
github.comgithub.com/patriksimek/vm2/security/advisories/GHSA-v37h-5mfm-c47c
access.redhat.comaccess.redhat.com/errata/RHSA-2026:26234
access.redhat.comaccess.redhat.com/errata/RHSA-2026:36754
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-24781
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2466531
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-24781.json

Frequently asked

questions

It can be, if an attacker can provide or influence the JavaScript executed inside the vm2 sandbox through network-facing features such as user-defined scripts, plugin systems, or rule engines. In those scenarios, the breakout can often be triggered remotely.

Not necessarily. The required access level depends on how the application exposes vm2. If a public endpoint accepts arbitrary or partially validated scripts, exploitation may be possible without authentication. If only authenticated or internal users can supply code, the risk is scoped to those users or compromised internal components.

From a design perspective, avoid depending on vm2 as the sole isolation boundary for hostile code. Combine sandboxing with process-level or container-level isolation, strict least privilege for the host process, and careful restriction of available APIs and features inside the sandbox. Where possible, eliminate the need to run arbitrary user-supplied code at all.

Preventive strategies include minimizing or removing untrusted code execution capabilities, treating any sandbox as a soft boundary, performing regular security reviews of sandbox configurations, and keeping security-critical libraries under close scrutiny. Architectural patterns that favor isolation—separate processes, containers, minimal privileges, and strict API contracts—reduce the impact of inevitable sandbox bypasses.

Find out what's already
exploitable in your codebase.