How I Found a Google API Key Leak in a Bug Bounty Program
A Google API key was exposed in a publicly accessible JavaScript file. An attacker could use the key to access sensitive data and incur financial costs through API requests.
Published on medium.com
The original lives on medium.com
We do not hold its text, 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, the API key was hardcoded in client-side JavaScript, making it publicly accessible.
Impact
The exposed key could allow access to sensitive data and, if abused, incur significant financial costs due to API request fees.
What the attacker needed
None
The fix
The API key should be removed from client-side code and restricted or rotated.
How it was found
- Enumerate subdomains and collect URLs using tools like Katana, Waybackurls, and Gospider.
- Merge and deduplicate the collected URLs, then filter for JavaScript files.
- Scan the JavaScript files for secrets using a tool called Mantra.
- Identify the exposed Google API key by its pattern.
- Test the key's validity using a public Google API checker, which returned 200 OK and revealed sensitive data.
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 that lets programs talk to Google's services was left in a file that anyone can download from the website. If someone finds that key, they can use Google's services as if they were the company, potentially seeing private data and running up a bill.
What is Leaked secrets?
Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.