DNS & Domain Names

Dangling DNS and Subdomain Takeover

Learn how forgotten DNS records let strangers serve content on your subdomains, and how to find, remove and prevent them.

Key takeaways

  • The risk appears when a DNS record outlives the service, address or account it refers to.
  • Aliases to third-party platforms, released cloud addresses and abandoned delegations are the main sources.
  • Content on a taken-over subdomain looks fully legitimate, because the name really is yours.
  • Remove DNS records first when retiring a service, and audit your zones regularly for orphans.

A dangling DNS record is one that still points somewhere you no longer control: a canceled cloud service, a released IP address or a name server account that's gone. If someone else can claim that destination, they can serve content under your subdomain. That's called subdomain takeover.

The fix is housekeeping. Delete the DNS record before you give up the resource it points to, keep an inventory of what each record is for and review the zone on a schedule.

How a record becomes dangling

Picture a marketing team that launches a campaign page. Someone creates promo.example.com as a CNAME to a hosting platform, for instance example-promo.hosting.example.net. Months later the campaign ends and the team closes the hosting account. Nobody asks the person who manages DNS to remove the record.

The CNAME still exists. It now names a space on the platform that nobody owns. If the platform lets any customer register that same name and attach your subdomain without proving they control it, a stranger can do so. Visitors to promo.example.com then see whatever the stranger publishes.

Nothing was broken into. Your DNS faithfully sent visitors where you told it to.

How a forgotten record turns into a takeover
1 Launch A subdomain is pointed at an outside service. 2 Retire The service account is canceled. 3 Forget The DNS record stays behind, pointing at nothing you own. 4 Claim Someone else obtains the vacated destination. 5 Abuse Their content now appears under your name. Launch A subdomain is pointed at an outside service. 1 Retire The service account is canceled. 2 Forget The DNS record stays behind, pointing at nothing you own. 3 Claim Someone else obtains the vacated destination. 4 Abuse Their content now appears under your name. 5

The three common sources

Aliases to platforms. CNAME records pointing to site builders, help desks, storage buckets, content delivery networks and app hosting. Whether takeover is possible depends on how each platform verifies ownership. Many now require proof, but you shouldn't assume yours does. CNAME records explains aliases.

Released IP addresses. An A or AAAA record points to a cloud server's address. You delete the server and the address returns to the provider's pool. It may later be assigned to another customer, who then receives your visitors.

Abandoned delegations. An NS record hands a subdomain such as lab.example.com to another DNS service. If the zone there is deleted and someone else can create it, they control every name below that point, including any record type. This is often the most serious case. NS and SOA records explains delegation.

Mail records can dangle too. An MX or SPF entry referring to a service or domain you've dropped may let someone else receive or send mail that appears connected to you.

Why it matters

A subdomain carries your reputation. People who've learned to check the domain in the address bar will find exactly what they expect to find.

Possible consequences include:

  • Convincing phishing pages under your real name.
  • Valid TLS certificates for the subdomain, since the new holder can pass ownership checks for it.
  • Access to cookies that your main site scoped to the whole domain.
  • Slipping past allow lists that trust anything ending in your domain, such as redirect or script rules in your applications.
  • Damage to search standing and mail reputation, and the cleanup work that follows.

The cookie point deserves attention. A cookie set with a Domain attribute covering example.com is sent to every subdomain. Scope session cookies as narrowly as your application allows, and use the __Host- prefix where possible, which ties a cookie to one host. How cookies work in HTTP has the details.

Record type What left it dangling Possible reach
CNAME Canceled platform account Web content on that name
A or AAAA Released cloud address Any service on that name
NS Deleted zone at another DNS service The whole subtree, all record types
MX Dropped mail service Incoming mail for that name
SPF include Abandoned sending domain or service Mail that passes your sender checks

Finding dangling records

Work only on domains you own or are authorized to review.

  1. Export every zone you manage.
  2. List each record that points outside your own infrastructure: CNAME, NS, MX, and A or AAAA to cloud or hosting addresses.
  3. For each target, check that it resolves and that it belongs to an account you can sign in to.
  4. For IP addresses, compare against the list of addresses currently assigned to your cloud accounts.
  5. Ask an owner to confirm anything unclear.

A few commands help with the resolution check.

# macOS or Linux
dig promo.example.com CNAME +short
dig example-promo.hosting.example.net A
dig lab.example.com NS +short

A target that returns NXDOMAIN is a strong sign of a dangling alias. A web page saying the site or bucket doesn't exist is another. A target that resolves isn't automatically safe, since someone else may already hold it. NXDOMAIN and other DNS errors helps read the results.

Remember names you've forgotten about. Certificate Transparency logs list certificates issued for your subdomains and often reveal hosts missing from your notes. Certificate transparency explains how to use them.

Reviewing one outward-pointing record
Does anyone know what the record is for? YES Record the owner and purpose, then keep checking below. 1 NO Is the target missing, erroring or unclaimed? YES Delete the record now. 2 NO Is the target outside any account you control? YES Treat it as suspect: remove it or verify the relationship in writing. 3 NO Keep and schedule review Note when to look again and what must happen if the service ends. Does anyone know what the record is for? 1 IF YES Record the owner and purpose, then keep checking below. NO Is the target missing, erroring or unclaimed? 2 IF YES Delete the record now. NO Is the target outside any account you control? 3 IF YES Treat it as suspect: remove it or verify the relationship in writing. NO Keep and schedule review Note when to look again and what must happen if the service ends.

Preventing it

Order your steps. When creating a service, claim the resource first and add DNS second. When retiring it, remove DNS first, wait for the TTL to pass and only then release the resource.

Tie DNS to your provisioning. If infrastructure is defined in code, create and destroy the record together with the thing it points to. Manual zones drift.

Use platform verification. Many services offer a domain verification record that stops other customers from attaching your domain. Enable it, and keep that record in place.

Reserve addresses. Cloud providers usually let you hold a static address. Release it only after nothing refers to it.

Be careful with wildcards. A wildcard CNAME to a platform can expose every possible subdomain at once if the platform allows claims.

Limit who can add records, and require a stated owner and purpose for each. A short comment in your inventory saves hours later.

Check certificate issuance. CAA records restrict which authorities may issue for your names, which can narrow options for an intruder, though it won't stop one using an authority you allow. See CAA records.

Making it part of offboarding

Most dangling records come from process gaps between teams. Add a DNS line to every decommissioning checklist: which names pointed here, and have they been removed? Do the same when a vendor contract ends. Finance teams that cancel subscriptions can be a useful early warning if they know to tell whoever manages DNS.

A scheduled script that resolves every outward target and reports failures catches much of the rest. Review its output, since it can't judge who currently holds a target that still resolves.

A worked audit of one zone

Say a small company reviews example.com and finds forty records. Most point to its own web and mail servers. Six point elsewhere, and those get the attention.

The help desk alias resolves to a vendor the company still pays, and the account owner confirms it. It stays, with a note. A status alias resolves, but nobody remembers creating it. A search of old invoices shows the service was dropped, so the record goes. An assets record points to a storage service that returns a "no such bucket" page, which makes it urgent. An address record for test points to a cloud address that doesn't appear in any current account. It's deleted too.

The last two are NS delegations for dev and events. The dev zone exists in an account the engineering team can open. The events delegation points to name servers that refuse queries for it, which means the zone is gone. That delegation is removed at once.

The whole exercise might take an afternoon. The lasting benefit comes from writing down each survivor's owner and purpose, so the next review starts from a list instead of from memory.

If a subdomain has been taken over

Delete or correct the DNS record immediately. That ends the exposure as caches expire. Then:

  • Check for certificates issued for the name that you didn't request, and ask the issuer to revoke them.
  • Invalidate sessions if cookies could have reached the subdomain, and rotate any related secrets.
  • Preserve screenshots and logs.
  • Report abusive content to the platform hosting it.
  • Warn people who may have visited, with plain instructions.
  • Search the rest of your zones for the same mistake.

Don't try to log in to or interfere with the other party's account. Removing your pointer is within your control and solves the core problem.

Receiving a report from a researcher

Outsiders sometimes notice dangling records and tell the owner. Give them somewhere to go: publish a security contact, for example in a security.txt file, and make sure someone reads it. Verify the claim by checking your own zone, fix it and thank the sender. Domain hijacking covers the related case where the domain itself is at risk.

Common questions

Is a record that returns an error harmless until someone claims it?

It's a standing opportunity. You can't tell when someone will notice, and deleting an unused record costs nothing.

Does DNSSEC prevent subdomain takeover?

No. Your zone correctly and verifiably says to go to that target. The problem is who now controls the target.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in DNS & Domain Names →

Latest news on this topic