Human identity vs service-account identity: which one gets breached, and how
Google Cloud has two kinds of identity, and they fail in different ways. Understanding the difference is the whole subject, because the fix for one does nothing for the other.
| Identity type | How it gets stolen | What the attacker gains | The fix that matters most |
|---|---|---|---|
| Human user — a person with a Google account | Phishing, password reuse, a stolen session token | Whatever that person's roles allow, across every project they can reach | Phishing-resistant MFA and conditional access; remove standing admin roles |
| Service account — a machine identity for apps and automation | Leaked key file, key committed to a repository, over-broad role | Whatever the service account's role allows, often broad and rarely reviewed | Short-lived credentials or workload identity; least-privilege roles; key rotation |
| API key / OAuth token — a credential for a specific service | Left in client-side code, logs, or a shared document | Access to the one API it opens, sometimes with billing attached | Restrict the key by API and by referrer or IP; rotate on a schedule |
The uncomfortable truth is that service accounts cause the worse breaches. A human account is watched: the person notices odd sign-ins, the security team sees a new location. A service account runs in the background, its key may not have been touched by a human in years, and its role is often far broader than the job it does — because when the service was first set up, giving it the Editor role was the easiest way to make it work, and nobody ever came back to tighten it.
Where GCP identities are used — and where they leak
CI/CD pipelines
Build systems need a Google Cloud identity to deploy. Keys stored as pipeline variables or in configuration files are copied, screenshotted, and committed by mistake more often than anyone admits. A key that can deploy can usually also read storage and create machines.
Local development
Developers download a key file to test against the real project, then forget it on a laptop, in a backup, or in a dotfiles repository. The key outlives the task it was created for, and its permissions outlive the developer's memory of what it can do.
Third-party tools
Monitoring, backup, and migration tools ask for a service account with broad read access. Each one is a new copy of a powerful credential held by someone else's system, and each one needs reviewing when the tool is no longer used.
Shared projects
In a project shared by several teams, roles accumulate. Someone who needed access for a week in 2024 still has it, and a service account created for a retired experiment still holds its role. Unused access is the attacker's favourite kind: nobody notices when it is used.
How the breach unfolds, step by step
First comes discovery. Automated scanners constantly search public code repositories, paste sites, and misconfigured storage buckets for Google Cloud keys. A key is a long string with a recognisable shape, and finding one takes seconds. The attacker does not need to know whose it is yet — they test it, see which project it opens, and check what the attached role allows.
Second comes the quiet phase. With a valid identity, the attacker behaves like a legitimate service: listing buckets, reading configurations, checking which APIs are enabled. This looks normal in the logs, because from Google's point of view it is a valid credential doing valid things. The giveaway is usually the pattern — access at an odd hour, from an unusual network, to resources the service account has never touched before.
Third comes the use. The two most common goals are theft and compute. Theft means copying data out of storage or databases, often slowly enough to avoid tripping alarms. Compute means spinning up machines to mine cryptocurrency, which shows up as a billing spike before anything else. A third goal, rarer but more damaging, is persistence: creating a new service account or granting extra roles so the access survives the original key being revoked.
Fourth comes the cover-up, which is often crude: deleting log entries where the role allows it, or simply moving fast enough that discovery does not matter. This is why the audit logs should be stored where the breached identity cannot reach them — in a separate project with its own access controls. If the attacker can delete the evidence of their own visit, the investigation starts blind.
The fixes that close the door
The single most effective change is to stop using long-lived service-account keys where they are not needed. Google's workload identity federation lets a workload prove who it is without a stored key at all, and short-lived credentials expire before a leaked copy can be used for long. Where a key is genuinely required, rotate it on a schedule and keep an inventory of every key in existence, including the ones created for a one-off task two years ago.
The second change is least privilege, applied properly. Google's IAM recommender will tell you which permissions a service account has never used; removing them is unglamorous work, but it is the work that turns a leaked key from a catastrophe into a footnote. Custom roles that grant exactly the permissions a job needs are better than the broad predefined roles, and they are worth the effort for any account that touches customer data or billing.
The third change is organisational: treat the IAM policy like code. Review it on a schedule, require approval for role grants, and use organisation policies to block the riskiest configurations — such as public storage buckets or the creation of external service-account keys — by default. A policy that prevents the dangerous configuration is worth more than a hundred alerts about it after the fact.
Frequently asked questions
What is the most common cause of a Google Cloud identity breach?
A leaked service-account key or an over-broad IAM role. Service-account keys are long-lived credentials that get copied into code, committed to repositories, or left in old scripts, and once one leaks, anyone who finds it can act as that service account. Roles that grant far more than the job needs turn a small leak into a large one.
Does Google Cloud's security protect me automatically?
Google protects its own infrastructure, but your project's configuration is your responsibility. Google's shared-responsibility model means Google secures the cloud itself while you secure what you put in it: who can access your project, what roles they hold, and whether your keys and credentials are exposed.
How do I find out if a service-account key has leaked?
Check the Cloud Audit Logs for activity that does not match the service account's normal job, review where keys are stored and who has seen them, and use Google's Security Command Center or the IAM recommender to spot unused or over-broad permissions. If a key has ever appeared in a public repository or a shared document, treat it as compromised and rotate it.
What should I do first after a Google Cloud identity breach?
Revoke the compromised credential immediately, then look at what it touched. Disable or rotate the affected service-account key, remove any roles or permissions the attacker added, and review the audit logs for the period the credential was live. Only after the access is closed should you rebuild the permissions with least privilege.
Keep your real inbox out of the phishing lists
Cloud breaches often start with a phishing email aimed at an admin. Use a free disposable address for low-trust GCP signups, and keep your real address for the admin and billing accounts that matter.
Get a free temp mail address