[{"data":1,"prerenderedAt":16},["ShallowReactive",2],{"fix-leaked-source-maps":3},{"id":4,"slug":5,"title":6,"description":7,"bucket":8,"severity":9,"status":10,"publishedAt":11,"summary":12,"affectedCheck":13,"fixSteps":14,"agenticPrompt":15},"fix-leaked-source-maps","leaked-source-maps","Your production build is leaking source and secrets to the browser","Source maps and hardcoded keys in a client bundle hand your original code and your API secrets to every visitor. Here is how to check what you are shipping, and what to do about it.","NEW_VULNERABILITY","high","published","2026-11-23T09:15:00.000Z","\u003Cp>Modern front end tooling makes this easy to get wrong, because the default behaviour is tuned for debugging rather than for shipping. Two separate problems usually arrive together.\u003C\u002Fp>\n\u003Cp>The first is source maps. A \u003Ccode>.js.map\u003C\u002Fcode> file next to your bundle lets anyone reconstruct your original, unminified source, with comments, file names and directory structure intact. That is a disclosure problem rather than a direct break, but it removes the effort from finding everything else.\u003C\u002Fp>\n\u003Cp>The second is the serious one. Any value compiled into a client bundle is public, permanently, no matter how it is named. A build time variable prefixed for client exposure, an API key passed to a browser SDK, a token inlined for convenience: all of it ships to every visitor. Minification is not protection, and neither is removing the source map. If a secret reached the browser, it has already been disclosed.\u003C\u002Fp>","\u003Cp>First, look for source maps. Open your site, view the main JavaScript bundle, and check the last line for a comment like:\u003C\u002Fp>\n\u003Cpre>\u002F\u002F# sourceMappingURL=index-a1b2c3.js.map\u003C\u002Fpre>\n\u003Cp>Then request that file directly. If it loads, your original source is public.\u003C\u002Fp>\n\u003Cp>Second, and more important, search the shipped bundle for secrets. In your browser devtools, open the Network tab, load your site, and search the JavaScript responses for telltale fragments such as \u003Ccode>secret\u003C\u002Fcode>, \u003Ccode>api_key\u003C\u002Fcode>, \u003Ccode>apikey\u003C\u002Fcode>, \u003Ccode>password\u003C\u002Fcode>, \u003Ccode>token\u003C\u002Fcode>, and \u003Ccode>-----BEGIN\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Cp>Anything you find there is already public. Treat it as compromised, not as something to tidy up later.\u003C\u002Fp>","\u003Ch3>1. Rotate anything that reached the browser\u003C\u002Fh3>\n\u003Cp>Any credential found in a client bundle must be rotated. It was served to every visitor and may sit in caches, proxies and archives. Removing it from the next build does not undo the disclosure.\u003C\u002Fp>\n\u003Ch3>2. Decide what genuinely belongs client side\u003C\u002Fh3>\n\u003Cp>Some keys are designed to be public, such as a publishable payment key or a map tile key. Those are fine, but they must be restricted by referrer, domain or scope in the provider's dashboard. Everything else belongs on the server.\u003C\u002Fp>\n\u003Ch3>3. Move real secrets behind your own endpoint\u003C\u002Fh3>\n\u003Cp>If the browser needs data that requires a privileged key, call your own server route, keep the key there, and return only the result. The browser should never hold the credential.\u003C\u002Fp>\n\u003Ch3>4. Stop publishing source maps\u003C\u002Fh3>\n\u003Cp>Either disable source map output for production builds, or keep generating them and upload them to your error tracker instead of deploying them. Most trackers support uploading and then deleting the files from the build output, which is the best of both: readable stack traces for you, nothing public.\u003C\u002Fp>\n\u003Ch3>5. Check your client exposure prefix\u003C\u002Fh3>\n\u003Cp>Frameworks expose variables to the browser through a naming convention. Audit every variable using that prefix and confirm each one is genuinely safe to publish. It is a common mistake to add the prefix to make a build work and ship a real secret by accident.\u003C\u002Fp>","You are helping me audit and fix what my production front end build exposes to the browser. I own and operate this site.\n\nProblem: my production build may be publishing source maps and, more seriously, may contain secrets compiled into the client bundle.\n\nWork through the following in order, and confirm with me before any destructive or irreversible step.\n\n1. Identify the framework and the bundler, and find the production build configuration.\n2. Tell me whether source maps are emitted for production builds, and show me the exact setting that controls it.\n3. Find every environment variable this project exposes to the client. Identify the framework's client exposure prefix first (for example the prefix used by Vite, Next, Nuxt or Create React App), then list every variable using it.\n4. For each client exposed variable, classify it as SAFE TO PUBLISH (designed to be public, such as a publishable payment key or a map key) or MUST NOT BE PUBLIC. Explain each classification. Refer to variables by NAME ONLY and never print a value.\n5. Search the repository for secrets passed into client side code by any other route: hardcoded literals, values imported into components, keys handed to browser SDKs. Report file and line, names only, never values.\n6. For everything classified MUST NOT BE PUBLIC, produce a rotation checklist naming the credential, its provider, and where it is rotated. I will do the rotating.\n7. Propose the refactor that moves each real secret behind a server route, so the browser receives only the result and never the credential. Show me the change before applying it.\n8. For keys that are legitimately public, tell me what restriction I should apply in the provider's dashboard (referrer, domain, IP or scope allowlist).\n9. Recommend a production source map strategy: either disable emission, or emit and upload to my error tracker then delete from the deployed output. Tell me which this project already supports.\n\nFinish with a summary of what you changed, the rotation checklist, and anything I must do by hand.",1795449486783]