Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applicationsUpgrade vm2 to version 3.11.0 or higher.
vm2 is a sandbox that can run untrusted code with whitelisted Node's built-in modules.
Affected versions of this package are vulnerable to Improper Isolation or Compartmentalization through the NodeVM constructor in lib/nodevm.js. An attacker can run host commands when the VM is set up with { nesting: true, require: false } and then using sandbox code to require('vm2'), build a nested NodeVM with attacker-chosen require settings, and load child_process. This leaves applications that rely on require: false with a sandbox that still exposes access to host modules to untrusted code, allowing arbitrary command execution as the host process user.
If your code uses new NodeVM({ nesting: true, require: false }), remove nesting: true to preserve deny-all behavior and prevent sandbox code from reaching require('vm2').