/

CVE-2026-21852

Severity:

HIGH RISK

(7.5)

Insufficient Credential Protection in Claude Code Project

CVE-2026-21852

Analyzed

Vulnerability type

Category:

Insufficient Credential Protection

CWE:

CWE-522

Impact:

API Key and Sensitive Data Exfiltration

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A vulnerability in Claude Code's project-load flow allowed attacker-controlled repositories to exfiltrate sensitive data, including Anthropic API keys, before users confirmed they trusted the project.

By setting ANTHROPIC_BASE_URL to an attacker-controlled endpoint in a configuration file, a malicious repository could trigger outbound API requests on project open and capture the user's keys and related data.

Affected context

This issue affects environments where Claude Code is configured with Anthropic API keys and is used to open untrusted or third-party repositories.

The vulnerability is present when:

  • Project configuration files are automatically read and applied on project load
  • Network calls are made using user credentials prior to any explicit trust confirmation
  • Environment-level secrets (like API keys) are implicitly reused for repository-specific operations

Exploit preconditions

  • Attack surface: Opening a project/repository inside Claude Code.
  • Required access: Ability for the attacker to supply or control a repository that a user opens (e.g., through a shared repo, template, or downloaded project).
  • Trigger point: The moment Claude Code loads the project and reads its settings file, before displaying or enforcing the trust prompt.
  • Why exploitation is possible: Project configuration is applied automatically and used to construct outbound API requests that include or rely on the user's Anthropic API keys, without prior isolation, validation, or confirmation that the repository is trusted.

Why this happens

The core issue is an insecure handling of sensitive configuration and secrets tied to untrusted project context.

Claude Code processes repository-level settings on load, including ANTHROPIC_BASE_URL, and immediately uses them to perform API requests with the user's existing credentials.

This maps to CWE-522: Insufficiently Protected Credentials, where sensitive authentication data (API keys) are exposed through abusive flows because trust boundaries are misapplied and secrets are not segregated or guarded when interacting with untrusted configurations.

Potential impact

  • Exfiltration of Anthropic API keys to attacker-controlled endpoints
  • Unauthorized use of the victim's Anthropic account and quota consumption
  • Access to or inference about code, prompts, or project data sent during the initial API calls
  • Potential pivot to compromise other services or tools that reuse the same or related credentials

General mitigation guidance

Effective mitigation focuses on strengthening trust boundaries and limiting how secrets are used with untrusted projects:

  • Treat project configuration files as untrusted input until a user explicitly confirms trust.
  • Avoid automatically applying network-related settings (like base URLs or proxies) from project files before user approval.
  • Isolate secrets from project context by using separate, scoped credentials for untrusted repositories or running them in a restricted mode with no outbound calls.
  • Implement least-privilege use of API keys, minimizing what operations can be performed before trust is established.
  • Provide clear UX that distinguishes "trusted" from "untrusted" projects and defaults to the safest, least-connected state.

How teams detect issues like this

Organizations can detect and monitor similar issues through:

  • Code review practices that flag any automatic use of user credentials in response to untrusted configuration (e.g., project files, workspace settings).
  • Static analysis rules that look for flows where secrets or authentication tokens are combined with unvalidated, user-controlled network endpoints.
  • Logging and security monitoring for anomalous outbound connections to unrecognized domains immediately after opening new projects.
  • Policy-based tooling in CI or internal review that enforces explicit trust checks before applying configuration that affects network behavior or credentials.

Sources

SourceLink
github.comgithub.com/anthropics/claude-code/security/advisories/GHSA-jh7p-qr78-84p7

Frequently asked

questions

It is indirectly remote: an attacker must convince a user to open a malicious repository in Claude Code, but once the project is opened, exfiltration can occur without further user interaction.

The attacker only needs the ability to provide or control a repository that the victim opens in Claude Code. They do not need direct access to the victim's machine or Anthropic account; the vulnerable project-load behavior performs the exfiltration.

The strongest fix is to ensure that untrusted projects cannot trigger any use of user credentials or network-sensitive configuration until after the user explicitly confirms trust, and even then, to run with the minimum necessary privileges and isolated configuration.

Design project-load and configuration flows with strict trust boundaries, treat repository settings as untrusted by default, avoid automatic use of secrets with user-controlled endpoints, and employ systematic reviews and testing that simulate untrusted repositories attempting to manipulate configuration and network behavior.

Find out what's already
exploitable in your codebase.