Skip to content
Pwnversity
RECON-JSintermediate · 13 min · upd. 2026-11

JavaScript Recon: Bundles, Routes and Source Maps

OWASP A02:2025CWE-540CWE-200

In a modern application, much of the logic travels to the browser as JavaScript. That code includes the API routes the front end calls, page routes the menu doesn’t show, parameter names, environment configuration and, more often than it should, keys and internal hosts. JavaScript recon means reading that code with intent: it’s the map of the application, handed to you by the application itself.

flowchart LR
    A["Initial HTML"] --> B["Bundles and .js chunks"]
    B --> C["API endpoints and parameters"]
    B --> D["Router routes (including admin ones)"]
    B --> E["Configuration, keys, internal hosts"]
    B --> F["sourceMappingURL → .map"]
    F --> G["Rebuilt original source code"]
  • Whatever is sent to the client is public. Minifying isn’t hiding; a source map undoes even the minification.
  • The front end often knows more than it shows: admin routes loaded on demand, endpoints for unreleased features, calls from older API versions.
  • Misplaced trust shows up here: role checks done only in the front end, service keys with write permissions, URLs of internal or staging environments.
Piece What it is What it gives you
Main bundle (main.[hash].js, app.[hash].js) The application code packaged by Webpack, Vite or similar API calls, routes, configuration
Chunks ([n].[hash].js) Pieces loaded only when certain routes are visited Sections you can’t see without permissions (the /admin chunk exists even if you never get in)
Manifests Lists of routes and chunks generated by the framework (e.g. _buildManifest.js in Next.js) Every page of the application in one file
Public environment variables NEXT_PUBLIC_, VITE_, REACT_APP_ prefixes: deliberately embedded in the bundle API and environment URLs; sometimes a secret ends up there by mistake
Source map (.map) A JSON file mapping minified code to the original The source code with names, comments and folder structure

A bundle with a source map ends with a line like //# sourceMappingURL=main.3f2a1c.js.map. If that file is served, the original code is one request away.

  1. Collect the files: browse the application with Burp running (each section loads its chunks) and filter the history by .js. Complement it with a crawler that follows references in JavaScript and with old versions of the bundles from historical archives.
  2. Prioritise: the application’s own bundles, not well-known libraries (react-dom, lodash…).
  3. Read with intent: routes, HTTP calls, parameter names, role checks, configuration.
Ventana de terminal
# Scripts loaded by the home page
curl -s https://app.example.local/ | grep -oE 'src="[^"]+\.js"' | sort -u
# Download a bundle and make it readable
curl -s https://app.example.local/static/js/main.3f2a1c.js -o main.js
npx --yes js-beautify main.js > main.pretty.js
# Routes and endpoints: strings starting with /
grep -oE '"/(api|admin|internal|v[0-9]+)[^"]*"' main.pretty.js | sort -u
# HTTP calls and auth headers
grep -nE 'fetch\(|axios\.|XMLHttpRequest|Authorization|Bearer' main.pretty.js | head -40
# Role checks the API may not repeat
grep -nE "role|isAdmin|permission|can[A-Z][a-zA-Z]+\(" main.pretty.js | head -40
Ventana de terminal
# Is there a source map?
tail -c 200 main.js # //# sourceMappingURL=main.3f2a1c.js.map
curl -s -o /dev/null -w '%{http_code}\n' https://app.example.local/static/js/main.3f2a1c.js.map

Minified, obfuscated and “encrypted” on the client

Section titled “Minified, obfuscated and “encrypted” on the client”

These are three different things, reversed in different ways:

What it does How to reverse it
Minified Strips whitespace and shortens variable names. Behaviour is unchanged js-beautify or prettier. Improves readability but doesn’t recover the original names (only a source map does)
Obfuscated Transforms the code so it’s hard to read: encoded strings, convoluted flow Identify each transformation and undo it, by hand or with a deobfuscator
“Encrypted” on the client The code decrypts data or strings with a key The key travels in the same code: read it and decrypt the same way the browser does

The most common obfuscation transforms:

Technique Looks like What to do
Hex strings "\x2f\x61\x70\x69" Decode the string (browser console, Python, CyberChef)
Unicode strings "\u002f\u0061\u0070\u0069" Same as above
String array _0x1b2c(0x1a4): a decoder function returning the string from a rotated array (older versions used direct access, _0x3a1f[0x1]) Dump the decoded array and replace the calls; this is the javascript-obfuscator pattern
Base64 atob("L2FwaS9hZG1pbg==") base64 -d or atob() in the console: /api/admin
Dead code Blocks and conditions that never run Ignore them: they only add length
Control-flow flattening A switch inside a loop jumping between cases according to an order string Follow the order string or let a deobfuscator resolve it
Ventana de terminal
# Decode strings without running the script
python3 -c 'print("\x2f\x61\x70\x69\x2f\x61\x64\x6d\x69\x6e")' # /api/admin
echo 'L2FwaS9hZG1pbg==' | base64 -d # /api/admin
# Deobfuscator for javascript-obfuscator that also splits the modules of a webpack bundle
npx --yes webcrack main.js -o deobfuscated/

In minified code, an endpoint often doesn’t appear whole: it’s built in pieces and a grep for /api/admin won’t find it. Search for the constructions, not the paths:

Ventana de terminal
# Paths assembled with join, concatenation or template literals
grep -nE "join\(['\"]/['\"]\)" main.pretty.js
grep -nE "['\"]/[A-Za-z0-9_./-]*['\"][[:space:]]*\+" main.pretty.js
grep -nE '`[^`]*\$\{[^}]+\}[^`]*`' main.pretty.js | grep -iE 'api|admin|/v[0-9]' | head
# e.g. ["api","v2","users"].join("/") or `${BASE}/admin/${id}`
# rebuild.py — usage: python3 rebuild.py main.js.map out/
import json, os, sys
srcmap = json.load(open(sys.argv[1]))
out = os.path.realpath(sys.argv[2])
for path, code in zip(srcmap.get("sources", []), srcmap.get("sourcesContent") or []):
if code is None:
continue
# Normalise the path and drop anything that lands outside the output folder
# ("../" paths, absolute paths, another drive on Windows, or symlinks)
clean = os.path.normpath(path.replace("webpack://", "").lstrip("/"))
dest = os.path.realpath(os.path.join(out, clean))
try:
if os.path.commonpath([out, dest]) != out:
continue
except ValueError: # different drives on Windows
continue
os.makedirs(os.path.dirname(dest), exist_ok=True)
with open(dest, "w") as f:
f.write(code)
print(dest)

With the rebuilt tree, search the routing, service and configuration files: that’s where the endpoints, their parameters and the role names live.

Ventana de terminal
# Next.js: the buildId is in the HTML's __NEXT_DATA__
curl -s https://app.example.local/ | grep -oE '"buildId":"[^"]+"'
# With it, the manifest lists every page
curl -s https://app.example.local/_next/static/<buildId>/_buildManifest.js
  • Burp Suite: history filtered by JS and search across all responses.
  • katana (-jc): crawler that extracts paths from the JavaScript it finds.
  • jsluice: extracts URLs, paths and potential secrets from JS files (jsluice urls, jsluice secrets).
  • webcrack: deobfuscates javascript-obfuscator output and splits the modules of a bundle.
  • LinkFinder: regular expressions for endpoints in JS.
  • trufflehog and gitleaks: secret detection with format checks; useful on the rebuilt code.
  • Admin routes and hidden endpoints → test whether the API enforces access control: IDOR, APIs.
  • Parameters the form doesn’t send → mass assignment.
  • Internal or staging hosts → SSRF targets or less-protected environments (always within scope).
  • Keys with real permissions (cloud provider, payment gateway, third-party services) → direct access to data or resources.
  • Requests for .map files from outside the organisation.
  • Direct hits on API endpoints that the legitimate front end never calls in that order or without the preceding navigation.
  • Service keys used from origins or IPs that don’t match the application.
  • Web server or CDN logs (.map paths, _buildManifest.js, chunks).
  • Secret scanning in the CI pipeline over the source code and over the generated bundle.
  • Provider dashboards (cloud, payments) showing usage for each key.
  1. Don’t publish source maps in production, or generate them as hidden and serve them only to internal error tooling.
  2. No secrets in client code: only keys designed to be public, with minimal permissions and restricted by domain.
  3. Server-side authorisation for every endpoint, even if the front end doesn’t show the option.
  4. Secret scanning in CI that blocks the deployment. See secrets management.
  5. Strip unreleased routes and features from the bundle, or protect them with feature flags evaluated on the server.

If a secret has been published: rotate it immediately (removing it from the bundle isn’t enough; it’s already in caches and historical archives), review that key’s usage logs for the exposure window, and pull the source map if there was one.

  • CWE-540 (Inclusion of Sensitive Information in Source Code) and CWE-200 describe the class of flaw: sensitive information reachable because it ships with the code.
  • A common pattern in bug bounty programmes: third-party secret keys embedded in production bundles, published source maps revealing internal routes, and admin endpoints found in on-demand chunks. Public HackerOne reports contain many examples of each.
  • Collected every bundle and chunk by browsing through the proxy and with a crawler.
  • Extracted routes, endpoints and parameters, and compared them with what the front end uses.
  • Looked for sourceMappingURL and checked whether the .map files are served.
  • Reviewed framework manifests (_buildManifest.js, router routes).
  • Searched for secrets and told publishable keys apart from secret ones.
  • Decoded encoded strings and searched for endpoints built in pieces.
  • Tested hidden endpoints directly, with an unprivileged user.