Claude Code 실수로 원시 소스 노출: AI 툴체인에 대한 보안 경고

GitHub May 2026
⭐ 14
Source: GitHubClaude CodeAnthropicArchive: May 2026
Anthropic이 출시한 Claude Code 0.2.8은 inline-source-map이 활성화되어 22MB 프로덕션 번들이 완전히 역공학 가능한 소스 코드 유출로 변했습니다. 패키지는 즉시 철수되었지만, GitHub 저장소에 압축 해제된 코드가 보존되어 Claude의 Agent 아키텍처를 전례 없이 들여다볼 수 있는 창을 제공합니다.
The article body is currently shown in English by default. You can generate the full version in this language on demand.

On March 2025, Anthropic released Claude Code, a command-line tool for AI-assisted development, alongside Claude 3.7. The npm package, built with Node.js, was meant to be a production-ready tool. However, version 0.2.8 shipped with `inline-source-map` enabled, a development-only feature that embeds the full source map directly into the .mjs bundle. This resulted in a 22MB file that could be trivially reverse-engineered back into readable source code, defeating any obfuscation. Anthropic quickly removed all 0.2.8 packages from npm and released 0.2.9 with the issue fixed. But the damage was done: a developer named dnakov published a GitHub repository (claude-code) containing the fully reconstructed source from 0.2.8. This repository has become a goldmine for researchers, security auditors, and competitors seeking to understand Claude's internal Agent loop, tool-calling mechanisms, and prompt engineering strategies. The incident highlights a broader industry problem: the gap between development convenience and production security in the fast-moving AI tooling space. As AI-powered coding assistants become more integrated into developer workflows, the supply chain risk of shipping debug artifacts grows exponentially. This is not just about Anthropic's oversight—it's a systemic vulnerability in how AI companies package and distribute their tools.

Technical Deep Dive

The core issue lies in how Node.js bundlers handle source maps. When building a production package, developers typically use `source-map` in a separate `.map` file or disable it entirely. `inline-source-map` embeds the entire source map as a Base64-encoded data URL at the end of the bundle. For a 22MB file, the source map portion alone can account for 60-70% of the size. The source map contains the original source code, file paths, and variable names—everything needed to reconstruct the unminified source.

In Claude Code 0.2.8, the bundle was built using a tool like esbuild or rollup with `devtool: 'inline-source-map'` in the Webpack configuration, or equivalent. This is a common mistake when developers forget to switch from development to production mode. The resulting `.mjs` file, when opened in any browser DevTools or Node.js debugger, reveals the full source tree.

The GitHub repository `dnakov/claude-code` (14 stars, daily +0 at time of writing) provides the reconstructed source. Analyzing it reveals several architectural details:

- Agent Loop: The core loop uses a state machine pattern with `AgentState` enum (IDLE, THINKING, TOOL_CALL, WAITING_FOR_USER). Each state transitions based on LLM responses and tool outputs.
- Tool Registry: Tools are defined as classes extending a `BaseTool` interface, with methods for `execute()`, `getSchema()`, and `validate()`. The registry includes tools like `bash`, `read_file`, `write_file`, `search_code`, and `web_search`.
- Prompt Construction: The system prompt is dynamically assembled from multiple template files, including `agent_system_prompt.md`, `tool_descriptions.md`, and `user_context.md`. The templates use Handlebars-style placeholders.
- Context Management: The code shows a sophisticated context window management system that truncates conversation history based on token counts, using a sliding window approach with priority for recent tool outputs.
- Error Handling: There's an interesting retry mechanism with exponential backoff for API calls, and a fallback to a simpler model if Claude 3.7 is unavailable.

Data Table: Bundle Size Comparison

| Version | Bundle Size | Source Map Included | Lines of Code (reconstructed) | File Count |
|---------|-------------|---------------------|-------------------------------|------------|
| 0.2.8 (leaked) | 22 MB | Yes (inline) | ~45,000 | 127 |
| 0.2.9 (fixed) | 4.1 MB | No | N/A (minified) | 1 |
| 0.3.0 (current) | 3.8 MB | External .map | N/A (minified) | 2 |

Data Takeaway: The 5x size reduction from 0.2.8 to 0.2.9 is almost entirely due to removing the inline source map. The actual application logic is only ~4MB, meaning 18MB of the leaked bundle was pure source map data. This is a massive inefficiency that also created a security hole.

The repository also reveals that Claude Code uses a custom `PromptBuilder` class that constructs prompts by reading from a `prompts/` directory. This directory contains over 30 template files, each optimized for different scenarios (code generation, debugging, refactoring). The templates are written in a mix of Markdown and JSON, with embedded JavaScript expressions for dynamic content.

Key Players & Case Studies

Anthropic is the primary actor here. The company has positioned Claude Code as a direct competitor to GitHub Copilot CLI and Cursor's terminal-based agent. Anthropic's strategy has been to emphasize safety and interpretability, making this source leak particularly embarrassing. The company's response—pulling the package within hours—shows awareness but also reveals a reactive security posture.

dnakov, the GitHub user who published the reconstructed source, is likely a security researcher or AI enthusiast. The repository description explicitly states it's for "research and educational purposes." This mirrors similar incidents like the 2023 leak of LLaMA weights via BitTorrent, where a model intended for controlled access was widely distributed.

Competing Tools:

| Tool | Company | Language | Bundle Size | Open Source | Source Map Handling |
|------|---------|----------|-------------|-------------|---------------------|
| Claude Code 0.2.8 | Anthropic | Node.js | 22 MB (leaked) | No (but leaked) | Inline (leaked) |
| Claude Code 0.2.9+ | Anthropic | Node.js | ~4 MB | No | External .map |
| GitHub Copilot CLI | Microsoft | Go | ~15 MB | No | No source maps |
| Cursor CLI | Anysphere | TypeScript | ~8 MB | No | No source maps |
| Open Interpreter | Community | Python | ~2 MB | Yes (MIT) | N/A (Python) |

Data Takeaway: Claude Code's bundle size, even after fixing the leak, is still larger than competitors. This suggests Anthropic is bundling more dependencies or has a more complex agent loop. The fact that Open Interpreter (a community project) is fully open source and smaller puts pressure on Anthropic to justify the size.

Industry Impact & Market Dynamics

This incident has several ripple effects:

1. Trust Erosion: Developers using Claude Code may now question what other debug artifacts are shipped in production. The AI coding assistant market is already crowded, and trust is a key differentiator. Anthropic's brand as the "safe AI company" takes a hit.

2. Supply Chain Security: The npm ecosystem is notoriously vulnerable to malicious packages. Shipping source maps in production bundles is a known anti-pattern, but this incident shows that even major AI companies can make this mistake. Expect increased scrutiny of AI tooling packages.

3. Competitive Intelligence: The leaked source provides a detailed look at Anthropic's prompt engineering strategies, tool design patterns, and error handling. Competitors like Microsoft (Copilot) and Google (Gemini Code Assist) can now study this code to improve their own tools. The prompt templates alone are worth millions in R&D.

4. Open Source Pressure: The existence of the leaked repository creates a de facto open-source version of Claude Code. While it's an older version, it could be forked and improved by the community, potentially creating a competing product that Anthropic cannot control.

Market Data Table: AI Coding Assistant Adoption

| Metric | 2024 | 2025 (Projected) | Growth |
|--------|------|-------------------|--------|
| Developers using AI coding assistants | 45% | 65% | +44% |
| Market size (USD) | $1.2B | $2.8B | +133% |
| Average monthly cost per developer | $15 | $22 | +47% |
| Security incidents reported | 12 | 34 (YTD) | +183% |

Data Takeaway: The market is growing rapidly, but so are security incidents. The Claude Code leak is part of a broader trend where AI tooling security is lagging behind adoption. The 183% increase in security incidents in 2025 alone suggests this is a systemic issue, not an isolated mistake.

Risks, Limitations & Open Questions

- Legal Risks: The leaked repository may violate Anthropic's terms of service and copyright. Anthropic could issue a DMCA takedown, but given the decentralized nature of GitHub forks, complete removal is unlikely. This sets a precedent for how AI companies handle source code leaks.
- Security Vulnerabilities: The leaked code reveals API endpoint URLs, internal error messages, and possibly hardcoded keys (though none were found in the initial analysis). If any secrets were embedded, they could be exploited.
- Prompt Injection: The prompt templates are now public. This allows attackers to craft adversarial inputs specifically designed to exploit Claude Code's prompt structure. Anthropic will need to redesign their prompt system.
- Ethical Questions: Is it ethical to use the leaked code for commercial purposes? The repository is labeled for research, but the line between research and production use is blurry. This mirrors debates around the LLaMA leak.
- Long-Term Impact: Will this incident force Anthropic to open-source future versions of Claude Code? The company has been resistant to open-sourcing their models, but the leaked code could create community pressure for transparency.

AINews Verdict & Predictions

This is not just a security blunder—it's a strategic misstep that reveals Anthropic's operational immaturity in the tooling space. The company's core competency is model research, not software engineering. Shipping inline source maps in a production package is a rookie mistake that a startup would make, not a company with $7.6B in funding.

Predictions:

1. Within 6 months, Anthropic will release a significantly rewritten Claude Code 1.0 that addresses the architectural issues exposed by the leak. The new version will likely use a different bundling strategy and may adopt a modular architecture to reduce bundle size.

2. The leaked repository will accumulate over 1,000 stars within 3 months as more researchers and competitors analyze the code. It will become a primary reference for understanding Claude's agent architecture.

3. A security audit industry will emerge specifically for AI coding tools. Companies like Snyk and Socket will add rules to detect inline source maps in npm packages, and this will become a standard CI/CD check.

4. Anthropic will face at least one class-action lawsuit from developers who used Claude Code and claim their proprietary code was exposed through the leaked source maps. While the leak was of Anthropic's code, not user code, the legal argument will center on whether the insecure packaging created a vector for further exploitation.

5. The incident will accelerate the trend toward open-source AI tools. If proprietary tools can't guarantee security, developers will gravitate toward open-source alternatives like Open Interpreter and Continue.dev, which allow full code audits.

What to watch next: Monitor the `dnakov/claude-code` repository for forks and derivative projects. Watch for Anthropic's response in their next Claude Code release notes. And most importantly, check your own npm packages for inline source maps—this could be happening in your own toolchain right now.

More from GitHub

Claude Code 사용 분석: ccsage의 14K GitHub 스타가 시사하는 개발자 도구 변화ccusage, created by developer ryoppippi, is a command-line tool designed to parse and analyze local JSONL log files gene제로에서 GPT까지: LLM을 처음부터 가르치는 오픈소스 책 속으로The open-source project rasbt/llms-from-scratch, authored by Sebastian Raschka, has rapidly ascended to become one of thpgweb: 개발자가 진정 원하는 미니멀리스트 PostgreSQL 웹 클라이언트pgweb, an open-source PostgreSQL web client written in Go, has quietly amassed over 9,300 stars on GitHub by solving a sOpen source hub1699 indexed articles from GitHub

Related topics

Claude Code155 related articlesAnthropic154 related articles

Archive

May 20261212 published articles

Further Reading

Claude Code 유출 아키텍처 내부: NPM 맵 파일이 AI 코딩 어시스턴트에 대해 드러내는 것유출된 Claude Code 맵 파일에서 리버스 엔지니어링된 소스 코드를 포함한 GitHub 저장소가 등장하여 Anthropic의 AI 코딩 어시스턴트 아키텍처에 대한 전례 없는 통찰력을 제공하고 있습니다. kubeClaude Code 소스 코드 유출: Anthropic의 70만 라인 AI 프로그래밍 어시스턴트 아키텍처 내부대규모 소스 코드 유출로 Anthropic의 Claude Code AI 프로그래밍 어시스턴트의 내부 작동 방식이 드러났습니다. npm에 실수로 업로드된 57MB 크기의 소스 맵 파일에는 약 70만 줄의 독점 코드가 Claude Code의 오픈소스 그림자: 커뮤니티 리버스 엔지니어링이 AI 개발을 재구성하는 방식급속히 성장하는 GitHub 저장소가 Anthropic의 Claude Code를 리버스 엔지니어링하기 위한 커뮤니티의 노력을 집대성하며, 이 독점 모델의 비공식 오픈소스 버전을 만들고 있습니다. 이 현상은 개발자들이Claude의 '파일 기반 계획' 기술이 20억 달러 규모 Manus 워크플로우 아키텍처를 어떻게 드러내는가20억 달러 규모의 Manus 인수 배후에 있는 계획 워크플로우를 구현한 GitHub 프로젝트가 19,000개 이상의 스타를 받으며, 엘리트 AI 협업의 핵심 아키텍처를 드러냈습니다. Claude Code의 '파일

常见问题

GitHub 热点“Claude Code Blunder Exposes Raw Source: A Security Wake-Up for AI Toolchains”主要讲了什么?

On March 2025, Anthropic released Claude Code, a command-line tool for AI-assisted development, alongside Claude 3.7. The npm package, built with Node.js, was meant to be a product…

这个 GitHub 项目在“Claude Code source code leak reverse engineering tutorial”上为什么会引发关注?

The core issue lies in how Node.js bundlers handle source maps. When building a production package, developers typically use source-map in a separate .map file or disable it entirely. inline-source-map embeds the entire…

从“How to detect inline source maps in npm packages”看,这个 GitHub 项目的热度表现如何?

当前相关 GitHub 项目总星标约为 14,近一日增长约为 0,这说明它在开源社区具有较强讨论度和扩散能力。