What Is Subdomain Takeover? Examples and Fixes
TL;DR: A subdomain takeover happens when your DNS record still points to a cloud resource you deleted, like an S3 bucket, Heroku app, GitHub Pages site or Azure app. Someone else creates a resource with the same name and now serves content on your subdomain. The fix is boring: remove DNS records when you delete the resource, and check your zone for dangling CNAMEs regularly. You can check one host with our subdomain takeover check.
How it happens
Say your team launched a campaign site last year:
- You created an Azure App Service called
promo-2025.azurewebsites.net. - You added a DNS record:
promo.example.com CNAME promo-2025.azurewebsites.net. - Campaign ended and someone deleted the App Service.
- Nobody removed the CNAME.
Now promo.example.com points to a name nobody owns. That's a dangling DNS record. Anyone can create a new App Service called promo-2025 in their own account, and traffic to promo.example.com goes to them.
Microsoft describes exactly this flow in its guide Prevent dangling DNS entries and avoid subdomain takeover. The same idea works with many services, as long as the service lets a new customer claim the old name and doesn't check who owns the domain.
Why it's serious
Its not just a defaced page. From Microsoft's guide and real cases:
- Cookies. If your app sets cookies for
.example.com, the attacker's page on a subdomain can receive them. - Valid HTTPS. The attacker controls the content, so they can pass domain validation and get a real certificate for your subdomain. The padlock shows and the page looks legit.
- Phishing and spam. A login page on
promo.example.comis very convincing. If MX or SPF records point to a lost resource too, mail is at risk.
Real examples
SubdoMailing (MSN and others)
In 2024 Guardio Labs reported a spam campaign they called SubdoMailing. It used hijacked subdomains of well known brands to send spam. Kaspersky's write-up explains the MSN case: marthastewart.msn.com was a CNAME to msnmarthastewartsweeps.com, a domain from an old prize giveaway. That domain's registration expired, but the CNAME stayed. In 2022 the attackers registered the expired domain and could send mail as marthastewart.msn.com.
This one wasn't even a cloud service. The CNAME pointed to a normal domain that anyone could buy once it expired.
The can-i-take-over-xyz list
The can-i-take-over-xyz project on GitHub tracks which services can be taken over and what a dangling resource looks like. When we checked it:
| Service | Status in the list | What a dangling target looks like |
|---|---|---|
| AWS S3 | Vulnerable | The specified bucket does not exist |
| Microsoft Azure | Vulnerable | NXDOMAIN on the target |
| GitHub Pages | Edge case | There isn't a GitHub Pages site here. |
| Heroku | Edge case | No such app |
The project marks GitHub Pages and Heroku as "Edge case", and each service has its own issue with the details. Services change their rules, so read the issue before you decide you're safe.
What a dangling target looks like
These are real responses from names that don't exist. We made up random names so nothing belongs to anyone.
S3, a bucket that doesn't exist:
curl -s https://xura-no-such-bucket-8f3k2.s3.amazonaws.com/
<Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Message>...
GitHub Pages, a user with no Pages site:
curl -s https://xura-no-such-user-8f3k2.github.io/ | grep -o "There isn't a GitHub Pages site here[^<]*"
There isn't a GitHub Pages site here.
Heroku, an app that doesn't exist:
curl -s https://xura-no-such-app-8f3k2.herokuapp.com/ | grep -o -i "no such app"
No such app
Azure, the name doesn't resolve at all:
dig xura-no-such-app-8f3k2.azurewebsites.net | grep status
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 18478
If one of your subdomains has a CNAME to a target that gives one of these answers, treat it as urgent.
How to find dangling DNS records
1. Get the full list of names
Export your DNS zone from your provider (Cloudflare, Route 53, Azure DNS and others all have an export or API). That's the only list you can fully trust. Certificate Transparency logs are a good second source, because they show subdomains people forgot about. Our CT search lists them, see github.com.
2. Check where each CNAME goes
Put your names in subs.txt, one per line, and run:
while read -r name; do
target=$(dig +short CNAME "$name" | tail -1)
[ -z "$target" ] && continue
rcode=$(dig "$target" | grep -o 'status: [A-Z]*' | cut -d' ' -f2)
echo "$name -> $target ($rcode)"
done < subs.txt
For www.github.com it prints:
www.github.com -> github.com. (NOERROR)
Look for two things:
NXDOMAINon the target. The target name doesn't exist. Very risky for Azure, and for any CNAME to a normal domain that may have expired.- A target on a cloud service (
s3.amazonaws.com,github.io,herokuapp.com,azurewebsites.net,cloudapp.netand others). Open it withcurland compare with the answers above.
3. Use our check for one host
The takeover check follows the CNAME chain of one host, matches the target against known services and looks for the "deleted" fingerprint. For example www.github.com shows the CNAME to github.com and no takeover signs. It checks only the host you enter. It doesn't scan your whole domain, and it never tries to claim anything.
How to prevent subdomain takeover
- Delete DNS first, then the resource. Put "remove DNS record" on the checklist for shutting down any service. Microsoft suggests delete locks on Azure resources that have a custom domain, as a reminder.
- Use domain verification where the service offers it. Azure App Service uses an
asuid.<subdomain>TXT record. Microsoft's guide says that when this TXT record exists, no other Azure subscription can validate the custom domain. GitHub lets you verify a custom domain for Pages in your account or organization settings. - Use alias records where they help. Azure DNS alias records follow the resource: when it's deleted, the record set becomes empty. Microsoft says this works for Front Door, Traffic Manager, Azure CDN and public IPs.
- Keep DNS in code. If records live in Terraform or similar next to the resource, they get deleted together.
- Review regularly. Run the loop above monthly, or after any big cleanup. Check new names in CT logs too.
- Watch your own domains expire. SubdoMailing worked because an old domain expired. Keep a list of domains your CNAMEs point to, and renew or remove them.
If you find a dangling record: remove it, or point it back to a resource you own. Then check if it was already taken over. Look at what the subdomain served, check CT logs for certificates you didn't order, and review whether sessions or tokens were sent to it.
Related: CAA records limit which CAs can issue for your domain, which is another small layer here (CAA guide). And our cookie check shows the Secure, HttpOnly and SameSite flags on your cookies.
FAQ
What is subdomain takeover?
It's when an attacker gets control of content on your subdomain because your DNS still points to a cloud resource or domain you no longer own.
What is a subdomain takeover example?
A CNAME from promo.example.com to a deleted Azure App Service or S3 bucket. Someone creates a resource with the same name and serves their page on your subdomain. The MSN SubdoMailing case is a public example with an expired domain.
How to prevent subdomain takeover?
Remove DNS records before you delete the resource, use domain verification (like Azure's asuid TXT record) and alias records, and review your zone for dangling CNAMEs often.
What is a dangling CNAME?
A CNAME record whose target no longer exists or no longer belongs to you. It's the most common cause of subdomain takeover.
Is there a subdomain takeover test online?
Yes. Our takeover check tests one host for known dangling fingerprints. For the whole zone, use the shell loop above on your exported DNS records.
Is your site affected? Run the free P-256 check.