Secrets in Plain Sight: How I Found a Hardcoded API Key in a Public JS File
A publicly exposed JavaScript file contained a hardcoded client secret and a fallback secret key. An attacker could use the leaked credentials to call backend APIs within the granted scope, though the finding was closed as a duplicate.
Published on medium.com
I’m Bassem (AKA. satan11), a bug bounty hunter and aspiring penetration tester. I publish real-world writeups to help others learn from the bugs I find in live programs.
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 secrets such as a client secret and a fallback key were embedded directly in client-side JavaScript instead of being kept on the server.
Impact
Leaked credentials could let an attacker call backend or third-party APIs within the granted scope, potentially exposing data or causing cost and availability problems; the report was ultimately marked a duplicate.
What the attacker needed
Access to the public site; none
The fix
Secrets should be removed from client-side files and kept server-side, with any exposed keys rotated.
How it was found
- Browse the application and map endpoints and public assets such as JavaScript bundles.
- Search the captured traffic for credential-like strings.
- Find a JavaScript file containing a client secret and a fallback secret key.
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 send JavaScript files to every visitor's browser, so anything inside them is public. This file contained a password-like value (a secret) that the site uses to talk to its own backend services. Anyone who reads the file can copy that secret and pretend to be the application.
What is Leaked secrets?
Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.