vm2 is an open source vm/sandbox for Node.js. Prior to 3.11.3, 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 caught by the runtime and passed to the yield* iterator as the next value. This allows attackers to write code which can escape from the VM2 sandbox and execute arbitrary commands on the host system. This vulnerability is fixed in 3.11.3.
The vulnerability consists of the ability to intercept a host exception using the yield* expression inside an asynchronous generator. When the generator is closed by the return function, the return value is awaited, and exceptions thrown in the then call are caught by the runtime environment and passed back to the yield* iterator as the next value. This mechanism allows code to escape the isolated vm2 context and gain access to the host environment. The attack requires no privileges or user interaction.
An attacker can completely escape the isolated vm2 sandbox environment (sandbox escape) and execute arbitrary code on the host system, leading to complete violation of system confidentiality, integrity, and availability.
The vm2 library should be updated to version 3.11.3 or newer, in which the vulnerability has been fixed. Details are available in the vendor's GitHub Security Advisories references.
The vm2 library in versions prior to 3.11.3 for Node.js.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:HVm2 Project Vm2
APPVm2 Project< 3.11.3
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'
vm2 (Node.js): ucieczka z sandbox przez zagnieżdżony NodeVM (RCE)