PIVTR-D
RGoogle Cloud playbook · Identity and access

Leaked service account key used to change permissions

An attacker authenticates with a leaked user-managed service account key, then grants roles and creates new keys or service accounts to keep access. Every Admin Activity entry made with that key carries the key's name. Disable the key and the service account first, then remove what the attacker added.

Look here

LogSearch for
Admin Activity audit logCalls made with the key: gcloud logging read 'protoPayload.authenticationInfo.serviceAccountKeyName:"<key-id>"' --project=<project> --freshness=30d
Admin Activity audit logRole grants. SetIamPolicy on projects, folders and the organization grants roles. On service accounts, this method grants rights to impersonate them: google.iam.admin.v1.SetIAMPolicy
Admin Activity audit logNew keys and service accounts, and disabled ones turned back on: google.iam.admin.v1.CreateServiceAccountKey, google.iam.admin.v1.UploadServiceAccountKey, google.iam.admin.v1.CreateServiceAccount, google.iam.admin.v1.EnableServiceAccountKey, google.iam.admin.v1.EnableServiceAccount
Data Access audit log for iamcredentials.googleapis.com (only if enabled)Tokens the service account minted for other service accounts, where the caller is the service account: protoPayload.serviceName="iamcredentials.googleapis.com" AND protoPayload.methodName=("GenerateAccessToken" OR "SignJwt" OR "SignBlob" OR "GenerateIdToken")
Any audit log entry made through impersonationThe principal at the start of an impersonation chain: protoPayload.authenticationInfo.serviceAccountDelegationInfo.firstPartyPrincipal.principalEmail
Security Command CenterKey and grant findings: Initial Access: Leaked Service Account Key Used Account has leaked credentials, Persistence: IAM Anomalous Grant, Persistence: Service Account Key Created Discovery: Service Account Self-Investigation

Contain

#Item
1Disable the leaked key: gcloud iam service-accounts keys disable <key-id> --iam-account=<sa-email>
2Disable the service account to block tokens already minted from the key. Workloads using it stop: gcloud iam service-accounts disable <sa-email>
3List user-managed keys on each affected account, and disable the ones created in the window: gcloud iam service-accounts keys list --iam-account=<sa-email> --managed-by=user
4Disable service accounts the attacker created with gcloud iam service-accounts disable
5Remove bindings the attacker added: gcloud projects remove-iam-policy-binding <project> --member='<type>:<member>' --role=<role> --all

Eradicate and recover

#Item
1Deploy a new credential for the workload, record the evidence, then delete the leaked key destructive: gcloud iam service-accounts keys delete <key-id> --iam-account=<sa-email>
2Re-enable the service account at least 60 minutes after disabling it: gcloud iam service-accounts enable <sa-email>
3Compare organization, folder and project IAM policies against baseline and restore the previous version
4Block new service account keys wherever keys are not required. The legacy form of this constraint is iam.disableServiceAccountKeyCreation: iam.managed.disableServiceAccountKeyCreation
5Confirm iam.serviceAccountKeyExposureResponse is not set to WAIT_FOR_ABUSE. DISABLE_KEY, which disables keys Google finds exposed, has been the default since June 2024
Watch out
  • Disabling a key leaves short-lived tokens issued from it valid until they expire: 60 minutes by default, up to 12 hours with an extended token lifetime policy. Disable the service account or apply an IAM deny policy to stop them.
  • Reads made with the key appear only for services with Data Access audit logs enabled. Treat data the service account could read as exposed where those logs were off.
Adapts material from Dynamic Incident Response: A Framework for Security Teams by Joshua Wright, © 2026 The Escal Institute of Advanced Technologies, Inc. d/b/a SANS Institute, licensed under CC BY 4.0. Figures reproduced under that license. Changes were made. Not published by, endorsed by, or affiliated with the SANS Institute.