Claude Code’s Edit tool can be tricked into writing files outside the workspace
Code running inside Claude Code’s Bash sandbox can exploit a timing gap in the Edit tool and overwrite a file outside the workspace on macOS, Anthropic’s advisory warns.
- Affected
- @anthropic-ai/claude-code (npm): < 2.1.251
- Fixed
- @anthropic-ai/claude-code (npm): 2.1.251

The advisory says exploitation requires attacker-controlled code inside the sandbox, such as from a malicious repository or dependency script. That narrows exposure, but a compromised project could still reach user-writable files outside Claude Code’s workspace.
On macOS, point-in-time path and symlink validation is not bound to directory inodes or file descriptors. After validation, sandbox code can replace an in-workspace parent directory with a symlink, causing the unsandboxed Edit implementation to write to an attacker-selected file outside the workspace.
Versions below 2.1.251 of @anthropic-ai/claude-code are affected; version 2.1.251 is fixed. Auto-update users have received the patch automatically, while manual users should install the latest version.
Sources & technical scope 2 sources
Claude Code advisories — original source ↗
GitHub_M CNA / CVE Program — original source ↗
Affected: @anthropic-ai/claude-code (npm): < 2.1.251
Fixed: @anthropic-ai/claude-code (npm): 2.1.251
Exploitation: Requires attacker-controlled code running in Claude Code’s Bash sandbox on macOS; supplied evidence does not establish in-the-wild exploitation.
Scope & limitations: The supplied evidence does not specify versions individually tested or detail patch mechanics beyond the version fix.
External findings belong to the credited researchers.