Version analyzed: March 31, 2026 leak
Package: @anthropic-ai/claude-code
Discovery: Chaofan Shou (@Fried_rice)
Package: @anthropic-ai/claude-code
Discovery: Chaofan Shou (@Fried_rice)
Timeline
March 31, 2026 - The Discovery
Security researcher Chaofan Shou (@Fried_rice on X/Twitter) discovered that Anthropic had accidentally published source maps alongside their minified npm package. His tweet:“Claude code source code has been leaked via a map file in their npm registry!” — @Fried_rice, March 31, 2026The discovery spread rapidly through the developer and security communities.
What Happened
The Source Map File
When Anthropic published@anthropic-ai/claude-code to npm, they included a .map file (JavaScript source map) in the package. Source maps are typically used for debugging — they map minified/compiled code back to the original source.
The source map contained a reference to a zip archive hosted on Anthropic’s R2 storage bucket (Cloudflare’s S3-compatible object storage). This archive contained the complete, unobfuscated TypeScript source code.
How Anyone Could Access It
What Was NOT a Hack
This is important to understand:Why This Matters
The distinction is crucial:- No laws were broken - The files were public
- No systems were compromised - Everything was on npm’s public registry
- No credentials were stolen - The source was openly accessible
- No exploitation occurred - This was a publishing mistake, not a security breach
What Was Exposed
The leak revealed approximately:| Component | Scale |
|---|---|
| Files | ~1,900 TypeScript files |
| Lines of Code | 512,000+ lines |
| Directories | ~35 major directories |
| Tools | 40+ tool implementations |
| Commands | 50+ slash commands |
Key Exposed Components
-
Complete Source Code
- All TypeScript implementation files
- Tool definitions and schemas
- Command implementations
- Service integrations
-
System Prompts
- Agent instructions
- Tool usage guidelines
- Context assembly logic
- Model-specific prompts
-
Architecture
- Internal design patterns
- State management approach
- API integration details
- Permission system implementation
-
Configuration
- Schema definitions (Zod)
- Environment variable handling
- Settings hierarchy
- Feature flags
-
Experimental Features
- Feature-gated code paths
- Internal experiments
- Beta functionality
- Ant-only (Anthropic employee) features
Why Source Maps Were Included
Source maps are commonly included in npm packages for debugging purposes. However, they’re typically configured to:- Point to local files - Not remote URLs
- Be excluded from production builds - Via
.npmignore - Reference minified sources - Not full original source
- Be stripped in public releases - For proprietary code
- Generated source maps pointing to a remote archive
- Included those source maps in the published package
- Made the remote archive publicly accessible
- Not caught this in their release process
- Build tooling (likely Bun’s bundler)
- Release pipeline
- Quality assurance checks
.npmignoreor package.jsonfilesconfiguration
Community Response
Immediate Reaction
The security and developer communities responded quickly:- Analysis began - Developers started examining the source
- Documentation efforts - Community members began documenting findings
- Security review - Researchers looked for vulnerabilities
- Educational use - Developers studied the architecture and patterns
What the Community Learned
The leak provided unprecedented insight into:- How production AI agents are built - Real-world agentic architecture
- Tool system design - How to structure tool-calling systems
- Permission models - Balancing autonomy with safety
- Prompt engineering - Production-grade system prompts
- State management - Handling complex agent state
- MCP integration - Model Context Protocol implementation
Ethical Considerations
The community generally agreed on ethical guidelines:Anthropic’s Response
As of the documentation date, Anthropic has not publicly commented on the leak. The source maps remain in published npm packages, though future versions may address this. Typical responses to such incidents include:- Removing source maps from future releases
- Updating build configurations
- Reviewing release processes
- Potentially rotating sensitive credentials (if any were exposed)
Legal Implications
Copyright
The source code remains copyrighted by Anthropic PBC. The leak does not change ownership or licensing.Fair Use
Community documentation and analysis likely fall under fair use:- Educational purpose - Teaching about AI agent architecture
- Transformative use - Explaining, not reproducing
- Limited reproduction - Short snippets for illustration
- No market harm - Educational docs don’t compete with the product
No Liability for Viewers
Accessing publicly available npm packages is not illegal. Anyone who:- Downloaded the package via
npm pack - Viewed the source maps
- Analyzed the source code
Lessons for the Industry
This incident highlights important considerations for software companies:Build Pipeline Security
- Review source map configurations - Ensure they don’t expose proprietary code
- Audit published packages - Check what actually gets uploaded to npm
- Implement pre-publish checks - Automated validation before release
- Use
.npmignoreproperly - Exclude sensitive files
Release Process
- Manual review of packages - Human verification before publish
- Staging environments - Test package contents before production
- Automated scanning - Tools to detect sensitive data in packages
- Rollback procedures - Quick response if issues are discovered
Transparency
- Clear licensing - Make intentions explicit
- Public communication - Address incidents openly
- Community engagement - Work with researchers constructively
Impact on Claude Code
The leak has had several effects:Positive
- Increased understanding - Developers better understand how it works
- Community contributions - Bug reports and feature suggestions
- Educational value - Real-world example of production AI agents
- Transparency - Users can verify security and privacy claims
Neutral
- No security breach - No credentials or user data exposed
- No service disruption - Claude Code continues to function normally
- No competitive advantage - Architecture is complex to replicate
Potential Concerns
- Intellectual property - Proprietary implementation details exposed
- Security research - Easier to find vulnerabilities
- Competitive analysis - Competitors can study the approach
Related Links
Introduction
Back to the main introduction page
Architecture Overview
Understand the system architecture revealed by the leak
Security Overview
Security implications and considerations
Project Structure
What the leaked source code contains