VibeSecCheck
Home/Security Guides/public-sourcemaps-risk
Medium RiskSecrets & ExposureViteNext.jsSentryBolt.new

Why Public JS SourceMaps Leak Your SaaS Logic

Production JavaScript sourcemaps reconstruct your exact original folder structure, TypeScript comments, prompt templates, and hidden admin route URLs straight inside Chrome DevTools.

Why AI Builders Introduce This

Boilerplates and debugging sessions frequently turn on `sourcemap: true` or `productionBrowserSourceMaps: true` and ship `.map` files straight to public CDN buckets.

Real-World Exploit Impact
  • Competitors and attackers read your original unminified TypeScript files verbatim
  • Comments containing TODOs, staging URLs, or internal admin paths become public
  • Makes discovering hidden API parameters and business logic flaws trivial

Vulnerable Pattern vs. Production Fix

Exposing SourceMaps Publicly in Vite & Next.jstypescript
// next.config.ts — Publishes *.js.map to every visitor!
const nextConfig = {
  productionBrowserSourceMaps: true,
};
Private / Disabled SourceMaps in Production
// next.config.ts
const nextConfig = {
  productionBrowserSourceMaps: false,
};

// vite.config.ts (use "hidden" ONLY if uploading .map privately to Sentry & deleting before deploy)
export default defineConfig({
  build: {
    sourcemap: false,
  },
});

Copy-Paste AI Fix Prompt (Cursor · Lovable · Bolt · Claude Code)

Disable public production JavaScript sourcemaps in this repository:
1. Set productionBrowserSourceMaps: false in next.config.* OR build.sourcemap = false in vite.config.*.
2. If Sentry is configured, switch to hidden sourcemaps uploaded during CI and deleted from the public build directory before deployment.
3. Run a production build and confirm no //# sourceMappingURL= comments appear in built JS bundles.

How to Verify Your Fix Worked

  1. 1Run `npm run build` and check that `.next/static` or `dist/assets` contains zero `.js.map` files.
  2. 2Inspect a live JS chunk with `curl` and confirm no `sourceMappingURL=` footer exists.
  3. 3Re-run VibeSecCheck to verify the Public JavaScript SourceMap check passes.

Frequently Asked Questions

How can I debug production errors without public sourcemaps?

Use hidden sourcemaps uploaded privately to Sentry, Highlight, or Datadog during your CI build, and delete the .map files before deploying to your CDN.

Are public sourcemaps a critical vulnerability by themselves?

They are a medium-severity information disclosure risk, but in vibe-coded apps they frequently accelerate exploitation by revealing internal endpoints, comments, and hardcoded logic.

Does Next.js enable production browser sourcemaps by default?

No, Next.js defaults to false, but Vite templates and third-party build plugins often toggle sourcemaps on.

Related Security Playbooks