Anthropic disclosed that Claude Code 2.1.63 through 2.1.83 trusted a git worktree commondir file without validating it. A malicious repository could point that file at a folder the victim had already trusted, skip the trust dialog, and immediately run hooks from its .claude/settings.json, which execute commands with the user's access to keys and tokens. Update to 2.1.84 or later; if you opened untrusted repositories on an affected version, rotate credentials the machine held.
| Disclosed | April 24, 2026 |
|---|---|
| Affected | Claude Code, @anthropic-ai/claude-code, Anthropic |
| Type | AI agent |
| Status | Resolved |
| CVE | CVE-2026-40068 |
What was exposed
Anything a shell command run as the user could read. Claude Code hooks are commands defined in settings that run at points in a session; the trust dialog exists so that a repository's own hooks do not run until you agree. With this bypass a cloned repository's hooks ran at once, so an attacker could read Anthropic and other provider API keys from the environment or config files, SSH keys, cloud credentials, Git credential helpers and .env files, or install persistence. The advisory describes the outcome as arbitrary code execution. Exploitation needed three things: the victim cloned the malicious repository, ran Claude Code in it, and the attacker knew or guessed a path the victim had previously trusted (for example a common project folder name). Anthropic does not report exploitation in the wild.
Am I affected?
You are affected if you ran Claude Code 2.1.63 through 2.1.83 inside a repository from an untrusted source. Users on standard auto-update have the fix, according to Anthropic. Check with claude --version. In repositories you cloned during that period, a .git file or worktree metadata whose commondir points outside the repository, combined with hooks in .claude/settings.json, is the pattern the advisory describes.
What to do now
- Update Claude Code to 2.1.84 or later.
- Inspect
.claude/settings.jsonin repositories you cloned from untrusted sources for hooks, and remove any you do not recognize. - If a suspicious hook ran, rotate your Anthropic API key, GitHub tokens, cloud credentials and SSH keys from a clean machine.
- Open unfamiliar repositories in a container or VM that holds no long-lived credentials.
Keys to rotate
Guides to the credentials this incident put at risk:
Timeline
- Anthropic publishes GHSA-q5hj-mxqh-vv77 (high), crediting a HackerOne reporter; fixed in 2.1.84. Source
- NVD publishes CVE-2026-40068, listing affected versions 2.1.63 through 2.1.83. Source
Indicators
From the advisories listed below. Use them to search your logs, lockfiles and workflow runs.
- A cloned repository whose git
commondirfile points to a path outside the repository. - Unexpected hooks in a repository's
.claude/settings.json.
What this changes for credential handling
- Hooks run with the developer's full access, so a trust check was the only barrier. BotPassword is built so that keys are not readable by arbitrary processes on the machine, which limits what a hook that slips past such a check can take.
Frequently asked questions
Am I affected by the Claude Code incident?
You are affected if you ran Claude Code 2.1.63 through 2.1.83 inside a repository from an untrusted source. Users on standard auto-update have the fix, according to Anthropic. Check with claude --version. In repositories you cloned during that period, a .git file or worktree metadata whose commondir points outside the repository, combined with hooks in .claude/settings.json, is the pattern the advisory describes.
What was exposed in the Claude Code incident?
Anything a shell command run as the user could read. Claude Code hooks are commands defined in settings that run at points in a session; the trust dialog exists so that a repository's own hooks do not run until you agree. With this bypass a cloned repository's hooks ran at once, so an attacker could read Anthropic and other provider API keys from the environment or config files, SSH keys, cloud credentials, Git credential helpers and .env files, or install persistence. The advisory describes the outcome as arbitrary code execution. Exploitation needed three things: the victim cloned the malicious repository, ran Claude Code in it, and the attacker knew or guessed a path the victim had previously trusted (for example a common project folder name). Anthropic does not report exploitation in the wild.
Other ai agent and mcp incidents
- OpenCode on Windows and WSL ran commands from a malicious MCP server during OAuth sign-in 2026-10-04
- OpenCode server's upgrade endpoint let any webpage install an attacker's npm package 2026-09-24
- Cursor before 3.0: prompt-injected agent could escape its sandbox and run code as the user 2026-06-05
- Claw Chain: four OpenClaw flaws let a foothold read agent secrets and escape the sandbox 2026-04-23
- OpenClaw Control UI sent its gateway token to any gatewayUrl in a link, enabling 1-click RCE 2026-01-31
- Claude Code could send Anthropic API keys to a malicious repo's endpoint before the trust prompt 2026-01-20