vm2 is vulnerable to Remote Code Execution
100
Critical Risk
When require.external is enabled but no require.root is configured, the resolver defaults to host context with unrestricted root paths, so its path check returns true and it runs the real Node require(). Sandboxed code can host-require arbitrary files, including the installed vm2 package, obtain the unwrapped NodeVM and VM classes, and build an unrestricted nested instance that runs child_process. 3.11.7 blocks requiring host vm2 itself and warns once at construction, but it does not refuse the configuration or close host-require of other paths. Closing the remaining escape requires setting require.root to a directory boundary and/or require.context to sandbox.
You are affected if you are using a version that falls within the vulnerable range and you enable require.external without setting require.root, or you set require.root to a path that still includes modules you do not intend to execute in the host process (for example the project node_modules tree).
vm2 is vulnerable to Remote Code Execution in versions 0.0.1 - 3.11.6.
Upgrade the vm2 library to the patch version and, whenever require.external is enabled, set require.root to a directory that cannot reach untrusted packages and/or set require.context to sandbox. Omitting require.root or using a project-root value such as ./ is not sufficient.
Connect your repositories to instantly see whether vulnerable or malicious packages exist in your codebase.
Free. No credit card required.

I consent to receiving marketing communications based on Aikido’s Privacy Policy.
SOC 2Compliant
ISO 27001Compliant