Risk: Medium 5.3 Medium CWE-540: Inclusion of Sensitive Information in Source Code

Production Source Map Exposure: Risks of Deployed .map Files

Source maps (*.js.map) are generated by modern bundlers to facilitate debugging by mapping minified production code back to original TypeScript, JSX, and React source files.

When .map files are left on production web servers, any visitor using browser developer tools can inspect the original unminified application source code, file structures, internal comments, and helper functions.

Vulnerability Risk & Threat Impact

Unminified source code substantially eases reverse engineering, helping attackers uncover hidden administrative endpoints, internal APIs, and logic flaws.

Attack Vector: Automated botnets continuously harvest public endpoints matching this signature. Once discovered, exploitation is triggered automatically without human review.

How Our Scanner Inspects for This Flaw

Site Check analyzes //# sourceMappingURL= directives within client script bundles and verifies whether referenced .map files are accessible over HTTP.

During configuration and secret scanning, the Site Check engine executes lightweight, non-destructive HEAD and GET probes evaluating status code responses (404/403 vs 200). Diagnostic queries adhere to safety bounds without caching payload contents to external storage, ensuring full confidentiality.

Remediation Guide (Step-by-Step Fix)

To resolve this vulnerability, apply the following configuration or code snippet to your web server:

Disabling source map generation in bundler configuration
      // In vite.config.ts or next.config.js:
export default defineConfig({
  build: {
    sourcemap: false, // Disable source map generation for production builds
  },
});
    
  • Set build.sourcemap to false in your Vite, Webpack, or Next.js build configurations.
  • Purge existing *.map files from your public production server directories.
  • If error debugging in production is required, upload source maps directly and privately to an error monitoring platform (such as Sentry) instead of publishing them on the web.

Attack Anatomy & Real-World Business Impact

Publishing production .map files enables any visitor to open Chrome DevTools Sources and inspect unminified TypeScript source code, revealing internal architecture, authorization endpoints, and proprietary business logic.

Financial & Legal Liability Risks: De-anonymization of proprietary backend logic, hidden administrative routes, and internal database interfaces, radically lowering attacker effort during zero-day vulnerability discovery.

Compliance Framework Impact: Non-conformance with OWASP Top 10 guidelines (A05:2021 Security Misconfiguration) and corporate IP protection controls.

Defense-in-Depth Engineering Matrix

Defense Layer Technical Action Tool / Enforcement
Bundler Configuration Enforce sourcemap: false or sourcemap: "hidden" inside vite.config.ts / webpack.config.js Vite / Rollup Engine
Ingress Web Server Layer Reject external HTTP queries requesting *.map artifacts returning HTTP 404 Nginx Access Policy
Observability & APM Integration Upload hidden symbol maps directly to Sentry/Datadog using CI/CD CLI tools without publishing them publicly Sentry Release CLI

CLI Remediation Verification: Terminal Commands

After applying configuration changes or patching source code, verify that the exposure is neutralized using command-line diagnostic tools:

Bash / cURL: Diagnostic Endpoint Verification
curl -I -s https://your-domain.com/index.js.map | grep "HTTP/"
# Expected: 404 Not Found
    

DevSecOps Best Practices & CI/CD Hardening

Configure sourcemap: false in your production bundler settings (vite.config.ts / webpack.config.js) or set sourcemap: "hidden" to restrict map upload to private monitoring platforms.

Frequently Asked Remediation Questions

Why do development teams generate source maps for production?
Error monitoring solutions like Sentry require maps to render minified exception traces into human-readable code. This must be handled via hidden maps uploaded directly to Sentry.
Can source maps expose build-time environment values?
Yes. Whenever bundlers inline environment tokens into application chunks, the original TypeScript source files embedded in maps will expose them in plain text.
Application Security Lead Auditor Assessment

Exposed configuration files and credentials present the highest risk of automated cloud takeover. We advise implementing pre-commit git hooks (GitLeaks, TruffleHog), migrating environment configurations into encrypted secret managers (HashiCorp Vault, Doppler, AWS Secrets Manager), and configuring web servers to explicitly deny access to hidden dot-files.

To permanently close the «Production Source Map Exposure: Risks of Deployed .map Files» threat vector, integrate verification gates into your CI/CD pipeline and maintain automated perimeter checks with Site Check.