Source Map Leak in an AI Coding CLI: What Was Exposed and How to Prevent It
This article analyzes a source map leak in a mainstream AI coding CLI, where a published package shipped complete .map files that made the original TypeScript source directly recoverable. It explains why the presence of sourcesContent turns a build artifact into readable source without any reverse engineering, what the exposure did and did not include, and which engineering choices the artifact revealed. It closes with a practical remediation checklist for release pipelines and a cloud-based approach to keeping debugging assets internal.
1. What Happened: A Non-Intrusion Source Exposure
Security researchers recently found that a mainstream AI coding tool (referred to below as “the CLI”) had shipped complete source map files inside its published package artifacts, making the original front-end TypeScript source directly recoverable. The news spread within hours, and community members quickly assembled mirrored repositories that drew significant attention.
Notably, this was not an intrusion. There was no exploit, no privilege escalation, and no data exfiltration. The release process simply bundled the debugging mapping files along with the package. Incidents of this type share a distinct profile: the barrier to entry is extremely low, the scope of impact is clear, the fix costs almost nothing, yet the amount of information exposed is enormous.
This class of problem is not new to the industry. An earlier version of the same tool had a nearly identical incident that was subsequently fixed, and a recent release reintroduced source maps into the artifacts after a build configuration change. Comparing adjacent versions confirms this: the previous version’s artifact was “clean,” which further indicates the problem came from an unintended change in build parameters or the packaging process rather than a security flaw in the codebase itself.
2. Why a Source Map Equals Direct Source Output
Modern front-end and Node/Bun ecosystems typically go through three steps: compile, bundle, and minify. Artifacts shrink from several MB to a few hundred KB, but stack traces become unreadable. Source maps exist to solve that debuggability problem. A source map is a JSON document built around two corresponding arrays:
{"version": 3,"sources": ["src/tools/file-read.ts", "src/tools/bash.ts"],"sourcesContent": ["<full original source string>", "<full original source string>"],"mappings": "AAAA,CAAC,KAAK,..."}
sources: the original file paths, which effectively publishes the directory structure as well;sourcesContent: an optional field that is frequently enabled in production builds, embedding the complete source inline;mappings: the encoded mapping from minified positions back to original positions, used to restore breakpoints and stack traces.
The key conclusion: as long as sourcesContent is present, recovery requires no decompilation, no de-obfuscation, and no reverse engineering technique at all. A script of a dozen lines that walks the JSON is enough to export everything. This is why the security community treats such incidents as configuration accidents rather than attack-and-defense contests.
The package size tells the same story: the artifact grew from roughly 17MB to 31MB, and the difference is a .map file tens of MB in size. Abnormal growth in package size is itself the cheapest and most effective early warning signal.
3. Exposure Assessment: What Was Leaked and What Was Not
Community analysis indicates the recovered code spans roughly 1,900 source files and more than 500,000 lines, essentially covering the CLI’s complete implementation. Broken down by risk:
| Layer | Exposed | Notes |
|---|---|---|
| Model weights, training data | No | Not present in client artifacts |
| End-user data | No | No server-side storage involved |
| Internal architecture and implementation details | Yes | Directory structure, module layout, naming conventions |
| Security control logic | Yes | Permission checks, input validation, audit instrumentation |
| Unreleased feature clues | Yes | Hidden commands, experiment flags, internal tooling |
For ordinary users, the direct security impact is limited. The real cost falls on the engineering team: the attack surface has been made visible. Once permission decision logic, allowlist implementations, and command execution boundaries are public, any subsequent bypass attempt can be designed directly against the code. Exposure of command names and flags for unreleased features also disrupts product timing.
4. Engineering Choices Worth Noting in the Artifact
Setting the incident aside, the artifact offers considerable reference value for engineering practice.
1) Runtime and terminal UI combination. The tool uses Bun as its runtime, builds its terminal interface on a React-based rendering abstraction (UI described as a component tree, then rendered to a terminal character stream), parses command-line arguments with a mature command parsing library, validates structure with a schema validation library that infers types, embeds a high-performance search binary, and integrates a standard protocol SDK, a telemetry specification, and a remote feature flag service.
The value of writing a CLI with declarative UI is that interaction states (loading, streaming output, multi-step confirmation) can be expressed as components and state machines, avoiding large amounts of hand-written cursor control and ANSI escape concatenation. The cost is that the rendering layer needs extra adaptation and fallback handling for terminal capabilities such as line wrapping, width, color, and mouse events.
An illustrative component structure:
function ConfirmPanel({ step, onConfirm, onCancel }: Props) {const [busy, setBusy] = useState(false);return (<Box flexDirection="column" borderStyle="round"><Text>Step {step}/3, continue?</Text>{busy ? <Spinner label="Running" /> : <Text>(y/n)</Text>}<Button onClick={async () => { setBusy(true); await onConfirm(); setBusy(false); }} /></Box>);}
2) Tool registration system. The code contains about 39 tool implementations covering command execution, file reads and writes, path matching, content search, sub-agent dispatch, web fetching and retrieval, external protocol tool integration, skill loading, and task management. Unified registration plus unified schema validation plus unified permission checks is the key abstraction that keeps “model capabilities” under control:
interface Tool<Input> {name: string;schema: Schema<Input>; // input validationrequiresApproval?: (i: Input) => boolean; // permission decisionrun(i: Input, ctx: Ctx): Promise<ToolResult>;}
3) Commands and observability. Dozens of slash commands cover diagnostics, diff viewing, cost accounting, and cross-device bridging, including a small number of internal experimental commands. Diagnostic commands (checking the environment, dependencies, configuration) and cost commands (per-session usage statistics) are low-cost, high-return designs for improving operability.
5. Remediation Checklist for Engineering Teams
- Pre-release artifact audit. Add an artifact allowlist check in CI that explicitly rejects
.mapfiles,.d.tsfiles, test fixtures, and internal documentation from the release package. - Codify build parameters. Put switches such as
sourcemap,inlineSources, anddeclarationinto version-controlled build configuration, and assert their values in the pipeline so that “a local change that got carried into the main branch” cannot happen. - Two-stage builds. Keep full mappings in development builds; disable mappings in release builds and archive them separately to an internal artifact store for production stack trace recovery (recovery happens server-side and is never shipped out).
- Size baseline gate. Set a threshold on artifact size and block the release with an alert when it exceeds the baseline by a given percentage. This class of incident usually shows up as a size anomaly first.
- Reproducible artifact verification. Rebuild the same commit repeatedly and compare digests; any difference must be explainable. Also scan public repositories periodically for your own artifacts using an automated script.
- Secret and internal information scanning. Run credential scanning on both the codebase and the artifacts to prevent internal domains, intranet addresses, and experiment flag names from leaking with the source.
- Move permission decisions forward. Use default-deny plus explicit allow for high-risk operations, and never let permission logic depend on the assumption that “users cannot see it.”
6. Building a Compliant Release and Protection Chain in the Cloud
If the development pipeline runs in the cloud, a closed loop can be assembled from general-purpose capabilities: use a container platform to run build jobs with consistent environments; use object storage to hold “public artifacts” and “internal mapping files” separately, with least-privilege access policies; use a message queue to decouple the build, scan, and release stages; use log and monitoring services to set threshold alerts on artifact size, scan hit rate, and release failure rate; use a key management service to hold signing keys and credentials; and use access controls in the artifact repository to separate internal from public visibility. The core principle is a single one: keep debuggability resources internal, and publish only the minimum necessary artifacts.
7. Closing Thoughts
This incident was not technically sophisticated, but it is highly instructive: security boundaries are often not breached but handed away by one “convenient” packaging step. Treating build configuration as security configuration, folding artifact audits into release gates, and managing mapping files as controlled assets rather than temporary debugging files eliminates this entire class of risk at very low cost. For users of AI coding tools, the same question is worth asking: what exactly is bundled inside the artifacts of the tool you are using?
