Home / patterns

Dangling DNS records that let someone take over your subdomain

A young developer at a standing desk in a small apartment at night studying a monitor with a blurred table of DNS records and one row highlighted, sticky notes on the monitor edge, a desk lamp and plant, no brand logos
Quick answer: Vibe-coded projects pile up subdomains fast: a demo.yourapp.com on one host, a docs or status page on a SaaS tool, a preview app you deleted last month. If the DNS record (usually a CNAME) still points at a hosting service after the app or account behind it is gone, someone else may be able to claim that same name on the provider and serve their own content on your subdomain. MDN calls this a subdomain takeover. From there an attacker can host a convincing phishing page, read cookies scoped to your parent domain, or slip past a content security policy that trusts *.yourapp.com. The fix is mostly housekeeping: inventory your DNS, delete records first when you take something down, and claim the host before you add DNS.

Last updated November 12, 2026

Steps

  1. Export every DNS record for your domain from your registrar or DNS host (Cloudflare, your registrar, Vercel DNS and so on) into a sheet.
  2. For each CNAME, A/AAAA and MX record, write down what it points to and whether that app, bucket, page or account still exists and belongs to you. Pay extra attention to records pointing at hosting, storage, CDN, docs, status-page, help-desk and email services.
  3. Visit each subdomain in a browser. A provider error page such as “no such app,” “project not found” or “bucket does not exist” is a red flag that the name is dangling.
  4. Delete DNS records for anything you no longer run. MDN’s rule: when taking something down, remove the DNS record first; when setting something up, claim the virtual host first and create the DNS record last.
  5. Where your hosting provider offers domain verification (a TXT record proving you own the domain), use it, so another account can’t attach your subdomain.
  6. Scope session cookies to the exact host that needs them instead of the whole parent domain, and keep CSP and CORS allow-lists to the specific subdomains you actually use instead of *.yourdomain.com.
  7. If a subdomain has already been taken over, remove its DNS record immediately, then check every layer (CDN, hosting) to find where the attacker claimed it.
  8. Add a DNS check to your launch and shutdown checklist, and repeat the inventory every few months.

Why it matters

MDN explains that a takeover typically happens when a subdomain has a CNAME in DNS but no host is serving content for it, either because the host was never set up or was removed, so an attacker can create their own virtual host for that name. It lists the risks as reading cookies set from the main domain, cross-site scripting and getting around content security policies, which can expose logins. Microsoft’s guidance on dangling DNS adds that attackers can get a valid TLS certificate for a hijacked subdomain, so the padlock in the browser doesn’t prove the page is yours, and that MX records left pointing at removed services can let someone receive email meant for your subdomain. This page is for checking and fixing domains you own.

Sources

MDN Web Docs: Subdomain takeover — https://developer.mozilla.org/en-US/docs/Web/Security/Subdomain_takeovers

Microsoft Learn: Prevent dangling DNS entries and avoid subdomain takeover — https://learn.microsoft.com/en-us/azure/security/fundamentals/subdomain-takeover

Checked at the source on November 12, 2026.

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.