Skip to content
Leaked secrets Write-up Beginner

Token Tales: Finding Hidden API Keys in JavaScript and Turning Them Into Gold

A hardcoded API key was found in a client-side JavaScript file. The key granted admin-level access to an API endpoint, allowing retrieval of sensitive user data.

infosecwriteups.com

Published on infosecwriteups.com

Free link 🎈

Iski, on infosecwriteups.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

Impact

The exposed key allowed admin-level access to an API endpoint, which returned sensitive user data.

What the attacker needed

None

The fix

The report says the issue was patched immediately; the recommended fix is to move secrets to the backend, use environment variables, rotate keys, and apply least privilege.

How it was found

  1. Enumerate subdomains and live hosts, then collect JavaScript files.
  2. Download suspicious scripts and search for keywords like api_key, token, secret.
  3. Use browser DevTools to find the key in a JavaScript file.
  4. Send a request with the key in the Authorization header to an admin API endpoint.
  5. Observe that sensitive user data is returned.

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.

A secret key was left inside a website's JavaScript file, which anyone can download. The key let the finder access an admin part of the site and see private user information.

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.