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.

