CVE-2026-24118: VM2 Sandbox Breakout Through __lookupGetter__
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('childprocess').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.
Other sources
vm2 is an open source vm/sandbox for Node.js. Prior to version 3.11.0, 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. This issue has been patched in version 3.11.0.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/vm2to a version that resolves this vulnerability.Fixed in 3.11.0 - Upgrade
Upgrade
vm2to a version that resolves this vulnerability.Fixed in 3.11.0 - Compensating control
Assume VM2 sandbox escape is possible until upgraded; restrict network access/permissions for any service using vm2 so RCE attempts have minimal impact if the sandbox is bypassed.
Event History
Frequently Asked Questions
What is the severity of CVE-2026-24118?
CVE-2026-24118 is classified as a high-severity sandbox breakout vulnerability.
How do I fix CVE-2026-24118?
To fix CVE-2026-24118, upgrade the VM2 package to version 3.11.0 or later.
Which versions of VM2 are affected by CVE-2026-24118?
All versions of VM2 up to and including 3.10.4 are affected by CVE-2026-24118.
What type of vulnerability is CVE-2026-24118?
CVE-2026-24118 is a sandbox breakout vulnerability that allows execution of arbitrary commands on the host system.
Who is impacted by CVE-2026-24118?
Any application using the affected versions of VM2 for sandboxing is potentially impacted by CVE-2026-24118.