AI agent · April 24, 2026

Claude Code trust dialog could be bypassed with a spoofed git worktree, running repo hooks

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.

DisclosedApril 24, 2026
AffectedClaude Code, @anthropic-ai/claude-code, Anthropic
TypeAI agent
StatusResolved
CVECVE-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

  1. Update Claude Code to 2.1.84 or later.
  2. Inspect .claude/settings.json in repositories you cloned from untrusted sources for hooks, and remove any you do not recognize.
  3. If a suspicious hook ran, rotate your Anthropic API key, GitHub tokens, cloud credentials and SSH keys from a clean machine.
  4. 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

  1. Anthropic publishes GHSA-q5hj-mxqh-vv77 (high), crediting a HackerOne reporter; fixed in 2.1.84. Source
  2. 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 commondir file 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.

Which keys should I rotate?

Rotate any Anthropic, GitHub credentials that were reachable from affected systems, starting with the ones that can publish code or reach production.

Keep keys out of reach of the next compromised package

BotPassword is in early access. Request an invite and we'll email you when your spot opens.