Skip to main content

VM2 CVE-2026-24118

| EUVDEUVD-2026-26984 CRITICAL
Code Injection (CWE-94)
2026-05-04 https://github.com/patriksimek/vm2 GHSA-grj5-jjm8-h35p
9.8
CVSS 3.1 · Vendor: https://github.com/patriksimek/vm2
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Submit malicious JavaScript to VM2 sandbox
  2. Delivery
    Access host Buffer.apply via sandbox Buffer
  3. Exploit
    Chain apply with __lookupGetter__ to traverse prototype
  4. Install
    Retrieve host Function.prototype via Buffer.__proto__
  5. C2
    Extract host Function constructor using Object.getOwnPropertyDescriptor
  6. Execute
    Instantiate host Function with arbitrary code
  7. Impact
    Execute child_process.execSync for system commands

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Code injection prevention, sandbox exec
MITRE ATT&CK

2 techniques across 2 tactics: Execution, Initial Access

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

The attacker must be able to execute arbitrary JavaScript code within a VM2 sandbox context. This requires the application to accept user-supplied JavaScript and execute it using the VM2 library, which is the intended use case for VM2 in scenarios like online code editors, plugin systems, serverless function runtimes, or educational coding platforms. No special VM2 configuration is required - default VM2 sandbox instantiation via new VM() is sufficient. The vulnerability affects VM2 in its standard operating mode, not an edge-case configuration. Limiting factors: The attacker needs a code path where their JavaScript reaches VM2 execution (applications using VM2 only for trusted internal code are not exposed). The exploit requires Node.js runtime with Buffer object access, which is standard in VM2 environments. Network-level access is not a prerequisite - the attack occurs at the application logic layer once the attacker can submit code through the application's intended interface (web form, API endpoint, file upload, etc.).

Impact

This represents critical real-world risk confirmed by multiple strong signals. CVSS 9.8 with vector AV:N/AC:L/PR:N/UI:N indicates network-accessible, low-complexity exploitation requiring no privileges or interaction - attackers need only the ability to submit code to a VM2 sandbox. Publicly available exploit code exists (GitHub Gist and vendor advisory PoC), significantly lowering the barrier to exploitation. The vulnerability is a complete sandbox escape, the worst possible outcome for an isolation technology. Applications using VM2 to execute untrusted user code (such as online code playgrounds, serverless function platforms, plugin systems, or code evaluation APIs) are immediately vulnerable to full host compromise. The straightforward exploit chain (7-8 lines of JavaScript) means exploitation can be automated. However, the scope is limited to environments where attackers can inject arbitrary JavaScript into VM2 contexts - this is not exploitable against applications merely using VM2 internally with trusted code. Real-world impact depends entirely on whether the application's threat model includes untrusted code execution, but for those that do, this is an immediate patch-now priority. The availability of working PoCs and the fundamental nature of the bypass (circumventing the core security promise of the library) make this high-severity in practice despite absence from CISA KEV.

Exploit ScenarioDerived

An attacker submits JavaScript code to a web application's code execution API that uses VM2 for sandboxing, such as an online code playground or a serverless function platform. The attacker's payload uses Buffer.apply to access the host's apply method, chains it with __lookupGetter__ to traverse to the host Function.prototype via Buffer's __proto__, then uses Object.getOwnPropertyDescriptor to extract the host Function constructor despite VM2's attempted blocks. With the host Function constructor, the attacker executes process.mainModule.require('child_process').execSync() to run arbitrary shell commands, exfiltrate environment variables containing API keys, establish reverse shells, or pivot to other systems on the internal network. The publicly available PoC demonstrates the complete exploit chain in under 10 lines of JavaScript.

Act Now Prioritize within 24-48h. Why: CRITICAL severity + public POC available.
Patch available 0.1% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – May 04, 2026

Remote code execution in VM2 sandbox (npm package) versions ≤3.10.4 allows attackers to escape the JavaScript isolation boundary and execute arbitrary system commands on the host. The vulnerability exploits prototype chain traversal through Buffer.apply and __lookupGetter__ to access the host Function constructor, bypassing VM2's context isolation. Publicly available exploit code exists, and vendor-released patch version 3.11.0 addresses the issue. This is a complete sandbox escape requiring no authentication or user interaction, making it critical for environments executing untrusted code within VM2 contexts.

RemediationAI

Upgrade to VM2 version 3.11.0 or later, which includes patches from commits 2b5f3e3a060d9088f5e1cdd585d683d491f990a3 and f9b700b1c7d9ef2df416666cb24e0b659140cc74 that block the descriptor chain exploit. The release is available at https://github.com/patriksimek/vm2/releases/tag/v3.11.0. If immediate upgrade is not possible, compensating controls include disabling VM2 usage entirely and replacing with alternative isolation mechanisms such as running untrusted code in dedicated containers (Docker), separate processes with strict resource limits (child_process with V8 isolates), or WebAssembly sandboxes. These alternatives trade performance and complexity for stronger isolation boundaries but eliminate JavaScript prototype chain traversal attacks. Note that attempting to filter specific method names (__lookupGetter__, Object.getOwnPropertyDescriptor) is ineffective due to the many alternate access paths in JavaScript. There is no safe workaround that keeps VM2 ≤3.10.4 in use for untrusted code. Organizations should also audit logs for suspicious VM2 usage patterns such as repeated sandbox creation failures or code containing prototype traversal keywords.

Affected VersionsENISA

vm2 < 3.11.0

Affected Packages

npm vm2 fix: 3.11.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in npm

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

VM2 is a Node.js npm package (pkg:npm/vm2) designed to provide sandboxed JavaScript execution environments. The vulnerability stems from CWE-94 (Improper Control of Generation of Code) in VM2's context isolation mechanism. The flaw lies in how VM2's bridge layer handles prototype chain traversal when switching between host and sandbox contexts. The __lookupGetter__ method is special-cased in VM2 to switch between host and sandbox versions, but this switching can be exploited. By chaining Buffer.apply (accessible from sandbox) with __lookupGetter__ and Object.getOwnPropertyDescriptor, an attacker can traverse from sandbox Buffer through __proto__ to the host's Function.prototype, then extract the host Function constructor. Previous fix attempts at blocking direct constructor access were bypassed using Object.getOwnPropertyDescriptor to indirectly retrieve the constructor property descriptor. The vulnerability demonstrates a fundamental challenge in JavaScript sandboxing: preventing prototype chain traversal across security boundaries when built-in objects must be shared between contexts.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/patriksimek/vm2) PRIMARY 9.8 CRITICAL
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Red Hat 9.1 HIGH

Primary rating from Vendor (https://github.com/patriksimek/vm2).

CVSS VectorVendor: https://github.com/patriksimek/vm2

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

Lifecycle Timeline

3
PoC Detected
May 04, 2026 - 17:16 vuln.today
Public exploit code
Patch released
May 04, 2026 - 16:30 nvd
Patch available
CVE Published
May 04, 2026 - 16:29 nvd
CRITICAL 9.8

DescriptionCVE.org

Summary

VM2 suffers from a sandbox breakout vulnerability. This allows attackers to write code which can escape from the VM2 sandbox and execute arbitrary commands on the host system.

Details

The __lookupGetter__ method allows to read the getter of an object. It is special in VM2 since it will switch between the host and sandbox version of the method when passed to the other context. This allows to access getters on an object in the host context if the method is called from the host context which can be achieved by using the host apply method which can be accessed through Buffer.apply. Afterwards, this function can be used to call the host version of __lookupGetter__ with Buffer and __proto__ resulting in the prototype lookup method from the host context. With this method the hosts Function.prototype object can be retrieved and the host Function acquired through the constructor property which allows to create and run code in the host context. This issue was attempted to be fixed with https://github.com/patriksimek/vm2/blob/4b009c2d4b1131c01810c1205e641d614c322a29/lib/bridge.js#L427. However, this can be circumvented by using Object.getOwnPropertyDescriptor to get the constructor property.

PoC

The following code demonstrates this issue by acquiring the host process object and executing touch pwned.

js
const {VM} = require("vm2");
const vm = new VM();
vm.run(`
const g = ({}).__lookupGetter__;
const a = Buffer.apply;
const p = a.apply(g, [Buffer, ['__proto__']]);
Object.getOwnPropertyDescriptor(p.call(a),'constructor').value('return process')().mainModule.require('child_process').execSync('touch pwned');
`);

Impact

Attackers can perform Remote Code Execution under the assumption that arbitrary code can be executed inside the context of a vm2 sandbox.

Executive ViewAI

Why It Matters

VM2 sandbox escape vulnerability (CVE-2026-24118) in npm package versions ≤3.10.4 allows unauthenticated remote code execution on host systems, completely bypassing the isolation layer designed to safely execute untrusted code. Organizations using VM2 to sandbox third-party or user-supplied scripts face immediate risk of full system compromise; this requires urgent patching across all affected deployments.

Business Impact: Severe
Compensating Controls

Apply vendor patch (upgrade to VM2 3.11.0). If immediate patching is impossible: implement OS-level process isolation (containers, seccomp, AppArmor), disable VM2 execution of untrusted code until patched, and monitor process execution logs for suspicious syscalls from VM2 runtime. These controls do not eliminate the vulnerability-patching is mandatory.

Threat Intelligence Overview

EPSS Score
0.1%
Top 68% exploitable
Threat Intel
1
1 source
Exploit
POC
Public exploit code exists
Data Quality
8 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment GHSA Vendor GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity CRITICAL
CISA KEV No
Public POC Yes
EPSS 0.1%
Patch available Yes
Active threat No
Deciding rule
CRITICAL severity + public POC available
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision
Out-of-Cycle
Exploitation
Poc
System Exposure· derived
Open
Automatable
Yes
Human Impact
Very High
Technical Impact
Total

Priority Score

69
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +49
PoC: +20
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Code Injection CRITICAL

Code injection occurs when an application accepts user input and passes it directly into a language interpreter or evaluator without proper sanitization.

Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.

Vendor StatusVendor

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy