Offensive Security

Subdomain Takeover: How a Forgotten DNS Record Hands Over Your Domain

Marketing spins up a campaign site on a hosting platform and points promo.yourcompany.com at it. The campaign ends. The hosting account is deleted. The DNS record is not.

Subdomain Takeover: How a Forgotten DNS Record Hands Over Your Domain

That record now points at a name on a provider where anybody can claim an unused name. Whoever claims it serves whatever they like at promo.yourcompany.com, with a valid certificate, from your domain.

What makes it possible

A CNAME delegates a name to a provider. Providers allocate names on a first-come basis. When you release your resource, the name returns to the pool while your CNAME keeps pointing at it.

The vulnerable pattern is always the same: your DNS record resolves, the target no longer belongs to you, and the provider lets a new account claim it. Platform hosting, object storage, documentation and support tools, status pages, email and marketing platforms have all been affected at various times.

Why it is worse than it sounds

This is not a defacement of an unused page.

  • Cookies. Cookies scoped to .yourcompany.com are sent to every subdomain, including the hijacked one. Session tokens scoped this way are readable by the attacker.
  • Phishing with a genuine domain. The page is on your real domain with a valid certificate. Nothing a user can check will look wrong, and awareness training specifically teaches people to check exactly that.
  • Trusted origins. Content security policies and CORS configurations that allow *.yourcompany.com now trust attacker content.
  • Reputation. Your domain starts serving malware or scam content and gets listed by blocklists, affecting the main site and email delivery.

Finding them

The method is straightforward: enumerate your subdomains, resolve each, and look for records that resolve to a provider but return a provider error page rather than your content.

  1. Pull subdomains from your own DNS zones, certificate transparency logs and passive DNS sources. Certificate transparency is particularly useful because any certificate ever issued for a name appears in it.
  2. Resolve each one and note the CNAME target.
  3. Request each and look for the characteristic "no such app" or "bucket does not exist" responses.
  4. Verify before reporting. Some provider error pages look alarming and are not actually claimable.

Open-source tooling automates all of this, which is precisely why attackers scan for it continuously. Assume your domain is being checked regularly.

Fixing and preventing

The fix is almost always to delete the record. If the subdomain is still needed, reclaim the name on the provider first.

Prevention is process rather than technology:

  • Decommissioning must include DNS. Most takeovers trace back to a checklist that covered the application and not the record pointing at it.
  • Record an owner and purpose for every entry. Records nobody can explain are the ones that get abandoned.
  • Review the zone periodically and resolve everything in it.
  • Scope cookies narrowly. Avoid domain-wide cookies so a hijacked subdomain cannot read sessions.
  • Avoid wildcard trust in content security policies and CORS configuration.
  • Publish a security contact so researchers who find one can tell you quickly.

Wildcards cut both ways

A wildcard DNS record means every possible subdomain resolves, which prevents this specific issue and creates others — any name resolves, so phishing with an arbitrary subdomain of your domain becomes trivial and enumeration becomes meaningless.

Prefer explicit records with an owner recorded against each.

Frequently asked questions

How do I know if a subdomain is vulnerable?
It resolves through a CNAME to a provider, and requesting it returns a provider error page saying the resource does not exist. Verify that the target name is genuinely claimable before treating it as confirmed.
Is a takeover serious if the subdomain was unused?
Yes. The risk comes from the domain, not the page: domain-scoped cookies, trusted-origin rules and phishing credibility all apply regardless of whether anyone visited the subdomain before.
How often should DNS records be reviewed?
At least quarterly, and as a mandatory step whenever a service is decommissioned. Most takeovers originate in a shutdown process that did not include DNS.

Related reading

0 comments

Leave a comment

Comments are moderated before appearing.