An attacker with a privileged identity adds access that survives the first clean-up: service accounts, keys, IAM bindings at any level, custom roles and impersonation grants. Some also deploy a function or scheduled job that runs as a privileged account, or add SSH keys to metadata. Save the IAM policies, then disable what the attacker created before you delete anything.
Look here
Log
Search for
Admin Activity audit log, IAM
New service accounts, keys and custom roles, and service accounts turned back on: google.iam.admin.v1.CreateServiceAccount, google.iam.admin.v1.CreateServiceAccountKey, google.iam.admin.v1.UploadServiceAccountKey, google.iam.admin.v1.EnableServiceAccount, google.iam.admin.v1.CreateRole, google.iam.admin.v1.UpdateRole
Admin Activity audit log, IAM
Grants on a service account that add roles/iam.serviceAccountTokenCreator (getAccessToken, signBlob, signJwt) or roles/iam.serviceAccountUser (actAs): google.iam.admin.v1.SetIAMPolicy
Admin Activity audit log, Resource Manager
Role grants on the organization. The match ignores case. Repeat with --folder and --project: gcloud logging read 'protoPayload.serviceName="cloudresourcemanager.googleapis.com" AND protoPayload.methodName:"setIamPolicy"' --organization=<org-id> --freshness=30d
Cloud Asset Inventory
Every binding for one member: gcloud asset search-all-iam-policies --scope=organizations/<org-id> --query='policy:<member>'
Cloud Asset Inventory
Every Token Creator grant: gcloud asset search-all-iam-policies --scope=organizations/<org-id> --query='policy:roles/iam.serviceAccountTokenCreator'
Admin Activity audit log, Cloud Run functions and Cloud Scheduler
Functions and scheduled jobs created or changed to run as a privileged account: google.cloud.functions.v2.FunctionService.CreateFunction, google.cloud.functions.v2.FunctionService.UpdateFunction, google.cloud.scheduler.v1.CloudScheduler.CreateJob, google.cloud.scheduler.v1.CloudScheduler.UpdateJob
Admin Activity audit log, Compute Engine
SSH keys and startup scripts in metadata: protoPayload.methodName:"setCommonInstanceMetadata" OR protoPayload.methodName:"setMetadata"
Security Command Center (Event Threat Detection, Premium or Enterprise tier)
IAM and SSH key findings: Persistence: IAM Anomalous Grant, Persistence: Service Account Key CreatedPersistence: Project SSH Key Added, Persistence: GCE Admin Added SSH Key, Defense Evasion: Project-Level Service Account Token Creator Role AddedPrivilege Escalation: New Service Account is Owner or Editor
Contain
#
Item
1
Save IAM policies as evidence, and the same for folders and projects: gcloud organizations get-iam-policy <org-id> --format=json
2
Disable service accounts the attacker created: gcloud iam service-accounts disable <sa-email>
3
Disable keys created in the window: gcloud iam service-accounts keys disable <key-id> --iam-account=<sa-email>
4
Remove impersonation grants. Repeat for roles/iam.serviceAccountUser: gcloud iam service-accounts remove-iam-policy-binding <sa-email> --member='<type>:<member>' --role=roles/iam.serviceAccountTokenCreator --all
5
Remove bindings the attacker added at the organization. Use gcloud resource-manager folders and gcloud projects with the same flags: gcloud organizations remove-iam-policy-binding <org-id> --member='<type>:<member>' --role=<role> --all
6
Pause attacker jobs: gcloud scheduler jobs pause <job> --location=<location>
7
Record each function's runtime service account: gcloud functions describe <function> --region=<region>
8
Remove attacker SSH keys from project and instance metadata, and attacker grants of roles/compute.osLogin or roles/compute.osAdminLogin
Eradicate and recover
#
Item
1
List custom roles. Repeat with --project: gcloud iam roles list --organization=<org-id>
2
Read each custom role's permissions: gcloud iam roles describe <role-id> --organization=<org-id>
3
Delete custom roles the attacker created destructive: gcloud iam roles delete <role-id> --organization=<org-id>
4
Enable OS Login: gcloud compute project-info add-metadata --metadata=enable-oslogin=TRUE
5
Enforce compute.requireOsLogin at the organization
6
Block service account key creation where keys are not required: iam.managed.disableServiceAccountKeyCreation
7
Block service account key upload where keys are not required: iam.managed.disableServiceAccountKeyUpload
8
Re-run the Asset Inventory searches and compare policies with the saved copies
9
Delete attacker service accounts after evidence is recorded destructive. Remove their bindings first: gcloud iam service-accounts delete <sa-email>
Delete attacker scheduled jobs destructive: gcloud scheduler jobs delete <job> --location=<location>
Watch out
A Token Creator or Service Account User grant at project level covers every service account in the project. Check project and folder policies as well as each service account's own policy.
A deleted service account stays in bindings with a deleted: prefix for up to 60 days. For 30 days gcloud iam service-accounts undelete <unique-id> restores it with its roles, using the 21-digit unique ID. Remove its bindings before deletion.
Token minting with getAccessToken and signBlob appears only in Data Access logs for iamcredentials.googleapis.com. Trace chains with impersonation and delegation.
Google Cloud documentation: IAM audit logging; Resource Manager audit logging; Cloud Run functions audit logging; Cloud Scheduler audit logging; Logging query language; Roles for service account authentication; Delete and undelete service accounts; Restrict IAM service account usage; Create and manage custom roles; gcloud reference for asset, organizations, resource-manager folders, iam service-accounts, scheduler, functions and compute project-info; Restrict SSH keys from VMs; SSH login access best practices; Security Command Center IAM and Compute Engine threat findings. Checked September 2026. Re-checked October 2026: Delete and undelete service accounts (30-day undelete, bindings purged within 60 days, unique ID); gcloud reference for iam service-accounts undelete (GA).