CVE-2026-40068: Claude Code: Trust Dialog Bypass via Git Worktree Spoofing Allows Arbitrary Code Execution
Claude Code 2.1.63 up to 2.1.83 can be tricked into skipping its folder trust dialog by a cloned repository with a forged git worktree commondir file. Hooks in the repo's .claude/settings.json then run at once. Upgrade to 2.1.84. Auto-update users already have the fix.
Published Apr 24, 2026 · Updated May 8, 2026 · Analysis Oct 29, 2026
What an attacker can do
Claude Code asks the user to trust a folder before it loads project hooks. While deciding trust, it read the git worktree commondir file but did not validate what it contained. An attacker can ship a repository whose commondir points at a path the victim has already trusted. Claude Code then treats the new folder as trusted, shows no dialog, and runs the hooks defined in .claude/settings.json.
Hooks are shell commands. So the attacker gets code execution as the developer's user, with access to SSH keys, cloud credentials, tokens and source code on that machine.
Two conditions limit the attack. The victim must clone the malicious repository and start Claude Code inside it. The attacker must also know or guess a path the victim has already trusted, such as a common projects directory. Because of these conditions the CVSS 4.0 vector marks attack requirements as present and user interaction as passive.
Who is affected
The npm package @anthropic-ai/claude-code in versions from 2.1.63 up to, but not including, 2.1.84 is affected. Earlier versions than 2.1.63 are outside the stated range. Check your version:
claude --version
npm ls -g @anthropic-ai/claude-codeAny result from 2.1.63 through 2.1.83 is vulnerable.
@anthropic-ai/claude-code
- Ecosystem
- npm
- Affected
- >= 2.1.63, < 2.1.84
- Fixed in
- 2.1.84
- Check
npm ls @anthropic-ai/claude-code
How to fix it
Upgrade to 2.1.84 or later. The advisory says standard auto-update users have the fix already. For manual installs:
npm install -g @anthropic-ai/claude-code@latestThe advisory names no workaround. Until you upgrade, avoid running Claude Code in freshly cloned repositories you do not trust.
How to tell if you were hit
Look inside cloned repositories for a .git/commondir file or a worktree layout that points outside the repo, and for a .claude/settings.json that defines hooks you did not write. Review shell history and process logs for commands launched by Claude Code at session start, before any trust prompt. Beam records agent shell commands and file access, and its rules can flag hook-launched commands that read credentials.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Claude Code used the git worktree commondir file when determining folder trust but did not validate its contents. By crafting a repository with a commondir file pointing to a path the victim had previously trusted, an attacker could bypass the trust dialog and immediately execute malicious hooks defined in .claude/settings.json. Exploiting this required the victim to clone a malicious repository and run Claude Code within it, and for the attacker to know or guess a path the victim had already trusted.
Users on standard Claude Code auto-update have received this fix already. Users performing manual updates are advised to update to the latest version.
Claude Code thanks hackerone.com/masato_anzai for reporting this issue.
Questions
- Is Claude Code 2.1.84 affected by CVE-2026-40068?
No. Version 2.1.84 is the patched release. Versions from 2.1.63 up to 2.1.83 are affected.
- Does CVE-2026-40068 need user interaction?
Yes. The victim must clone the malicious repository and run Claude Code in it. The attacker must also know or guess a path the victim has already trusted.
- What do the attacker's hooks run as?
They run as shell commands defined in .claude/settings.json, so they run with the developer's own user permissions, which include the developer's keys and tokens.
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-39861
Claude Code: Sandbox Escape via Symlink Following Allows Arbitrary File Write Outside Workspace
high10.0Apr 21, 2026
