vm2: Sandboxed code can read and write host-realm memory via Node's shared Buffer pool
What fixes it
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
Summary
Sandboxed code is able to disclose host memory used by small allocations by Buffer.from, Buffer.concat.
Details
vm2 exposes Buffer object to sandboxed code by default. Small [Buffer allocations](https://nodejs.org/api/buffer.html#static-method-bufferallocunsafesize) (for example, Buffer.allocUnsafe(), Buffer.from(array), Buffer.from(string), and Buffer.concat()) use the same Buffer pool, which is shared with the sandbox. This allows sandboxed code to disclose host memory used by the functions listed above.
PoC
Tested against vm2@3.11.5 in the node REPL.
Buffer.from('host-memory-should-not-leak-to-sandbox')
new (require('vm2').VM)().run(`Buffer.from(Buffer.from([0]).buffer, 0, Buffer.from([0]).buffer.byteLength).toString('ascii')`)<img width="1044" height="104" alt="Screenshot 2026-07-23 at 17 54 15" src="https://github.com/user-attachments/assets/987b860c-6702-4818-bfaa-c77919c777e5" />
Impact
Since sandbox acquires an ArrayBuffer that is used by the host, it can disclose sensitive data going through functions mentioned above and even write to these buffers, which can lead to sensitive data exposure and potentially denial-of-service.
Text from GitHub Advisory Database
Affected versions 4
- vm2, npm<= 3.11.6GitHub
- vm2affected: all versions before 3.11.7CVE List
- vm2unaffected: 3.11.7CVE List
- vm2, npmfrom first release, fixed in 3.11.7OSV
References 6
- github.com/patriksimek/vm2/commit/4f2508abeb252aa86eb6761c78b3b000248fb089Fixvia GitHub
- github.com/patriksimek/vm2/releases/tag/v3.11.7Fixvia GitHub
- vulncheck.com/advisories/vm2-before-3.11.7-memory-disclosure-via-buffer-poolAdvisoryvia CVE List
- github.com/advisories/GHSA-fcqc-726x-5wfcAdvisoryvia GitHub
- github.com/patriksimek/vm2/security/advisories/GHSA-fcqc-726x-5wfcExploitvia CVE List
- nvd.nist.gov/vuln/detail/CVE-2026-92947Referencevia GitHub