VM2 Sandbox Escape via __lookupGetter__ Vulnerability
VM2 is vulnerable to a sandbox breakout via the `__lookupGetter__` method, enabling attackers to execute arbitrary commands on the host system by exploiting context switching and property descriptor manipulation, leading to remote code execution.
The vm2 library, a popular Node.js sandbox environment, is susceptible to a critical sandbox breakout vulnerability. This flaw allows malicious code executed within the vm2 sandbox to escape its confines and execute arbitrary commands on the host operating system. The vulnerability leverages the __lookupGetter__ method to bypass context isolation and gain access to host-level functions and objects. Previous attempts to mitigate similar issues were circumvented using Object.getOwnPropertyDescriptor to access the constructor property. The vulnerability affects vm2 versions 3.10.4 and earlier. Exploitation allows an attacker to achieve remote code execution with the privileges of the Node.js process running the vm2 sandbox, which could lead to significant system compromise.
Attack Chain
- Attacker injects malicious JavaScript code into the vm2 sandbox.
- The injected code retrieves the
__lookupGetter__method, which is used to access the getter of an object. - The malicious code obtains the
applymethod from theBufferobject within the sandbox. - The
applymethod is used to invoke the host version of__lookupGetter__withBufferand__proto__as arguments, gaining access to the host’s prototype lookup method. - The host’s
Function.prototypeobject is retrieved using the prototype lookup method. - The
constructorproperty of theFunction.prototypeobject is accessed usingObject.getOwnPropertyDescriptorto bypass previous mitigation attempts. - The host
Functionconstructor is used to create a new function that returns theprocessobject, granting access to Node.js runtime functions on the host. - The code then uses
child_process.execSyncto execute arbitrary commands on the host system (e.g.,touch pwned).
Impact
Successful exploitation of this vulnerability allows attackers to execute arbitrary code on the host system. Given the critical nature of many applications that employ sandboxing, this can lead to complete system compromise, data exfiltration, and denial of service. The vulnerability affects vm2 versions up to and including 3.10.4. The impact includes remote code execution, potentially leading to sensitive data exposure, system takeover, or further lateral movement within a network.
Recommendation
- Upgrade to a patched version of vm2 greater than 3.10.4 to remediate CVE-2026-24118.
- Implement strict input validation and sanitization to minimize the risk of malicious code injection into the vm2 sandbox.
- Monitor process creation events on the host system for suspicious activity originating from Node.js processes, which may indicate a sandbox escape (see the process_creation Sigma rule below).
- Monitor for the execution of commands such as
child_process.execSynccalled from within vm2 sandboxes to detect potential exploitation attempts (see thenodejs_child_process_execSigma rule).
Detection coverage 3
Detect Node.js Child Process Execution
highDetects the use of child_process.execSync within a Node.js environment, which could indicate a sandbox escape attempt.
Detect Suspicious __lookupGetter__ Use in Process Creation
mediumDetects process creation events where the command line contains `__lookupGetter__`, which is often used in exploits targeting JavaScript sandboxes such as vm2.
nodejs_child_process_exec
highDetects the use of child_process.execSync within a Node.js environment, indicating potential command execution.
Detection queries are kept inside the platform. Get full rules →