Toutes les vulnérabilités
MEDIUMAppSec

APPSEC-SOURCEMAP-DISCLOSURE

AppSec · Web · Client-side source maps in production

Résumé

A source map (.map) is a build artifact that maps minified bundle code back to the original source, and bundlers embed the full original code in its sourcesContent field. Left reachable in production or shipped inside a package, it hands anyone the unminified codebase, internal comments, hidden API endpoints, auth logic, and any secrets that were compiled in. Discovery is trivial: open DevTools and read the Sources tab, request the bundle's .map URL directly, or Google-dork for ext:map intext:webpack, then reconstruct the whole project with a tool like unwebpack-sourcemap. Passive scanners such as Acunetix and Burp already flag it as a standalone finding. It is usually rated medium on its own but escalates fast when the recovered source contains live credentials or undocumented endpoints; exposed Webpack source maps have leaked hardcoded Stripe secret keys that enabled unauthorized payments. High-profile cases include Apple's App Store web front-end in November 2025, shipped with source maps still enabled, and Anthropic's Claude Code, whose entire TypeScript source leaked via a source map left in a published npm package in March 2026.

Comment l’éviter dans votre code

  • Disable production source maps unless you actively need them (Vite build.sourcemap false, webpack devtool false, GENERATE_SOURCEMAP=false for Create React App).
  • If you need stack traces, use hidden source maps: generate them, upload to your error tracker, then strip the sourceMappingURL comment and the .map files from what you serve or publish.
  • Strip sourcesContent from any map you do ship, so the original code is not embedded in it.
  • For packages, exclude *.map via .npmignore or a files allowlist, and inspect the tarball with npm pack before publishing.
  • Add a CI check that fails when a reachable .js.map (or a map containing sourcesContent) is found in the deploy output or package.

Références

Vulnérabilités liées

Tout AppSec →