How do you find a dangling CNAME before it becomes a subdomain takeover?
A dangling CNAME still resolves in DNS but points at a cloud resource, CDN endpoint or hosting slot you've since deleted or stopped renewing, letting whoever claims that same name on the provider's side serve content from your subdomain instead; AdminKit's live DNS lookup tool shows exactly which target a CNAME currently points at, the first step in spotting one.
By AdminKit team, Netbase JSC · Updated
Key takeaways
- A dangling CNAME is an alias that still resolves to a provider hostname you no longer own. Anyone who claims that hostname at the provider can serve content on your subdomain.
- CNAME records are the most common case, but A records pointing at released cloud IPs, NS delegations to deleted zones and MX records can dangle in the same way.
- Finding them is an inventory job: export your zone, resolve every target, and treat
NXDOMAIN,SERVFAILor a provider “not found” page as a lead to chase. - Fix the order of work: remove the DNS record first, then delete the resource. Provider domain verification closes most of the gap for the records you keep.
What is a dangling CNAME?
A CNAME record, defined in RFC 1035 (also on the IETF Datatracker), makes one domain name an alias for another — resolvers look up the target name instead of returning an address directly. It’s the standard way to point a subdomain at a service you don’t control the IP address for: a custom domain pointed at a CDN, a SaaS vendor’s hosting, or a marketing platform’s tracking domain are all common cases. A CNAME goes dangling when you stop using the underlying resource — delete the storage bucket, cancel the hosting plan, decommission the CDN distribution — but never remove the CNAME record itself. The alias still resolves; it just points at something that no longer exists on the other end, or that the provider may let a different customer claim.
How does a dangling CNAME turn into a subdomain takeover?
It turns into a takeover when someone else registers the provider-side name your CNAME still points at. Many cloud platforms let customers claim a hosting slot, bucket or app name on a first-come basis. If your dangling CNAME still points old-promo.example.com at a platform’s generic endpoint for a resource you deleted, anyone who notices and re-registers that same resource name on the provider’s side can start serving their own content from old-promo.example.com — a domain that still visibly belongs to you in the browser’s address bar, with your organization’s name attached.
Major cloud providers document this exact failure mode and recommend removing the DNS record at the same time a resource is decommissioned, not after — see Microsoft’s guidance on preventing dangling DNS entries as one example. Microsoft describes the sequence in three phases, which map onto any provider with claimable names:
| Phase | What happens | State of your DNS |
|---|---|---|
| Creation | You create a resource with a provider hostname, such as promo-app.example.net, and add a CNAME from old-promo.example.com to it. | Correct: alias points at a resource you own. |
| Deprovisioning | The resource is deleted. The CNAME stays in your zone. | Dangling: alias points at a name nobody owns. |
| Takeover | Someone creates a new resource with the same provider hostname in their own account. | Hijacked: your subdomain now serves their content. |
A wildcard DNS record pointed at a shared target carries a related risk: it can silently resolve subdomains that were never explicitly provisioned, masking exactly the kind of orphaned name this check is looking for. GitHub’s documentation is blunt about it: it strongly recommends against wildcard records such as *.example.com because they put you at immediate risk of takeover, even with a verified domain.
Which DNS records can dangle besides CNAME?
Any record that delegates trust to something outside your zone can dangle. The OWASP Web Security Testing Guide covers A, CNAME, MX, NS and TXT records in its takeover tests, and singles out NS records as the highest-impact case because they can hand over control of a whole zone.
| Record | Points at | How it dangles | Who can claim it |
|---|---|---|---|
CNAME | A provider hostname | Resource deleted, CNAME left behind | Any customer who creates a resource with that hostname |
A / AAAA | A cloud IP address such as 203.0.113.40 | IP released back to the provider’s pool | Whoever is assigned that IP next |
NS | Nameservers for a delegated subdomain | Hosted zone deleted, or nameserver domain expired | Anyone who creates a zone on those nameservers, or registers the expired domain |
MX | A mail host | Mail service cancelled | Whoever claims the mail host, who then receives your mail |
NS delegations deserve special attention. AWS documents dangling delegation records in Route 53: if a hosted zone is deleted while the parent still delegates to its nameservers, those delegation records point at servers that someone else may get assigned. Route 53 blocks reuse of the same nameservers for a recreated zone with the same name, but AWS lists several other scenarios it cannot protect against, such as delegating to Route 53 nameservers before the hosted zone exists. OWASP adds the case where a nameserver’s own domain has expired and can be bought, which ties this check to domain expiry. For how delegations should look when they are healthy, see interpreting subdomain delegation and NS/glue mismatches.
What can an attacker do with a taken-over subdomain?
More than deface a page. Microsoft’s guidance lists the consequences:
- Cookie theft. Web apps often scope session cookies to the parent domain, so any subdomain can read them. A page on a hijacked subdomain can collect those cookies from visitors.
- Valid TLS certificates. Microsoft points out that the attacker can use the hijacked subdomain to apply for and receive a valid certificate, so the padlock offers no protection here.
- Phishing. A login page on
old-promo.example.comcarries your brand’s credibility. A dangling MX record extends the same risk to email sent to that subdomain.
How do you check a specific subdomain?
Look up the subdomain’s CNAME, then check whether the target itself still resolves. AdminKit’s DNS lookup tool is live and resolves the CNAME record type directly. Look up the subdomain you’re concerned about and check what it currently points at — a target on a recognizable cloud storage, CDN or app-hosting domain that you don’t believe is still in active use is the signal worth chasing down.
With dig on your own machine, query the subdomain for an address record and read both the header status and the answer section. Example output (illustrative, documentation names):
$ dig old-promo.example.com A
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 41203
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; ANSWER SECTION:
old-promo.example.com. 300 IN CNAME promo-app.example.net.
;; AUTHORITY SECTION:
example.net. 900 IN SOA ns1.example.net. hostmaster.example.net. 2026111001 7200 3600 1209600 900
The answer section shows your CNAME is still published. The status line shows the chain ended in a name that does not exist. RFC 6604 (Section 3) says that when a resolver follows a CNAME chain, the response code reflects the final step, so NXDOMAIN here describes promo-app.example.net, not your own record. That combination — your alias present, its target gone — is the classic dangling pattern. A healthy alias would show the same CNAME followed by an A record such as promo-app.example.net. 60 IN A 198.51.100.25 and status: NOERROR. See NXDOMAIN for what that response code means in general.
How do you build an inventory of every subdomain?
Start from your own zone, not from guesswork. AdminKit’s DNS lookup checks one name at a time; it doesn’t enumerate every subdomain of a domain automatically. A real review starts with a full list of subdomains you’ve actually published — your DNS provider’s own zone export is the most reliable source for that, since it’s the definitive list of every record you control — then running each CNAME target through the lookup above and comparing it against what you currently have provisioned in the relevant cloud or SaaS account.
A zone export is plain text in the master-file format from RFC 1035. The records that need review are the ones pointing outside your own infrastructure (illustrative):
; excerpt from a zone export for example.com
www 3600 IN CNAME site-frontend.example.net.
old-promo 300 IN CNAME promo-app.example.net.
status 3600 IN CNAME example-status.example.org.
files 3600 IN A 203.0.113.40
dev 3600 IN NS ns1.dev-dns.example.net.
dev 3600 IN NS ns2.dev-dns.example.net.
For each line, write down the owner: which account the target lives in and which team pays for it. Microsoft recommends exactly this kind of service catalog, mapping provider endpoints to application owners and reconciling it against an export of what actually exists in your accounts. A record without an owner is the one to investigate first. Repeat the review after every decommissioning and on a regular schedule; OWASP’s remediation advice pairs removing vulnerable records with periodic checks.
How do you confirm a target is actually exploitable?
You confirm it at the provider, not in DNS. A CNAME pointing somewhere unfamiliar isn’t automatically takeable — confirming that depends on the specific target provider. Many cloud and CDN providers show a distinctive error page (an explicit “no such bucket,” “domain not configured,” or similar message) when you browse directly to a dangling target, which is a strong signal the underlying resource is gone. Definitively confirming the name is claimable generally means attempting to register that exact resource name yourself with the target provider — AdminKit’s DNS lookup confirms the DNS pointer, not the destination service’s claim state, so treat an unfamiliar target as worth investigating rather than proof of an active risk on its own.
OWASP’s test lists the DNS responses that point to a dead record. Here is how to read them:
| What you see | Likely meaning | Next step |
|---|---|---|
NXDOMAIN with your CNAME in the answer | The target hostname no longer exists | Check whether that name can be created at the provider |
SERVFAIL or REFUSED on a delegated subdomain | The delegated nameservers do not serve the zone | Check the hosted zone still exists in your account |
| “no servers could be reached” | Delegated nameservers do not answer at all | Check whether the nameserver domain is still registered |
NOERROR, provider “not found” page | Hostname resolves to shared infrastructure, but no customer has claimed it | Treat as high priority; this is the provider error-page signal described above |
NOERROR, content you don’t recognize | Possibly already taken over | Start incident response, then remove the record |
How do you fix a dangling record, and in what order?
Delete the DNS record first, then the resource. Remove the CNAME record the moment you decommission the resource it points to — make that step part of your deprovisioning checklist, not an afterthought. For CNAMEs you still need, keep an explicit inventory of what each one is supposed to point at so an unexpected target stands out immediately the next time you review it, rather than blending into a long, unreviewed zone file.
This order leaves no window: while the record exists, the resource is still yours. Microsoft suggests putting a delete lock on any resource that has a custom DNS entry, as a reminder that the mapping must be removed before the resource goes.
If you find a record that is already dangling, Microsoft’s remediation steps are, in short:
- Remove every CNAME that points at a resource no longer provisioned, or recreate the resource in your own account if you still need the name.
- Search your application code and configuration for references to the subdomain.
- Investigate whether the subdomain was taken over and whether secrets, such as OAuth credentials or cookies, were sent to it.
- Find out why the record survived the decommissioning and fix that process.
Which provider features help prevent a takeover?
Domain verification is the strongest control for records you keep, because it ties a hostname to your account rather than to whoever creates the resource first. These are documented examples, not a complete list:
| Provider feature | How it works | What it stops |
|---|---|---|
| Azure App Service domain verification | A TXT record at asuid.<subdomain> holds your verification ID | Another subscription cannot validate or take over the custom domain |
| Azure DNS alias records | The DNS record is tied to an Azure resource’s lifecycle | Deleting the resource empties the record set instead of leaving it dangling |
| GitHub Pages domain verification | A TXT record at _github-pages-challenge-<account>.example.com | Only your account’s repositories can publish on the domain and its immediate subdomains |
| Route 53 delegation hold | Nameservers of a deleted zone are not reassigned to a new zone with the same name | One dangling delegation scenario; others remain your job |
Verification records only work while they exist: GitHub tells you to keep the TXT record in place for the domain to stay verified. Microsoft notes that the App Service TXT record does not stop someone creating an app with the same default hostname, but without proving ownership of your domain they cannot receive its traffic.
Other exposure checks worth running
If you’re reviewing DNS hygiene more broadly, see is your DNS resolver an open resolver; for mail infrastructure, see how to publish and test MTA-STS; and for a ports-focused check, see how to check if port 123 (NTP) is exposed. This guide sits in AdminKit’s DNS cluster alongside the live tools and glossary terms that back it.
This guide is general information, not a security audit of your specific network — see our disclaimer for what AdminKit's guidance does and does not commit to.
Frequently asked questions
What exactly makes a CNAME 'dangling'?
A CNAME record, defined in RFC 1035, makes one name an alias for another and tells resolvers to look up the target instead of returning an address directly. It becomes dangling when the subdomain's CNAME still points at a target you no longer control — a deleted cloud storage bucket, a decommissioned CDN distribution, a cancelled SaaS hosting slot — while the CNAME record itself was never removed.
How do I check a specific subdomain for this?
Run it through AdminKit's live DNS lookup tool, querying the CNAME record type for the subdomain in question. If it returns a target on a third-party platform (a cloud storage, CDN or app-hosting domain) that you don't recognize as currently in use, that's worth investigating further — start by checking whether that resource still exists in your own provider account.
Can I check every subdomain at once?
Not with a single click today — AdminKit's DNS lookup tool checks one name at a time rather than enumerating every subdomain of a domain automatically. A real review means first building an inventory of subdomains you actually have (from your DNS provider's own zone file export, which lists every record you've published, is the most reliable source), then checking each CNAME target against what you currently have provisioned.
How do I know a CNAME target is actually claimable, not just unfamiliar?
That depends on the specific provider the target belongs to, and AdminKit's DNS lookup only confirms what the CNAME points at, not the destination service's claim state. Many cloud and CDN providers return a distinctive error (an explicit 'no such bucket' or 'domain not configured' page) when you browse to a dangling target directly, which is a strong signal; definitively confirming it's claimable generally means attempting to provision that exact name yourself in the target provider, or removing the CNAME if you don't actually need it anymore.
Should I delete the cloud resource or the DNS record first?
The DNS record. While the record exists and the resource is still yours, nobody else can claim the name; once the record is gone, the resource can be deleted without leaving an alias behind. Microsoft suggests adding a delete lock to any resource that has a custom DNS entry, as a reminder that the mapping must be removed before the resource is deprovisioned.
Sources
- RFC 1035 — Domain Names - Implementation and Specification
- RFC 2181 — Clarifications to the DNS Specification
- Microsoft Learn — Prevent dangling DNS entries and avoid subdomain takeover
- IETF Datatracker — RFC 1035, Domain Names: Implementation and Specification (canonical document record)
- RFC 6604 — xNAME RCODE and Status Bits Clarification
- OWASP Web Security Testing Guide — Test for Subdomain Takeover
- GitHub Docs — Verifying your custom domain for GitHub Pages
- Amazon Route 53 Developer Guide — Protection from dangling delegation records
Want AdminKit to watch this for you?
Free checks tell you the state today. Protective DNS and monitoring tell you when it changes.
Talk to an expert
Huy Nguyen (David), Founder & CEO, Netbase JSC
Ask whether this fix applies to your setup, or get a second pair of eyes on your DNS and mail records.