Subdomain Takeover: How Dangling DNS Is Found and Fixed
Skip to content

Subdomain Takeover

Subdomain takeover is the claim of an organization’s subdomain by an outside party, through a DNS record that still points at a resource the organization has given up.

On this page

The outsider registers that cloud resource, hosting account or domain, then serves content, receives mail or answers DNS queries under the organization’s own name. The cause sits in the organization’s own DNS zone, so the fix belongs to the record owner even when someone else hosted the resource.

This guide covers how records are left dangling, which record types and platforms are involved, what a claimed subdomain allows, and how to find, fix and prevent dangling records, with one case followed from the first signal to closure.

How Records Become Dangling

A subdomain usually starts as a working pair: a resource on a cloud or SaaS platform, and a record in the organization’s zone that sends visitors to it. Microsoft’s documentation on dangling DNS entries describes the sequence that breaks the pair.

  1. Creation. A team provisions a resource with a provider hostname, such as a web app under azurewebsites.net, and adds a CNAME so that a friendly subdomain routes to it.
  2. Deprovisioning. The resource is deleted when the project ends, and the CNAME stays in the zone, still advertising the subdomain.
  3. Discovery. An outsider finds the subdomain with commonly available tools and sees that its target no longer exists.
  4. Claim. The outsider creates a resource with the same provider hostname in their own account, and traffic for the subdomain now reaches content they control.

Microsoft calls the leftover record a dangling DNS entry and notes that CNAME records are especially exposed. It describes takeovers as a common, high-severity threat for organizations that create and delete many resources.

The record tends to outlive the resource because different people look after each one.

  • Split ownership: A network or IT team holds the DNS zone, while an application or marketing team creates and deletes the resource, and neither step triggers the other.
  • Short-lived projects: Campaign sites, event pages, test environments and proofs of concept get friendly names quickly and are retired without a checklist.
  • Supplier offboarding: An agency or contractor deletes the resource it hosted when a contract ends, and the DNS owner hears nothing about it.
  • Acquisitions and rebrands: Zones inherited from an acquired company carry records whose purpose nobody in the new organization remembers.
  • Manual DNS edits: Records added by hand in a registrar portal sit outside the infrastructure code that later deletes the resource.

Record Types at Risk

CNAME records get most of the attention, and the same problem appears wherever a record hands trust to something outside the zone. NIST SP 800-81r3, the Secure DNS Deployment Guide revised in March 2026, treats dangling CNAMEs and lame delegations as threats to the integrity of an organization’s public domains.

Record What it points at How it becomes claimable What the claimant gets
CNAME to a cloud hostname A provider name for an app, storage account or traffic profile The resource is deleted and the platform releases the name Control of the web content on the subdomain.
CNAME to an outside domain A domain held by a supplier or a past project The target domain’s registration lapses and anyone can register it Control of how the subdomain resolves.
A or AAAA record A public address in a cloud provider’s range The address is released and later assigned to another customer The subdomain’s traffic, delivered to a server the claimant runs.
NS delegation Name servers at a DNS hosting service The hosted zone is deleted while the delegation stays in the parent zone Every record under the delegated name.
MX record A mail host or a parked domain The mail service or the referenced domain is given up Mail addressed to the subdomain.
SPF include or script source A domain named inside a mail policy or a web page The referenced domain expires and is registered by someone else Mail that passes sender checks, or code running in visitors’ browsers.

NIST covers both the lapsed target domain, which an attacker can register to send resolutions to their own infrastructure, and a target that resolves to an address the owner no longer uses.

Delegations carry the widest exposure, because whoever answers for a delegated name controls every record beneath it. NIST notes that a subdomain delegated to a DNS hosting provider can be hijacked when the hosting contract lapses, or when the zone is deleted from the service while the delegation remains in place.

Platforms and Their Safeguards

Any service that lets a customer attach a custom domain to a name the service allocates can be involved, from App Service and Blob Storage to API Management on Microsoft’s list. Platforms differ in whether a stranger can recreate a released name, and several now add safeguards of their own.

Platform Safeguard What it covers What stays with the owner
Azure App Service Tenant-only reuse of a deleted app’s name, an asuid TXT verification record, and secure unique default hostnames with a random hash A stranger cannot validate a verified custom domain, and a unique hostname cannot be recreated outside the organization Unique hostnames apply only at creation, so existing apps must be cloned or restored to adopt them.
Azure DNS Alias records for Front Door, Traffic Manager, CDN endpoints and public IP addresses The record set empties when the resource is deleted Other resource types, and zones hosted with another DNS provider.
GitHub Pages A verified custom domain, which includes its immediate subdomains Only the verified account’s repositories can publish to those names Wildcard records, which GitHub says carry takeover risk even on a verified domain.

Each safeguard narrows the window, and each depends on the organization having turned it on. Microsoft’s point about the App Service verification record is that, without proof of ownership of the domain, another party cannot receive the subdomain’s traffic or control its content.

Order matters too. GitHub’s documentation warns that adding a domain at the DNS provider before adding it to GitHub can let someone else host a site on that subdomain.

What a Claimed Subdomain Allows

A subdomain carries the organization’s name, its reputation with users and mail filters, and often a share of the browser trust given to the main site. Microsoft’s guidance groups the consequences as loss of control over content, cookie harvesting, phishing, and follow-on web attacks such as cross-site scripting and CORS bypass.

  • Content under the brand: The claimant can publish any page, including a copy of a sign-in screen, on a hostname users have reason to trust.
  • Valid certificates: Microsoft points out that a claimant can apply for and receive a valid TLS certificate for the hijacked name, so the browser padlock gives users no warning.
  • Cookie access: Under the IETF cookie standard, RFC 6265, a cookie set with a Domain attribute of the parent domain is sent to every host beneath it, so a claimed subdomain receives those cookies from visitors’ browsers.
  • Cookie tampering: The same standard notes that one subdomain can set a cookie for the parent domain that a sibling cannot tell apart from its own, which opens attacks on the main application.
  • Mail interception: A claimed mail target lets the claimant receive mail sent to the subdomain, and the UK Government Cyber Unit warns that this exposes sensitive messages and can enable business email compromise.
  • Sign-in flows: Microsoft’s app registration guidance warns that a lapse in ownership of a single redirect URI can lead to application compromise, because sign-in responses are sent to that address.
  • Trusted origins: Content security policies, CORS rules and allowlists written as a wildcard for the parent domain extend their trust to whoever holds the subdomain.

A claimed subdomain is more convincing than a lookalike domain, because the address in the browser is genuine. The damage depends mostly on what the rest of the estate trusts the name with, so a forgotten campaign page under a domain whose session cookie is scoped to the parent becomes a route into customer accounts.

Finding Dangling Records From the Inside

The inside view starts from the zone files and the cloud accounts, which the organization can read in full. A zone export lists every record, and a cloud inventory lists every resource that still exists.

  1. Export every zone. Records are collected from each DNS host, including zones run by subsidiaries, agencies and stray registrar accounts.
  2. Follow each alias to its end. UK government guidance on records that point at missing services follows the CNAME chain with dig until a name has no further alias, then queries its address record, and an NXDOMAIN answer shows the target is gone.
  3. Match live targets to the inventory. A target that still resolves needs an owner too, since the resource may now belong to another customer, so each provider hostname is matched against an export from the organization’s cloud accounts.
  4. Check outside registrations. Every domain named in a CNAME, NS, MX or SPF record that the organization does not hold has its registration status and expiry date checked.
  5. Compare delegations. Each NS delegation in a parent zone is matched against the name servers of the hosted zone it should reach, and a delegation with no matching zone is treated as claimable.
  6. Match addresses. A and AAAA records that point into cloud ranges are compared with the list of addresses currently allocated to the organization.

For Azure, Microsoft publishes a PowerShell tool, Get-DanglingDnsRecords, that uses Azure Resource Graph to list CNAMEs tied to resources in the organization’s subscriptions. It accepts CNAMEs held in other DNS services as an input file, and it needs at least Reader access to each subscription it checks.

Microsoft Defender for App Service adds an alert for one specific case: an App Service website that was decommissioned while its custom domain stays in DNS. The alert works whether the domain sits in Azure DNS or with an external registrar.

Finding Them From the Outside

An outside view catches names the zone exports miss, such as subdomains in a zone a supplier manages or a registrar account nobody remembers. It is also the view an attacker has.

  • Certificate Transparency logs: Public logs record every certificate issued for the organization’s names, which reveals hostnames and flags new issuance. The NCSC’s guidance on managing public domain names says an unexpected certificate may indicate that an attacker has control of DNS associated with the domain.
  • Passive DNS: Historical resolution data shows which names once pointed at cloud services, including records that have since dropped out of internal documentation.
  • Platform default pages: A request to a subdomain whose target is gone typically returns the platform’s default page for an unknown site or bucket, which names the platform and suggests the name can be claimed.
  • Content changes: An established subdomain that suddenly serves unfamiliar content, a sign-in form or ads points to a claim already made.
  • Mail answers: New MX answers or delivery failures for a subdomain show a mail dependency that has moved.

Outside checks also catch takeovers that have already happened, which an inside check can read as healthy. A claimed name resolves and its page loads, and only the ownership check shows that the resource now belongs to someone else.

Confirming and Rating a Candidate

Each candidate needs a verdict before anyone changes DNS, because a target that looks abandoned may be a resource another team still uses. The checks stay read-only: DNS answers, the cloud inventory, registration records and the page itself.

  • Live and owned: The target resolves to a resource in the organization’s own accounts, so the record stays and its owner is noted.
  • Dangling and claimable: The target is gone and the platform would let any customer create it again, so the record is fixed first.
  • Dangling and protected: The target is gone and a verification record or a provider hold stops strangers attaching the name, so the record is removed in the next change window.
  • Claimed by another party: The target resolves to a resource outside the organization’s accounts, so the response follows the incident process.
  • Unresolved: Ownership cannot be settled from the records, so the zone owner and the last known project owner are asked for an answer by a set date.

Among claimable records, priority follows what the name is trusted with. Delegations come first, then names used for sign-in redirects, parent-scoped cookies, mail or SPF, then plain web aliases. The UK Government Cyber Unit treats references used in authentication or redirect flows, or included in SPF and DMARC records, as the highest priority.

Reclaiming the name is a legitimate holding step for the organization’s own hostnames. Microsoft lists provisioning a resource with the dangling target name, in the organization’s own subscription, as one way to route traffic back to something it controls.

Fixing a Dangling Record

The fix is a DNS change, and the follow-up work is everything else that trusted the name. The zone owner makes the change, and the team that owned the resource confirms nothing still depends on it.

  1. Remove or repoint the record. The zone owner deletes the record or points it at a resource the organization still runs, and the change is confirmed from an outside resolver once the old TTL has passed.
  2. Reclaim the name where removal must wait. Where a live application still calls the hostname, the team recreates the resource in its own account so the name cannot be taken while references are cleaned up.
  3. Clean up references. Application code, redirect URIs, CORS rules, content security policies, SPF records and published links are searched for the hostname and updated, in line with Microsoft’s advice to review code for outdated subdomain references.
  4. Keep verification records. Verification TXT records for platforms still in use stay in the zone, as GitHub advises for staying protected after a Pages site changes.
  5. Record the cause. The change ticket notes why the record survived decommissioning, and the process fix goes to the team that owned the resource.

Responding to a Claimed Subdomain

A subdomain already in someone else’s hands is an incident, and the DNS change is only the first step. Microsoft’s guidance says to investigate whether compromise occurred, noting that secrets such as OAuth credentials or privacy-sensitive data sent to the subdomain may have been exposed.

  1. Preserve the evidence. The page, its HTTP response, the DNS answers with timestamps, and the Certificate Transparency entries for the name are saved before anything changes.
  2. Cut the route. The record is removed or repointed, and its TTL decides how long cached answers keep sending some users to the claimant.
  3. Withdraw the trust. Sessions carried in parent-scoped cookies are invalidated, redirect URIs for the name are removed from app registrations, and wildcard allowlists are narrowed.
  4. Look for use. Sign-in and application logs for the claim window are searched for sessions or tokens used from unfamiliar addresses, and mail logs are checked when an MX record was involved.
  5. Inform the people affected. Users who followed links to the subdomain, or whose mail went to it, are told what happened and what to do next.
  6. Report the hosted content. Where the claimant’s resource serves phishing or malware, the hosting platform’s abuse channel is asked to remove it.

The claim window starts at the first certificate issued to the new holder or the first change in the page, and where neither is known, the search covers everything since the resource was deleted.

Records That Show the Problem

Each check above rests on a record the team can pull and keep. The table lists them with what each one settles.

Record What it settles How to pull it
DNS zone export Every alias, delegation and mail record, with its target. The DNS host’s export function, or the infrastructure code repository.
Resolution chain Whether each target still exists, hop by hop. dig queries following each CNAME to an address, saved with the time.
Cloud resource inventory Which provider hostnames the organization holds today. Azure Resource Graph, the Azure portal, or each provider’s account inventory.
DNS change history Who added a record, and when it was last changed. The DNS host’s audit or activity log.
Certificate Transparency entries Certificates issued for the subdomain, with the issuing authority and date. A public Certificate Transparency log search for the organization’s domains.
HTTP response and screenshot What the subdomain serves now. A request from outside the corporate network, saved with its headers.
Registration record Registration status and expiry of outside domains named in records. The registrar, or an RDAP lookup of the domain.
App registration settings Redirect URIs that use the subdomain. The authentication settings of each app in Microsoft Entra ID.
Session and sign-in logs Use of sessions or tokens during a claim window. Application logs and the identity provider’s sign-in logs.

The NCSC advises enabling any logging the DNS host offers, storing it securely, and feeding it into a SIEM to alert on changes.

One Case Followed Through

Acme Corp runs its customer portal at portal.acmecorp.com, with DNS hosted at an external provider. In 2024 a marketing agency built a promotion at offers.acmecorp.com on an Azure Traffic Manager profile in the agency’s own subscription.

  1. Signal. On a Saturday, Certificate Transparency monitoring shows a new certificate for offers.acmecorp.com from an authority Acme has never used.
  2. Resolution. The on-call analyst follows the chain: offers.acmecorp.com is a CNAME to acme-offers.trafficmanager.net, which resolves and returns a page.
  3. Ownership. Acme’s Azure inventory has no such profile, and the agency confirms it deleted the profile when its contract ended in early 2026. Someone else has since created a profile with the same name.
  4. Content. The page is a copy of the portal’s sign-in screen, served with the new certificate.
  5. Exposure. The portal sets its session cookie with a Domain attribute of acmecorp.com, so any signed-in customer who opened the page sent that cookie to the claimant. An old Entra app registration for the promotion also lists offers.acmecorp.com as a redirect URI.
  6. Containment. The DNS administrator deletes the CNAME, and outside resolvers return NXDOMAIN once the one-hour TTL has passed. The portal team invalidates every session, and the identity team removes the redirect URI.
  7. Investigation. Portal logs for the claim window show a handful of sessions used from addresses unrelated to the customers who own them, and those accounts get password resets and a notice.
  8. Prevention. The portal cookie becomes host-only, a zone review removes further CNAMEs to deleted agency resources, and DNS removal joins the supplier offboarding checklist.

The record caused no harm for more than a year while the profile existed. Exposure began the day the agency deleted the resource, and the parent-scoped cookie is what turned a copied page into access to customer accounts.

Preventing New Dangling Records

Prevention ties the life of each DNS record to the life of the resource it points at. Microsoft’s guidance puts “Remove DNS entry” on the required checks for decommissioning a service, and the measures below make that check hard to skip.

  • DNS first at decommissioning: Microsoft’s App Service guidance says DNS records should be updated before the site is deleted, so there is no gap between deletion and recreation.
  • Delete locks: Microsoft suggests a delete lock on any resource with a custom DNS entry, as a signal that the mapping must be removed before the resource goes.
  • Records beside resources: Where infrastructure is defined as code, the record and the resource live in the same template, so destroying one destroys the other.
  • Platform safeguards: Alias records, unique default hostnames and domain verification from the platform table are switched on for every new resource, as a standard part of the build.
  • Narrow trust: Cookies are set host-only by leaving out the Domain attribute unless sharing is needed, and wildcard allowlists are avoided along with wildcard DNS records, which GitHub strongly recommends against for Pages domains.
  • Change alerts: DNS change logs and new Certificate Transparency entries for the organization’s names raise an alert to the team that owns the zone.

NIST SP 800-81r3 asks DNS administrators to monitor and assess these configurations and registrations regularly, and to delete CNAME records once they are no longer required. The NCSC gives the same instruction for delegations and alias records once the services behind them are retired.

First Pass Through the Zones

A first pass through an organization’s zones fits in about six weeks in most environments, and it leaves a routine that later runs on its own. The external attack surface management guide covers the wider discovery program this sits inside.

  1. List the zones. Every zone, DNS host and registrar account is listed, including those held by subsidiaries and suppliers, and each zone gets a named owner.
  2. Sweep the records. Every CNAME, NS, MX and outward-pointing A record is resolved and matched against the cloud inventories, and each candidate gets a verdict.
  3. Fix the urgent ones. Claimed and claimable records are fixed, starting with delegations and names used for sign-in, cookies and mail.
  4. Clean the references. Redirect URIs, cookie scopes, allowlists and SPF records are cleaned of retired hostnames.
  5. Change the process. Decommissioning and supplier offboarding checklists gain a DNS step, alias records and verification records go in where platforms offer them, and change alerts are switched on.

After the first pass the sweep repeats on a schedule, and every decommissioning triggers a check of its own. Progress shows in the count of records without a named owner and in the time from a resource’s deletion to the removal of its record.

Subdomain Checks With ThreatDefence

Dangling DNS shows up in ThreatDefence findings as a hostname whose CNAME still points at a deleted cloud resource that anyone can claim. The check runs from outside the customer’s network, as part of the attack surface work on the ThreatDefence AI SOC platform.

  • Mapping: The Attack surface agent maps the customer’s internet-facing domains, hostnames, services and certificates, and records every change to them.
  • Detection: A hostname whose target has gone is raised as a takeover finding, with the record, its target and the evidence attached.
  • Review: An analyst confirms a significant finding before the customer hears about it.
  • Follow-up: Where ThreatDefence also monitors the customer’s logs, the 24x7 SOC searches them for activity tied to a hostname that someone else has claimed.

Changing the record remains a job for the customer’s zone owner. A copied sign-in page on a claimed hostname is treated as a brand finding as well, since the Brand monitor matches clones of the customer’s real pages wherever they are hosted. MSPs and MSSPs can run subdomain checks for their clients under their own brand, as part of attack surface management.

Frequently Asked Questions

What is a subdomain takeover?

A subdomain takeover happens when an outside party gains control of an organization’s subdomain because a DNS record still points at a resource the organization deleted or let lapse. The outsider creates or registers that resource in their own account, and visitors to the subdomain then reach content, mail servers or name servers the outsider runs. The organization’s DNS zone is the root cause.

Is a dangling CNAME the only cause of subdomain takeover?

No. CNAME records to deleted cloud resources are the most common cause, and the same risk follows any record that hands trust outside the zone. NIST SP 800-81r3 covers lame delegations and targets that resolve to released addresses, and UK government guidance covers MX records pointing at parked domains and SPF or script references to expired domains.

Can an attacker get a valid TLS certificate for a taken-over subdomain?

Yes. Microsoft’s guidance states that a threat actor can use a hijacked subdomain to apply for and receive a valid certificate. Visitors then see a normal padlock in the browser. The issuance is recorded in public Certificate Transparency logs, which makes those logs a useful detection source.

Do secure cookies stay safe after a subdomain takeover?

No. The Secure attribute only keeps a cookie off unencrypted connections, and after a takeover the claimant serves the subdomain over HTTPS with a valid certificate. Microsoft calls the belief that certificates protect users and their cookies from takeover a common misconception. A cookie scoped to the parent domain reaches the claimant’s page like any other, so host-only cookies are the safer setting.

Are wildcard DNS records a takeover risk?

Yes. A wildcard record makes every unused name under it resolve to the same target, so a claimant can attach any of those names on the platform it points at. GitHub strongly recommends against wildcard records such as *.example.com for Pages domains and says they carry takeover risk even when the domain is verified.

Can a dangling MX record expose email?

Yes. Microsoft notes that MX records could let threat actors receive mail sent to legitimate subdomains. The UK Government Cyber Unit adds that if a parked domain named in an MX record is registered by a third party, inbound mail can be intercepted, and in some cases mail can be sent that passes SPF and DKIM checks.

Does domain verification on a hosting platform prevent takeover?

Yes, on that platform. An Azure App Service asuid TXT record or a verified GitHub Pages domain stops another account proving ownership of the name, so it cannot receive the traffic. Verification covers only the platform that issued it, and the dangling record still needs removing to close the gap on every other service.

Is a subdomain takeover a flaw in the cloud provider?

No. The provider releases a deleted resource’s name as designed, and the takeover depends on the customer’s own DNS record still pointing at it. Providers have added safeguards, including verification records, alias records and hostnames with random hashes, but the record lives in the customer’s zone and only its owner can remove it.

How often should DNS records be checked for dangling entries?

The check runs at every decommissioning and on a regular schedule between them. Organizations that deploy and delete cloud resources often benefit from a continuous check, because a record becomes claimable the moment its resource is deleted. NIST SP 800-81r3 asks administrators to monitor and assess CNAME configurations and registrations regularly.

Talk to Our Experts

See how ThreatDefence automates security monitoring, compliance and cyber risk management in one platform.

    I'm an MSP, MSSP, or reseller

    By submitting this form, you accept the terms in our privacy policy.