How I Earned $0 for a Google Cloud Takeover via a Leaked Service Account Private Key
A Google Cloud service account private key and client email were hardcoded in frontend JavaScript files. An attacker could use these credentials to authenticate to Google Cloud and enumerate projects, IAM policies, and resources, potentially accessing sensitive data.
infosecwriteups.com
Published on infosecwriteups.com
This is a practical guide you may find useful if you ever come across a Google Cloud service account private key during web application testing or bug bounty program.
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, the developers embedded a service account private key and client email directly in client-side JavaScript, making them publicly accessible.
Impact
The attacker could enumerate Google Cloud projects, IAM roles, and resources, and potentially access or modify data depending on the service account's permissions; the issue was fixed after responsible disclosure.
What the attacker needed
Access to the target's JavaScript files; no authentication needed
The fix
The issue was fixed after being reported responsibly; the fix likely involved removing the hardcoded credentials from the JavaScript files.
How it was found
- Analyse JavaScript files of the target to find hardcoded credentials.
- Verify the private key format using OpenSSL.
- Install the Google Cloud SDK and initialise it.
- Create a JSON credentials file with the client email and private key.
- Activate the service account with gcloud auth activate-service-account.
- List projects and IAM policies to enumerate permissions and resources.
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 service account is like a robot user for programs, and its private key is a password. If that key is left in a website's code, anyone can pick it up and act as that robot, possibly reading or changing cloud data.
What is Leaked secrets?
Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.