Preventing Subdomain Takeover From Dangling DNS

Subdomain takeover is one of the most common security problems found on otherwise well-run domains, and one of the easiest to prevent. It happens when a DNS record keeps pointing at something you no longer control. If someone else can claim that something, they can serve their own content on your subdomain, under your name and, often, with a valid certificate. This guide explains how takeovers happen, why they matter and the habits that stop them. It is written for defenders: the people who own the zone.

How a takeover happens

The classic case involves a CNAME record and a hosted service. Imagine the sequence:

  1. A team creates a site on a hosting platform. The platform gives it a name such as campaign-site.platform.example.
  2. Someone adds a CNAME so that promo.example.com points at that name, and adds the custom domain in the platform's dashboard.
  3. Months later the campaign ends. The site is deleted on the platform, but nobody removes the CNAME.
  4. The record now points at a name that no longer belongs to anyone. On some platforms, any customer can create a new site with that same name, or claim the custom domain promo.example.com.
  5. Whoever does so now controls what promo.example.com serves.

The record that points at an unclaimed resource is called a dangling record. The risk depends on the platform: some verify domain ownership before letting anyone attach a custom domain, and some do not.

Other kinds of dangling record

Why it matters

A taken-over subdomain is not just an embarrassing page. Because it sits under your domain, it can be used to:

Prevention habit 1: Remove DNS first, then the resource

The single most effective rule is order of operations. When you retire anything a subdomain points at, delete or change the DNS record before you delete the hosted site, release the IP address or close the account. If the record goes first, there is never a moment when it points at something unclaimed. The checklist for retiring a subdomain safely builds this into a routine, and the retirement notice template helps coordinate it with other teams.

Prevention habit 2: Keep a register

You cannot protect subdomains you do not know you have. A simple register, even a spreadsheet, listing each subdomain, what it points at, who owns it and when it was last reviewed makes forgotten records visible. Review it on a schedule, such as every quarter. See putting a subdomain register into practice.

Prevention habit 3: Audit the zone regularly

Export your zone and check every record that points outside your own infrastructure:

Record typeWhat to checkWarning sign
CNAMEDoes the target name still resolve, and is the resource on the platform still yours?Target returns NXDOMAIN, or the platform shows a "no such site" page
A / AAAAIs the address still assigned to your account?Address not listed in your cloud console
NSDoes the delegated zone still exist in your account at that provider?Provider's servers return SERVFAIL or REFUSED for the zone
MXIs the mail service still active for that name?Service cancelled or account closed

The takeover risk self-check walks through one subdomain at a time, and the scenario on cleaning up forty forgotten subdomains shows an audit end to end.

Prevention habit 4: Prefer platforms that verify ownership

Many hosting and SaaS platforms now require you to prove you control a domain, for example by adding a TXT record, before they will serve a custom domain. When choosing a service, prefer those that do, and complete the verification step rather than skipping it. Avoid wildcard CNAMEs that send every possible subdomain to a third-party service, since that makes every unused name a potential target.

Prevention habit 5: Monitor continuously

For domains with many subdomains, add monitoring that alerts you when a record's target stops resolving, when a certificate is issued for one of your names unexpectedly, or when a record changes outside your normal process. Certificate Transparency logs, which publicly record issued certificates, are a useful source for the second check. Managing DNS as code, with changes reviewed before they are applied, adds a further layer. See certificate and DNS monitoring and DNS as code.

If you find a dangling record

  1. Remove or correct the DNS record straight away.
  2. Check whether the subdomain is currently serving content you did not publish.
  3. If it was taken over, review cookie scope, sessions and any certificates issued for the name, and follow your organisation's incident process.
  4. Add the cause to your retirement checklist so it does not recur.

The Learn hub lists every page in the security module, and launching a subdomain shows how to start each new name with an owner on record.

← Back to Home