Exposed private key leads to Google cloud service account takeover — Privilege Escalation
A Google Cloud service account private key was exposed in a publicly accessible JavaScript file. An attacker with the key could authenticate as the service account and view, modify, or delete cloud resources depending on its permissions.
An attacker with access to a private key associated with a Google Cloud service account can gain full control over the account and its resources.
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, sensitive service account credentials were hardcoded into a client-side JavaScript file that was publicly accessible.
Impact
An attacker could gain complete control over the service account, including viewing and managing roles, modifying permissions, and accessing sensitive data, depending on the account's permissions.
What the attacker needed
Publicly accessible JavaScript file; exposed service account key; Google Cloud SDK installed
The fix
Sensitive credentials should not be embedded in client-side code; they should be stored in a secret manager and accessed server-side.
How it was found
- Find an exposed Google Cloud private key in a JavaScript file during recon.
- Save the service account information as a JSON key file.
- Activate the service account using the gcloud command with the key file.
- Verify authentication and list accessible projects.
- List IAM roles to see available permissions.
- Describe a specific role to view its details.
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 that lets anyone act as that robot. Here, the key was left in a JavaScript file that anyone could download, so a stranger could use it to log in to the cloud account and change things.
What is Leaked secrets?
Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.