What is a dangling DNS record?
A dangling DNS record is a record in your zone, usually a CNAME, sometimes an A or NS record, whose target is a resource you no longer control. A team creates an app on a hosting platform and adds shop.example.com as a CNAME to the name the platform issued. Later the app is deleted. The CNAME stays. If the platform lets any customer register the freed name, that customer now controls what shop.example.com serves.
Microsoft describes exactly this sequence for Azure: a CNAME that points to a deprovisioned resource can be taken over by assigning the name to another subscription's resource (Microsoft Learn). AWS says the same of its globally shared namespaces and adds that the tactic does not exploit a vulnerability in the service (AWS Security Blog). OWASP files the issue under configuration and deployment management for the same reason (OWASP WSTG, Subdomain Takeover).
Why does the cloud platform let a stranger claim the name?
DNS and the hosting platform are separate systems with no shared memory. Your DNS provider answers for a record whose target no longer exists because it does not know what the target is. The hosting platform sees a free name in a namespace shared by its customers and cannot know that a third party's zone still points at it. Whether the platform asks a new claimant to prove anything about the custom domain varies; OWASP describes the weakness as a leftover record combined with a provider that does not verify ownership before allowing a new claim.
The attacker needs no access to your DNS, cloud account or code, only the leftover record, which anyone can read.
Which kinds of record end up dangling?
OWASP lists A, CNAME, MX, NS and TXT records among the types involved and notes that a dangling NS record, although less likely, has the highest impact (WSTG). In practice three shapes matter most.
CNAME to a deprovisioned PaaS, storage or CDN endpoint. This is the most common case; OWASP calls it "typically a CNAME". The record points at a platform-issued hostname, the resource behind that hostname is deleted, and the name may become claimable. Not every service behaves the same way. AWS notes that CloudFront assigns distribution domain names itself, so an attacker cannot choose one, though it warns that a deleted distribution's name could in principle be reissued to another customer. S3 bucket names and Elastic Beanstalk environment names sit in globally shared namespaces (AWS). OWASP's cheat sheet adds that for CloudFront a dangling record alone does not make a name claimable, because attaching a new alternate domain name requires a trusted certificate that covers it (OWASP Cheat Sheet). Provider behaviour changes: remove the record.
Dangling NS delegation, the worst case. If labs.example.com is delegated by NS records to a DNS provider and the zone there is deleted, whoever can create a zone for that name on those name servers answers for everything under it: A, MX, TXT, all of it. OWASP's cheat sheet describes this for deleted Route 53 hosted zones and for closed third-party DNS accounts. AWS documents that Route 53 now blocks the simple case, a hosted zone deleted while the parent NS records remain, but not others, such as re-adding delegation records before the zone exists. It tells customers to keep the parent NS records matched to the hosted zone's delegation set (Route 53 documentation).
Stale A records to released cloud IPs. An A record to an address you have since released points at whoever the provider assigns it to next. OWASP notes this is common in cloud environments, where released elastic IPs return to a shared pool. Treat any address you no longer hold as dangling, whichever provider it came from.
What can an attacker do from a subdomain of yours?
Browsers and applications often treat *.example.com as a family, so one subdomain is more than a defaced page. Five mechanisms matter.
Content under your name. The attacker decides what shop.example.com serves.
Phishing with a valid certificate. A padlock is no defence here. Certificate authorities validate that the requester controls the name, typically by an HTTP check or an email to the domain. Whoever serves the subdomain passes HTTP-based validation; whoever controls its mail can pass email-based validation. OWASP lists obtaining certificates through email- or HTTP-based validation as an impact, and Microsoft states that a hijacked subdomain can receive a valid SSL certificate (Microsoft Learn).
Cookies scoped to the parent domain. When a server sets a cookie with a Domain attribute, the cookie is available on that host and its subdomains; when Domain is omitted it goes only to the host that set it (MDN, and RFC 6265bis section 4.1.2.3 in the IETF draft). So a session cookie set with Domain=example.com is sent to a malicious shop.example.com when your user visits it. The reverse direction also exists. A subdomain can set cookies for the parent domain, and OWASP calls out cookie "tossing": planting cookies the main application will receive, enabling session fixation or overwriting anti-forgery cookies.
CSP allow-lists that trust the wildcard. A policy such as script-src https://*.example.com tells the browser to run script from every subdomain. MDN calls domain allow-listing a broad-brushed approach. One hijacked subdomain becomes a trusted script origin. See also CSP nonce and allow-list bypasses.
CORS and OAuth trust. If your API reflects any *.example.com origin into Access-Control-Allow-Origin with credentials allowed, the taken-over subdomain can make authenticated cross-origin requests as your user. MDN notes that credentialed requests need a specific origin rather than the * wildcard, and that a server choosing the origin from an allow-list should send Vary: Origin (MDN, CORS). For OAuth, RFC 9700 requires exact string matching of redirect URIs and describes the dangling CNAME case as the reason wildcard redirect patterns are risky: an authorisation code sent to a hijacked subdomain goes to whoever controls it (RFC 9700, sections 2.1 and 4.1).
How do I check for subdomain takeover on my own domains?
For every record, ask whether its target still exists and is yours. Four steps:
- Export every record. Pull the full zone from each DNS provider, including the ones a former team set up.
- Resolve every target. Look at what each CNAME, NS and A record currently resolves to. You can look up a single name with our free DNS lookup, which shows what public resolvers return for a name at that moment. DNS answers alone are not enough, as AWS points out: a taken-over name still resolves, just to someone else's resource. Compare each target against your inventory of resources.
- Look at what answers. A target that returns a provider's default "no such app" or "no such bucket" page, or an NXDOMAIN, deserves attention. OWASP's guidance recommends matching responses against known provider error pages.
- Find the names you forgot. Browsers require publicly trusted certificates to be logged in certificate transparency, so a search of CT logs for your domain lists names that have had certificates, including hosts nobody has touched in years. Wildcard certificates hide individual hostnames, so a name covered only by one may not appear. More on this in our forgotten-assets post.
Vendors offer tooling for their own platforms. Microsoft publishes a PowerShell tool that lists CNAMEs pointing at your Azure resources, and its Defender for App Service plan includes dangling DNS alerts. AWS publishes a sample custom AWS Config rule that compares Route 53 CNAME targets against S3, CloudFront and Elastic Beanstalk resources in your inventory, and does not cover CNAMEs to third-party services.
How do I fix a dangling record?
Delete the record once you have confirmed nothing you run still depends on it. If removal would break links users rely on, point it at a host you control that serves a redirect or maintenance page, as OWASP suggests, then remove it. The order of operations is what prevents the next one. AWS's guidance for deprovisioning is to delete the CNAME first, wait for the DNS TTL to expire so cached answers clear, delete the resource, then confirm the record no longer resolves. OWASP gives the same sequence. Deleting the resource first opens a window in which the name is dangling.
After removal, treat any found record as a possible incident. Microsoft's remediation steps include checking whether secrets such as OAuth credentials or privacy-sensitive data were ever sent to the dangling name, and finding out why the record survived decommissioning. Search certificate transparency logs for certificates issued for that name while it was dangling; any you did not request should be reported to the issuing CA for revocation. Search your code and configuration for references to the subdomain as well.
How do I prevent it from happening again?
Tie the record to the resource. The most robust fix is structural. If DNS is declared in the same infrastructure-as-code change as the resource it points to, deleting one without the other shows up in review. Some providers also couple the two directly: Microsoft documents Azure DNS alias records, which become empty if the underlying Front Door, Traffic Manager, CDN endpoint or public IP is deleted, and notes the list of supported services is limited. Where a platform offers domain verification, use it: Microsoft documents an asuid TXT record for App Service that stops other subscriptions validating your custom domain. OWASP advises keeping such records after decommissioning.
Make deletion a checklist item. Microsoft recommends a "remove DNS entry" step in decommissioning, and delete locks on resources that carry a custom DNS entry. Keep a catalogue of endpoints with named owners.
Shrink the blast radius. Assume some subdomain will eventually be compromised.
- Omit
Domainon session cookies so they stay host-only, or use the__Host-prefix, which per MDN requiresSecure, noDomainattribute andPath=/, so the browser sends the cookie only to the host that set it. - Replace
*.example.comin CSP and CORS settings with explicit hostnames and in OAuth settings with exact redirect URIs, and remove an entry from those lists when you decommission the host. - Restrict wildcard DNS records, as OWASP advises.
- Use Subresource Integrity for third-party scripts, as OWASP suggests for broken-link hijacking.
DNSSEC adds a layer where your provider supports it. AWS says signing a Route 53 hosted zone can serve as another layer of protection against dangling delegations, beyond the delegation hygiene it describes. Our free DNSSEC checker and DNS propagation checker show what public resolvers return; like the lookup tool, they are one-off passive lookups, not monitoring.
Finding the names you have forgotten
Everything above assumes you know which names exist. Certificate transparency, DNS and live probing are how an outsider would list those names. Our OSINT / Recon engine ($399 per scan) does that, passively plus light probing, for a domain you have verified or attested you are authorised to test. It lists subdomains discovered from certificate-transparency logs, enumerates DNS records and delegation, and checks which discovered hosts answer. It does not test whether a host is claimable, and cannot see an asset with no certificate and no DNS record. Treat it as a list of names to check, not a verdict on any of them. For wider cloud context see our cloud penetration testing guide.
Frequently Asked Questions
What is a dangling DNS record?
A dangling DNS record is a record, usually a CNAME, whose target is a cloud resource you have deleted or no longer control. The record still resolves from your zone, so the name looks live, but if a provider lets someone else register the freed target name, they can serve content on your subdomain.
How do I check for subdomain takeover?
Export every record from every DNS zone, resolve each target, and compare it against your own inventory of resources, because a taken-over name still resolves. Look for provider "no such app" or "no such bucket" responses and NXDOMAIN, and search certificate transparency logs for hostnames you have forgotten.
Is a subdomain takeover dangerous if my main site is secure?
Yes, because browsers and applications often trust the whole domain. A claimed subdomain can read cookies set for the parent domain, plant cookies the main app receives, satisfy CSP, CORS or OAuth rules that allow *.yourdomain, and obtain a valid TLS certificate for the name.
Why is a dangling NS record worse than a dangling CNAME?
A CNAME affects one name. An NS record delegates an entire subdomain to another set of name servers, so whoever can answer for that zone controls every record beneath it, including A, MX and TXT records. OWASP notes that an NS takeover, although less likely, has the highest impact.
How do I prevent subdomain takeover?
Delete the DNS record first, wait for its TTL to expire, then delete the resource. Declare DNS and resources together as code, keep provider verification records, and avoid wildcard trust in cookies, CSP, CORS and OAuth redirect lists.