Subdomain takeover: the DNS record you forgot when you deleted the project

A subdomain takeover happens when a DNS record of yours, usually a CNAME, still points at a hosting service where your project no longer exists. Someone else can then create a project there and serve their content on your subdomain. Makers who try several hosts are exposed because they delete the project and forget the record. The fix: list your DNS records and remove every one whose target you no longer control.

The team behind Keybrum's attacksUpdated 9 min read

In short

  • The cause is an order of operations: the project was deleted first and the DNS record stayed. That leftover is called a dangling record.
  • A taken-over subdomain is your domain in the address bar. Microsoft lists cookie harvesting and phishing among the risks.
  • The check takes ten minutes: export your DNS records, and for each CNAME ask whether the project behind it still exists and is yours.
  • When you retire a project, delete the DNS record first, then the project. When you launch one, create the project first and the record last.
  • Domain verification at your host, such as a TXT record, makes a leftover record much harder to claim. Removing the record is still the fix.
On this page

What is a subdomain takeover?

You point blog.yourapp.com at a hosting service with a CNAME record. Months later you move the blog, or drop it, and delete the project at the host. The CNAME stays in your DNS. It now points at a name on someone else's platform where nothing of yours lives. That leftover is a dangling DNS record.

A subdomain takeover is what can follow. MDN defines it as an attacker gaining control over a subdomain of a target domain, typically when the subdomain has a CNAME in DNS but no host is providing content for it. If the hosting service lets a new customer create a project under the name your record points at, that customer's content is served on your subdomain.

Nothing of yours is broken into. Your DNS says, in public, that this hosting service speaks for blog.yourapp.com, and the service hands the name to whoever asks next.

Why makers who try many hosts are exposed

Microsoft describes subdomain takeovers as a common threat for organisations that regularly create and delete many resources. A solo maker fits that description better than most companies. A typical year looks like this:

  • the landing page started on one static host and moved to another;
  • the API ran on a platform with a free tier until the free tier ended;
  • staging, beta and demo subdomains were created for a launch and abandoned;
  • the docs, the status page, the help desk and the blog each lived on a hosted service with a custom domain;
  • a coding agent set up a deployment and its DNS record in one prompt, and nobody wrote it down.

Every one of those steps added a DNS record. Deleting the project took one click in the host's dashboard. Removing the record meant logging in to a different site, the registrar or the DNS provider, and it had no visible effect, so it did not happen.

What someone can do with your subdomain

The value of a taken-over subdomain is that it is really yours as far as browsers and people can tell. Microsoft's guidance lists these risks:

RiskWhy it works
PhishingA login page on app-help.yourapp.com is on your real domain. Users and password managers have little reason to doubt it.
Cookie harvestingWeb apps often set session cookies for the whole domain, so every subdomain can read them. Microsoft notes that a valid TLS certificate can be obtained for the hijacked subdomain, which gives access to secure cookies too.
Loss of control over contentWhatever is published there appears under your brand.
Further attacks on the main appMDN mentions cross-site scripting and getting around a content security policy that trusts your own subdomains.
Summarised from Microsoft Learn and MDN.

How to list your DNS records and spot dangling ones

This is a check on your own domain. It needs your DNS provider's dashboard and a terminal.

  1. 1

    Export every record

    Open the DNS settings where your domain's nameservers point, and export or copy the full list of records. If you have several domains, do each one. This list is the inventory MDN recommends keeping up to date.

  2. 2

    Mark the records that point at someone else's platform

    Go through the CNAME records. Any target that ends in a hosting provider's domain, such as a .herokuapp.com, .netlify.app, .vercel.app, .github.io or .azurewebsites.net name, is a pointer to a project. Do the same for records that point at a storage bucket, a help desk, a docs host or a landing page builder.

  3. 3

    For each one, find the project

    Log in to that provider and look for the project the record names. If you cannot find it, or you no longer have an account there, the record is dangling.

  4. 4

    Look at what the subdomain serves

    Run the two commands below. A provider's default page saying that no site or app exists at this address is the sign of a record pointing at nothing.

  5. 5

    Check the other record types

    An A record that points at the IP address of a server you gave back can end up pointing at someone else's server. Microsoft also flags MX records: a leftover one can let another party receive mail for that subdomain.

bash
# Your own domain only.
# Where does the name point?
dig +short CNAME blog.yourapp.com

# What answers there?
curl -sI http://blog.yourapp.com | head -n 5
A CNAME to a provider plus a 404 from that provider's default page deserves a closer look.

Do not rely on memory for the list of subdomains. Every TLS certificate issued for your domain is recorded in public certificate transparency logs, which you can search for your own domain to find names you forgot. Attackers read the same logs, which is why a forgotten record does not stay hidden.

The fix: remove the record, then fix the habit

For a dangling record, the fix is to delete it at your DNS provider. If you still need the subdomain, point it at a project you control instead. MDN's first advice when a takeover is discovered is the same: cut it off by removing the DNS entry.

Prevention is a matter of order. MDN puts it in two rules.

When youDo this firstDo this last
Launch a subdomainCreate the project and claim the custom domain at the hostCreate the DNS record
Retire a subdomainDelete the DNS recordDelete the project at the host
  • One list of every subdomain, its host and its purpose, kept next to your project notes
  • "Remove the DNS record" as the first line of your shutdown routine for any project
  • No wildcard record such as *.yourapp.com pointing at a host, unless you really need it
  • Domain verification turned on at hosts that offer it
  • Session cookies scoped to the host that needs them
  • The DNS list reviewed after every migration between hosts

Many hosts now check ownership before they serve a custom domain, which makes a leftover record harder to claim. GitHub says that verifying your domain stops other GitHub users from taking over your custom domain, and warns against wildcard DNS records. Vercel asks for a TXT record when a domain is already in use by another account. Azure App Service has a verification TXT record for the same purpose. These protections differ from one provider to the next and can change, so treat them as a second layer and remove the record anyway.

What people miss after the cleanup

  • Records at a second DNS provider. The domain moved from the registrar's DNS to another provider, and the old zone still exists. Only the zone your nameservers point at matters, but check which one that is.
  • Subdomains of subdomains. eu.api.yourapp.com is easy to overlook in a long list.
  • References in your own app. A script tag, an OAuth redirect URL or a CORS allow-list entry that names the old subdomain trusts whoever holds it. Microsoft advises reviewing application code for outdated subdomain references.
  • Mail records. Microsoft warns that a leftover MX record can let another party receive email sent to that subdomain.
  • The next project. The habit matters more than the cleanup: record first out, record last in.

What Keybrum tests for dangling records

Keybrum is the automated pentest we build for apps made with AI. Its checks on the server behind an app include one for dangling DNS, and it runs only for an owner who has proved ownership of the domain.

The check resolves the CNAME of your domain, of www, and of common subdomains such as api, app, blog, staging, docs and status, plus names already known for your domain from certificate logs. When a CNAME points at one of the hosting and SaaS platforms on its list, which includes Heroku, Azure, AWS S3, GitHub Pages, Netlify, Vercel and others, it sends one GET request to the subdomain. It reports a finding only when the answer is the provider's own page saying that no site or app exists at that name. Whether such a name could then be claimed depends on the provider's ownership checks. The finding means the record points at nothing and should be removed. A record that points at a live project is recorded as tested and blocked.

The limits are worth stating. It is one DNS lookup and one request per name: nothing is claimed, registered or changed. It looks at CNAME records only, so an A record pointing at an IP address you released, or a leftover MX or NS record, is not covered. It does not guess unusual subdomain names beyond that list and the certificate logs, so your own export of the DNS zone remains the complete check. A domain on a platform's shared name, where the DNS is not yours, is skipped.

The same run attacks the app itself: tables and storage readable with the public key, working API keys in the bundle, one user reading another's data. A one-time report is €49. The Maker plan, €29 a month excluding VAT for 5 apps, runs again on every deploy and on a schedule, which catches the record left behind by next month's migration. The external penetration testing guide describes the wider scope.

Questions

What is a dangling DNS record?

A DNS record that points at a resource that no longer exists or that you no longer control, such as a CNAME to a hosting project you deleted. Microsoft uses the term for records pointing at deprovisioned resources. It is the precondition of a subdomain takeover.

How do I check for subdomain takeover on my own domain?

Export your DNS records, and for each CNAME that targets a hosting or SaaS provider, confirm that the project it names still exists in your account. A subdomain that shows the provider's default not-found page is the usual sign of a dangling record.

Which DNS records can be affected?

CNAME records are the common case, and Microsoft calls them especially vulnerable. A records pointing at released IP addresses and MX or NS records pointing at services you left can carry similar risks. Review all of them when you clean up.

Does HTTPS protect against subdomain takeover?

No. Microsoft's guidance calls this a common misconception: whoever controls the content served on the subdomain can obtain a valid certificate for it. The padlock then makes the fake page look more legitimate.

How do I prevent subdomain takeover?

Remove the DNS record before you delete the project, and create the project before you add the record. Keep a list of subdomains and their hosts, avoid wildcard records, and turn on domain verification where your host offers it.

Is my provider vulnerable to subdomain takeover?

It depends on how the provider checks ownership of a custom domain, and those checks change over time. Several providers require a verification record before serving a domain. Since you cannot rely on every provider's rules, the dependable fix is to keep no record that points at a project you do not have.

Sources

  1. 1.Subdomain takeovers, MDN Web Docs
  2. 2.Prevent dangling DNS entries and avoid subdomain takeover, Microsoft Learn
  3. 3.Verifying your custom domain for GitHub Pages, GitHub Docs
  4. 4.Adding and configuring a custom domain, Vercel Docs

Your app is public. So are its mistakes.

Check what any attacker can already see in it, free, in ten seconds. The full attack, with proof and fixes: €49 once, or €29 a month on a plan.

or continue with Google or GitHub