Claude Code below 2.1.251 let code in its Bash sandbox redirect an Edit outside the workspace on macOS (CVE-2026-88968)

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

Claude Code’s sandbox isolates shell commands, and its file tools run outside it. CVE-2026-88968, published on 2026-10-26 and fixed in 2.1.251, used the gap between the two on macOS: code running inside the Bash sandbox could swap a folder for a symlink after the Edit tool had checked the path, so the edit landed outside the workspace.

Claude Code 的沙盒隔离了 shell 命令,而其文件工具则在沙盒外运行。CVE-2026-88968 于 2026 年 10 月 26 日发布并于 2.1.251 版本中修复,该漏洞利用了 macOS 上两者之间的间隙:在 Bash 沙盒内运行的代码可以在 Edit 工具检查路径后,将文件夹替换为符号链接,从而使编辑操作落在工作区之外。

It is the second time-of-check to time-of-use fix for Claude Code’s file writes in three weeks. Below is what each advisory required, and how to make sure your installation cannot fall behind the fix. Two advisories, three weeks apart Both advisories are in the Claude Code repository, both are rated High (CVSS 7.7), and both describe the same family of bug: a path that was checked at one moment and used at another.

这是三周内 Claude Code 文件写入功能第二次进行“检查时”到“使用时”(TOCTOU)的修复。以下是每份公告的要求,以及如何确保您的安装版本不会落后于修复进度。两份公告相隔三周,均位于 Claude Code 仓库中,评级均为高危(CVSS 7.7),且描述了同一类漏洞:路径在某一时刻被检查,却在另一时刻被使用。

The October 5 advisory describes the first shape: “Claude Code validated that a target file path resided within the project working directory at permission-check time, but re-resolved the path at write time without repeating that validation.” Someone with write access to the same workspace could “atomically replace a project file with a symlink”, so that “a lower-privileged attacker” could “redirect benign edits to sensitive files (e.g., shell configuration) in a higher-privileged session.”

10 月 5 日的公告描述了第一种形式:“Claude Code 在权限检查时验证了目标文件路径位于项目工作目录内,但在写入时重新解析了路径,而没有重复该验证。”拥有同一工作区写入权限的人可以“原子地将项目文件替换为符号链接”,从而使“低权限攻击者”能够“将良性编辑重定向到高权限会话中的敏感文件(例如 shell 配置文件)”。

The October 26 advisory is the one this post is about, because of where the attacker sits. The boundary the race used The description: “On macOS, a process running inside Claude Code’s Bash sandbox could exploit the resulting time-of-check to time-of-use window by atomically swapping an in-workspace parent directory with a symlink after validation completed, causing the unsandboxed Edit implementation to overwrite an attacker-selected user-writable file outside the workspace.”

10 月 26 日的公告是本文讨论的重点,原因在于攻击者的位置。该竞争条件所利用的边界描述如下:“在 macOS 上,运行在 Claude Code Bash 沙盒内的进程可以利用检查到使用之间的时间窗口,在验证完成后原子地将工作区内的父目录替换为符号链接,导致未沙盒化的 Edit 实现覆盖工作区外攻击者选定的、用户可写的文件。”

The phrase to notice is “the unsandboxed Edit implementation”. Claude Code’s sandboxing documentation states the scope near the top: “The sandbox wraps shell commands.” The tools that run outside it include the built-in file tools such as Read, Edit and Write, which “follow permission rules instead”, along with command hooks and local MCP servers.

需要注意的短语是“未沙盒化的 Edit 实现”。Claude Code 的沙盒文档在开头说明了其范围:“沙盒包装了 shell 命令。”在沙盒外运行的工具包括内置的文件工具(如 Read、Edit 和 Write,它们“遵循权限规则”),以及命令钩子和本地 MCP 服务器。

Our reading is that the split makes sense, since the file tools go through permission rules of their own. But it means two parts of Claude Code look at the same workspace with different powers. A sandboxed process can change things inside the workspace, which is what a build or test needs. The Edit tool can write wherever its checks allow. When the Edit tool checked a path and then used it a moment later, a sandboxed process that changed one directory in between could steer a write that the sandbox itself would never have allowed.

我们的理解是这种拆分是有道理的,因为文件工具通过其自身的权限规则运行。但这意味着 Claude Code 的两个部分以不同的权限查看同一个工作区。沙盒进程可以更改工作区内的内容,这是构建或测试所必需的。Edit 工具可以在其检查允许的任何地方进行写入。当 Edit 工具检查路径并在稍后使用它时,中间更改了目录的沙盒进程可能会引导一次沙盒本身绝不允许的写入操作。

The advisory names the root cause precisely: validation used “point-in-time pathname and symlink resolution that was not bound to the underlying directory inodes or file descriptors.” Checking a name and then writing to the name leaves a window. Binding the check to the actual directory the write will use closes it. The condition is also precise, and it is the realistic part: “Exploiting this required the ability to run attacker-controlled code inside the sandbox, such as through a malicious repository or dependency script.”

公告准确地指出了根本原因:验证使用了“未绑定到底层目录 inode 或文件描述符的即时路径名和符号链接解析”。检查名称然后写入该名称会留下一个窗口。将检查绑定到写入将使用的实际目录即可关闭该窗口。该条件也很精确,并且是现实的一部分:“利用此漏洞需要能够在沙盒内运行攻击者控制的代码,例如通过恶意仓库或依赖脚本。”

How to check that you have the fix The advisory’s guidance is short: “Users on standard Claude Code auto-update have received this fix automatically. Users performing manual updates are advised to update to the latest version.” Whether you are one or the other depends on how Claude Code was installed, and the setup documentation is explicit: “Native installations automatically update in the background.” “Homebrew, WinGet, apt, dnf, and apk installations do not auto-update by default”.

如何检查您是否已获得修复:公告的指导很简短:“使用标准 Claude Code 自动更新的用户已自动收到此修复。建议手动更新的用户更新到最新版本。”您属于哪种情况取决于 Claude Code 的安装方式,安装文档明确指出:“原生安装会在后台自动更新。”“Homebrew、WinGet、apt、dnf 和 apk 安装默认不会自动更新”。

On Homebrew and WinGet, setting CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE to 1 lets Claude Code run the upgrade in the background; apt, dnf and apk still need a manual upgrade. claude —version gives the number. claude doctor gives the rest; the setup page describes it as printing “read-only installation and settings diagnostics without starting a session”.

在 Homebrew 和 WinGet 上,将 CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE 设置为 1 可以让 Claude Code 在后台运行升级;apt、dnf 和 apk 仍需手动升级。claude —version 会显示版本号。claude doctor 会显示其余信息;设置页面将其描述为“在不启动会话的情况下打印只读安装和设置诊断信息”。

The channel, the floor, and the switch Three settings decide how quickly a fix like this reaches you. The channel. The setup page describes autoUpdatesChannel with two values. “latest” receives new versions as they ship. “stable” uses “a version that is typically about one week old, skipping releases with major regressions”. Our reading, not a statement from the advisory: on the stable channel, a security fix typically reaches you about a week after it ships, which is a fair trade for some teams and worth knowing either way.

通道、底线和开关:三个设置决定了此类修复到达您的速度。通道:设置页面描述了 autoUpdatesChannel 的两个值。“latest”会在新版本发布时接收。“stable”使用“通常约一周前发布的版本,跳过有重大回归的版本”。我们的理解(非公告声明):在稳定通道上,安全修复通常在发布后约一周到达,这对某些团队来说是一个公平的权衡,无论如何都值得了解。

The floor. minimumVersion sets a version that “Background auto-updates and claude update refuse to install any version below”. Setting it to the version that carries a fix you care about means a channel switch cannot quietly move you back past it: { “autoUpdatesChannel”: “stable”, “minimumVersion”: “2.1.251” } The page is careful to say this “only constrains updates”. For an organization that wants Claude Code to refuse to start below a version, the managed setting requiredMinimumVersion does that. The switch. DISABLE_AUTOUPDATER set to “1” in the env block turns the background updates off, and claude doctor then shows disabled (set by env: DISABLE_AUTOUPDATER) on.

底线:minimumVersion 设置了一个版本,“后台自动更新和 claude update 拒绝安装低于此版本的任何版本”。将其设置为包含您关心的修复的版本,意味着通道切换无法悄悄地将您移回该版本之前:{ “autoUpdatesChannel”: “stable”, “minimumVersion”: “2.1.251” } 该页面谨慎地指出这“仅限制更新”。对于希望 Claude Code 拒绝在低于某个版本时启动的组织,托管设置 requiredMinimumVersion 可以实现这一点。开关:在 env 块中将 DISABLE_AUTOUPDATER 设置为“1”可关闭后台更新,此时 claude doctor 会显示已禁用(由 env: DISABLE_AUTOUPDATER 设置)。