Anthropic disclosed that Claude Code before version 2.0.65 read a repository's settings file and made API requests before showing its folder trust prompt. A malicious repository could set ANTHROPIC_BASE_URL to an attacker-controlled server, so simply opening it could send the user's Anthropic API key there. Update Claude Code, and rotate your Anthropic key if you opened untrusted repositories with an older version.
| Disclosed | January 20, 2026 |
|---|---|
| Affected | Claude Code, @anthropic-ai/claude-code, Anthropic |
| Type | AI agent |
| Status | Resolved |
| CVE | CVE-2026-21852 |
What was exposed
The credential Claude Code sends with its API requests: an Anthropic API key, or other request data, according to the advisory. Claude Code lets a project's settings set environment variables, and ANTHROPIC_BASE_URL controls where API traffic goes. Before the fix, Claude Code loaded that configuration and issued requests as soon as it started in the folder, ahead of the dialog that asks whether you trust the repository. An attacker who persuaded you to clone and open a repository (a pull request to review, a sample project, a dependency you wanted to inspect) could therefore receive your key at their endpoint without any further action from you. A stolen Anthropic key can be used to run paid API calls on your account until it is revoked. The advisory does not report exploitation in the wild.
Am I affected?
You are affected if you ran Claude Code below 2.0.65 inside a repository you did not create, especially one cloned from an unfamiliar source. Users on the standard auto-update channel already have the fix, per Anthropic. Check your version with claude --version. To look for signs of a planted setting, search cloned repositories for a .claude/settings.json (or similar project settings) that sets ANTHROPIC_BASE_URL to a host other than Anthropic's.
What to do now
- Update Claude Code to 2.0.65 or later (auto-update handles this for most users).
- If you opened untrusted repositories with an older version, revoke and recreate your Anthropic API key in the Claude Console and review usage for calls you did not make.
- Before opening a cloned repository with an agent, inspect its project settings for environment overrides such as
ANTHROPIC_BASE_URL. - Use a separate, spend-limited key for agent work so a leak has a bounded cost.
Keys to rotate
Guides to the credentials this incident put at risk:
Timeline
- Anthropic publishes GHSA-jh7p-qr78-84p7 (medium), titled as a data leak via malicious environment configuration before trust confirmation; fixed in 2.0.65. Source
- NVD publishes CVE-2026-21852 for the same issue. Source
Indicators
From the advisories listed below. Use them to search your logs, lockfiles and workflow runs.
- A project settings file in a cloned repository that sets
ANTHROPIC_BASE_URLto a non-Anthropic host. - Claude Code versions below 2.0.65.
What this changes for credential handling
- Configuration in a repository decided where a key was sent. BotPassword is built so the agent is not handed the key by default, and requests to an unapproved host are refused by policy.
Frequently asked questions
Am I affected by the Claude Code incident?
You are affected if you ran Claude Code below 2.0.65 inside a repository you did not create, especially one cloned from an unfamiliar source. Users on the standard auto-update channel already have the fix, per Anthropic. Check your version with claude --version. To look for signs of a planted setting, search cloned repositories for a .claude/settings.json (or similar project settings) that sets ANTHROPIC_BASE_URL to a host other than Anthropic's.
What was exposed in the Claude Code incident?
The credential Claude Code sends with its API requests: an Anthropic API key, or other request data, according to the advisory. Claude Code lets a project's settings set environment variables, and ANTHROPIC_BASE_URL controls where API traffic goes. Before the fix, Claude Code loaded that configuration and issued requests as soon as it started in the folder, ahead of the dialog that asks whether you trust the repository. An attacker who persuaded you to clone and open a repository (a pull request to review, a sample project, a dependency you wanted to inspect) could therefore receive your key at their endpoint without any further action from you. A stolen Anthropic key can be used to run paid API calls on your account until it is revoked. The advisory does not report exploitation in the wild.
Which keys should I rotate?
Rotate any Anthropic credentials that were reachable from affected systems, starting with the ones that can publish code or reach production.
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
- Claude Code trust dialog could be bypassed with a spoofed git worktree, running repo hooks 2026-04-24
- 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