CVE-2026-39861: Claude Code: Sandbox Escape via Symlink Following Allows Arbitrary File Write Outside Workspace
Claude Code before 2.1.64 had a sandbox escape through symlinks. A sandboxed command could create a symlink that points outside the workspace, and Claude Code's unsandboxed process then followed it when writing a file, without asking the user. This could lead to code execution outside the sandbox. Update to 2.1.64.
Published Apr 21, 2026 · Updated Apr 27, 2026 · Analysis Oct 29, 2026
What an attacker can do
Claude Code runs commands in a sandbox and writes files from a separate, unsandboxed process. Each half had a limit: the sandboxed command could not write outside the workspace, and the app would prompt before writing outside it. The sandbox did not stop the command from creating a symlink to an outside location. When Claude Code later wrote to a path inside that symlink, the unsandboxed app followed the link and wrote to the target with no confirmation. Neither part could write outside alone, but together they could write anywhere the user's account can. This is CWE-61, symlink following.
The advisory says reliable exploitation needed a way to put untrusted content into the Claude Code context window, so that prompt injection triggers the sandboxed code execution. A malicious repository file, a web page the agent reads or a tool result can serve as that content. A write to a shell startup file, an SSH config or a similar file can turn into code execution outside the sandbox.
Who is affected
@anthropic-ai/claude-code before 2.1.64. Check your version:
claude --version
npm ls -g @anthropic-ai/claude-codeThe flaw matters most for people who rely on the sandbox to let the agent run commands on projects with untrusted content.
@anthropic-ai/claude-code
- Ecosystem
- npm
- Affected
- < 2.1.64
- Fixed in
- 2.1.64
- Check
npm ls @anthropic-ai/claude-code
How to fix it
Update to 2.1.64 or later. Standard auto-update installs have received the fix automatically. If you update by hand, run:
npm install -g @anthropic-ai/claude-code@latestThe advisory lists no workaround. Until you update, avoid running Claude Code on untrusted repositories or with untrusted content in context.
How to tell if you were hit
Look in your workspaces for symlinks that point outside the project directory, particularly ones the agent created, and for unexpected changes to files outside the workspace such as shell rc files, SSH config or cron entries. Beam records the shell commands and file access of AI agents, and its rules can flag an agent creating a symlink to a sensitive path or writing outside the project.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Claude Code's sandbox did not prevent sandboxed processes from creating symlinks pointing to locations outside the workspace. When Claude Code subsequently wrote to a path within such a symlink, its unsandboxed process followed the symlink and wrote to the target location outside the workspace without prompting the user for confirmation. This allowed a sandbox escape where neither the sandboxed command nor the unsandboxed app could independently write outside the workspace, but their combination could write to arbitrary locations, potentially leading to code execution outside the sandbox. Reliably exploiting this required the ability to add untrusted content into a Claude Code context window to trigger sandboxed code execution via prompt injection.
Users on standard Claude Code auto-update have received this fix automatically. Users performing manual updates are advised to update to the latest version.
Claude Code thanks hackerone.com/philts for reporting this issue.
Questions
- Is Claude Code 2.1.63 affected by CVE-2026-39861?
Yes. Every version before 2.1.64 is affected. Version 2.1.64 contains the fix.
- Does exploitation need user interaction?
The attack needs untrusted content in the Claude Code context to trigger sandboxed execution by prompt injection. The write outside the workspace then happens without a confirmation prompt.
- Do I need to patch manually?
Standard auto-update users received the fix automatically. People who update manually should move to the latest version.
- Why is the CVSS 3.1 score 10?
The vector marks scope as changed with high confidentiality, integrity and availability impact. The 4.0 score is 7.7, which reflects the need for passive user involvement.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Claude Code vulnerabilities
All Claude Code entriesCVE-2026-88968
Claude Code: TOCTOU Race in Edit Tool Allows File Writes Outside the Workspace
high7.7Nov 9, 2026CVE-2026-86063
Claude Code: Plugin Hash Pin Bypass Allows Bypass of Hash Pinning
high7.5Oct 15, 2026CVE-2026-55607
Claude Code: Sandbox Escape via Git Worktree Path Confusion Allows Unsandboxed Code Execution
high7.7Jul 24, 2026CVE-2026-46406
@anthropic-ai/claude-code has an Insecure Temporary File in /copy Command that Enables Response Disclosure and Symlink-Based File Write
medium4.4Jun 25, 2026CVE-2026-54316
Claude Code: Out-of-Band Data Exfiltration via Pre-Approved HuggingFace Domain in WebFetch
medium9.1Jun 17, 2026CVE-2026-40068
Claude Code: Trust Dialog Bypass via Git Worktree Spoofing Allows Arbitrary Code Execution
high7.7Apr 24, 2026
