Join our Newsletter — 33% off our NHI Course
Home› Guides› Subdomain Takeover and Dangling DNS Guide: Detect, Prevent…
Guide Vulnerability Management

Subdomain Takeover and Dangling DNS Guide: Detect, Prevent and Clean Up

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 27 October 2026 11 min read
On this page

When a cloud resource is deleted but the DNS record that pointed to it is not, anyone who can claim the same resource name inherits your subdomain, your users' trust and often your cookies. This is subdomain takeover, and it follows directly from how cloud services are used: teams create and delete web apps, storage buckets, CDN endpoints and public IPs constantly, while DNS is managed somewhere else by someone else. Microsoft rates it a common, high-severity threat for organisations that regularly create and delete resources. This guide explains how dangling DNS arises, where it shows up across providers, what an attacker can do with a captured subdomain, and how to detect, prevent and clean it up. It is written for cloud, DNS and vulnerability management teams, and goes deeper than the Attack Surface Management Guide on this one issue.

Key takeaways

  • The root cause is lifecycle drift. A DNS record outlives the resource it points to, and the provider allows someone else to claim that resource name.
  • Delete DNS first, resource second. Reversing the decommissioning order closes the takeover window; add it to every deprovisioning runbook and pipeline.
  • Use provider ownership verification. Azure App Service asuid TXT records, GitHub Pages domain verification and CloudFront's certificate requirement stop other tenants claiming your names.
  • A captured subdomain is a trusted origin. It can read cookies scoped to the parent domain, obtain valid TLS certificates and receive OAuth tokens or webhooks still pointed at it.
  • Inventory beats scanning. Continuous comparison of DNS zones against the cloud resources you actually own finds dangling records before attackers do.

How the attack works

Microsoft's documentation describes the typical sequence with Azure App Service, and the pattern is the same elsewhere:

  1. Creation: a team creates app-contogreat-dev-001.azurewebsites.net and adds a CNAME greatapp.contoso.com pointing to it.
  2. Deprovisioning: the app is deleted but the CNAME stays. The record now points at a name nobody owns: it is dangling.
  3. Takeover: someone finds the dangling record, creates a resource with the same provider name in their own subscription, and traffic for greatapp.contoso.com now reaches content they control.

The condition OWASP's Web Security Testing Guide (WSTG-CONF-10) describes is the same: a DNS record points to a resource that no longer exists, and the hosting provider does not verify ownership. OWASP lists A, CNAME, MX, NS and TXT records as relevant, with CNAME the most common case and NS takeover less likely but highest impact, because it can hand over control of the whole delegated zone. A related variant is a CNAME pointing to another organisation's domain that has lapsed: whoever re-registers that domain controls the target.

In ATT&CK, taking over a victim's domain or subdomain is described under T1584.001 Compromise Infrastructure: Domains, a resource development technique: the attacker gains trusted infrastructure for later phishing or delivery.

Where it shows up

Record typeDangling whenTypical targetsProvider control that helps
CNAMEThe target cloud resource is deleted but its provider name can be recreatedApp Service (azurewebsites.net), Blob Storage (blob.core.windows.net), Azure CDN (azureedge.net), Front Door (azurefd.net), Traffic Manager (trafficmanager.net), API Management (azure-api.net), Container Instances, S3 buckets, GitHub PagesDomain verification TXT records; alias records; certificate requirements
A / AAAAA public IP is released and can be reallocated to another customerCloud public IPs, load balancer addressesAlias records tied to the IP resource; reserving IPs for long-lived services
CNAME to a third-party domainThe third party's domain expiresOld SaaS, agencies, campaign sites, vendor-hosted portalsInventory of external targets; monitoring their registration status
NSA delegated subzone points to name servers or a hosted zone that no longer exists or can be claimedDelegations to cloud DNS zones, old DNS providersRemove delegations when zones are deleted; audit NS records
MXThe mail service for a subdomain is decommissionedLegacy mail or marketing platformsRemove MX records; Microsoft notes dangling MX could let attackers receive mail for the subdomain
Wildcard recordsA wildcard points at a service where any name can be claimed*.example.com to a hosting platformAvoid wildcards to shared platforms; GitHub strongly advises against wildcard records

For Azure classic cloud services, Azure reserves a deleted service's cloudapp.net name so that only subscriptions in the same Microsoft Entra tenant can reuse it for a period; after the reservation expires anyone can claim it, so do not rely on it. GitHub notes that takeovers of Pages custom domains can follow a deleted repository, a downgraded billing plan or disabling Pages while the domain remains configured and unverified.

Impact

  • Content and brand: attacker-controlled pages under your domain, used for phishing, malware delivery or defacement that users and filters trust.
  • Cookies and sessions: cookies scoped to the parent domain (for example Domain=contoso.com) are sent to every subdomain, so a captured subdomain can read session cookies. Microsoft also notes that the attacker can obtain a valid TLS certificate for the hijacked name, so the padlock offers users no warning.
  • Web security bypass: Microsoft lists cross-site scripting, CSRF and CORS bypass where applications trust their own subdomains in allowlists or CORS policies.
  • Credentials and tokens sent to the name: OAuth redirect URIs, webhook endpoints, SSO assertion consumer URLs and API callbacks that still point at the subdomain will deliver secrets to whoever controls it. Microsoft warns that secrets such as OAuth credentials sent to a dangling subdomain may be exposed.
  • Email: dangling MX records may let an attacker receive mail for the subdomain, useful for password resets or domain validation.

Where identity fits: stale names are part of the trust configuration of applications and machine identities. App registrations, OAuth clients, SAML service providers and webhook subscriptions all embed URLs, and nobody reviews them when a site is retired. Include redirect URIs and callback URLs in NHI and application reviews. See the OAuth 2.0 Security Best Current Practice (RFC 9700) Guide and the SaaS and OAuth App Governance Guide.

Detection

  • Zone-to-inventory reconciliation: export every DNS zone you host and, for each record pointing at a cloud or SaaS target, confirm the target exists and belongs to you. Microsoft recommends maintaining a service catalogue of FQDN endpoints and owners and reviewing zones regularly.
  • Provider tooling: Microsoft publishes the Get-DanglingDnsRecords PowerShell script, which lists CNAMEs pointing at Azure resources and checks whether they exist; it needs Reader on the subscriptions and read access to Azure Resource Graph, and accepts an input file for zones hosted elsewhere. Microsoft Defender for App Service alerts when an App Service is decommissioned but its custom domain remains in DNS.
  • Response fingerprints: OWASP notes typical signs such as a GitHub Pages 404 "There isn't a GitHub Pages site here" or an S3 NoSuchBucket response for a CNAME target. Treat automated fingerprint matches as leads and confirm manually; OWASP warns that tools produce false positives. When testing your own estate, never claim a resource to "prove" the issue unless your rules of engagement allow it.
  • External attack surface monitoring: passive DNS, certificate transparency logs and ASM tools reveal subdomains you did not know existed, including ones created by other teams or agencies.
  • Expiry monitoring: track registration expiry for every third-party domain your records point to, and for your own secondary domains.
  • Certificate transparency: alert on new certificates issued for your names by issuers you do not use, which can indicate a takeover in progress.

Metrics:

  1. Number of dangling records found per month, and mean time from detection to removal.
  2. Percentage of DNS records with a mapped owner and live target.
  3. Percentage of decommissioning changes that removed DNS before the resource (from change records or pipeline logs).
  4. Percentage of custom domains on supported platforms with ownership verification in place.

Prevention and hardening

ControlHow it worksLimits
Delete DNS before deprovisioningRemoves the pointer before the name becomes claimable; Microsoft suggests delete locks on resources with custom DNS entries as a reminderDepends on people and runbooks; automate it in pipelines
Alias records (Azure DNS, Route 53)The record is tied to the resource lifecycle; in Azure, deleting the resource leaves the alias empty rather than danglingAzure supports alias targets for Front Door, Traffic Manager, CDN endpoints and public IPs only
App Service domain verificationAn asuid.{subdomain} TXT record with your verification ID prevents another subscription validating the custom domainOthers can still create an app with the old name, but cannot bind your domain to it
GitHub Pages domain verificationA _github-pages-challenge-ORGANIZATION TXT record limits publishing on the domain and its immediate subdomains to your repositoriesDoes not protect deeper names under a wildcard
Certificate-bound custom domainsCloudFront requires a trusted certificate covering an alternate domain name before it can be addedRemove alternate names and DNS when distributions are deleted
No wildcards to shared platformsRemoves whole classes of claimable namesRequires explicit records per service
Infrastructure as code for DNSDNS records are created and destroyed in the same change as the resourceOnly covers zones managed in code
Narrow cookie scopeSet cookies host-only or use the __Host- prefix so subdomains cannot read themDoes not stop phishing or token delivery
CAA recordsRestrict which certificate authorities may issue for your domainsAn attacker controlling the name can still obtain a certificate from a permitted CA that validates by HTTP or DNS

Process matters as much as tooling. Add "remove DNS entry" to every decommissioning checklist, give each zone an owner, and require that any new CNAME to an external platform is registered in the service catalogue with an owner and review date. See the Authoritative DNS and Registrar Account Security Guide for protecting the zones themselves.

Framework mapping

FrameworkReferenceRelevance
NIST SP 800-53 Rev. 5CM-8 System Component Inventory; CM-3 Configuration Change Control; SC-20 Secure Name/Address Resolution Service (Authoritative Source); RA-5 Vulnerability Monitoring and ScanningDNS and endpoint inventory, decommissioning as controlled change, authoritative DNS integrity, scanning for dangling records
NIST CSF 2.0ID.AM-02 inventories of services; ID.AM-04 supplier services; ID.RA-01 vulnerabilities identifiedKnowing which names exist, which third parties they point to, and recording dangling records as vulnerabilities
OWASP WSTGWSTG-CONF-10 Test for Subdomain TakeoverTest procedure for application assessments
MITRE ATT&CKT1584.001 Compromise Infrastructure: DomainsAdversary use of captured domains and subdomains

Rolling out the controls

  1. Discover: export all zones (including those managed by agencies and subsidiaries) and run reconciliation against cloud inventories in report-only mode.
  2. Triage: for each dangling record, follow Microsoft's sequence: investigate whether it was already abused, find out why it was missed, delete or repoint it, and review code for hard-coded references.
  3. Fix the pipeline: move DNS for cloud services into the same infrastructure-as-code modules as the resources, and add a pre-destroy check that fails if a record still points at the resource.
  4. Verify ownership: add verification TXT records for every platform that supports them, then remove wildcard records to shared platforms.
  5. Monitor continuously: schedule reconciliation daily, alert the zone owner on any new dangling record, and track the metrics above.

Lessons from incidents

Stale domains do not only sit in your DNS zones; they sit in allowlists. In the ForcedLeak research on Salesforce Agentforce, an expired domain remained on a content security policy allowlist. A researcher re-registered it for about $5, and data sent to that trusted domain was no longer blocked. Salesforce secured the domain and began enforcing Trusted URLs for Agentforce and Einstein AI on 8 September 2025. The lesson matches dangling DNS: any name you trust, in DNS, CSP, CORS, OAuth redirect URIs or webhook settings, must be owned and monitored for as long as the trust exists.

Practitioner checklist

  • Export every DNS zone and map each record to an owner and a live target you control.
  • Run dangling DNS reconciliation at least daily and alert zone owners on findings.
  • Make "remove DNS first" a mandatory step in decommissioning runbooks and pipelines.
  • Use alias records and DNS in infrastructure as code wherever supported.
  • Add ownership verification records for Azure App Service, GitHub Pages and other platforms that support them.
  • Remove wildcard records that point at shared hosting platforms.
  • Scope cookies to the host and review CORS, CSP and OAuth redirect allowlists for names you no longer own.
  • Monitor certificate transparency and third-party domain expiry for names you depend on.
  • When a dangling record is found, investigate for prior abuse before deleting it.

Standards and references

Related NHI Mgmt Group resources: Attack Surface Management Guide · DNS Security Guide · Authoritative DNS and Registrar Account Security Guide · DNS Hijack Playbook

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 27 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.