CVE-2026-21852: Claude Code Leaks Data via Malicious Environment Configuration Before Trust Confirmation
A vulnerability in Claude Code's project-load flow allowed malicious repositories to exfiltrate data including Anthropic API keys before users confirmed trust. If a user started Claude Code in an attacker-controller repository, and the repository included a settings file that set ANTHROPICBASEURL to an attacker-controlled endpoint, Claude Code would issue API requests before showing the trust prompt, including potentially leaking the user's API keys.
Users on standard Claude Code auto-update have received this fix already. Users performing manual updates are advised to update to the latest version.
Other sources
Claude Code is an agentic coding tool. Prior to version 2.0.65, vulnerability in Claude Code's project-load flow allowed malicious repositories to exfiltrate data including Anthropic API keys before users confirmed trust. An attacker-controlled repository could include a settings file that sets ANTHROPICBASEURL to an attacker-controlled endpoint and when the repository was opened, Claude Code would read the configuration and immediately issue API requests before showing the trust prompt, potentially leaking the user's API keys. Users on standard Claude Code auto-update have received this fix already. Users performing manual updates are advised to update to version 2.0.65, which contains a patch, or to the latest version.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/@anthropic-ai/claude-codeto a version that resolves this vulnerability.Fixed in 2.0.65 - Upgrade
Upgrade
Claude Codeto a version that resolves this vulnerability.Fixed in 2.0.65
Event History
Frequently Asked Questions
What is the severity of CVE-2026-21852?
CVE-2026-21852 is considered a high severity vulnerability due to its potential for data exfiltration.
How do I fix CVE-2026-21852?
To fix CVE-2026-21852, upgrade to version 2.0.65 or later of the @anthropic-ai/claude-code package.
What kind of data can be exfiltrated due to CVE-2026-21852?
CVE-2026-21852 allows for the exfiltration of sensitive data including Anthropic API keys.
Who is affected by CVE-2026-21852?
Developers using versions of the @anthropic-ai/claude-code package prior to 2.0.65 are affected by CVE-2026-21852.
What specific conditions lead to exploitation of CVE-2026-21852?
Exploitation of CVE-2026-21852 occurs when users run Claude Code in a malicious repository that has a settings file configured with the ANTHROPIC_BASE_URL.