Subdomain takeover
TL;DR: Dangling CNAME pointing at an unclaimed cloud resource — register it, serve attacker content from the trusted subdomain.
What it is
Apps frequently point subdomains at third-party SaaS (foo.target.tld → app.heroku.com, s3.amazonaws.com, azureedge.net, ghs.googlehosted.com). When the SaaS resource is deleted but the CNAME is left in DNS, anyone who can claim a resource with that name at the SaaS captures the subdomain. The attacker now serves arbitrary content from a trusted origin — cookies, CSP allowlists, SSO redirects, password reset URLs all extend the impact.
Preconditions / where it applies
- DNS CNAME / ALIAS pointing at a third-party service that allows attackers to register the dangling identifier
- Service does not verify ownership of the target hostname (or verification is bypassable)
- Optional: parent domain cookie scope, SSO trust, CSP allowlist, OAuth
redirect_uriallowlist that includes the subdomain
Technique
- Enumerate subdomains — passive (crt.sh, Subfinder, Amass, Chaos), active brute-force (puredns + commonspeak/dns-words).
- Probe each subdomain for a takeover fingerprint:
1 2
subfinder -d target.tld -silent | dnsx -cname -resp \ | nuclei -t http/takeovers/ -severity high
Look at HTTP responses: “There isn’t a Github Pages site here.”, “NoSuchBucket”, “Repository not found”, “Heroku | No such app”, “404 Web Site not found” (Azure).
- Match service — the dangling-target list at
EdOverflow/can-i-take-over-xyzdocuments each fingerprint, which SaaS, and how to claim. - Claim the resource — create the matching bucket/app/site name at the SaaS using a fresh account.
- Upload content / cert — many SaaS issue TLS certs (Let’s Encrypt) automatically for the claimed name; you now have HTTPS on
foo.target.tld. - Weaponise:
- Cookies scoped to
.target.tldare sent to your origin (session theft). - Phishing under the trusted brand.
- Bypass CSP
script-src foo.target.tld. - Hijack OAuth
redirect_urithat allow*.target.tldor include the subdomain. - Pixel-track every visitor.
- Cookies scoped to
- NS / DNS-zone takeover — variant:
target.tlddelegates a zone to a nameserver provider account that lapsed; register the account, control the entire zone. - MX takeover — dangling MX to abandoned mail provider → receive mail (password resets, etc.).
Detection and defence
- Inventory DNS records with
dnscontrol/octoDNS; CI job that resolves every CNAME and verifies the target responds with an owned indicator. - When deprovisioning a SaaS resource, delete the DNS record first, the resource second.
- Use ownership-verified subdomains where the SaaS supports it (Cloudflare Workers, Vercel custom-domain verification).
- Monitor cert transparency for new certs on your zones — attackers issuing for
foo.target.tldshow up immediately. - Scope cookies narrowly (no
Domain=.target.tldunless required); limit CSP/OAuth allowlists to specific subdomains. - Related: dangling-dns-takeover, cors-misconfig, oauth-flows, sso-attacks.
References
- can-i-take-over-xyz — service-by-service fingerprint catalog
- HackerOne — subdomain takeover writeups — real cases
- Detectify — subdomain takeover — taxonomy