STUPID-2026-0083

Claude Code leaked API keys via malicious repo settings before trust prompt

7.0high
January 20, 2026Source checkedRepro reported

Why 7/10

Opening a crafted repo could send the developer's API key to an attacker before the trust prompt. Fixed; no exploitation reported. Keys can be rotated.

Scope
3/4
A whole machine or drive, an organisation's production system or data, or many credentials
Recoverability
2/3
Partly lost, or loss reported without saying whether it was recovered
Did it happen
1/2
Demonstrated (proof of concept, reproduction, controlled test or near-miss) with no real victim reported
Beyond the user
1/1
Production systems, customers or third parties, or credentials and sensitive personal data

The score is the sum of these four factors. How each factor is scored · scored 2026-10-29

  1. Instruction given

    Open and start working in a repository containing a project-level Claude Code settings file.

  2. Expected behavior

    Claude Code should display the workspace trust prompt and wait for user confirmation before making any network requests driven by that repository's configuration.

  3. Actual behavior

    If the untrusted repository's settings file set ANTHROPIC_BASE_URL to an attacker-controlled endpoint, Claude Code issued API requests to that endpoint before the trust prompt was ever shown, sending the user's Anthropic API key along with them.

  4. Damage

    Simply opening a crafted, untrusted repository in Claude Code could exfiltrate the developer's active API key to attacker infrastructure. Fixed in Claude Code 2.0.65; users on auto-update received the patch automatically.

Full write-up

Claude Code's project-load flow processed a repository's settings file — including an ANTHROPIC_BASE_URL override pointing at an attacker-controlled endpoint — before displaying the workspace trust prompt that is supposed to gate exactly this kind of untrusted configuration. As a result, opening a malicious repository could cause Claude Code to issue live API requests to the attacker's server carrying the user's API key, with no opportunity to review or reject the redirect first. Tracked as CVE-2026-21852 (GHSA-jh7p-qr78-84p7, CWE-522, CVSS 5.3), the flaw affected versions of @anthropic-ai/claude-code below 2.0.65 and was fixed in that release.

Classification

Root cause
Logic Error
Domain
Security
OWASP Agentic Top 10 (our mapping)
ASI03 Identity and Privilege Abuse list
MIT AI Risk Repository (our mapping)
2.2 AI system security vulnerabilities and attacks taxonomy

Related incidents

Cite this record
StupidLLM. "STUPID-2026-0083: Claude Code leaked API keys via malicious repo settings before trust prompt." AI Agent Incident Database, 2026. https://www.stupidllm.com/incident/STUPID-2026-0083/ (accessed 2026-11-19). CC BY 4.0.

← STUPID-2026-0082By IDSTUPID-2026-0084 →

Get told when an agent breaks something

We document AI agent failures daily, severity-scored against a published scale. Each Monday, if any scored 7 or above that week — deleted data, leaked secrets, broken production — you get one email with the sources. When nothing did, you get nothing.

This database is callable over MCP — query it from inside your agent.