# What a public source map gives away
*articles*
Leave a source map in production and anyone can turn minified code back into a readable copy of your source. Here is how V09 in vuln sees it, and how to stop it in each build tool.


A source map (a file that links the compressed code back to the code you wrote) can sit inside the JavaScript on your site, even if you never open developer tools. If a check flagged one, this article covers what leaks and how to stop it.

The short answer: **do not publish source maps in production**. If you need them for error tracking, keep them somewhere private. If they are already public, delete the files, then check whether they contained any secrets.

## A source map is the assembly instructions

When you buy flat-pack furniture, the parts arrive with assembly instructions. A source map is close to that.

The JavaScript your visitors download is compressed until it is hard to read (minified). Variable names shrink to one letter, comments disappear, line breaks are squeezed out. That is what makes the file small.

A source map is a JSON file that records where each piece of the minified file came from: the original file name and line number. Developer tools use it to show an error at the place in the original code. While you build, it is very useful.

The marker is one line at the end of the JavaScript, like `//# sourceMappingURL=app.js.map`. Some builds embed the map inside the file instead, starting with `data:`.

## What leaks

A source map contains original file names, function names and line numbers. Depending on the settings, `sourcesContent` holds the original text itself, so the code before minification can be read directly.

Here is what a reader can learn:

- The file layout, and the names of functions and variables
- Comments (TODOs, internal notes, API explanations)
- Code for features you have not shipped yet
- The paths and URLs of APIs the app calls

**A source map on its own does not mean your site was broken into.** It means the inner workings can be read.

It does make the attacker's early probing much cheaper. Knowing what is where narrows down what to try first. This kind of exposure is classified as CWE-540 (an international numbering system for software weaknesses).

## If a key is inside, that is a separate problem

If you wrote an API key or password directly into the code, it can be read from the source map too. Removing the source map does not fix that.

The JavaScript you ship is readable by anyone anyway. Even without a source map, a determined reader can work through the minified code. **Keep keys out of the code and move them to environment variables (settings kept outside the code, with values not shown on screen) or the server side.**

The problem of keys in code is covered in [secrets in client JavaScript](/en/checks/client-secrets).

## How vuln shows it

In vuln (a [free check that only needs the public URL](/en/vuln)), a source map appears as one row, V09.

- V09 Source map exposure (Area: Exposure, Priority: 2)

When it needs attention, the fix column reads "Disable source maps in production, or exclude them from the deployed files. Remove maps already uploaded."

The range it looks at is fixed.

- Up to two scripts and modulepreloads from the top page's HTML, when they are on the same origin (same domain, protocol and port)
- The last 2 KB of each file, to find the last sourceMappingURL
- The map is fetched only when it is on the same origin (same domain and protocol)
- A finding requires the map to load, parse as JSON, declare version 3 and have at least one entry in sources

Maps on an external CDN are not fetched. They are not part of what you ship.

The result depends on the contents. If `sourcesContent` (the original text) is present, the status is "Needs work"; if only `sources` (the file list) is, it is "Check". The result shows the URL of the map that was fetched.

If the JavaScript cannot be fetched, if it is too large and gets cut off, or if a same-origin map cannot be fetched, V09 becomes "not checked". **A pass means "nothing found in that range".** When there is nothing to inspect, it is also "not checked" (the case for this site, below).

The official documentation is here.

- [MDN's guide to using a source map (English)](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map)
- [MDN's reference for the SourceMap header (English)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/SourceMap)

## Measured on this site

On 26 November 2026 we used curl (a command that fetches the contents of a URL) to fetch `https://ismyappok.com/ja` and `/en`. Counting occurrences of `<script src=`, both counts were **0**.

There are two inline scripts. One is JSON-LD (structured data for search engines); the other is a small script with a nonce (a one-time mark issued for each page). Neither loads an external file.

This site ships no JavaScript bundle (several files packed into one), so V09 becomes "not checked". The screen says "There was nothing to check for this item (for example, no same-origin JavaScript)". It means there is nothing to inspect; it is not a pass.

The flip side: as soon as you deploy a built app, this check has something to inspect. Today's "not checked" does not mean safe.

## How to stop it

Turn production source maps off in your build tool.

- Vite: set `build.sourcemap` to `false` (the default is false)
- Next.js: set `productionBrowserSourceMaps` to `false` (the default is false)
- webpack: set `devtool` to `false` (the production default is false)

Even when the default is false, a template or an old setting can have it on. Check the config file once.

`hidden` and `hidden-source-map` still produce the .map file, but leave no marker in the JavaScript. That lets you upload maps only to an error tracker.

The official settings are here.

- [Vite's build options (English)](https://vite.dev/config/build-options)
- [Next.js productionBrowserSourceMaps (English)](https://nextjs.org/docs/app/api-reference/config/next-config-js/productionBrowserSourceMaps)
- [webpack devtool (English)](https://webpack.js.org/configuration/devtool/)

If you do not use a build tool, check the deployed directory for leftover `.map` files. If your host can refuse to serve `*.map`, that also works.

## What to check after deleting them

If the maps were already public, delete the files. Deleting them does not undo any copy someone already took.

- Remove the .map files from what you deploy
- Purge the CDN or host cache
- If anything looked like a key, revoke it and issue a new one
- Check JavaScript on pages other than the top page too (vuln only reads two files from the top page)

You can confirm the deletion in a browser. Open a JavaScript file in the Network tab of developer tools and look at the sourceMappingURL at the end. Open that URL in a private window; if no JSON comes back, it is gone.

## Summary

A source map is the assembly instructions that help you debug while you build. The trade-off is that shipping one ships the inner workings too.

Start by opening one JavaScript file from your top page and looking for a sourceMappingURL at the end. If there is none, you are done for today.

Each check is explained here.

- [Source map exposure](/en/checks/source-map-exposure)
- [Secrets in client JavaScript](/en/checks/client-secrets)
- [.env file exposure](/en/checks/env-file-exposure)

Related articles:

- [Don't trust external scripts blindly (SRI)](/en/articles/subresource-integrity)
- [Security headers, explained](/en/articles/security-headers)

When you have made the changes, [run a check with vuln](/en/vuln). You can also review display and links before launch with [audit (no login)](/en/audit).

We wrote this article after checking our own site. It contains no results from scanning third-party sites. The numbers describe how the implementation works; measured values are only those stated with a date and method in the text.

## Check your own site
Enter a URL and see what is missing before launch. Free, and no login required.
[Run the free check](https://ismyappok.com/en/audit)