vm2 is an open source vm/sandbox for Node.js. Prior to 3.11.0, NodeVM's builtin allowlist can be bypassed when the module builtin is allowed (including via the '*' wildcard). The module builtin exposes Node's Module._load(), which loads any module by name directly in the host context, completely bypassing vm2's builtin restriction. This allows sandboxed code to load excluded builtins like child_process and achieve remote code execution. This vulnerability is fixed in 3.11.0.
vm2 implements a builtin module allowlist, however the 'module' builtin — when permitted (including through the use of wildcard '*') — exposes the Node.js Module._load() function. This function loads any module directly in the host context, completely bypassing vm2 restrictions. This allows sandboxed code to load excluded modules, such as 'child_process', and then execute arbitrary system commands.
An attacker can gain complete control over the host Node.js process, including access to the file system, execute arbitrary commands, and escalate the attack to further infrastructure resources.
Update vm2 to version 3.11.0 or later, where the vulnerability has been patched.
vm2 in versions earlier than 3.11.0
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:HVm2 Project Vm2
APPVm2 Project< 3.11.0
Related vulnerabilities
vm2 (Node.js): ucieczka z sandbox przez BaseHandler.getPrototypeOf (RCE)
vm2 (Node.js): ucieczka z sandbox przez zagnieżdżony NodeVM (RCE)
Ucieczka z sandboxa w bibliotece vm2 dla Node.js (RCE)
vm2: mutacja prototypów hosta z poziomu sandbox (prototype pollution)
Ucieczka z sandboxu vm2 poprzez getter na prototypie tablicy