Subdomain takeover: dangling DNS records and how to find yours first
How a CNAME or NS record left pointing at a deleted cloud resource lets someone else claim it and serve content on your subdomain, how to inventory your DNS for dangling records, and how to clean up for good.
Diagram
From a deleted resource to someone else’s page
Step 1 of 4
Record
promo.example.org is a CNAME to a cloud hosting resource.
promo.example.org. 300 IN CNAME promo-site.azurewebsites.net.
The example on the open step is one illustration, or the fix you can paste into an application you own.
What this page is made of
3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.
Same-origin trust
- What fails
- Content on your subdomain inherits cookies scoped to the parent domain and your users’ trust.
- Who is affected
- Users whose parent-domain cookies are sent to the subdomain.
- What you would notice
- Session cookies scoped to .example.org.
- What you change
- Scope cookies to exact hosts and clean DNS.
Inventory drift
- What fails
- Marketing and test sites come and go faster than DNS is reviewed.
- Who is affected
- The brand and the users who visit.
- What you would notice
- CNAMEs to cloud services that return provider error pages.
- What you change
- Tie DNS records to infrastructure-as-code so deleting a resource deletes its record.
NS and MX too
- What fails
- Delegated zones and mail records can also dangle.
- Who is affected
- Mail recipients and the delegated zone.
- What you would notice
- NS records pointing at a deleted hosted zone.
- What you change
- Include NS and MX in the dangling-record check.
Discovering your subdomains
Export your zones from your DNS provider; that is the authoritative list. Certificate Transparency logs and passive DNS tools such as subfinder and amass show names the public has seen, which catches records in zones you forgot about. Only test names in your own zones.
$ subfinder -d example.org -silent | sort -u > seen.txt $ comm -13 <(sort our-zone-export.txt) seen.txt legacy-promo.example.org <- seen publicly, missing from our export: investigate
Recognizing a dangling target
Provider error pages such as “NoSuchBucket”, “There isn’t a GitHub Pages site here”, or a default app-service page on your subdomain indicate the target is unclaimed. Public lists of provider fingerprints help, and nuclei has takeover templates for your own domains.
Cleaning up
Delete the record, or reclaim the resource temporarily while you remove it. Then add the check to your deprovisioning runbook and run the dangling check on a schedule.
Check yourself
Recognition and the fix. Nothing here is a procedure.
A CNAME points at a deleted cloud storage website. What is the risk?
Sibling techniques
Pages at the same depth, plus a lab and a glossary card for this one.