Toutes les vulnérabilités
HIGHAI/LLM

AI-CLAUDECODE-SOURCEMAP-2026

npm · @anthropic-ai/claude-code

Résumé

On March 31, 2026, Anthropic accidentally shipped the full source of its Claude Code CLI inside a published npm package. A missing .npmignore rule for *.map left a roughly 59.8 MB source map in the tarball, embedding about 512,000 lines of unobfuscated TypeScript across some 1,900 files, including internal prompts, tool definitions and architecture. The root cause was a packaging failure compounded by a bundler bug: Bun continued emitting source maps even when generation was disabled, and nothing stripped or excluded them before publish. Because npm releases are immutable and mirrored instantly, the source was cloned, dissected and re-hosted within hours, and a clean-room reimplementation reached tens of thousands of GitHub stars the same day. It is a textbook source-map disclosure: the sourcesContent field of a .map file carries the original code verbatim, so a single map left in a shipped artifact hands an attacker the entire codebase, comments and all. The same class hit Apple's App Store web front-end in November 2025, where production source maps left enabled let a researcher reconstruct and publish the full client source.

Comment l’éviter dans votre code

  • Exclude source maps from published packages: add *.map to .npmignore, or use an explicit files allowlist in package.json.
  • Verify the real artifact before publishing. Run npm pack (or npm publish --dry-run) and inspect the tarball; never trust a bundler's disable flag alone.
  • If you need production stack traces, generate hidden source maps and upload them to your error tracker (Sentry, Bugsnag), then strip them from what you ship.
  • Add a CI gate that fails the build or publish when any *.map file (or a map containing sourcesContent) is present in the package or deploy output.
  • Treat everything embedded in shipped code as public: keep secrets, internal endpoints and unreleased logic out of the bundle in the first place.

Références

Vulnérabilités liées

Tout AI/LLM →