Introduction
In modern web development, minification and bundling are standard practices for improving load times and obfuscating code. But there's a catch: developers often leave behind .map files, or "source maps," which can reverse-engineer minified JavaScript into its original, readable format. These forgotten files provide a blueprint to the application's inner workings.
For bug bounty hunters and red teamers, exposed source maps are a goldmine.
In this article, we explore how to discover, parse, and exploit exposed source maps to uncover sensitive logic, admin panels, secrets, and potential attack vectors.
1. What Are Source Maps?
Source maps (.map files) are JSON-based files that link minified JavaScript back to its original source code.
Example snippet from main.js.map:
{
"version": 3,
"file": "main.min.js",
"sources": ["webpack://src/auth.js", "webpack://src/admin.js"],
"names": ["login", "adminPage"],
...
}Why are they dangerous when public?
- They reveal internal logic, comments, and filenames.
- They undo the obfuscation, giving attackers full visibility.
- They often expose dev-only endpoints or debug variables.
2. Finding Exposed Source Maps
Use these methods to discover source maps in the wild:
Crawling and Wordlists
gobuster dir -u <https://target.com> -w wordlists/common.txt -x mapCDN/Script Patterns
If you see:
<script src="/static/js/main.min.js"></script>Try accessing:
/static/js/main.min.js.mapWayback Machine and Gau
gau target.com | grep ".js.map"Custom Dorks
site:target.com ext:map3. Analyzing the .map File
Download the .map file and use tools like:
Or locally:
npm install -g source-map-explorer
source-map-explorer main.min.js main.min.js.mapLook for:
- Admin panel URLs (
/admin,/dashboard) - Feature flags (
isAdmin: true) - API tokens (
auth_token,jwtToken) - Hidden debug functions (
testUser(),internalLog())
4. Turning Debug Code into Exploits
Hidden Admin Interfaces
function openAdminPanel() {
if (user.isAdmin) {
window.location.href = "/super-admin-secret-panel";
}
}Use this to brute force or test access control
API Key/Token Leakage
const API_KEY = "sk_live_ABC123...";Replay API requests, access private data
Disabled Features or Secrets
if (!isProduction) {
window.DEBUG_MODE = true;
console.log("JWT:", user.jwt);
}JWT printed in console = potential ATO
5. Real-World Case Study
A hacker found a .map file on a private beta app:
- Reconstructed
/src/auth.js,/src/payment.js - Found an unused but still-live
/beta/adminpanel - Used leaked Firebase config to access Firestore DB
- Reported to the company and got $3,000 bounty
Moral? One .map file opened the entire backend.
6. Mitigation (for Devs)
- Never deploy
.mapfiles in production - Use
.gitignoreto prevent accidental commits - Configure Webpack:
new SourceMapDevToolPlugin({
filename: false
})- Add CI checks to block
.mapfrom builds
Conclusion
Exposed source maps are like leaving your app's blueprints on the front lawn. For security researchers, they're a critical recon step. Always test for them, and treat them as high-priority if discovered.
Happy Hunting