RoastMyOpsec

Vulnerabilities

JavaScript Source Maps on Production Origins vs Public Bundles

November 26, 2026

Short answer: open a production JavaScript file on an origin you own and look for a //# sourceMappingURL= comment. If it points at a .map file on that same origin, request the map and read the body, not just the status code. A JSON document with sources, sourcesContent, or mappings is a shipped source map. Treat the original source as public, remove maps from the production bundle, and redeploy. A 404 or 403 on the map URL is what you want. Only test domains you own or have permission to test.

Source maps are a debugging aid. They tell a browser how minified production JavaScript corresponds to the files you actually wrote. That is useful on a laptop and in a staging environment you control. On a public marketing or app origin, a reachable .js.map is closer to leaving the floor plan next to the front door.

The practical difference

A public JavaScript bundle is what you intended visitors to download: minified or compiled code the app needs to run. Some of it may still contain public identifiers (NEXT_PUBLIC_*, analytics IDs). That is a different leak, covered in public JavaScript API keys vs server secrets — public-by-design values are one problem, accidental original source is another.

A source map is a separate JSON file (or an inline payload) that can include original file paths and, often, the original source text in sourcesContent. MDN describes source maps as the file that maps transformed source to the original, so devtools can show the code you wrote. If that file is downloadable on the production origin, anyone who can request the bundle can usually request the map.

This is not a close race. Keep maps for local and private staging. Do not ship them next to index.html on the origin customers use.

How to choose based on what you shipped

What you findWhat it meansWhat to do
No sourceMappingURL in the production JS, and no .map beside the bundleMaps were probably not publishedGood. Still keep the production setting off in CI
sourceMappingURL points at a URL that 404s or 403sComment leftover, file not servedRemove the comment in the next build so you do not advertise a path
200 and a JSON body with mappings / sourcesThe map is publicStop shipping maps, redeploy, review what the sources contained
200 and your homepage HTMLSoft 404: a catch-all route answeredNot a leak, not a lock. Deny .map at the edge
sourceMappingURL=data: inline mapThe map is inside the JS itselfRebuild without inline maps; the bundle is the leak

Why the status code alone lies: plenty of single-page apps return 200 for every path. A checker that only reads codes will panic over a marketing page or miss a real map. Read the body. Check Content-Type. The same soft-404 lesson is in the .env exposure guide.

Check every hostname you actually serve: apex and www, staging., preview deployments, and old project domains. The hardened production site is rarely the only place a map was left on.

When a source map belongs — and when it does not

Use source maps in local development, and on a staging origin that is not public, or that is behind authentication you actually enforce.

Do not ship source maps on the public production origin, including “just for this week while we debug.” If you need production debugging, prefer a private symbol server or a short-lived, access-controlled artefact — not a file sitting next to the bundle.

Framework defaults matter. Next.js, for example, documents productionBrowserSourceMaps as an explicit opt-in because browser source maps in production have public-performance and exposure tradeoffs. If a flag has to be turned on, do not leave it on after the incident is over.

Common mistakes

  • Turning on production source maps to debug one error, then leaving the flag in the deploy.
  • Uploading the whole .next or dist folder, maps included, because the upload script does not exclude *.map.
  • Blocking /src in robots.txt and calling it fixed. Crawlers that already have the bundle still have the sourceMappingURL.
  • Checking only the apex and missing a preview URL that still serves last week’s maps.
  • Assuming minification is hiding secrets. If sourcesContent is in the map, minification did not hide the original file.

What a URL roast can prove

A roast of a URL you own looks for sourceMappingURL breadcrumbs and .js.map links in the page it fetches, requests the map URLs they point at, and reports which ones answer. It will not “hack” your app, and it is not a full source-code audit. It is the same bounded, permissioned check as asking whether /.env is sitting on the origin. No exploit payloads, no card for the free pass.

Free audit the URL you own

RoastMyOpsec is a defensive public-surface roast: headers, cookies, sensitive paths, and more — no exploit payloads. Start with the free audit, then open the vault if the blurred findings look expensive.

Free audit now

FAQ

Does a sourceMappingURL always mean the map is public?
No. The comment can point at a file that is not served, or at a private host. Request the map URL on origins you own and read the body.
Is a 403 on the .map file enough?
It means that path is denied, which is what you want. Confirm it on every hostname, and still drop the maps from the build so you are not one CDN rule away from serving them again.
If the map was public, did we leak secrets?
Maybe. Treat any secrets that appeared in original source, comments, or forgotten .env examples inside the repo as exposed, and rotate those. A map is not automatically a password file. It is original source you did not mean to publish.
Can I check someone else’s site?
Don’t. Test only what you own or have written permission to test.
Should we disable source maps in development too?
No. Use them locally. The decision is whether the public production origin serves them.

Sources

Related guides