Summary
A sandbox escape vulnerability in Enclave, a secure JavaScript sandbox for AI agent code execution, allows attackers to break out of the @enclave-vm/core security boundaries and inject arbitrary code.
When untrusted or semi-trusted agent code is executed inside the vulnerable sandbox, an attacker may achieve remote code execution (RCE) on the underlying host environment.
Affected context
This vulnerability affects applications and platforms that:
- Use Enclave as a secure JavaScript sandbox for running AI agent or plugin code
- Rely on
@enclave-vm/coreto enforce strong isolation between untrusted code and the host - Treat sandboxed JavaScript as constrained in what it can access or modify
The issue becomes relevant wherever untrusted or user-supplied code is executed with the assumption that Enclave fully prevents access to the host runtime or OS.
Exploit preconditions
- Attack surface: Enclave sandbox interfaces that accept or generate JavaScript code for execution (e.g., AI agent actions, user-provided scripts, plugin code).
- Required access: Ability to influence or control code that is run inside the Enclave VM; this may be via direct script upload, prompt injection, or compromised agent logic.
- Trigger point: Execution of crafted JavaScript within the vulnerable Enclave environment that abuses flaws in
@enclave-vm/coreto bypass isolation. - Why exploitation is possible: The sandbox implementation fails to fully contain code execution, enabling crafted code to escape the sandbox and execute with the privileges of the host process.
Why this happens
The root cause maps to CWE-94: Improper Control of Generation of Code ('Code Injection').
Enclave's sandbox relies on programmatically controlling what code can execute and what resources it can reach. A flaw in @enclave-vm/core means that attacker-controlled JavaScript can influence the evaluation environment in unintended ways, bypassing isolation constraints.
In abstract terms, the sandbox exposes an execution environment where untrusted code can indirectly reach powerful primitives (e.g., host objects, native APIs, or unsafe evaluators). Because these are not fully sealed, a determined attacker can construct payloads that cross the boundary from "interpreted, restricted code" to "host-level execution," resulting in a sandbox escape and arbitrary command or code execution.
Potential impact
- Remote code execution within the host process running the Enclave sandbox
- Access to sensitive data available to the host (API keys, model outputs, prompts, system files)
- Lateral movement to other services reachable from the compromised host
- Tampering with AI agent behavior, decision logic, and logs
- Use of the compromised environment as a pivot for further supply-chain or infrastructure attacks
General mitigation guidance
Effective mitigation focuses on strengthening isolation boundaries and minimizing trust in sandboxed code:
- Prefer sandbox implementations that minimize exposed host capabilities and use defense-in-depth (e.g., OS-level isolation, containers, seccomp, or WebAssembly) rather than relying solely on in-process JavaScript sandboxes.
- Treat all code executed within the sandbox as fully untrusted; do not grant it access to powerful host objects, secrets, or unrestricted network capabilities.
- Apply strict capability-based design: explicitly whitelist only the minimal APIs and resources that agents need, and avoid exposing generic evaluation or reflection primitives into the sandbox.
- Separate duties by running sandboxes under dedicated, least-privileged OS users or containers; limit filesystem, network, and process-level permissions.
- Implement robust secret management: never inject long-lived credentials directly into the sandbox context; instead, broker sensitive operations through tightly scoped, audited service endpoints.
- Design execution timeouts, memory limits, and resource quotas to reduce the blast radius of compromised sandboxes.
How teams detect issues like this
Detection should combine code-level analysis with runtime controls:
- Static analysis & review:
- Flag use of in-process JavaScript sandboxes that claim strong isolation without OS or process-level boundaries.
- Review Enclave integration points for any direct exposure of host APIs, globals, or unsafe evaluation functions into the sandbox.
- Analyze agent orchestration code for assumptions that sandboxed code is "safe" to trust with secrets or privileged operations.
- Configuration & policy checks:
- Enforce policies that require isolation layers (containers, VMs) around sandboxes that execute untrusted or model-influenced code.
- Require security review before exposing new host capabilities or APIs to sandboxed scripts.
- Runtime monitoring:
- Monitor for unexpected filesystem access, process spawning, or network connections originating from the sandbox processes.
- Track anomalous behavior from AI agents, such as attempts to read environment variables, system files, or invoke shell-like functionality.
- Automated tooling:
- Use SAST/IAST tools and custom rules to flag patterns like unrestricted evaluation, dynamic require/import exposure, or access to global host objects from within sandbox interfaces.

