Summary
A sandbox isolation weakness in vm2 through 3.12.0 exposes Node.js's crypto.setFips() function to guest code when an embedder explicitly allowlists the crypto builtin. Guest code may change the FIPS mode of the entire host process, allowing trusted host code to observe a security-sensitive state change outside the intended NodeVM boundary.
Affected context
The issue occurs in vm2 deployments that expose the Node.js crypto builtin to untrusted NodeVM guest code through an explicit allowlist. It is relevant when the builtin sanitizer and readonly wrapper forward host functions without isolating their process-wide side effects. Deployments that do not expose crypto to guest code, or that otherwise prevent access to the affected function, may not be exposed to this specific condition.
Exploit preconditions
- Attack surface: NodeVM guest-code execution with access to an allowlisted Node.js builtin
- Required access: Ability to execute code within the affected vm2 guest context
- Trigger point: Invocation of the exposed
crypto.setFips()function - Why exploitation is possible: The sanitizer removes some sensitive functionality but leaves
setFips()callable, while the readonly wrapper forwards the function's side effect to the host process rather than localizing it within the sandbox
Why this happens
The underlying bug is an incomplete capability-restriction boundary in the builtin sanitizer. Although one sensitive crypto function is replaced, crypto.setFips() remains available through the host module wrapper. Because this function changes process-wide cryptographic state, forwarding it without a sandbox-local implementation allows guest-controlled state changes to affect trusted host code. This behavior maps to CWE-284: Improper Access Control, because the sandbox fails to restrict access to a security-sensitive host capability.
Potential impact
- Guest code may change the FIPS mode observed by trusted host code.
- Applications may make cryptographic decisions using an attacker-influenced process state.
- Host security-policy assumptions may be weakened or invalidated.
- Shared-process workloads may experience integrity or availability impacts.
- The isolation boundary between guest and trusted code could be bypassed for other process-wide side effects exposed through similar wrappers.
General mitigation guidance
Mitigation generally focuses on reducing guest access to host capabilities and ensuring that forwarded functions cannot alter process-wide state.
Common defensive patterns include:
- Avoiding exposure of the
cryptobuiltin to untrusted NodeVM code unless it is strictly required. - Using narrowly scoped, capability-based interfaces instead of forwarding complete host modules.
- Replacing process-global APIs with sandbox-local or policy-controlled abstractions.
- Maintaining explicit deny-lists for functions that change runtime, cryptographic, environmental, or process-wide state.
- Isolating untrusted workloads in separate processes or containers when strong boundaries are required.
- Running guest workloads with least privilege and limiting access to sensitive host resources.
How teams detect issues like this
Detection approaches may include:
- Static analysis rules that identify allowlisting of
cryptoor other host builtins for untrusted execution contexts. - Code review checks for wrappers that forward host functions without modeling global or process-wide side effects.
- Tests that compare security-sensitive host state before and after execution of guest code.
- Policy enforcement that blocks exposure of process-global configuration APIs to sandboxed workloads.
- Dependency and configuration reviews that verify sandbox boundary controls and approved builtin lists.
Automated code-review and software-composition tools may help identify risky builtin exposure, but behavioral tests are also important because the problem depends on side effects across the isolation boundary.

