Executive brief
vm2 is a popular Node.js library that creates isolated JavaScript sandbox environments. A critical vulnerability in versions 3.11.3 through 3.11.6 allows attackers with access to allowed TLS and URL modules to manipulate the host process's trusted certificate authorities. This enables an attacker to inject a fraudulent CA certificate into the host, causing subsequent HTTPS connections to accept attacker-controlled certificates and potentially intercept sensitive credentials, API tokens, and application data.
Technical details
The vulnerability stems from improper sandbox boundary enforcement in the builtin loader (lib/builtin.js). Although the tls module is exposed as read-only to the sandbox, the module's functions still execute against the host process's global state. Specifically, tls.setDefaultCACertificates() modifies the process-wide default CA list. An attacker can exploit this by using URLSearchParams.getAll() from the allowed url module to create a host-realm array containing attacker-controlled PEM-formatted CA certificates. When this array is passed back to tls.setDefaultCACertificates(), the sandbox bridge unwraps it to the original host array, allowing the native TLS function to replace the entire host trust store. No file system, process, module loading, or external package access is required—only the narrowly scoped tls and url builtins. The attack affects Node.js 22.19.0+ and 24.5.0+, where the vulnerable API is present.
Affected products
- patriksimek vm2 3.11.3 through 3.11.6
Timeline
- 2026-08-24: disclosed
- 2026-09-17: advisory
- 2026-09-17: patched: Fixed in version 3.11.7