Anatomy of an AI Coding Tool Source Leak and How to Prevent It
A closed-source AI coding CLI shipped with a source map and a misconfigured cloud bucket, exposing hundreds of thousands of lines of TypeScript within hours. This article reconstructs the timeline, explains why source maps and object storage permissions fail, summarizes what the leak revealed about the product, and outlines CI/CD, storage, and review practices to keep proprietary code out of public packages.
Introduction: Closed-source risk in AI coding tools
LLM-driven coding agents are now widely distributed as CLI or IDE products. Vendors often ship them as bundled JavaScript or WebAssembly to protect core algorithms while still offering a convenient client. Small mistakes in the build and release pipeline can still dump the original source. A recent incident in which hundreds of thousands of lines of code were exposed is a reminder for the whole ecosystem.
Timeline: from release to widespread copies
The leak spread in hours from publish to public archives.
1. The leak is shipped (06:36 UTC the same day)
An AI company published v2.1.88 of its flagship coding CLI to a major package registry. The package accidentally included a 59.8MB cli.js.map file. That was not a typical compile artifact: it contained a full original TypeScript source map. Metadata in the file also pointed at an internal object-storage bucket with incorrect access control, so anyone with the direct link could download an unobfuscated source archive.
2. Public disclosure (08:23 UTC the same day)
A well-known security researcher posted the issue on social media with a direct download link. Because of the tool’s visibility, the post quickly reached tens of millions of views.
3. Mirrors and deep analysis
Mirror repositories appeared on several code hosts. The community archived the tree and reverse-engineered the internal architecture.
Technical analysis: why source maps become the insider
The root cause was a build-configuration miss. In modern frontend and Node.js stacks, bundlers (Webpack, Rollup, or fast Rust-based packagers) often emit source maps by default so developers can debug minified production code. For closed-source products shipped to third parties, those files must be excluded.
1. Bundler defaults
The packager generated source maps by default. The team did not turn them off with an explicit flag (for example --sourcemap=false) and did not exclude them in the publish ignore file (for example .npmignore).
2. Bucket permissions
Worse, the artifact hardcoded an internal object-storage path. Object storage is commonly used for static assets and build outputs. The bucket policy was set to public read, so a source archive that should have been private was reachable on the public internet.
3. Recurring process gaps
This was not the first such failure. Months earlier, a CMS misconfiguration leaked next-generation model information; an earlier version had already leaked source via source maps. That points to missing mandatory security gates and automated pre-release review.
What leaked: complexity of a production AI coding platform
Community counts put the dump at 1,906 files and more than 512,000 lines of TypeScript. That undercuts the idea that such tools are thin wrappers around a model API.
The source showed a production-grade platform:
- Permission layer: more than 40 fine-grained tools for file I/O, network requests, and command-execution boundaries.
- Query engine: more than 46,000 lines for data queries and context management.
- Multi-agent coordination: role-based collaboration that splits work across internal execution flows.
- Environment and debug surface: 35 compile-time feature flags, more than 120 unpublished environment variables, and 26 internal slash commands (including ones used for specific tests or a “dream” mode).
Community response and a clean-room rewrite
Reaction was intense. Some developers worried that merely having the leaked tree on disk could create legal risk.
Under that mix of curiosity and pressure, one developer did a clean-room rewrite overnight: no copy of the leaked code, but a Python reimplementation of core behavior from public API behavior and the architecture implied by the leak. The open-source repo gained tens of thousands of stars in hours and became one of the fastest-growing repositories on that host—an illustration of how quickly the community can reverse and reimplement a high-value closed-source tool.
Prevention: defense in depth for build and release
Teams need a layered build and publish process.
1. Security gates in CI/CD
After packaging, automatically scan the output for .map files and other unexpected debug artifacts. On a code-hosting and continuous-delivery service (for example Baidu AI Cloud), a pipeline step can whitelist artifacts with a shell check, halt the release, and alert if sensitive files appear.
2. Tighten object storage and infrastructure access
Keep build artifacts and original source in separate stores. If object storage must host packages, follow least privilege. On Baidu AI Cloud Object Storage (BOS), keep source archives in a private bucket and issue time-limited signed URLs via STS (Security Token Service). Do not set a whole bucket to public read/write.
3. Treat config as code with mandatory review
Put .npmignore, .dockerignore, and bundler config under the same review as application code. Changes should require senior approval so a local mistake cannot roll back or omit global exclusions.
4. Regular red-team and config audits
Periodically scan public assets: package-registry history, object-storage exposure, and similar. Scripts should pull your own published packages, unpack them, and verify contents match intent.
Conclusion
A 512,000-line dump looks like a one-off packager mistake; at a deeper level it is a failure of the security lifecycle under rapid iteration. Closed source is a commercial choice and a test of how well you run the infrastructure. Embedding checks in every build is what actually protects core code.
