Source Map Leak in an AI Coding Tool: How a Build Artifact Exposed the Source Code
An accidentally published source map exposed more than 1,900 TypeScript files from an AI coding tool, revealing its architecture, security controls, unreleased features, and internal roadmap details. This article explains how embedded source content enabled the disclosure and outlines build, audit, release, and monitoring practices that can help prevent similar incidents.
1. Incident Overview: Accidental Disclosure, Not a Hack
This was not an April Fools’ joke, but a real security incident.
An AI company accidentally included a source map of approximately 60 MB in the official package for its coding tool, published to a public package registry. That single build artifact allowed more than 1,900 source files—roughly 510,000 lines of TypeScript—to be recovered and made public.
The incident did not result from a hacker breaking into the company’s systems. It stemmed from a configuration oversight in the internal build pipeline: a source map intended for internal debugging was bundled into the public release.
After a security researcher disclosed the issue on social media, a repository containing a copy of the code gained thousands of stars within half an hour. Developers worldwide could inspect the tool’s internal architecture.
2. Why Source Maps Can Expose Source Code
Source maps are often treated as simple lookup tables that connect generated code to its original source. However, they can also contain the original source code itself. A typical structure looks like this:
{"version": 3,"sources": ["src/core/QueryEngine.ts", "src/tools/bash.ts"],"sourcesContent": ["// Complete original source code goes here..."],"mappings": "AAAA,CAAC..."}
The critical field is sourcesContent, which can store the full contents of the original files. When a published artifact includes a source map with this embedded content, browser developer tools or open-source extraction scripts can recover readable TypeScript source, rather than merely display the minified or obfuscated output.
In modern frontend workflows, source maps are often uploaded to internal error-monitoring systems instead of being distributed with release artifacts. If a packaging script accidentally includes .map files in the release, it can effectively publish the source code.
The approximately 60 MB mapping file in this incident was a direct consequence of that configuration mistake.
3. What the Exposed Code Revealed
From an engineering perspective, the disclosure revealed much more than readable source files.
Architecture and Core Modules
Approximately 1,900 TypeScript files and 510,000 lines of code suggest an engineering footprint approaching that of a large IDE.
The codebase included a core engine file exceeding 40,000 lines. It contained key logic for the main conversation loop, tool dispatch, and context management, reflecting a “monolithic core with tool plugins” architecture.
Feature Implementation and Security Controls
The implementation of nearly 40 built-in tools and about 50 slash commands was exposed. These included details of how command-line tools handled sandbox isolation, permission checks, and filesystem access controls—all important areas of security design for AI coding tools.
Unreleased Features
The code also contained several previously undisclosed modules:
- A background daemon designed to persist over time, with support for memory consolidation during idle periods.
- A mode that automatically removed AI-related traces from commit history and could not be manually disabled.
- An embedded virtual pet system.
These discoveries prompted discussion about product transparency and users’ right to understand the software they use. In particular, a trace-removal feature that was enabled by default and could not be disabled raised security and compliance questions.
Internal Roadmap Information
The disclosure also exposed internal model codenames and some testing metrics. Such information is commercially sensitive, and its exposure could have consequences greater than those of the source code leak itself.
4. How Teams Can Prevent Similar Incidents
The incident highlights the need for controls at four levels: builds, auditing, development processes, and monitoring.
Build Controls: Separate Debugging Artifacts from Release Artifacts
Source maps intended for internal use should be uploaded only to internal error-monitoring systems. Release scripts should explicitly exclude *.map files.
CI pipelines should also flag artifacts that exceed expected size thresholds. A source map measuring tens of megabytes should trigger a review before publication.
# Example: check release artifacts for source maps before publishingif find dist -name "*.map" | grep -q .; thenecho "ERROR: source map detected in release artifacts"exit 1fi
Auditing: Maintain an Artifact Inventory
Every public release should have a file inventory and an artifact-size baseline. Changes that depart from that baseline should require manual approval.
Teams should also periodically scan previously published versions. Otherwise, an older package may continue exposing sensitive information long after its release.
Development Processes: Keep Sensitive Information Out of Client Code
Internal codenames, roadmap comments, and feature-switch logic for unreleased functionality should not appear in final release artifacts.
Feature flags should be delivered through server-side configuration rather than hardcoded into client-side code. Teams should minimize the sensitive information that enters code distributed to users.
Monitoring: Track Public Disclosure and Distribution
In this incident, only half an hour passed between the initial disclosure and the rapid growth of a repository containing the code.
Companies need a rapid response process that includes publishing an emergency release without the sensitive files, assessing the scope of the exposure, and, where necessary, using platform complaint channels to address repositories distributing copies.
5. The Broader Lesson: Release Artifacts Need Security Governance
This accidental disclosure was fundamentally a software supply chain governance failure, not a breach caused by an attacker.
As AI coding tools and AI agent products increasingly ship as JavaScript and TypeScript packages, engineering conveniences such as source maps, debugging symbols, and comments can become channels for unintended disclosure.
For companies that depend on protecting intellectual property, automated auditing of release contents is no longer optional. Knowing exactly what a published package contains must be part of the release process.
For developers, the lesson is equally clear: every line of code and every internal codename may become visible somewhere unexpected. Secure-by-default behavior should be a design principle for every build pipeline.
