/

CVE-2026-39861

Severity:

CRITICAL RISK

(10.0)

Sandbox Escape via Symlink Path Traversal in Claude Code

CVE-2026-39861

Analyzed

Vulnerability type

Category:

Sandbox Escape via Symlink Path Traversal

CWE:

CWE-22, CWE-61

Impact:

Arbitrary File Write and Potential Code Execution Outside Sandbox

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

Claude Code's sandbox previously allowed sandboxed processes to create symlinks that pointed outside the designated workspace, and the unsandboxed host process would follow these symlinks when writing files.

Under those conditions, an attacker who can inject untrusted content into a Claude Code context and trigger sandboxed code execution could cause writes to arbitrary filesystem locations outside the workspace, potentially leading to code execution beyond the sandbox boundary.

Affected context

This vulnerability arises in environments where Claude Code is used to run code in a file-system sandbox tied to a workspace directory.

The issue manifests when:

  • Sandboxed commands can create or manipulate symbolic links inside the workspace, and
  • The unsandboxed Claude Code process later performs file writes to paths that may traverse those symlinks, and
  • There is no explicit check that the resolved path remains inside the intended workspace boundary.

In this configuration, the logical trust boundary of the workspace is undermined by filesystem link resolution semantics.

Exploit preconditions

  • Attack surface: Claude Code's sandboxed execution environment and the associated host application file operations.
  • Required attacker capability: Ability to introduce untrusted content into a Claude Code context window and influence sandboxed code execution (for example, via prompt injection or compromised project content).
  • Sandbox behavior: The sandboxed process can create symlinks that point to arbitrary locations outside the workspace directory.
  • Host behavior: The unsandboxed Claude Code process subsequently writes to a path that resides under or traverses such a symlink without validating the final resolved path.
  • Why exploitation is possible: The combination of (1) symlink creation inside the sandbox and (2) unchecked symlink following by an unsandboxed process breaks the intended sandbox isolation, enabling writes outside the workspace even though neither actor alone can do so directly.

Why this happens

The core issue is a mismatch between the logical workspace boundary and how the filesystem resolves symbolic links.

The sandbox permitted the creation of symlinks that referenced locations outside the workspace, while the unsandboxed portion of the application later wrote to paths within that symlinked subtree without resolving and revalidating the destination.

This aligns with:

  • CWE-61: Untrusted Search Path / Uncontrolled Symlink Resolution, where symlinks are followed without appropriate restrictions or checks, and
  • CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), in that the code assumes operations are confined to a directory but fails to enforce this when symbolic links alter the effective path.

Conceptually, the sandbox enforced access control at the string path level rather than on the resolved canonical path, allowing sandbox escape through symlink indirection.

Potential impact

  • Arbitrary file creation or modification outside the intended Claude Code workspace.
  • Overwriting of configuration files, scripts, or binaries that may later be executed, leading to potential code execution outside the sandbox.
  • Tampering with application, build, or deployment artifacts on the host system.
  • Corruption of user data or project files located outside the workspace directory.
  • Facilitation of further privilege escalation if high-value or privileged paths are writable.

General mitigation guidance

Effective mitigation focuses on enforcing the workspace boundary on the resolved filesystem paths and treating all symlink-influenced paths as untrusted until proven safe.

Useful defensive patterns include:

  • Canonicalizing paths (e.g., resolving symlinks) before file operations and verifying that the final resolved location resides within the intended workspace directory.
  • Restricting or disallowing symlink creation and modification by sandboxed processes, especially for paths that might later be touched by unsandboxed components.
  • Applying a strict "deny by default" policy for file writes originating from sandbox-driven operations, only allowing writes to a vetted allowlist of directories that cannot be redirected via symlinks.
  • Separating privileges so that any component that can be influenced by untrusted content runs with minimal filesystem permissions and cannot directly perform sensitive writes.
  • Designing sandbox boundaries around capabilities rather than just directory paths, considering how filesystem features like symlinks, bind mounts, and shortcuts affect isolation.

How teams detect issues like this

Detection and assurance efforts can focus on both code-level patterns and runtime behavior:

  • Static analysis:
  • Flag code paths where unsandboxed components perform writes based on paths originating from sandboxed or otherwise untrusted sources without canonicalization and boundary checks.
  • Identify filesystem operations that do not validate the resolved path against the intended workspace or jail directory.
  • Code review signals:
  • Look for logic that assumes "under this directory == safe" without considering symlinks or mount points.
  • Review any hand-rolled sandbox or workspace isolation logic that lacks explicit checks on resolved paths.
  • Policy enforcement:
  • Integrate linters or security checks into CI pipelines that enforce safe path-handling practices and prohibit direct writes based on unvalidated user- or model-influenced paths.
  • Use host-level monitoring to detect unexpected file writes from developer tools or sandboxed environments to sensitive locations.
  • Automated tools:
  • Employ security scanners or SAST tools that include rules for CWE-22 and CWE-61, focusing on path traversal and symlink handling in codebases implementing sandboxing or workspace abstractions.

Sources

SourceLink
github.comgithub.com/anthropics/claude-code/security/advisories/GHSA-vp62-r36r-9xqp

Frequently asked

questions

It can be, but only in contexts where an attacker can reliably inject content into a Claude Code context and steer sandboxed code execution (such as through prompt injection or compromised project assets). The vulnerability itself is local to the machine running Claude Code but can be triggered indirectly by remote input.

The attacker must be able to provide untrusted content that Claude Code will interpret in a way that causes the sandboxed environment to create or manipulate symlinks and then induce the unsandboxed application to perform writes to those paths. Direct shell access is not required, but effective control over sandboxed commands is.

The most robust pattern is to resolve all file paths to their canonical form before performing operations and then verify that the resolved paths remain within the intended sandbox or workspace directory, rejecting or warning on any attempt to step outside. Complement this with restrictions on symlink creation and strict permission separation between sandboxed and unsandboxed components.

Future designs should model the sandbox boundary at the capability and resolved-path level, not just at the string-path level. This includes disallowing or carefully mediating filesystem features like symlinks, enforcing least privilege for host-side processes, applying defense-in-depth checks (e.g., both in the sandbox and host layers), and integrating security reviews that specifically examine how untrusted inputs can influence file operations across trust boundaries.

Find out what's already
exploitable in your codebase.