Skip to content
GitHub Security Advisories·Indexed by this site · Originally published· Event →SelectedAttention40

Claude Code fixes TOCTOU race vulnerability in the Edit tool; versions before 2.1.251 could be made to write files outside the workspace

Claude Code: TOCTOU Race in Edit Tool Allows File Writes Outside the Workspace

AI summary

Claude Code fixed a TOCTOU race vulnerability in the Edit tool. Versions of the npm package before 2.1.251 are affected, and it has been fixed in 2.1.251. The tool previously validated the edit target using pathname and symlink resolution at a single point in time, without binding to the underlying directory inode or file descriptor. On macOS, a process running inside the Claude Code Bash sandbox could, after validation completed, atomically replace a parent directory inside the workspace with a symlink, causing the unsandboxed Edit implementation to overwrite an attacker-chosen, user-writable file outside the workspace. Exploiting this vulnerability requires the ability to run attacker-controlled code inside the sandbox, for example a malicious repository or dependency script. Users using standard automatic updates have automatically received the fix; users who update manually need to upgrade to the latest version.

Why it was selected

The advisory sets out the race window between check and use and the precondition of execution within the sandbox, which can be used to judge the exposure surface of local Claude Code.

Read originalgithub.com