Summary
A critical memory-isolation flaw in vm2 exposes Node.js shared Buffer memory to sandboxed code. Under affected allocation patterns, sandboxed code may read sensitive host-memory contents or modify host-realm buffers, potentially causing data exposure or denial of service.
Affected context
The issue occurs in vm2 environments that expose Node.js Buffer-related allocation behavior to sandboxed code. It becomes risky when small Buffer or related allocations can obtain ArrayBuffers backed by Node's shared host Buffer pool, allowing sandboxed operations to cross the intended memory boundary.
Exploit preconditions
- Attack surface: Code executed inside a vm2 sandbox
- Required access: Ability to provide or execute JavaScript within the sandbox
- Trigger point: Buffer.from, Buffer.concat, or related small-allocation paths
- Why exploitation is possible: Shared host-realm Buffer memory can become reachable from sandboxed code, weakening isolation between the sandbox and host process
Why this happens
The vulnerability results from exposing Node.js's shared Buffer pool across the vm2 sandbox boundary without adequately isolating the underlying ArrayBuffer objects.
When sandboxed code can obtain references to host-backed memory, it may inspect or alter bytes outside its intended realm. This maps to CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, with the related integrity and availability risks arising from unintended access to shared process memory.
Potential impact
- Sandboxed code may read sensitive data held in host memory
- Credentials, tokens, or application data may be exposed
- Sandboxed code could modify host-realm buffer contents
- Applications may experience corruption or denial of service
- Confidentiality and isolation guarantees of the sandbox may be weakened
General mitigation guidance
Mitigation generally focuses on maintaining strict memory and object isolation between sandboxed code and the host process.
Common defensive patterns include:
- Avoiding exposure of shared or host-backed Buffer pools to untrusted code
- Using isolated allocation paths that do not reuse host-realm memory
- Restricting or wrapping Buffer and ArrayBuffer capabilities at the sandbox boundary
- Treating sandbox execution as untrusted and placing it in a separate process when strong isolation is required
- Applying least privilege and limiting sensitive data available to the hosting process
- Using defense-in-depth resource limits to reduce denial-of-service impact
How teams detect issues like this
Organizations can detect related risks through:
- Static analysis of sandbox bridges that expose Buffer, ArrayBuffer, or typed-array objects
- Code review checks for host-backed memory crossing trust boundaries
- Tests that verify sandboxed objects cannot observe or mutate host allocations
- Dependency and policy checks for sandbox components with known memory-isolation weaknesses
- Runtime monitoring for abnormal allocation patterns, memory corruption symptoms, or unexpected sandbox process behavior
Automated review tools may help identify unsafe object exposure and missing isolation controls.

