Summary
A boundary-validation flaw in vm2 can expose bytes from Node.js shared buffer memory to untrusted sandbox code when the zlib builtin is explicitly allowed. Guest code may read or modify data belonging to unrelated host buffers, creating cross-boundary information disclosure and memory corruption risks.
Affected context
The issue occurs in vm2 deployments that expose Node.js built-in modules through the NodeVM require allowlist and permit untrusted code to use zlib compression functions. It becomes risky when a returned Buffer retains a backing ArrayBuffer representing shared pool storage and the sandbox boundary does not enforce the expected ownership and length invariants.
Exploit preconditions
- Attack surface: The NodeVM sandbox and explicitly exposed Node.js built-in modules
- Required access: Ability to execute untrusted guest code within the affected vm2 instance
- Trigger point: Processing a zlib result returned as a Buffer across the sandbox boundary
- Why exploitation is possible: The returned Buffer may reference a shared backing store, while vm2 fails to ensure that the exposed ArrayBuffer is limited to the Buffer's owned bytes
Why this happens
The underlying bug is insufficient validation of Buffer backing-store ownership when values cross the vm2 sandbox boundary. A Buffer returned by a host builtin can reference a shared small-buffer pool whose ArrayBuffer is larger than the logical Buffer. If the boundary accepts that object without enforcing ownership, offset, and length invariants, guest code can obtain access to unrelated bytes. This maps to CWE-200 because data outside the intended disclosure scope becomes observable across a security boundary; the same flaw can also permit unintended modification of host-realm memory.
Potential impact
- Guest code may disclose sensitive data held in unrelated host buffers
- Guest code could corrupt host or neighboring buffer contents
- Application integrity may be degraded through tampered in-memory data
- Confidentiality and isolation guarantees of the sandbox may be weakened
- Downstream application behavior could be altered or destabilized
General mitigation guidance
Mitigation generally focuses on preserving strict ownership boundaries for all
host objects exposed to sandboxed code.
Common defensive patterns include:
- Applying explicit backing-store ownership, offset, and length checks before exposing Buffers
- Copying data into independently owned buffers rather than sharing pooled storage
- Limiting builtin-module exposure to narrowly required, reviewed interfaces
- Returning immutable or normalized data representations across the sandbox boundary where practical
- Running sandboxed workloads with least privilege and separate process or container isolation when stronger boundaries are required
- Treating all guest-accessible host-module results as untrusted boundary objects
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules that identify host objects crossing sandbox boundaries without ownership checks
- Code review signals involving Buffer, ArrayBuffer, shared pools, byte offsets, and unrestricted backing-store exposure
- Tests that verify returned views cannot observe bytes outside their logical range
- Policy checks requiring explicit allowlists and wrapper interfaces for host builtin modules
- Runtime monitoring for unexpected access to sensitive data or mutation of shared application buffers
Automated security review tools may help identify unsafe object-boundary patterns, but boundary-focused tests should validate the isolation guarantee directly.

