Anthropic Accidentally Leaks 'Claude Code' AI Source Code in Packaging Error

Anthropic's 'Claude Code' AI Source Code Accidentally Leaked to Public via npm Registry

MEDIUM
April 5, 2026
4m read
Data BreachPolicy and ComplianceOther

Related Entities

Organizations

npm

Products & Tech

Claude Code

Full Report

Executive Summary

AI safety and research company Anthropic inadvertently exposed the 'crown jewels' of its AI coding assistant, Claude Code, by accidentally leaking its complete source code. The incident, which occurred on March 31, 2026, was not a malicious breach but a critical operational failure. A developer mistakenly included a JavaScript source map file in a public package on the npm registry. This file contained the entire un-minified TypeScript source code for the advanced AI agent. The code, spanning 512,000 lines, was publicly available for over three hours and was widely mirrored on GitHub before it could be fully contained. While Anthropic confirms no customer data was exposed, this leak provides competitors and researchers with a detailed blueprint of their highly valuable AI architecture, representing a significant loss of intellectual property.


Incident Details

  • What Happened: A JavaScript source map (.js.map) file was included in a public npm package during a routine update.
  • The Error: Source maps are used for debugging minified JavaScript code by mapping it back to the original source. In this case, the source map file was misconfigured to bundle the entire original TypeScript source code within it.
  • Exposure: The package was live on the public npm registry for approximately three hours.
  • Data Leaked: 512,000 lines of code across 1,906 TypeScript files, detailing the complete architecture of the Claude Code agent, including memory management and task orchestration logic.
  • Company Response: Anthropic has described the incident as a "release packaging issue caused by human error." They have been actively issuing DMCA takedown requests to remove cloned repositories from GitHub.

Impact Assessment

This incident is a case study in operational security failures with severe consequences, even without a traditional 'breach'.

  • Intellectual Property Loss: The leak is a massive loss of competitive advantage. Competitors now have a detailed blueprint of Anthropic's proprietary technology, which cost millions to develop.
  • Security Vulnerabilities: The public now has the source code to analyze for vulnerabilities. At least one new flaw in subcommand processing has already been discovered and disclosed from the leaked code.
  • Malicious Scams: Threat actors are already taking advantage of the situation by circulating fake 'source code' archives that are laced with malware, targeting developers eager to examine the leak.
  • Reputational Damage: While not a hack, the incident raises questions about Anthropic's internal software development and release processes.

Lessons Learned

This incident provides critical lessons for all software development organizations, especially those working with proprietary code.

  • CI/CD Pipeline Hardening: Release pipelines must have automated checks to prevent sensitive information from being included in public packages. This should include checks for source maps in production builds, private keys, and other secrets.
  • Source Map Configuration: Developers need to be trained on the proper configuration of source maps. Production builds should either have source maps disabled or configured to not include the original source content (no-sources-source-map).
    • .npmignore and .gitignore: These files must be meticulously maintained to exclude source files, configuration files, and other sensitive data from being packaged and published.
  • Pre-Publish Dry Runs: Implement a mandatory 'dry run' step (npm publish --dry-run) in the release process that allows developers to inspect the exact contents of the package that will be published to the registry.

Mitigation & Recommendations

  1. Automate Release Validation: Integrate automated linters and scanners into the CI/CD pipeline. These tools can be configured to fail a build if they detect source maps in a production artifact or if the package size unexpectedly balloons (which could indicate bundled source code).
  2. Review Build Configurations: Conduct a thorough review of all webpack, rollup, or other bundler configurations to ensure that devtool settings are correctly set for production environments (e.g., 'hidden-source-map' or false).
  3. Developer Training: Regularly train developers on the risks of misconfigured build tools and the importance of sanitizing public releases.
  4. Staging Environments: Use a private or staging npm registry to publish and test packages internally before promoting them to the public registry. This provides a final manual review gate.

Timeline of Events

1
March 31, 2026
Anthropic accidentally publishes the Claude Code source code to the public npm registry.
2
April 5, 2026
This article was published

MITRE ATT&CK Mitigations

Implement secure build and release configurations to prevent sensitive files like source maps from being included in production packages.

Audit

M1047enterprise

Implement automated CI/CD pipeline checks and manual pre-release audits to verify the contents of packages before they are published.

Train developers on secure coding and release management practices, including the risks associated with build tools and package managers.

D3FEND Defensive Countermeasures

The Anthropic leak was a direct result of misconfigured build tools. To prevent this, organizations must harden their CI/CD and build configurations. Specifically for JavaScript/TypeScript projects, this involves setting the 'devtool' property in the webpack configuration to 'false' or 'hidden-source-map' for all production builds. Additionally, the CI/CD pipeline should have an automated 'linting' step that explicitly fails the build if it detects source map files (*.js.map) in the final production artifacts. Another crucial configuration is the .npmignore file, which should be configured to explicitly exclude all source directories (/src), test files, and configuration files, ensuring only the compiled, production-ready code is included in the final package. Automating these configuration checks removes the risk of human error.

Article Author

Jason Gomes

Jason Gomes

• Cybersecurity Practitioner

Cybersecurity professional with over 10 years of specialized experience in security operations, threat intelligence, incident response, and security automation. Expertise spans SOAR/XSOAR orchestration, threat intelligence platforms, SIEM/UEBA analytics, and building cyber fusion centers. Background includes technical enablement, solution architecture for enterprise and government clients, and implementing security automation workflows across IR, TIP, and SOC use cases.

Threat Intelligence & AnalysisSecurity Orchestration (SOAR/XSOAR)Incident Response & Digital ForensicsSecurity Operations Center (SOC)SIEM & Security AnalyticsCyber Fusion & Threat SharingSecurity Automation & IntegrationManaged Detection & Response (MDR)

Tags

AnthropicClaude CodeSource Code LeakData LeaknpmDevSecOpsHuman ErrorAI

📢 Share This Article

Help others stay informed about cybersecurity threats