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

Source: https://botpassword.com/incidents/2026-04-claude-code-worktree-trust-bypass
Disclosed: 2026-04-24 · Type: AI agent · Status: Resolved · Updated: 2026-10-25

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.

Identifiers: CVE-2026-40068, GHSA-q5hj-mxqh-vv77

## 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.

## Who is 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

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

- [Anthropic](https://botpassword.com/keys/anthropic)
- [GitHub](https://botpassword.com/keys/github)

## Timeline

- 2026-04-24: Anthropic publishes GHSA-q5hj-mxqh-vv77 (high), crediting a HackerOne reporter; fixed in 2.1.84. ([source](https://github.com/anthropics/claude-code/security/advisories/GHSA-q5hj-mxqh-vv77))
- 2026-05-05: NVD publishes CVE-2026-40068, listing affected versions 2.1.63 through 2.1.83. ([source](https://nvd.nist.gov/vuln/detail/CVE-2026-40068))

## Indicators

- A cloned repository whose git `commondir` file points to a path outside the repository.
- Unexpected hooks in a repository's `.claude/settings.json`.

## Sources

- https://github.com/anthropics/claude-code/security/advisories/GHSA-q5hj-mxqh-vv77
- https://nvd.nist.gov/vuln/detail/CVE-2026-40068
