Anthropic, a company known for developing AI technologies, recently found itself embroiled in a significant mishap involving the accidental exposure of the entire source code for its popular AI coding tool, Claude Code. The exposure occurred due to a misconfiguration in the npm package of Claude Code, which inadvertently included a map file. This inclusion led to the revelation of a link to an unobfuscated TypeScript source code in a zip archive hosted on Anthropic’s Cloudflare R2 storage bucket. Security researcher Chaofan Shou discovered the leak and alerted the public. Consequently, the source code was copied into a GitHub repository and forked over 41,500 times, spreading rapidly across the internet.
The leak exposed around 1,900 TypeScript files totaling over 512,000 lines of code, which included extensive libraries and built-in tools. Despite the comprehensive nature of the leak, it’s noteworthy to mention that Claude Code’s internals were not entirely unknown prior to this incident. Elements of Claude Code have been reverse-engineered in the past, with findings shared publicly on dedicated websites. Therefore, while the leaked source code provides an updated view and useful comparison point for those following Claude Code’s development, it does not reveal previously unknown aspects of the tool.
The inclusion of a map file in the npm package, which is typically used for debugging purposes and considered unnecessary and risky for production builds, turned out to be the root cause of the exposure. This industry practice is generally discouraged as it can lead to revealing connections back to original source codes if not properly configured. Gabriel Anhaia, a software engineer analyzing the leak, emphasized this incident as a cautionary tale urging developers to meticulously review their build pipelines to prevent similar mistakes. He pointed out how neglecting settings in .npmignore or the files field in package.json could inadvertently lead to major exposures.
In response to the breach, Anthropic stated that the inclusion of the source code in the software release was due to human error, asserting that it was not a breach of security per se. They assured that no customer data or credentials were compromised during the incident. The company also informed that they were implementing measures to avoid similar incidents in the future.
The original individual who uploaded the Claude Code source to GitHub later altered the repository’s content. He replaced the exposed source code with a Python feature port of Claude Code, indicating his concerns about potential legal repercussions for hosting copyrighted material. Despite this change, numerous forks and mirrors of the original upload remain available, allowing interested parties to explore the leaked source.
Anthropic has not publicly expressed intentions to request the removal of these repositories containing its exposed source code from the internet. This incident underscores the challenges and potential pitfalls associated with managing and securing intellectual property in the digital age, particularly when it involves popular and widely-used software tools in tech-savvy communities. Through this episode, the tech community is reminded of the importance of vigilance and precision in software development and distribution processes.
Read the full post on theregister.com


