/

CVE-2026-27597

Severity:

CRITICAL RISK

(10.0)

Code Injection / Sandbox Escape in Enclave JavaScript VM

CVE-2026-27597

Analyzed

Vulnerability type

Category:

Code Injection / Sandbox Escape

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(10.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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/core to 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/core to 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.

Sources

SourceLink
github.comgithub.com/agentfront/enclave/commit/09afbebe4cb6d0586c1145aa71ffabd2103932db
github.comgithub.com/agentfront/enclave/security/advisories/GHSA-f229-3862-4942

Frequently asked

questions

Yes, in many deployments it can be. If an attacker can influence the JavaScript executed inside Enclave—whether directly (uploading code) or indirectly (prompt injection or compromised plugins)—they may be able to achieve remote code execution on the host running the sandbox.

The attacker needs the ability to control or significantly influence code that the Enclave VM executes. This might be direct script submission, control over an AI agent's tools or plugins, or the ability to craft prompts that cause the agent to emit and run dangerous code within the sandbox.

The safest pattern is to treat the JavaScript sandbox as untrusted and enforce isolation in depth: use a hardened sandbox implementation, add OS-level or container isolation, restrict exposed capabilities to a minimal whitelist, and separate sensitive data and operations from anything the sandbox can directly access.

Future designs should assume that in-process sandboxes can fail and architect around that assumption: apply least privilege, strong compartmentalization (containers/VMs), explicit capability-based APIs, comprehensive security reviews for sandbox integrations, and continuous monitoring. Additionally, threat-model AI agents as potential adversaries and avoid granting them more authority or access than strictly necessary.

Find out what's already
exploitable in your codebase.