Source Code Leak in an AI Coding Tool: A Technical Post-Mortem
This article reviews a source code leak in an AI coding tool, where a Source Map v3 file shipped in the installer exposed roughly 33 MB of unminified TypeScript across more than 1,900 files. It breaks down the leaked tech stack, the multi-agent orchestration module, internal codenames, and the declarative permission model, then classifies the risks and outlines a governance checklist covering build-pipeline gates, secret externalization, artifact traceability, least privilege, isolated execution, and incident response.
1. What Happened: The Cost of a Build Configuration Gap
After one release of an AI coding tool’s terminal version, developers found a complete source map file inside the installer package. Under the Source Map v3 specification, the sourcesContent field inlines the original TypeScript text. As a result, more than 1,900 TS/TSX files—roughly 33 MB of unminified code—were fully reconstructed, from the tool’s permission checks to sub-agent scheduling, from internal project codenames to experimental interaction modules. Everything was readable. Mirror repositories gained over a thousand stars and nearly two thousand forks within hours, and the vendor rolled back the version number, repeating the same “emergency package withdrawal” path it had taken before.
Notably, the same class of issue had appeared a year earlier. Back then, shortly after the tool launched as a research preview, someone found the same kind of mapping file in its dependency directory. The vendor’s response was to delete the maps and pull historical versions. The version number moved from early iterations to 2.1.x and the feature set multiplied, but the rule “never emit maps” in the build pipeline was never enforced as a mandatory gate. This shows that source code leaks are usually not the result of an attack but an inevitable product of missing engineering discipline.
2. Technical Breakdown of the Leaked Content
2.1 Tech Stack and Code Volume
The implementation layer uses a common combination: a high-performance JavaScript runtime hosts the CLI process, a terminal rendering framework builds the interactive interface (a React/Ink-style approach), the official SDK handles model calls with manually managed streaming responses, and Zod v4 provides runtime type validation across the entire chain. In terms of scale, the largest single file is about 875 KB (the REPL entry point), the tool interface definition has 47 fields, and the permission decision pipeline contains more than a dozen checkpoints. These numbers explain why “bundle size optimization” and “source code secrecy” are naturally in conflict: the entry file couples all state, rendering, and event handling together, which makes compression difficult and makes the whole thing easier to reconstruct.
2.2 Multi-Agent Orchestration Module
The newly added coordinator module is a pure orchestration role that exposes only four tools: create agent, send message, stop task, and subscribe to events. It does no concrete work itself and only dispatches. Its core decision is “reuse or create new,” based on context overlap: high overlap means continuing to reuse an existing agent to save the context budget, while low overlap means spawning a new agent to isolate noise. This is a typical context cost management strategy that trades scheduling for token efficiency.
2.3 Internal Codenames and Dead Code Elimination
The assistant module carries internal codenames that were never made public, controlled by a large number of feature flags. The flags are evaluated at bundle time, and branches that return false are completely removed by dead code elimination, so these implementations are not visible in the external artifact—but they still leaked along with the source map. This points to a counterintuitive conclusion: compile-time trimming can only protect the artifact, not the source code; the real boundary is the artifact repository and the release pipeline.
2.4 Voice, Plugins, and the Skills System
The voice module had previously only been described in documentation, and its implementation details were a black box; this time they were fully exposed. The plugin and skills system uses skill definitions with metadata, declaring the available tool allowlist, reasoning effort, model selection, and path-based activation conditions via frontmatter, for example:
---name: db-migrationallowed-tools: [Read, Write, Bash]effort: highmodel: inheritpaths: ["migrations/**"]---
This “declarative capability authorization” narrows permissions down to file granularity, which is a design worth learning from—but only on the premise that the declarations cannot be bypassed.
3. Risk Classification: What Is Actually Dangerous
- High: hard-coded credentials, internal service addresses, private API contracts, and hidden switches that bypass permission checks;
- Medium: permission decision ordering, prompt templates, evaluation sets, and internal codenames, which make targeted bypasses easier once leaked;
- Low: directory structure, dependency manifests, and UI copy.
Most teams focus only on the first category, but the second poses greater long-term harm: attackers can use it to craft “legitimate path” inputs that make the tool perform unauthorized actions within its authorized scope.
4. Governance Checklist
- Mandatory pipeline gates: forbid map files in artifacts, automatically scan after the build and assert that
sourcesContentis empty, and run a “source code fingerprint comparison” before release. - Secret externalization: inject credentials only from a secrets management service or the environment, keep zero retention in the repository and artifacts, and configure rotation.
- Artifact traceability: retain a hash and signature for each release, and have consumers verify origin and integrity to avoid replacement of the dependency directory.
- Least privilege: tool allowlists, path allowlists, secondary confirmation for dangerous commands, and decision logs wired into logging services and monitoring alerts.
- Isolated cloud execution: place high-risk execution in a one-off sandbox on a container platform, archive artifacts to object storage, and deny network egress by default.
- Drills and response: prepare a three-stage plan for package withdrawal, version rollback, and credential revocation to shorten the exposure window.
5. Conclusion
A source code leak is essentially a supply chain hygiene problem. Making “do not emit, do not retain, stay traceable, stay revocable” a hard constraint of the pipeline is more effective than deleting packages after the fact. For consumers, choosing an AI coding tool with a clear permission model, auditable logs, and isolated execution is the way to hold both efficiency and risk in hand.
