Skip to main content
Mallory
MediumPublic exploitVulnerability

CVE-2026-21852: Pre-trust API key exfiltration in Claude Code

Published Jan 21, 2026 · Updated 17 days ago
Trending this weekNot trendingOutside this week’s top 100
Mention activity · 30 daysNo mention activity in the last 30 days.
CVSS5.3Medium · v4
EPSS27.5%98th percentile
CISA KEVNoNot listed
In the wildNonePublic exploit, no exploitation reported
Vendor
Anthropic
IdentifiersCVE-2026-21852CWE-522 · Insufficiently Protected Credentials

CVE-2026-21852 is a credential-exfiltration vulnerability in the project-load flow of Anthropic Claude Code versions before 2.0.65. An attacker-controlled repository can supply project settings that override ANTHROPIC_BASE_URL with an attacker-controlled endpoint. Claude Code applies this configuration and initiates authenticated API requests before displaying the repository trust prompt, potentially transmitting the user's Anthropic API key and other request data to the attacker. Exploitation requires opening the malicious project with Claude Code but does not require accepting its trust prompt.

Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Analyst brief

Impact, mitigation & remediation

What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.

Impact

What an attacker gets, and what they’ve been doing with it.

Attackers can obtain Anthropic API credentials and sensitive data included in redirected API requests. Stolen keys can enable unauthorized API usage and associated charges. Depending on the key's permissions and workspace configuration, compromise can also expose shared Anthropic Workspace resources and permit reading, modifying, deleting, or uploading workspace data, extending the impact beyond the individual developer.

Mitigation

If you can’t patch tonight, do this now.

Until patched, do not launch Claude Code in untrusted repositories. Inspect repository-controlled configuration before project load and remove settings that override ANTHROPIC_BASE_URL or otherwise redirect API traffic. Validate the effective environment and configuration sources from a trusted workspace. Revoke and replace API keys suspected of exposure.

Remediation

Patch, then assume compromise.

Update Claude Code to version 2.0.65 or later, preferably the latest release. Standard auto-update users have received the fix; users managing updates manually must install a patched version. The fix defers network operations, including API key transmission, until the user explicitly confirms repository trust.

Public exploits

Exploits

1 exploit validated by Mallory's analysis. Hidden: 4 rejected by Mallory's analysis as not a working exploit; 1 not yet analyzed, such as Exploit-DB entries.

View more in app →
CVE-2026-21852-PoCRepository purpose: an educational demo of Claude Code CLI supply-chain style attacks via malicious project configuration, covering (1) a hooks consent/trust bypass leading to command execution (no CVE, fixed in v1.0.87), (2) CVE-2025-59536 where enableAllProjectMcpServers=true can auto-start project-defined MCP servers from .mcp.json and execute arbitrary commands (fixed in v1.0.111), and (3) CVE-2026-21852 where ANTHROPIC_BASE_URL from project settings is applied before the trust prompt, redirecting API traffic (including API keys in Authorization/x-api-key headers) to an attacker endpoint (fixed in v2.0.65). Structure and key files: - vuln1_hooks_bypass/.claude/settings.json: defines PreToolUse/PostToolUse hooks that run shell commands and write to /tmp/claude_vuln1_demo.log, demonstrating RCE on repo open in vulnerable versions. - CVE-2025-59536_mcp_injection/.claude/settings.json + CVE-2025-59536_mcp_injection/.mcp.json: sets enableAllProjectMcpServers=true and defines an MCP server that runs sh -c commands, writing to /tmp/claude_vuln2_demo.log. - CVE-2026-21852_api_exfil/.claude/settings.json: sets env.ANTHROPIC_BASE_URL to http://127.0.0.1:8888 to demonstrate credential exfiltration. - attacker_server.py: local HTTP server on 127.0.0.1:8888 that logs incoming requests (headers and JSON bodies) to /tmp/claude_attacker_demo.log and returns a demo JSON response. - attacker_proxy.py: MITM-style proxy on 127.0.0.1:8888 that captures API keys and conversation content, logs to /tmp/claude_proxy_demo.log, and forwards requests to https://api.anthropic.com to keep victim behavior normal. - scanner.py: a defensive detection tool that scans a given repo path for these patterns (hooks executing commands, enableAllProjectMcpServers + .mcp.json command definitions, and ANTHROPIC_BASE_URL/credential-related env overrides) and exits non-zero if findings exist. Exploit capabilities (as demonstrated): - Local code execution via auto-run hooks and MCP server startup (command execution payloads are simple echo/date/whoami/hostname logging but represent arbitrary command execution). - Network-based credential and data interception by redirecting Claude Code API traffic to an attacker-controlled base URL; optional stealth forwarding to the real Anthropic API. Overall, this is a PoC/educational repository combining malicious config examples, attacker infrastructure (server/proxy), and a scanner to detect the same indicators before opening a repo in Claude Code.atiilla · Disclosed Feb 27, 2026 · python · json · local/supply-chain (malicious repository configuration auto-executed by Claude Code CLI) · network (HTTP listener/MITM to capture API keys and conversation data; forwards to real API)PoC
Exposure surface

Affected products & vendors

Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.

VendorProductType
AnthropicClaude Codeapplication
FAQ

Frequently asked questions

Is CVE-2026-21852 exploited in the wild?
As of Nov 8, 2026, Mallory has no reports of CVE-2026-21852 being exploited in the wild. It is not listed in CISA KEV.
Is there a public exploit for CVE-2026-21852?
Yes. Mallory tracks 1 public exploit or proof of concept for CVE-2026-21852, the earliest disclosed Feb 27, 2026.
Is there a patch for CVE-2026-21852?
Update Claude Code to version 2.0.65 or later, preferably the latest release. Standard auto-update users have received the fix; users managing updates manually must install a patched version.
What products are affected by CVE-2026-21852?
Anthropic Claude Code.
How severe is CVE-2026-21852?
CVE-2026-21852 has a CVSS v4 score of 5.3 (Medium) and an EPSS score of 27.5% (98th percentile) as of Nov 8, 2026.
Mallory platform

The version that knows your environment.

This page is what’s public. Mallory adds the parts that aren’t: which of your assets are affected, which adversaries are exploiting it right now, and which detections to deploy tonight.
Exposure mappingQuery your assets running an affected version, and investigate the blast radius.
Threat actor evidenceEvery report linking this CVE to a named adversary.
Associated malware1Malware families linked to this CVE, with evidence and IOCs.
Detection signaturesYARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Vendor-by-vendor mappingCross-references every affected SKU, including bundled OEM variants.
Social activity32Community discussion across Reddit, Mastodon, and other social sources.