Source Map Leak in an AI Coding Tool: A Technical Postmortem

    This article reviews a source map leak in an AI coding tool, where a misconfigured build pipeline published a 59.8 MB source map alongside a release. It explains why source maps can reconstruct original source code, what information was exposed, how to classify the risks, and provides practical detection, response, and prevention steps for engineering teams.

    1. Incident Overview: A Configuration Mistake Exposed the Source

    An AI coding tool accidentally shipped source maps with a new release distributed through a public package registry. Because the build pipeline was misconfigured, a source map file of about 59.8 MB was included in the published artifacts. That file mapped the minified entry script back to the original project structure, reconstructing roughly 1,900 source files and about 512,000 lines of TypeScript code. A security researcher disclosed the issue on social media, and mirror repositories attracted significant attention within half an hour.

    This was not an external intrusion but a flaw in the internal release process. Incidents like this share a common pattern: no attacker, no exploit, only files that should have been excluded were uploaded.

    2. How Source Maps Can Reconstruct Source Code

    A source map is essentially a coordinate lookup table. It maps line and column positions in the output back to original file paths, line numbers, and variable names, and often embeds the original content.

    1. {
    2. "version": 3,
    3. "file": "cli.js",
    4. "sources": ["src/engine/QueryEngine.ts"],
    5. "sourcesContent": ["export class QueryEngine { /* original implementation */ }"],
    6. "mappings": "AAAA,CAAC,OAAO..."
    7. }

    As long as sourcesContent is present, reconstruction is deterministic and requires no cracking. Even if that field is stripped, the remaining sources paths and mappings can still reveal directory structure, module boundaries, and code size, which is enough to support further inference.

    3. Exposure Analysis: What Was Actually Leaked

    • Architecture details: module boundaries, dependencies, and the size of core orchestration files (for example, a single file with tens of thousands of lines of “main control logic”) can directly reflect design trade-offs.
    • Capability inventory: the number of built-in tools and the set of shortcut commands expose the product’s capability boundaries.
    • Unreleased clues: internal codenames, background resident logic, and experimental flags are the most sensitive category of information.
    • Roadmap signals: if version codenames and quality metrics are interpreted together, they may affect outside perceptions of product maturity.

    4. Risk Classification: From Compliance to Competition

    1. Intellectual property risk: implementation details can be reused directly, making enforcement and evidence collection difficult.
    2. Security risk: once internal endpoints, debug switches, and trust boundaries become visible, the attack surface expands.
    3. Supply chain risk: exposed dependency lists and version combinations make it easier to match known vulnerabilities.
    4. Reputation and compliance risk: customers may reassess data handling and confidentiality capabilities.

    5. Detection and Response: An Actionable Workflow

    1. # 1) Pull and check whether the release package contains map files
    2. npm pack @scope/pkg --dry-run --json | grep -i "\.map"
    3. # 2) Scan artifacts for sensitive leftovers
    4. find dist -name "*.map" -o -name "*.d.ts" | xargs grep -l "sourcesContent"
    5. # 3) Verify the publish allowlist
    6. jq '.files' package.json

    The recommended response order is: take down the affected version → revoke related credentials and rotate keys → audit access logs → fix the pipeline → document the postmortem. Stop the bleeding first and analyze later to avoid secondary spread.

    6. Prevention: Make Release a Controlled Channel

    • Artifact allowlist: explicitly declare the directories and files allowed for publishing in the packaging configuration, using a default-deny policy.
    • Separate build and release: build machines do not hold release credentials; publishing is performed through a controlled channel.
    • Gate checks: add automated scanning for map files, secrets, and internal domains to the pipeline, blocking the release on any match.
    • Artifact signing and reproducible builds: ensure that production artifacts map one-to-one to source versions.
    • Key governance: centrally manage credentials, keep them short-lived, and grant least privilege.
    • Monitoring and alerting: set threshold alerts for abnormal package registry downloads and mirror spikes to shorten detection time.

    For cloud-based setups, you can combine object storage for build artifacts, container platforms for build jobs, and logging and monitoring services for an audit loop, all using common capabilities without relying on any proprietary interface.

    7. Checklist for Engineering Teams

    1. Before release, ask: does the user need to see this file?
    2. Can you prove in CI with a single command that the artifact contains no source code?
    3. Will credentials leave traces in build logs?
    4. If a leak occurs, who has the authority to take down the version within five minutes?

    Conclusion: source leaks rarely come from sophisticated attacks; most come from overlooked defaults. Writing “exclude by default, allow explicitly, block automatically” into the process is the sustainable defense.