Subdomain Takeover: How It Happens and How to Prevent It
A subdomain takeover happens when a Domain Name System (DNS) record still points to a cloud service you deleted and someone else claims it. The fix is to delete the DNS record before the resource and give every record an owner.
By Sangam Goel, Founder & C.T.O · Updated 18 Nov 2026

Key takeaways
- A subdomain takeover is a decommissioning and inventory failure: a DNS record outlives the resource it names.
- Remove the DNS record first and the resource second. When you provision, claim the resource first and create the record last.
- Triage every record on four tests: it resolves, it points to a resource you have claimed, it has an owner, and it has a decommission date.
- A padlock in the browser proves nothing here, because an attacker can obtain a valid certificate for a hijacked subdomain.
In this article
- 1What is a subdomain takeover?
- 2How it happens: the dangling record lifecycle
- 3Two ways it starts: the provisioning and deprovisioning gaps
- 4CNAME, A and NS records: which are at risk
- 5Where a subdomain takeover shows up in your estate
- 6What an attacker can do with a hijacked subdomain
- 7How to find your exposed subdomains
- 8Step by step: from zone export to provider check
- 9Triage table
- 10How to prevent subdomain takeover
- 11What to do if a subdomain is already taken over
- 12Why a one-off audit is not enough
- 13What to do this week
- 14Conclusion: close the gap between your DNS and your inventory
- 15Frequently asked questions
The record that gets hijacked is rarely one anyone remembers creating. A campaign page, a staging site or a trial of a hosted tool went live under your domain, was switched off, and left a line in the DNS zone behind.
That leftover line is the subdomain takeover vulnerability. Subdomain hijacking needs no access to your network, only a record you forgot, which makes it an inventory failure rather than an exploit. This page gives you the order of operations, a four-test triage table for your own DNS zone, and the steps to take if a subdomain has already been taken.
What is a subdomain takeover?
A dangling DNS record is a DNS entry for a name such as blog.example.com that still points at a service you have deleted, so anyone who can register that service name receives your traffic. The hijacked name lives under your own domain, so browsers, mail systems and customers treat it as yours, and the attacker borrows trust you spent years earning.
How it happens: the dangling record lifecycle
A dangling DNS record forms in five steps: provision, point, decommission, forget, claim. Four of those steps happen inside your own process. Only the last belongs to the attacker, which is why the fix sits in your hands.
1 Provision -> 2 Point -> 3 Decommission -> 4 Forget -> 5 Claim
(you) (you) (you) (you) (attacker)

- Provision.A team creates a resource with a provider, such as a hosted site or storage endpoint.
- Point.Someone adds a CNAME (canonical name) record, which makes blog.example.com an alias for the provider's address for that resource.
- Decommission.The project ends and the resource is deleted.
- Forget.The CNAME stays in the zone. It is now a dangling CNAME: it names a resource that no longer exists.
- Claim.
Where the provider lets anyone register that name again, an attacker does, and your subdomain now serves their content. Microsoft Learn describes the same sequence.
Two ways it starts: the provisioning and deprovisioning gaps
There are two gaps, and they are mirror images. Both come from doing the DNS step and the resource step in the wrong order (MDN Web Docs).
- The provisioning gap. You create the record for blog.example.com before you have claimed the matching name at the provider. Until you claim it, anyone else can register that name first, and your record already points to it.
- The deprovisioning gap. You delete the hosting account or resource for blog.example.com but leave the record. The name becomes free for anyone to register, and your record still points to it.
The rule that closes both gaps is the same: the resource must exist and be yours whenever the record exists.
Did you know? Some providers hold a deleted name back for a while, but not for ever. Microsoft Learn explains that after you delete a classic Azure cloud service, only subscriptions in your own tenant can reuse its DNS name during a reservation period, and once that period ends any Azure subscription can claim it. A record left in your zone outlasts that protection.
CNAME, A and NS records: which are at risk
CNAME records are the most common source of a dangling DNS record, but they are not the only one. CNAME, A (address), MX (mail exchange) and NS (name server) records can all be vulnerable (Open Worldwide Application Security Project (OWASP) Web Security Testing Guide, WSTG-CONF-10).
- CNAME. An alias to a provider name. This is the usual case.
- A. A record that points straight at an IP address. If you release the address and the provider reassigns it, your record points at someone else's server.
- MX. Mail routing records. A dangling one can send mail for the subdomain to the wrong party.
- NS. Delegation records that hand a subdomain to another set of nameservers. NS delegation is the most dangerous case: it is rated highest impact, because whoever claims the lapsed nameserver can answer DNS for everything beneath that name (WSTG-CONF-10).
Where a subdomain takeover shows up in your estate
A subdomain takeover shows up wherever a team can point a name at something it can later delete: cloud storage, application hosting, software-as-a-service (SaaS) pages, staging and campaign sites, and domains that have expired.
- Cloud storage and application hosting. A storage endpoint or app service gets a friendly name. The project is shut down and the cloud account is cleaned up, but the DNS line stays. If those records point at Amazon Web Services (AWS) resources, our AWS cloud infrastructure VAPT tests how they are configured.
- SaaS pages. Status pages, help centres, landing-page builders and trial accounts all ask you to add a CNAME. They are easy to start and easy to cancel without telling the DNS owner.
- Staging and campaign subdomains. Test sites and campaign microsites are built quickly and can sit outside IT’s usual inventory.
- Expired domains. A CNAME that points to another domain lets whoever registers that lapsed domain control where your subdomain lands.
CSC notes that ownership of these assets often fragments across IT, marketing, product and regional teams, and third-party providers, so collect zones from every account, not only the main one.
What an attacker can do with a hijacked subdomain
A hijacked subdomain lets an attacker publish pages, read cookies and receive mail as your organisation, so the damage runs from phishing to session theft. Each risk follows from one fact: the name belongs to your domain.
- Phishing under your brand. A login page on a name you own is far more convincing than a lookalike domain, which is why phishing campaigns are a documented risk (Microsoft Learn).
- Cookie and session theft. Cookies set for the parent domain can be read by its subdomains (MDN), and a hijacked subdomain can harvest even secure cookies (Microsoft Learn). Our web application penetration testing finds what an attacker could reach once a takeover is possible, including cookie and session abuse.
- Weakened browser protections. An attacker can also run cross-site scripting and get around a Content Security Policy (CSP), the rules that tell a browser which sources a page may load (MDN).
- A valid SSL certificate. An attacker can obtain a valid SSL (Transport Layer Security, or TLS) certificate for the hijacked subdomain (Microsoft Learn). The padlock then shows only that the connection is encrypted, not that your team runs the site.
- Malware hosting. The subdomain can serve downloads that visitors trust because of the domain name.
- Email abuse. If MX records dangle, an attacker can receive mail addressed to the subdomain.
- SEO abuse. Blackhat search engine optimisation (SEO) was the main abuse in the 2024 NSDI (USENIX Symposium on Networked Systems Design and Implementation) study by Frieß et al. The study identified 20,904 hijacked resources on 12 cloud platforms between 2020 and 2023, and found that blackhat SEO made up 75% of the abuse. The study covers cloud platforms, not every takeover. The researchers describe this as financially motivated: attackers pick resources that are easy and cheap to take over.
How to find your exposed subdomains
How to detect subdomain takeover in your own estate comes down to one comparison: every name in your DNS against the resources you actually hold. Everything below applies to domains you own only. Never test, probe or try to claim resources in accounts you do not control.
Step by step: from zone export to provider check
- Export your DNS zone.
Pull the full record list from every registrar and DNS host that serves any of your domains, including accounts held by marketing, product teams or agencies. Pass: you can account for every domain the company has registered. Fail: any domain with no export.
- Enumerate subdomains.
Subdomain enumeration means listing the names that exist in public records, not just in your export. Search public certificate transparency logs, which record publicly trusted certificates and so list many names that have had one. Names that never had a public certificate will not appear. Add names from old exports, site maps and application configuration. Pass: every name you find is in your export or explained. Fail: any public name that is not in your exports and that you cannot explain.
- Resolve each CNAME.
Follow every alias to its final target. Note whether the target answers, reports that the name does not exist, or returns the provider's "not found" or unclaimed page. Pass: every target answers with the service you expect. Fail: any target that does not answer, reports the name as non-existent, or shows a provider's unclaimed page.
- Confirm in your own provider account.
For each record that names an outside service, sign in to your own account with that provider. Confirm that the named resource still exists and belongs to you. Fail: any record whose resource you cannot find, or that sits in an account you cannot access.
- Record the resultAdd each name to the triage table below. Pass: every name has a row in the triage table. Fail: any name with no recorded result.
Triage table
Score every record on four tests. "Resolves" means the target answers. "Claimed" means the resource it names exists in an account you control.
| Resolves | Claimed by you | Has an owner | Has a decommission date | What to do |
|---|---|---|---|---|
| Yes, but shows a "not found" or unclaimed page | No | Any | Any | Fail. Highest priority. Remove the record now, then check for misuse. |
| No (the name does not exist) | No | Any | Any | Fail. This is a dangling DNS record. Delete it, and check whether the target is a lapsed domain. |
| Yes | Yes | No | Any | Weak. Find an owner. If nobody claims it, treat it as a decommission candidate. |
| Yes | Yes | Yes | Date has passed | Overdue. Remove the record first, then the resource. |
| Yes | Yes | Yes | No date | Passes for now. Set a review date. |
| Yes | Yes | Yes | Date set | Pass. Review on that date. |
Two cases sit outside the table. Treat every NS record below your zone's top level as its own item, and confirm that the DNS provider account it names is yours and active. Flag every wildcard record (one that matches any name, such as *.example.com). A wildcard pointing at a dangling target exposes an unbounded set of names through one mistake.
How to prevent subdomain takeover
Subdomain takeover prevention is an ordering rule plus ownership: claim the resource first and create the DNS record last when you provision, then remove the record first and the resource second when you decommission (MDN).
- Claim first, record last.When you provision, secure the resource at the provider, then create the DNS record. This closes the provisioning gap.
- Record out first, resource second.
When you decommission, delete the DNS record, confirm it no longer resolves, then delete the resource. Put "DNS record removed and checked" on every decommissioning ticket, as a required check (Microsoft Learn).
- No wildcard records.A wildcard makes every unused name resolve, so you cannot tell which names are live, and one dangling target covers all of them. Use named records.
- Keep verification TXT records.
Where a provider issues a domain-verification TXT record (a text entry in DNS that proves you control the domain), create it before you point the name and keep it until the service is gone. At providers that use it, such a record stops other customers validating your custom domain (Microsoft Learn). It does not replace deleting the record at decommissioning.
- One owner per subdomain.
Every name gets one named person or team, a purpose and a review date. Keep a catalogue of endpoints and their application owners (Microsoft Learn). The owner is who answers when a record fails the triage table.
Pro Tip: Make the DNS change and the resource change part of the same ticket, and finish both on the same day. MDN advises doing every provisioning and deprovisioning step as close together as possible, because a name stays exposed for as long as the record and the resource are out of step.
Prefer providers that verify domain ownership before they accept a custom name, and ask every vendor how they verify it. A dangling DNS record is a configuration mistake rather than a coding flaw. For background on why it counts as security misconfiguration, see our guide to the OWASP Top 10 vulnerabilities.
What to do if a subdomain is already taken over
If a subdomain has already been taken over, remove its DNS record first, because that cuts the attacker's route to your visitors (MDN). Then scope the problem, notify the team and review for misuse.
- Remove the DNS record.
Do this before anything else. If you still need the subdomain, re-create the resource in your own account afterwards and point the record back at it (Microsoft Learn).
- Scope the problem.
Work out when the record became dangling, what the subdomain served and which applications referred to it. Review your application code for references to the name. Secrets or sensitive data sent to a dangling subdomain may be exposed (Microsoft Learn).
- Notify the team.Tell security, IT, the owner of the subdomain, your support team and whoever handles communications, so nobody reuses or promotes the name.
- Review for misuse.Check web and mail logs for the period, and look at what was published under the name.
Four further checks matter:
- Check certificate logs for certificates issued to the subdomain that you did not request.
- Rotate sessions and secrets if your cookies are scoped to the parent domain, since the attacker could have read them.
- Review your SPF and DMARC records. Sender Policy Framework (SPF) lists who may send mail for your domain. Domain-based Message Authentication, Reporting and Conformance (DMARC) tells receivers what to do with mail that fails the check.
- Scan your other DNS zones for more dangling records, and find out why this one was not removed.
Why a one-off audit is not enough
A one-off audit shows your DNS on the day it ran, and records go stale as soon as a team switches off a service afterwards. Every new campaign page, staging site or trial adds a record, and any of them can become a dangling DNS record the day its resource is deleted.
According to the CSC CISO Outlook 2026 survey of 300 CISOs and other senior executives, domain and DNS hijacking and subdomain takeover attacks together ranked as the top threat organisations experienced in 2025, ahead of ransomware and malware. Only 14% said they were very confident in their organisation’s ability to mitigate domain attacks.
Our guide to penetration testing as a service (PTaaS) versus annual penetration testing explains why point-in-time checks miss subdomains that go stale between tests. Our recommendation is to repeat the triage on a fixed schedule, and to add a DNS check to every decommissioning ticket and every change that creates a record.
An outside view helps too, because your inventory shows what you believe exists, not what the internet can reach. SafeCybers EASM maps your internet-facing assets and scans them continuously for exposures such as misconfigurations, so you can set what is exposed beside what your own records say.
What to do this week
Run these six checks, each with a clear result:
- List every domain you own and every account that holds its DNS. Pass: the list matches your registrar records, and no account is unaccounted for.
- Export each zone. Pass: you hold one export per zone.
- Compare public certificate names with your exports. Pass: every public name is in an export.
- Score each CNAME on the four tests. Pass: no record fails resolve or claimed.
- Delete every failing record, DNS first. Pass: each deleted name returns no answer.
- Name an owner and a review date for every record that passes. Pass: no record has a blank field.
If you want help scoping the work or checking your results, contact us for a consultation.

Conclusion: close the gap between your DNS and your inventory
A subdomain takeover starts with a record nobody remembers and ends with a name someone else controls. When you review your own zone, use one rule.
If a record fails the resolve or claimed test, delete it first and find out who created it afterwards, because a record pointing at a resource you no longer hold serves nobody except whoever claims it. If it passes but has no owner, give it an owner and a review date within the week. Then add DNS removal to every decommissioning ticket, so the same gap does not open again.
If you would like help scoping the checks or deciding what to test first, get a consultation through our contact form. Prices are arranged through consultation.
Get help scoping your subdomain takeover checks
Frequently asked questions
No. An attacker who controls a hijacked subdomain can obtain a valid SSL (TLS) certificate for it (Microsoft Learn). The padlock then shows the connection is encrypted, not that your organisation runs the site.
Sources
- 1.OWASP Web Security Testing Guide, WSTG-CONF-10: Test for Subdomain Takeover
- 2.MDN Web Docs, Subdomain takeover
- 3.Microsoft Learn, Prevent dangling DNS entries and avoid subdomain takeover
- 4.Frieß, Gattermayer, Gelernter, Schulmann and Waidner, "Cloudy with a Chance of Cyberattacks: Dangling Resources Abuse on Cloud Platforms", USENIX NSDI 2024



