PIVTR-D
RGoogle Cloud playbook · Network and edge

Dangling DNS and subdomain takeover

An attacker takes over a hostname whose Cloud DNS record still points at a deleted bucket, a released IP address, or a Cloud Run or App Engine domain you no longer map. The attacker serves content from your subdomain, harvests cookies scoped to the parent domain, and passes OAuth and cross-origin resource sharing (CORS) allowlists that trust the name. Remove the record and pull the name from allowlists first.

Look here

LogSearch for
Cloud DNS recordsRecords that point at a Google-hosted target: c.storage.googleapis.com, ghs.googlehosted.com or an IP address. List each public zone: gcloud dns record-sets list --zone=<zone> --filter="type=(CNAME OR A OR AAAA)" --format='table(name,type,ttl,rrdatas)'
Cloud Asset InventoryEvery managed zone across the organization: gcloud asset search-all-resources --scope=organizations/<org-id> --asset-types=dns.googleapis.com/ManagedZone --format='table(name,project)'
Cloud Asset InventoryTargets to compare against, as asset types storage.googleapis.com/Bucket, run.googleapis.com/DomainMapping and compute.googleapis.com/Address. App Engine domain mappings are not an asset type, so list them per project: gcloud app domain-mappings list --project=<project>
Storage takeover checkWhether the bucket a record names still exists. For a record <host>. CNAME c.storage.googleapis.com., the bucket is named <host>. Not found means the bucket is dangling, and access denied means another project owns the name: gcloud storage buckets describe gs://<host>
Storage takeover checkThe same test as a permission check, which returns 403 when another project owns the name: gcloud storage buckets get-iam-policy gs://<host>
Domain mappingsNames mapped to fully managed Cloud Run in each project, which needs the beta command. A ghs.googlehosted.com record with no Cloud Run or App Engine mapping in any project of yours is dangling. gcloud domains list-user-verified lists domains verified for the signed-in account: gcloud beta run domain-mappings list --region=<region>
Address inventoryYour addresses that match each A record, per project: gcloud compute addresses list --project=<project> --filter="address=<ip>"
Address inventoryThe same match across the organization. An IP that none of your resources uses is dangling: gcloud asset search-all-resources --scope=organizations/<org-id> --asset-types=compute.googleapis.com/Address --query='<ip>'
Admin Activity audit log (dns.googleapis.com)Record changes and zone deletions. Match the deletion time of the resource to the record's age: dns.changes.create, dns.resourceRecordSets.create, dns.resourceRecordSets.delete, dns.resourceRecordSets.patch, dns.managedZones.delete
Traffic logsReferences to a deleted bucket, seen as repeated 404 Not Found for storage URLs in Cloud Logging. Request logs on the old backend show clients still resolving the name
What the hostname servesWhat the name serves now, and certificates issued to it that you did not request, from certificate transparency logs: dig +short CNAME <host>, curl -sI https://<host>

Contain

#Item
1Save the zone's records to a case file, with the dig and curl -s output for the hostname and a screenshot of what it serves. The saved JSON recreates any record you remove: gcloud dns record-sets list --zone=<zone> --format=json
2Remove the dangling record. Resolvers keep the old answer until the record's time to live (TTL) expires, so read the ttl value and plan for that delay: gcloud dns record-sets delete <host>. --type=<type> --zone=<zone>
3Remove the hostname from OAuth redirect URI lists, CORS allowed origins, Content Security Policy (CSP) source lists and identity provider callback settings until you control it again
4Invalidate sessions and rotate any secret a browser could have sent to the name. Cookies scoped to the parent domain reach every subdomain
5Reclaim a deleted bucket name only if you are an authorized owner of the domain. Keep the bucket empty and private: gcloud storage buckets create gs://<host> --project=<project> --uniform-bucket-level-access --public-access-prevention
6Open a Google Cloud support case that names the taken-over bucket, address or mapping, and the hostname it serves

Eradicate and recover

#Item
1Sweep every public zone with the record listing above and test each target. Include NS records that delegate a subdomain to Cloud DNS name servers for a zone that dns.managedZones.delete removed
2Delete stale Cloud Run domain mappings destructive: gcloud beta run domain-mappings delete --domain=<host> --region=<region>
3Delete stale App Engine domain mappings destructive: gcloud app domain-mappings delete <host>
4Remove former employees, contractors and vendors as verified owners of the domain in Search Console. Domain verification belongs to each user's account
5Ask the issuing certificate authority (CA) to revoke certificates for the hostname that you did not request
6Add a CAA record that names the CAs you use: gcloud dns record-sets create <domain>. --type=CAA --ttl=300 --rrdatas='0 issue "<ca-domain>"' --zone=<zone>
7Move production A records to reserved addresses. Use --region=<region> for a regional address, and release an address only after its DNS record is gone: gcloud compute addresses create <name> --global
8Search code, mobile apps and documentation for gs://<bucket>, storage.googleapis.com/<bucket> and <bucket>.storage.googleapis.com, and remove references to buckets that no longer exist
9Decommission in this order: remove the DNS record, wait at least a week and read the logs for remaining traffic, then delete the bucket, mapping or address
10Alert on dns.changes.create in Admin Activity logs for public zones and review each change against a ticket
Watch out
  • Cloud Asset Inventory does not cover every target. ResourceRecordSet and DomainMapping are unavailable in the analysis APIs, GlobalAddress is missing from search, and App Engine domain mappings are not an asset type. Search is synchronous and consumes quota on large inventories.
  • A bucket that answers access denied belongs to someone else now. You cannot recover the name, so remove the record and every reference to it.
  • Creating a domain-named bucket needs domain ownership verified through Search Console. Owners, delegated owners and verified site owners qualify, so a former delegate can still recreate the name.
  • A takeover lasts as long as the TTL on cached answers after you delete the record. Keep the session and origin changes in place until that time has passed.

Google Cloud documentation: Cloud DNS audit logging, records and best practices; gcloud dns record-sets list and delete, gcloud dns managed-zones list; Cloud Asset Inventory supported asset types and searching resources; domain-named bucket verification; gcloud storage buckets create; Cloud Run custom domain mapping; App Engine custom domain mapping; Google Cloud Blog, best practices to prevent dangling bucket takeovers. Checked September 2026. Re-checked October 2026: gcloud reference for run domain-mappings list (the GA command covers Cloud Run for Anthos; fully managed Cloud Run needs gcloud beta run domain-mappings).

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.