JavaScript Analysis

Collecting, de-minifying and mining a target’s client-side JavaScript (live, archived and lazy-loaded chunks, plus any leaked source maps) for routes, parameters, hosts, client-side checks, crypto keys and secrets the HTML never shows.

How it works

SPAs ship routing, API calls and validation logic to the browser, so the bundle usually knows about more of the app than the UI shows. Look for:

  • Endpoints and API routes (/api/v2/users/export, /internal/report), WebSocket endpoints, old API versions.
  • Hosts missed by Subdomain Enumeration, plus cloud identifiers such as S3 bucket names.
  • Parameter names the app accepts but doesn’t advertise.
  • Client-side checks (isAdmin, role, debug). Test whether the server enforces them too.
  • Comments, TODOs and feature flags for unreleased functionality.
  • Secrets and keys (front-end keys are often public and domain-restricted, so verify before reporting).

Sources: Suvendu Dash: JS recon, as93, YesWeHack.

Techniques / payloads

1. Collect: live and historical

echo https://target.example | katana -jc -d 3 -o katana.txt
grep -iE '\.js(\?|$)' katana.txt | sort -u > js-live.txt
echo target.example | gau | grep -iE '\.js(\?|$)' | sort -u > js-old.txt
cat js-live.txt js-old.txt | sort -u | httpx -mc 200 -content-length -o js-reachable.txt

Large files are the app bundles worth reading; small ones are usually vendor libraries. Archived JS often references endpoints the UI dropped but the server still serves (Suvendu Dash). Pipeline variants include subfinder → live check → waybackurls → grep .js → nuclei (LuffySec Automation-JS-Recon) and subfinder → httpx → katana -list + waybackurls → grep .js (Nuclei key exposure).

2. Extract endpoints

python3 linkfinder.py -i https://t/static/app.js -o cli
while read u; do python3 linkfinder.py -i "$u" -o cli; done < js-reachable.txt | sort -u > endpoints.txt
cat endpoints.txt | httpx -mc 200,201,301,302,401,403 -o endpoints-live.txt   # 401/403 = route exists
  • In the browser: Renniepak’s bookmarklet fetches every <script src> and regex-matches quoted /paths into a set (YesWeHack).
  • In Burp: JSLinkFinder, GAP (endpoints plus interesting values) and JSpector (YesWeHack). JSReconduit passively writes every JS response from Burp to disk, with optional beautify and source-map capture, lazy-chunk discovery (JSRECONDUIT_ENABLE_CHUNK_DISCOVERY=1; active fetch is off by default, capped by CHUNK_FETCH_LIMIT=40) and an in-scope-only switch. A VSCode extension then does AST analysis for routes, drift, clusters and dataflow traces (JSReconduit).
  • Manual grep after prettifying: fetch(, axios, /api, /admin, /internal, role, isAdmin, debug. Also run grep -rE '(api_key|apikey|secret|password|token|endpoint|/api/)' *.js (Suvendu Dash, as93).
  • Feed the extracted paths and params back into Content Discovery wordlists and parameter fuzzing.

3. Source maps

A //# sourceMappingURL=app.min.js.map trailer, or simply appending .map to a chunk URL, can return the original source. Extract sourcesContent with jq and the black box becomes a white box.

curl -s https://t/_next/static/chunks/app/.../page-<hash>.js.map | jq -r '.sourcesContent[]'

Next.js is fingerprinted by /_next/static/chunks/. Its fix is to disable production browser source maps in next.config.js (Frontend obfuscation via source maps, HackSmarter Casino).

4. Framework-aware crawling (lazy chunks, guarded routes)

js-recon’s lazyload enumerates framework chunks, and taintwire build -d <dir> -o graph.pg links every chunk through the webpack/Turbopack module registry into one graph. taintwire analyze -g graph.pg -q <queries> then runs Cypher-based taint rules across chunks. The next_interceptRouteNextUrl method targets Next.js intercepting routes defined under middleware-guarded paths (for example app/admin/@modal/(..)pub/[id]). Next serves them through the public source route when the request carries a Next-Url header naming the guarded path, while the middleware matcher only sees the public URL. Rules come from _buildManifest.js (__rewrites.beforeFiles), and redirecting paths are retried as /_next/data/<buildId>/<path>.json. It also distinguishes nuxt-dev/next-dev dev servers from production builds (js-recon changelog).

5. Secrets

  • nuclei -l js_files.txt -t exposures/ -o findings.txt flagged environment.js with apiKey: "sk_live_..." (Nuclei key exposure).
  • SecretFinder (python3 SecretFinder.py -i <js> -o cli) matches patterns, not confirmed keys. Prove access with the smallest possible test, and never test against out-of-scope third parties (Suvendu Dash).
  • Validation and triage are covered in Secret Scanning and Hardcoded Secrets.

6. Monitoring and automation

  • robre/jsmon: URLs listed in targets/ are fetched on cron (@daily /path/to/jsmon.sh) and stored by md5 prefix. Any change triggers a Telegram or Slack diff notification (robre/jsmon).
  • Jsmon (SaaS) Burp extension: auto-sends JS from HTTP history (set scope or it burns uploadUrl API quota). Findings appear under JS Intelligence and Keys & Secrets, with scheduled change monitoring (Jsmon Burp extension).
  • JSFScan.sh: -l gathers links (hakrawler -js -depth 2 -scope subs), -e endpoints, -s secrets, -m local copies, plus a wordlist from JS, variable names for XSS, DOM XSS scanning and an HTML report (JSFScan.sh).
  • Rerun and diff on every release, because new bundles mean new endpoints (Suvendu Dash).

Notable cases

  • Client-side crypto key → WAF-bypassing DOM XSS. A login bundle rendered t.msg through React dangerouslySetInnerHTML, guarded only by a tag denylist regex (script|form|iframe|…|svg|input|…). <details open ontoggle=...> passed the regex but the WAF blocked it. The same bundle AES-encrypted parameter names and values (CryptoJS, key hard-coded as i="sWaPV...", Base64→hex). Encrypting the payload client-side with that key sent an opaque hex blob past the WAF (reported as a duplicate) (0xGh4zy). See DOM-Based XSS and XSS Filter Bypasses.
  • Next.js .map → full backend blueprint. The target sat behind Cloudflare WAF and reCAPTCHA v3. Appending .map to a chunk returned 81 KB of source. That exposed a headless WordPress + WPGraphQL backend (via AcfMediaItemConnectionEdge from ~/__generated__/graphql), the exact /api/submitForm JSON schema, and the Zod env schema naming SENDGRID_API_KEY, NEXT_AWS_SECRET_ACCESS_KEY and RECAPTCHA_SECRET_KEY. A Mapbox token was correctly domain-restricted (InfoSec Write-ups).
  • Source map → hidden API → SSTI → root (lab). app.min.js.map leaked fetch('/api/v1/rooms/status?status=occupied'), which dumped 100 room-number/last-name pairs, i.e. valid logins. A profile field rendered via render_template_string gave Jinja2 RCE (HackSmarter Casino). See Jinja2 SSTI.
  • Bundle-held allow-list → SSRF (High, paid). A calendar bundle shipped the webhook destination allow-list (chat: ["*.chat.target.com/hooks/", "chat.*/hooks/"]); a hostname matching the wildcard but resolving to an OOB listener received the reminder POST. Source maps were 403 platform-wide and a secrets grep over 30+ bundles found nothing; the validation logic was the payload (six-day engagement).

Defenses

  • Don’t ship source maps to production, or restrict them to authenticated or internal origins.
  • No secrets or symmetric keys in the bundle. Client-side “encryption” with an embedded key is only obfuscation.
  • Enforce every role or feature check server-side, and don’t expose admin routes or guarded paths through framework routing quirks (Next.js intercepting routes plus middleware matchers).

Sources