When a Source Map Accidentally Exposed an AI Coding Tool’s Source Code

    A packaging mistake bundled source maps into an npm release, revealing access to more than 510,000 lines of TypeScript code. This technical postmortem explains how source maps and public object storage combined to cause the exposure, what was and was not leaked, how the community analyzed the code, and which release-process safeguards can prevent similar incidents.

    1. Incident Overview: A Packaging Mistake Exposed the Source Code

    Recently, the source code of a widely discussed AI coding command-line tool was accidentally exposed. The incident began with a seemingly minor release error: when an updated npm package was published, its source map files (.map) were mistakenly included in the distribution.

    Community developers quickly discovered that the public storage locations recorded in the source maps could be used to download a compressed archive containing the complete, unobfuscated TypeScript source code. The archive included approximately 1,900 TypeScript files and more than 510,000 lines of code.

    The person who discovered the issue posted about it on social media and included a download link. Community members then mirrored the source code to public code-hosting platforms, attracting significant attention and discussion within a short time. The vendor quickly released an updated npm package without the source maps, but by then the mirrored copies had already spread.

    On the surface, this was a release-process failure. However, its technical causes, scope, and the community’s subsequent analysis offer valuable lessons for frontend and Node.js developers.

    2. How Source Maps Can Expose Source Code

    2.1 What Is a Source Map?

    A source map is essentially a “recovery map” for compiled code. In modern frontend and Node.js projects, source code is often written in TypeScript and then compiled, minified, or obfuscated before release. The resulting JavaScript is smaller and more efficient to execute, but it can be difficult to read: function names may be reduced to single characters and comments removed, making production debugging much harder.

    Source maps are designed to solve this debugging problem. They are JSON-formatted mapping files that record the relationship between positions in compiled output and locations in the original source code. A typical structure looks like this:

    1. {
    2. "version": 3,
    3. "sources": ["src/index.ts", "src/utils/parse.ts"],
    4. "sourcesContent": ["Original source code..."],
    5. "names": ["parseInput", "validate"],
    6. "mappings": "AAAA,CAAC..."
    7. }

    Two fields are especially important:

    • sources: A list of relative paths to the original source files.
    • sourcesContent: Some build tools embed the complete source code directly in the map file.

    2.2 Two Paths to the Source Code

    In this incident, the exposure occurred through two related mechanisms.

    First, the source map itself could contain the source code. If the build configuration enabled sourcesContent, anyone who obtained the .map file could use browser developer tools or an open-source source map parser to reconstruct readable TypeScript code.

    Second, the source map exposed a storage location. The paths recorded in the sources field pointed to publicly accessible locations in an object storage bucket used by the development team. Because the bucket allowed public read access, anyone who downloaded the npm package could follow the reference and retrieve the complete compressed source archive.

    This means the incident was not only a source map packaging mistake. It was also compounded by a cloud object-storage permission misconfiguration.

    2.3 Why Were the Source Maps Packaged by Mistake?

    Common causes include:

    • The build cleanup script failed to remove .map files.
    • The npm pack configuration or the files allowlist was too broad and published the entire build directory, including source maps.
    • A debug-oriented build configuration was accidentally used in the release process or CI/CD pipeline.

    3. What Was Exposed—and What Was Not

    One important distinction is that the leaked code belonged to the client-side CLI tool, not to the underlying large language model.

    The exposed material included:

    • The tool’s overall architecture and module organization.
    • Invocation logic and parameter definitions for its built-in toolchain.
    • Supported commands, keyboard shortcuts, and configuration mechanisms.
    • Protocol implementations used to communicate with IDE integrations.
    • Session memory and context-management mechanisms.
    • Traces of features that had not yet been officially released.

    The exposure did not include:

    • Model weights.
    • Training data.
    • Server-side code.
    • Sensitive user information.

    Although client-side code does not contain the core model, its architectural design, prompt organization, and tool-orchestration logic still offer substantial research and reference value. This helps explain why the incident attracted such strong community interest.

    4. Community Follow-Up: From Investigation to Documentation

    After the exposure, community activity developed in three stages:

    1. Rapid mirroring: The source code was quickly copied to public repositories, triggering widespread attention.
    2. Code analysis: Developers examined the source in depth and documented the tool’s overall workflow, including authentication, authorization, tool invocation, and context management.
    3. Documentation: Some contributors turned their findings into structured guides and published them as documentation sites, making it easier for others to understand how an industrial-grade AI coding CLI was organized and implemented.

    This kind of community-led research is an interesting example of open-source dynamics. Once code becomes publicly available—whether intentionally or not—learning, analysis, and knowledge production around it can happen at remarkable speed.

    5. Engineering Lessons: How to Prevent Similar Incidents

    5.1 Inspect Release Artifacts Before Publishing

    Add an artifact review step to the release process. For example:

    1. # Inspect the contents of the package to be published
    2. npm pack --dry-run
    3. # Remove sensitive files
    4. find ./dist -name "*.map" -delete

    5.2 Use a Strict npm Package Allowlist

    In package.json, explicitly declare the files field and publish only the runtime files that are required. This is safer than relying on a blacklist to exclude unwanted files.

    5.3 Audit Object Storage Permissions

    Object storage, logging services, and similar cloud resources should follow the principle of least privilege:

    • Keep resources private by default.
    • Grant access only when necessary.
    • Regularly audit publicly readable buckets and objects.

    Build artifacts from production environments should not be stored in publicly accessible buckets.

    5.4 Make Release Checks CI/CD Gates

    Add automated checks to the pipeline to scan release artifacts for:

    • .map files.
    • .env files.
    • Embedded secrets or credential-like strings.
    • Other sensitive content.

    If a problem is detected, the pipeline should block the release automatically.

    5.5 Design for Defense in Depth Under a “Assume Exposure” Model

    For client-side tools, security boundaries should be designed with the assumption that client code will eventually become public. This means:

    • Do not ship secrets to the client.
    • Perform complete authentication and authorization on the server.
    • Keep sensitive logic out of client-side execution whenever possible.

    In this incident, the exposed material consisted of client-side logic and did not include model or server-side data. To some extent, that reflects the value of this design principle.

    6. Conclusion

    This accidental “open-source release” is a typical modern software supply-chain security incident. A seemingly insignificant source map, combined with a publicly readable object-storage location, was enough to expose more than 510,000 lines of code.

    For development teams, the incident demonstrates why every stage of the release process should be subject to automated auditing. For developers, it provides an unusual opportunity to examine the internal implementation of an industrial-grade AI coding tool.

    Security is not something to address only after an incident. It begins by designing systems around the assumption that anything capable of going wrong eventually will.