A source map exposure scanner checks whether your production site publishes JavaScript .map files that reveal original frontend source, comments, routes, and sometimes secrets. The practical answer is simple: scan the built site from the public internet, verify every discovered map file, remove or restrict production maps, then rotate anything sensitive that appeared in the bundle.
What exposed source maps reveal?
Source maps help developers debug minified JavaScript. In production, they can also give attackers a readable copy of code that was meant to be compact and harder to inspect. This does not automatically mean compromise, but it often shortens the path from curiosity to exploitation.
A source map leak can expose details that are not obvious from minified files alone:
- Original file paths, including framework folders, internal modules, and feature names.
- Readable business logic, such as pricing checks, role labels, and client-side guards.
- API routes and endpoints that were hidden inside bundled code.
- Comments and TODOs that mention temporary workarounds or weak assumptions.
- Embedded configuration values accidentally shipped into the client.
- Third-party service usage, which can guide credential and abuse attempts.
The highest-risk cases usually involve public .map files plus secrets already present in JavaScript. If your build accidentally embeds tokens, source maps make them easier to locate. For that reason, pair this review with a JavaScript bundle scan before shipping.
Attackers do not need special access. They can inspect sourceMappingURL comments, guess common asset paths, or fetch predictable map names from deployment output. If your app uses hashed assets, maps may still be discoverable through public build manifests, cache indexes, or error reporting configuration.
Source map exposure scanner checks
A good scan should behave like an external reviewer, not like a developer with repository access. It should crawl the public app, collect JavaScript assets, inspect response headers, follow sourceMappingURL references, and test common .map variants for each script.
The scan should check public reachability, not only whether a file exists in the build folder. Many teams generate maps locally, then assume deployment excludes them. In practice, hosting rules, stale CDN objects, and previous releases can leave old maps reachable long after a fix.
Useful checks include:
- Crawl rendered pages for script tags and framework asset manifests.
- Fetch JavaScript files and inspect trailing
sourceMappingURLcomments. - Test predictable names, such as
app.js.map,chunk.js.map, and hashed asset maps. - Review HTTP status codes for 200, 403, redirects, and cached responses.
- Sample map content for
sources,sourcesContent, comments, endpoints, and tokens. - Confirm CDN behavior after purge, because origin fixes do not always remove edge files.
Here is a small manual check that illustrates the basic idea. It is not a replacement for crawling, but it shows what many scanners automate.
#!/usr/bin/env bash
origin='https://example.com'
paths=('/assets/app.js' '/assets/vendor.js')
for path in "${paths[@]}"; do
js=$(curl -fsSL "$origin$path")
map=$(printf '%s' "$js" | grep -oE 'sourceMappingURL=.*' | cut -d= -f2)
if [ -n "$map" ]; then
curl -fsI "$origin/assets/$map" | head -n 1
fi
doneLook beyond the obvious 200 OK. A 403 can still disclose that the file exists, and a redirect may expose a storage bucket or asset host. A 404 from the page origin does not prove the CDN, preview domain, or static asset domain is clean.
Also review security headers and cache behavior around assets. Headers will not fix exposed source maps, but weak caching and missing hardening often appear in the same release process. A quick security headers scan can catch adjacent launch issues.
Fix exposed maps safely
The safest fix is to avoid publishing production source maps unless you have a clear operational need. If you use error monitoring, configure private upload to the monitoring service instead of serving maps from the public web root.
For most apps, the cleanup path is straightforward:
- Disable public maps in the production build configuration.
- Rebuild the app from a clean pipeline, not from a patched artifact.
- Delete old map files from hosting storage and release folders.
- Purge CDN caches for JavaScript and
.mappaths. - Retest public URLs from a fresh network, not an authenticated session.
- Rotate exposed secrets if any token, key, or credential appeared in shipped assets.
The last step is where teams often underreact. If a secret appeared in sourcesContent, treat it as exposed. Removing the file later does not prove nobody accessed it while it was public. Rotate the value, invalidate sessions if needed, and review logs for unusual use.
Do not rely on robots.txt blocking as a fix. Search engines are not the threat model, and attackers can request the file directly. Do not rely on hidden filenames either. Build manifests, browser devtools, and error stack traces often reveal enough to reconstruct asset names.
If maps must exist publicly for a narrow reason, restrict them with authentication, short-lived signed URLs, or network controls. Even then, verify that preview environments, branch deploys, and staging domains do not bypass the restriction. For broader coverage, run a deep scan against every public origin tied to the app.
Build a launch habit
Source map exposure is rarely an isolated mistake. It usually comes from a release process that treats the frontend build as harmless static content. Modern client bundles can reveal routes, feature flags, analytics keys, internal naming, and authorization assumptions.
Add this check near the end of your launch checklist, after deployment but before public announcement. Scanning before deployment misses CDN behavior. Scanning weeks later can leave a window where readable code is available to anyone who knows where to look.
A practical prelaunch routine looks like this:
- Scan the live domain and any asset domains.
- Include preview URLs if they are indexed, shared, or guessable.
- Check stale releases when your host keeps historical deployments online.
- Search for secrets in discovered maps and generated JavaScript.
- Record the result with timestamp, tested domains, and remediation notes.
For AI-built apps, this matters because generated code often includes verbose comments, temporary helpers, and copied snippets. Those are useful during development, but they become unnecessary context for attackers in production.
Ship with fewer leaks
Public source maps can turn a minified frontend into a readable blueprint. Scan the real production surface, remove exposed files, purge caches, and rotate anything sensitive. Treat the check as a normal launch gate, not a one-time cleanup task.
Faq
Are source maps always a security vulnerability?
No. Source maps are debugging artifacts, not vulnerabilities by themselves. The risk depends on what they reveal and where they are exposed. If they include readable application logic, comments, endpoints, or embedded values, they can materially help attackers understand and target your app.
Should i delete source maps or make them private?
For most production apps, delete public maps and upload private maps only to your error monitoring service. If your workflow requires access, protect them with authentication or signed URLs. Always test from an unauthenticated browser after deployment and CDN purge.
What if exposed maps contained API keys?
Assume the keys are compromised. Remove the source maps, rotate the affected credentials, review usage logs, and check whether the key had excessive permissions. If the key was client-safe but abusable, add rate limits, domain restrictions, and monitoring before relaunch.
If you want an external check before launch, run an AISHIPSAFE security scan to find exposed frontend artifacts and related production risks.