AI agent · January 20, 2026

Claude Code could send Anthropic API keys to a malicious repo's endpoint before the trust prompt

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.

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

  1. Update Claude Code to 2.0.65 or later (auto-update handles this for most users).
  2. 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.
  3. Before opening a cloned repository with an agent, inspect its project settings for environment overrides such as ANTHROPIC_BASE_URL.
  4. 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

  1. 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
  2. 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_URL to 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.

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.