vm2 CVE-2023-37903 Patch Bypass: Remote Code Execution
The vm2 npm package has a remote code execution vulnerability due to a patch bypass for CVE-2023-37903; the vulnerability occurs because the check for `nesting: true` and `require: false` in `nodevm.js` uses strict equality, which can be bypassed by omitting the `require` option entirely, allowing an attacker to execute arbitrary OS commands.
The vm2 npm package, a sandboxing solution for Node.js, is vulnerable to a remote code execution (RCE) bypass of the CVE-2023-37903 patch. This bypass occurs because the check implemented to prevent the combination of nesting: true and require: false uses strict equality (===). By simply omitting the require option when instantiating a NodeVM, the check is bypassed, as options.require becomes undefined, not false. This oversight allows an attacker to bypass the intended security restrictions and execute arbitrary code on the host system. This vulnerability affects vm2 versions 3.11.3 and earlier and poses a significant risk to applications relying on vm2 for sandboxing untrusted code.
Attack Chain
- An attacker injects malicious JavaScript code into a
NodeVMinstance configured withnesting: truebut without explicitly setting therequireoption. - The initial security check in
nodevm.jsat line 263 fails becauseoptions.requireisundefinedinstead offalse, thus bypassing the intended restriction. - The code inside the
NodeVMthen usesrequire('vm2')to gain access to the vm2 library itself. - The injected code constructs a new, nested
NodeVMinstance, this time explicitly enabling thechild_processmodule viarequire: { builtin: ['child_process'] }. - The nested
NodeVMinstance is then used to execute arbitrary operating system commands usingchild_process.execSync(). - The output of the command is converted to a string.
- The string is returned as the result of the initial
nvm.run()call, demonstrating successful command execution on the host. - The attacker achieves full remote code execution on the host system.
Impact
Successful exploitation of this vulnerability allows an attacker to execute arbitrary commands on the host system. In a multi-tenant environment or any situation where vm2 is used to sandbox untrusted code, this can lead to complete system compromise. The attacker can gain access to sensitive data, install malware, or pivot to other systems on the network. The observed damage is full RCE.
Recommendation
- Upgrade to a patched version of vm2 that addresses this vulnerability.
- Apply the suggested fix to
nodevm.jslocally if an immediate upgrade is not possible: Change the check toif (options.nesting === true && !options.require)as documented in the advisory. - Deploy the Sigma rules provided to detect attempts to exploit this vulnerability, focusing on
process_creationevents originating from within vm2 sandboxes. - Monitor for unusual
require()calls within vm2 sandboxes, especially those attempting to load thechild_processmodule.
Detection coverage 2
Detect CVE-2026-47137 Exploitation Attempt — vm2 sandbox escape via child_process
criticalDetects CVE-2026-47137 exploitation attempt — attempts to require child_process within a vm2 sandbox with nesting enabled, indicating a potential sandbox escape.
Detect CVE-2026-47137 Exploitation Attempt — vm2 requiring vm2
highDetects CVE-2026-47137 exploitation attempt — requiring 'vm2' from within a vm2 sandbox
Detection queries are available on the platform. Get full rules →