How to fix: Source Map Publicly Exposes Original Source Code
The .map file referenced by a //# sourceMappingURL comment was fetched directly and its 'sourcesContent' field is present and non-empty, meaning the original, un-minified source files are embedded in the map and are downloadable by anyone who requests the .map URL. This is a stronger confirmation than the sourcemap-reference check, which only observes the reference comment and cannot say whether the .map file is actually reachable.
Why it matters
Unlike the mere presence of a sourceMappingURL comment, this confirms the .map file is actually served and readable: the full original source (business logic, internal endpoint names, comments, and sometimes hardcoded values) can be reconstructed by simply downloading the .map file and reading its sourcesContent array.
A source map's optional sourcesContent field embeds the full text of every original source file directly in the map. Many bundler configurations include it by default, so a publicly reachable .map file becomes a complete download of the pre-minification source, not just line/column mappings.
How to fix it
- 1Restrict access to .map files at the web server/CDN level (deny public requests, or require authentication).
- 2Disable sourcesContent generation, or disable source maps entirely, for production builds.
- 3If source maps are needed for error tracking, upload them directly to your error-tracking service's API and keep them off the public web server.
Code examples
Disable sourcesContent / source maps in production
// next.config.mjs
export default {
productionBrowserSourceMaps: false,
};
// webpack: keep mappings but omit embedded source text
// devtool: 'nosources-source-map'
// Or block .map requests entirely at the edge/CDN
// location ~* \.map$ { deny all; return 404; }References
Detected automatically by VulnRadar. The check id is sourcemap-sourcescontent-exposed, stable across every scan so you can filter or diff on it.
More content checks
- MediumPotential Open Redirect Parameters
- HighDirectory Listing Appears Enabled
- MediumSensitive File References Detected
- HighPotentially Outdated JavaScript Libraries
- Inforobots.txt Present - Review Manually
- InfoCMS / Technology Fingerprinting
- MediumPotentially Dangerous Inline JavaScript
- LowServer version disclosed in response header
Questions
- How severe is Source Map Publicly Exposes Original Source Code?
- VulnRadar rates this high severity in the content category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id sourcemap-sourcescontent-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Source Map Publicly Exposes Original Source Code map to?
- It maps to CWE-540. In the OWASP Top 10 it falls under A05:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.