Summary
A sandbox escape-related access control weakness in vm2 permits sandboxed code to access operating-system and DNS builtins when the builtin: ['*'] configuration is used. This may expose host process identity and network topology, and can allow DNS resolution behavior for the host process to be redirected through an attacker-controlled resolver.
Affected context
The issue occurs in vm2 deployments that enable broad access to built-in modules through the builtin: ['*'] configuration. In this context, sandbox code may reach os and dns functionality that should remain outside the sandbox trust boundary, potentially affecting the host process's identity information and global DNS resolver settings.
Exploit preconditions
- Attack surface: Code executed inside a vm2 sandbox
- Required access: Ability to supply, modify, or cause execution of sandboxed JavaScript
- Trigger point: Access to exposed operating-system and DNS builtins under permissive builtin configuration
- Why exploitation is possible: The sandbox policy fails to adequately restrict sensitive builtins, allowing sandbox code to inspect host context and alter resolver behavior used by subsequent host DNS queries
Why this happens
The underlying flaw is an insufficient sandbox access-control policy. When all builtins are broadly enabled, vm2 does not reliably prevent sandbox code from reaching sensitive os and dns capabilities. This behavior maps to CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, because isolated code can observe host process identity and network topology; the same trust-boundary failure can also enable manipulation of process-wide DNS resolution behavior.
Potential impact
- Sandbox code may disclose host process identity information
- Attackers could map portions of the host network topology
- Subsequent host DNS queries may be redirected to an attacker-controlled resolver
- Applications may connect to attacker-selected destinations or receive tampered DNS responses
- Credentials, tokens, or other sensitive data could be exposed through redirected network traffic
- Availability and integrity of host-process network operations may be affected
General mitigation guidance
Mitigation generally focuses on reducing sandbox authority and enforcing a narrow trust boundary around host capabilities.
Common defensive patterns include:
- Exposing only an explicit allowlist of low-risk builtins rather than enabling all builtins
- Keeping operating-system, DNS, filesystem, process, and network-control APIs outside sandbox reach
- Treating sandboxed code as untrusted even when it originates from an internal workflow
- Isolating sandbox workloads with separate processes, identities, network policies, and restricted permissions
- Preventing sandboxed code from changing process-wide resolver configuration
- Applying outbound DNS and network policy enforcement independently of application-level controls
- Using least-privilege service accounts and minimizing access to secrets and sensitive network destinations
How teams detect issues like this
Detection approaches can include:
- Static analysis for vm2 configurations that enable wildcard builtin access
- Code review checks for exposure of
os,dns, process, filesystem, or network-control modules to sandbox code - Policy enforcement that rejects wildcard capability grants and requires explicit builtin allowlists
- Runtime monitoring for unexpected DNS resolver configuration changes
- Network telemetry comparing process DNS activity with approved resolvers and expected destinations
- Automated security review tools that flag excessive sandbox permissions and cross-boundary capability exposure

