How to fix: JavaScript Source Map Exposed in Production
A source map reference (//# sourceMappingURL=) was found in production JavaScript, pointing to a non-data-URI location. Source maps expose original, un-minified source code to anyone who fetches them.
Why it matters
Source maps expose the complete, readable, un-minified source code of your application to anyone with browser dev tools. This reveals business logic, proprietary algorithms, internal API endpoints, and can make finding vulnerabilities significantly easier.
Bundlers generate source maps for debugging. Production builds should either exclude source maps entirely or use a private source map server that requires authentication (Sentry, DataDog, etc.).
How to fix it
- 1Disable source map generation for production builds in Webpack: devtool: false.
- 2In Vite: build.sourcemap: false.
- 3If source maps are needed for error tracking: upload them to your error tracking service, then delete or restrict access to the .map files.
- 4Use hidden-source-map in Webpack to omit the reference comment while keeping the .map file for internal upload.
Code examples
Disable source maps in Vite production
// vite.config.ts
export default {
build: {
sourcemap: false, // No source maps in production
// Or: sourcemap: 'hidden', generates .map but no reference comment
}
};References
Detected automatically by VulnRadar. The check id is source-map-exposed-production, stable across every scan so you can filter or diff on it.
More client-side checks
- HighCSP Allows 'unsafe-inline' Scripts
- MediumCSP Allows 'unsafe-eval'
- HighpostMessage Without Origin Validation
- HighSensitive Data Stored in localStorage
- HighDOM XSS via location.hash Assignment
- Highdocument.write() in Page Scripts
- Higheval() in Client-Side JavaScript
- MediumExternal Script Without Subresource Integrity
Questions
- How severe is JavaScript Source Map Exposed in Production?
- VulnRadar rates this medium severity in the client-side 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 source-map-exposed-production, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does JavaScript Source Map Exposed in Production 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.