Skip to content
Leaked secrets Write-up Beginner

How I Discovered Sensitive API Keys & Auth Tokens in Public JavaScript Files — A Recon Journey

Sensitive API keys, authentication tokens, auth IDs and author names were exposed in publicly accessible JavaScript files on the target domain. An attacker who viewed or analysed those files could obtain the credentials and potentially gain unauthorised API access or account takeover.

kingstar75114 Follow

Published on medium.com

Hey folks! This is TehanG07 here, and today I’m going to walk you through a real-world bug bounty scenario where I discovered highly sensitive information such as API keys, auth tokens, auth IDs, and author names publicly exposed in.js(JavaScript) files on the domain xyz.com.

TehanG07, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely hardcoded secrets and configuration values were included in client-side JavaScript files that are served publicly.

Impact

Exposing credentials or tokens could lead to unauthorised API access, business logic manipulation, sensitive user data exposure, and full account takeover in some cases.

What the attacker needed

Publicly accessible JavaScript files; Secrets hardcoded in those files

The fix

The team responded promptly and took action to revoke/rotate the credentials and clean up their code.

How it was found

  1. Collect archived URLs for the target domain using waybackurls.
  2. Filter the collected URLs to keep only JavaScript file URLs.
  3. Download each JavaScript file and search for patterns such as apiKey, token, auth, authorization, email, user and password.
  4. Review the output for sensitive values and embedded API endpoints.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Websites often load JavaScript files that contain configuration and sometimes secret values. If those files are public, anyone can read them. Here, secrets like an API key (a password-like string for a service) and an auth token (a temporary proof of identity) were left in those files, so anyone could copy them and use them to access the service.

What is Leaked secrets?

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.

Similar reports

View all

Same bug class and techniques, clearest first.

Leaked secrets and credentials

The lesson behind this report.

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.