guides · 2026-11-14
Production Source Maps: You Are Probably Shipping Your Original Source Code
Published 2026-11-14 · Reviewed 2026-11-14 · By the Ingenious AI team
The short answer
If your production JavaScript has a sibling .map file served with it, visitors can reconstruct your original source — readable code, comments and structure — from the browser's dev tools. Check by requesting a bundle's .map URL, disable source-map generation (or upload maps privately to your error tracker only), and confirm the deployed files answer 404.
Check your own app free: paste your code or enter your site URL on the Vibe-Code Audit homepage — the free scan checks for exposed secrets, injection flaws, XSS patterns, missing headers and exposed .env/.git paths, with a copy-paste fix for every finding. No credit card.
What is Source map?
a build artefact (.map) that maps minified production code back to the original source files, so debuggers can show readable code. Served publicly, it publishes that original source — effectively open-sourcing your frontend, comments included, without a repository.
What a map file actually gives away
Open a production site's dev tools with maps enabled and the Sources panel shows the project as the developer sees it: file tree, original identifiers, comments — including the TODO with the internal URL, the commented-out test key, the honest variable names that map your API surface. Vibe-Code Audit's source-map detector family covers the served bundle referencing a map, Next.js productionBrowserSourceMaps, and maps shipped in deployment output, because the leak is binary: either the .map resolves publicly or it does not.
Calibrate the severity honestly: frontend source is never truly secret (the minified bundle ships too), and maps do not magically expose server code. What they expose is the readable version — the difference between an attacker skimming obfuscated output for a weekend and reading your code like a colleague in an afternoon, comments and all. Secrets do not belong in frontend code at all (that is a worse, separate finding), but maps routinely carry the near-secrets: internal endpoints, feature flags, staging URLs, and the logic of your client-side checks, neatly annotated.
Why your build ships them
Defaults and debugging sessions: a bundler's devtool setting left at a map-producing value, a framework flag enabled to chase one production bug and never reverted, a CI template that uploads the whole dist folder including artefacts meant only for the error tracker. AI-generated build configs reproduce the tutorial value (source maps on, for the nice debugging screenshots) with no notion of environment. The check belongs in the deploy pipeline, not in human memory: after each build, assert that no .map file lands in the publicly served directory — or, if maps are generated for the error tracker, that they travel a private channel and are excluded from the web artefact.
The ten-second check and the fix
Take any production bundle URL from your page source, append .map, and request it. A JSON response beginning with version/file/sources is a live leak; a 404 is the correct answer. Also grep your built HTML/JS for 'sourceMappingURL' — the comment that tells browsers where the map lives. Fix at the source: production builds set devtool to false (or the framework equivalent — Next.js: productionBrowserSourceMaps: false), CI stops copying maps into the web root, and any CDN-cached copies are purged, because deleting the file from origin while the CDN serves its cache is a press release, not a fix.
If your error tracker needs maps (a legitimate need — readable stack traces are gold), use its private upload step in CI and delete the maps from the artefact afterwards. Both worlds are available; the only wrong answer is the public one.
What to do about an already-public map
Assume it was downloaded — maps are small, and recon tools fetch them automatically. Read your own map like an attacker: hunt for credentials (rotate anything real, immediately — this becomes the secrets incident, not a config ticket), internal URLs worth probing, and client-side 'security' logic (hidden admin routes, client-only plan checks) that must move server-side regardless of the map, because the minified bundle reveals it too, just slower. The map is the symptom; anything genuinely sensitive it exposes was misplaced the day it entered frontend code.
Worked example: NorthLoop Analytics' dashboard
NorthLoop Analytics (fictional), a B2B dashboard with 210 customer teams, enabled productionBrowserSourceMaps while debugging a chart bug and shipped it for five months. A scan flagged the Next.js setting and a served bundle referencing its map. Reviewing their own map, the team found a commented staging API URL and an internal feature-flag scheme — no live secrets, this time. Maps were disabled in production config, the build gained a no-.map-in-dist assertion, CDN caches were purged, and error-tracker uploads moved to a private CI step. The follow-up check — bundle URL plus .map — returned 404, and the staging URL found in the map was retired rather than merely un-commented.
Five actions to take today
- Request your main production bundle's URL with .map appended; anything but a 404 is a live source leak.
- Grep built assets for sourceMappingURL and inventory every map your build emits.
- Disable source maps in production build config (framework flag or devtool: false), keeping them for development builds only.
- If your error tracker needs maps, upload them privately in CI and exclude them from the deployed web artefact; purge CDN caches of old maps.
- Read any long-exposed map as an attacker would: rotate real secrets, retire internal URLs, and move client-side-only checks server-side.
Sources
- OWASP Top 10, the OWASP Foundation's standard awareness list of the most critical web application security risks: owasp.org, 2021
- CWE-89: Improper Neutralization of Special Elements used in an SQL Command, MITRE's weakness entry for SQL injection and its mitigations: cwe.mitre.org, 2026
- OWASP Cheat Sheet Series — Secrets Management, OWASP's best-practice guide to storing, rotating and auditing secrets: cheatsheetseries.owasp.org, 2026
Frequently asked questions
Isn't frontend code public anyway?
The minified bundle is public but expensive to read; the map makes it fully readable with comments and structure. You cannot make frontend code secret — but you can decline to publish the annotated edition.
Can a source map expose my backend code?
No — maps cover the frontend bundle only. Backend exposure comes from other leaks (.env, .git, debug pages). If a map seems to show server secrets, they were embedded in frontend code, which is its own critical problem.
We need maps for production debugging. Alternatives?
Private upload to your error tracker during CI, then delete from the artefact. You keep readable stack traces; the public gets a 404.
Does removing the sourceMappingURL comment suffice?
No. The comment is a signpost; the file is the leak. Attackers guess the .map URL directly. Remove the files from the served output and purge caches.
Related guides
- Secrets in Dockerfiles: Why ARG and ENV Bake Keys Into Your Image Forever
- Race Conditions in Checkout and Balance Code: The Double-Spend Your Tests Never Catch
- Web Cache Poisoning and Deception: Making Your CDN Serve the Attack to Everyone
- DOM Clobbering: How a Form Field Named 'config' Silently Replaces Your JavaScript Objects
- Math.random() Is Not a Token Generator: Weak Randomness in Reset Links and Session IDs
- Session Cookies Without HttpOnly, Secure and SameSite: What Each Missing Flag Costs You
- 7 Security Mistakes AI Coders Keep Making
- Supply-Chain Attacks in the AI-Coding Era
- Secret Hygiene: Stop API Key Leaks
- What Code Scanners Can't Find
- Cursor-Generated Code Review Checklist
- Bolt.new Pre-Deploy Security Checklist
Browse the full library on the guides index, run the checks in the launch audit, or compare plans on pricing.
Informational explainer, not a security guarantee. Scan your code free before every deploy.