RGoogle Cloud playbook · Compute and containers
Resource hijacking
An attacker with compute permissions creates VMs, often with GPUs, in regions the organization does not use, and may request quota increases to run more. Your project pays for every hour they run. Stop the instances and contain the identity that created them, keeping one boot disk per build as evidence.
Look here
| Log | Search for |
|---|---|
| Admin Activity audit log | Instance creation, logged as v1.compute.instances.insert and beta.compute.instances.insert, by principal: gcloud logging read 'protoPayload.methodName:"compute.instances.insert"' --project=<project> --freshness=30d --format='table(timestamp,protoPayload.authenticationInfo.principalEmail,protoPayload.resourceName)' |
Admin Activity audit log (cloudquotas.googleapis.com) | Quota increase requests: google.api.cloudquotas.v1.CloudQuotas.CreateQuotaPreference, google.api.cloudquotas.v1.CloudQuotas.UpdateQuotaPreference |
| Admin Activity audit log, instance groups | Managed instance groups and templates created in the window. A managed instance group recreates instances you stop or delete: gcloud logging read 'protoPayload.methodName:"instanceGroupManagers.insert" OR protoPayload.methodName:"instanceTemplates.insert"' --project=<project> --freshness=30d |
| Inventory | Instances in each project, with zone, machine type and creation time: gcloud compute instances list --project=<project> --format='table(name,zone,machineType,status,creationTimestamp)' |
| Inventory | Managed instance groups in each project: gcloud compute instance-groups managed list --project=<project> |
| Billing | Cost by SKU and region for the window, from the billing reports or the billing export to BigQuery |
| Security Command Center | Mining and mass creation findings: Execution: Cryptocurrency Mining Hash Match Execution: Cryptocurrency Mining YARA Rule Impact: GPU Instance Created, Impact: Many Instances Created |
Contain
| # | Item |
|---|---|
| 1 | Snapshot the boot disk of one instance per build as evidence: gcloud compute disks snapshot <disk> --zone=<zone> --snapshot-names=<case-id>-<disk> |
| 2 | Resize attacker managed instance groups to zero. Use --region=<region> for a regional group: gcloud compute instance-groups managed resize <mig> --size=0 --zone=<zone> |
| 3 | Stop the remaining instances: gcloud compute instances stop <vm> --zone=<zone> |
| 4 | Contain the identity that created them, following credential leak, account takeover or workload credentials |
| 5 | Restrict new resources to approved regions. The policy file sets constraints/gcp.resourceLocations: gcloud org-policies set-policy <file> |
Eradicate and recover
| # | Item |
|---|---|
| 1 | Delete the instances once evidence is kept destructive. Boot disks auto-delete by default: gcloud compute instances delete <vm> --zone=<zone> |
| 2 | Sweep every zone for instances, instance templates and managed instance groups created in the window |
| 3 | Review quota preferences created in the window and lower them |
| 4 | Set billing budgets with alerts on each project |
| 5 | Send the cost record to Finance/Admin |
Watch out
gcp.resourceLocationsapplies only to new resources. Instances already running in a denied region keep running.- A managed instance group recreates instances that you stop or delete. Resize the group to zero first.
- Stopped instances still bill for persistent disks and reserved static addresses.