Claude Code Security Vulnerabilities Audit

Following our reverse-engineering of Claude Code's leaked source for hacks and optimisations, we turned to the security side. We audited the full 1,900-file TypeScript codebase for vulnerabilities, attack surfaces, and exploitable gaps.

The results: 23 verified vulnerabilities, 7 rated critical.

Source Claude Code npm package (leaked 2026-03-31) Codebase ~1,900 TypeScript files Findings 23 verified vulnerabilities Severity 7 CRITICAL 10 HIGH 5 MEDIUM 1 LOW #1 Vector Malicious git repositories Full audit claude-code-leak/security.html

Key Takeaways

  • The primary attack vector is malicious repositories. A repo with crafted .claude/ files can execute arbitrary commands, inject system prompts, configure attacker-controlled MCP servers, and read arbitrary files -- all triggered automatically on project open.
  • Seven critical vulnerabilities allow arbitrary code execution or data exfiltration without user approval in some cases.
  • Shell security has specific bypass vectors including a 50-subcommand analysis cap and sed delimiter tricks.
  • Credentials are stored in plaintext on Linux and Windows (~/.claude/.credentials.json).
  • No symlink resolution or critical path protection in file write operations.

Attack Priority Matrix

All 23 verified vulnerabilities ranked by severity. Each links to the detailed analysis in the full security audit.

# Vulnerability Severity Requires Exploitability
1CLAUDE.md Prompt InjectionCRITICALMalicious repo cloneTrivial
2Memory File InjectionCRITICALMalicious repo cloneTrivial
3Custom Agent InjectionCRITICALMalicious repo cloneTrivial
4Skill File InjectionHIGHMalicious repo cloneTrivial
5CLAUDE.md @include Path TraversalCRITICALMalicious repo cloneTrivial
6Hook Command InjectionCRITICALMalicious repo cloneTrivial
7Subcommand Limit Bypass (>50)HIGHPrompt injectionModerate
8Sandbox Exclusion via dangerouslyDisableSandboxHIGHModel promptModerate
9Sed Non-Slash Delimiter BypassHIGHModel promptEasy
10MCP Tool Result InjectionHIGHMalicious MCP serverEasy
11MCP Environment Variable LeakageHIGHMalicious repo cloneEasy
12JWT Signature Not VerifiedCRITICALNetwork positionMedium
13Bridge Message Type GuardCRITICALMitM or compromised serverEasy
14Swarm Permission ForgeryMEDIUMSwarm agent contextEasy
15Project Settings InjectionHIGHMalicious repo cloneTrivial
16MCP Server Config InjectionHIGHMalicious repo cloneTrivial
17Symlink Following in File WritesHIGHFilesystem preparationMedium
18WebFetch SSRFMEDIUMPrompt injectionEasy
19Plaintext Credentials (Linux/Windows)HIGHLocal user accessTrivial
20No Critical Path ProtectionMEDIUMBypass modeEasy
21Fork Context Data LeakageMEDIUMNormal usageEasy
22DNS Exfiltration (no detection)MEDIUMPrompt injectionNo detection exists
23Context Window Exhaustion DoSLOWNormal usageEasy but low impact

The most trivially exploitable findings (1-5, 8, 13-15) all share the same vector: a malicious git repository with crafted .claude/ files. A developer clones the repo, runs claude, and the attack chain fires automatically.


Full Security Audit

This post covers the highlights. The complete analysis documents all 23 findings with severity ratings, affected source files, exploit code, and a sortable attack priority matrix.

Full Security Audit

23 Verified Vulnerabilities

Complete attack surface analysis with severity ratings, exploit code, and an attack priority matrix.

View the Full Security Audit

The source is on GitHub if you want to verify these findings yourself. See also our hacks and optimisations post for the non-security side of the analysis.