RGoogle Cloud playbook · Data and storage
Storage exposed or data exfiltrated
An attacker grants allUsers or allAuthenticatedUsers access to a bucket, or downloads objects in bulk with a stolen identity. Signed URLs grant access to anyone with the link until they expire. Block public access first, then establish who read what.
Look here
| Log | Search for |
|---|---|
| Admin Activity audit log | Public grants: gcloud logging read 'protoPayload.methodName="storage.setIamPermissions" AND ("allUsers" OR "allAuthenticatedUsers")' --project=<project> --freshness=30d |
| Admin Activity audit log | Bucket changes and new buckets in the window: storage.buckets.update, storage.buckets.create |
| Data Access audit log for Cloud Storage (only if enabled) | Bulk reads, grouped by principalEmail and callerIp: gcloud logging read 'protoPayload.methodName="storage.objects.get" AND protoPayload.resourceName:"buckets/<bucket>"' --project=<project> --freshness=30d |
| Cloud Storage usage logs | Every request to objects while they were public, anonymous or authenticated. Audit logs record none of them |
| Hash-based message authentication code (HMAC) keys | Keys created in the window: gcloud storage hmac list |
Contain
| # | Item |
|---|---|
| 1 | Enforce public access prevention, which overrides existing public grants: gcloud storage buckets update gs://<bucket> --public-access-prevention |
| 2 | Remove each public binding. Repeat for allAuthenticatedUsers: gcloud storage buckets remove-iam-policy-binding gs://<bucket> --member=allUsers --role=<role> |
| 3 | Deactivate suspect HMAC keys: gcloud storage hmac update <access-id> --deactivate |
| 4 | Invalidate signed URLs by deleting the signing service account key or HMAC key destructive, or by removing the signer's storage permissions. For URLs signed with signBlob, remove the signing service account's storage permissions |
| 5 | Contain the identity that downloaded the data, following credential leak or workload credentials |
| 6 | Test from an unauthenticated client. A 401 or 403 answer means the object is closed: curl -I https://storage.googleapis.com/<bucket>/<object> |
Eradicate and recover
| # | Item |
|---|---|
| 1 | Enforce storage.publicAccessPrevention at the organization. The policy file sets enforce: true: gcloud org-policies set-policy <file> |
| 2 | Delete deactivated HMAC keys after evidence is recorded destructive: gcloud storage hmac delete <access-id> |
| 3 | Enable Data Access audit logs for storage.googleapis.com on sensitive projects |
| 4 | Enable usage logs on any bucket that must stay public |
| 5 | List exposed objects and exposure times for the Legal advisor and the notification decision |
Watch out
- Public access prevention does not block signed URLs, which can last up to 7 days.
- With no usage logs, nothing records who read a public object. Assume every exposed object was read.