vm2 is an open source vm/sandbox for Node.js. Prior to 3.11.1, when a NodeVM is created with nesting: true, sandbox code can unconditionally require('vm2') regardless of the outer VM's require configuration — including require: false. With access to vm2, the sandbox constructs a new inner NodeVM with its own unrestricted require settings and executes arbitrary OS commands on the host. Any application that runs untrusted code inside a NodeVM with nesting: true is fully compromised. This vulnerability is fixed in 3.11.1.
When NodeVM is created with the nesting: true option, code inside the sandbox can unconditionally call require('vm2') — regardless of the external virtual machine configuration, even when require: false is set. By gaining access to the vm2 module this way, malicious code creates a new, internal NodeVM instance with its own unrestricted require settings. This allows loading of arbitrary system modules and execution of unrestricted OS commands on the host machine.
An attacker can fully compromise the host application running the sandbox — execute arbitrary commands at the operating system level (RCE), gain access to data, modify the system, or install malicious software.
The vm2 library must be updated to version 3.11.1 or newer, in which the vulnerability has been fixed. Until the update is applied, avoid using the nesting: true option in NodeVM when running untrusted code.
The vm2 library for Node.js in versions preceding 3.11.1, when NodeVM is run with the nesting: true option.
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:HVm2 Project Vm2
APPVm2 Project< 3.11.1
Related vulnerabilities
vm2: mutacja prototypów hosta z poziomu sandbox (prototype pollution)
vm2 (Node.js): ucieczka z sandbox przez BaseHandler.getPrototypeOf (RCE)
Ucieczka z sandboxa w bibliotece vm2 dla Node.js (RCE)
vm2: ominięcie listy dozwolonych modułów i RCE przez builtin 'module'
Ucieczka z sandboxu vm2 poprzez getter na prototypie tablicy