Skip to content
cloudgrip

$ man subdomain-takeover

//Cloud and identity

What is a subdomain takeover?

A subdomain takeover happens when a DNS record still points to a cloud or hosting resource that has been deleted. An attacker registers that resource and then serves their own content from a subdomain the organization still owns.

  • Cloud and identity
  • 3 min read
  • updated Nov 11, 2026

How it works

The Domain Name System (DNS) maps names to destinations. A subdomain takeover is possible when a name you control points to a destination you no longer control.

The usual sequence looks like this. A team launches a documentation site on a hosting platform and creates a DNS record sending docs.acme.test to the platform. A year later the site is retired and the hosting account is closed, but the DNS record stays. The record now points at an empty slot. On many platforms, anyone can open an account and claim that slot. Whoever does so decides what visitors to docs.acme.test see.

The leftover record is called a dangling DNS record. The organization gave away the destination and forgot to remove the signpost.

What it looks like

This record remains in the company's DNS zone:

output
docs.acme.test.     3600   IN   CNAME   example-docs.hosting-provider.example.

A CNAME record says that one name is an alias for another. The target, example-docs.hosting-provider.example, belonged to the company's hosting account. That account was closed, so the target name is free.

An attacker signs up with the same provider, creates a site and requests the name example-docs. The provider grants it. From then on, https://docs.acme.test shows the attacker's page, in the company's own domain.

CNAME records are the most common case, but not the only one. A name server (NS) record that delegates a subdomain to a lapsed DNS hosting account can hand over the whole subdomain.

What an attacker gains

A real subdomain of a trusted company is valuable.

  • Convincing phishing. The address in the browser bar is genuine.
  • A valid certificate. Controlling the content of a host is normally enough to obtain a TLS certificate for it.
  • Cookies. Session cookies scoped to the parent domain are sent to every subdomain, including the hijacked one.
  • Bypassing allowlists. Applications often trust *.acme.test for cross-origin requests, login redirects or script loading. A hijacked subdomain inherits that trust, which can turn a takeover into account compromise.

How to test for it

  1. Collect the names. Export your DNS zones. Add names discovered from outside, through certificate logs and DNS enumeration, because zones in forgotten accounts are where problems hide. This is part of knowing your attack surface.
  2. Resolve each record. Note CNAME and NS records that point to third-party services.
  3. Look for dead targets. A CNAME whose target does not resolve is the strongest signal. Another is a provider's default error page saying that no such site, app or bucket exists.
  4. Check whether the target can be claimed. This depends on the provider. Some verify domain ownership before attaching a custom hostname, which blocks the attack. Others do not. Provider behavior changes over time, and the community project can-i-take-over-xyz tracks it.
  5. Prove it carefully. In an authorized test, claim the resource and serve a harmless file with a unique marker at an obscure path. Never serve content to real visitors, and release or hand over the resource afterwards.

How to fix it

For a dangling record, delete the record or reclaim the resource it points to. To prevent the next one:

  • Remove DNS first. When retiring a service, delete the DNS record before deleting the resource. When launching, create the resource before the record.
  • Define the record and the resource together in infrastructure code, so they are removed together.
  • Use provider safeguards where they exist, such as domain verification tokens or records that are tied to the life of the resource.
  • Monitor continuously. Check all records on a schedule for dead targets, as part of attack surface management. External discovery tools keep the list of hostnames current. Recon in Cloudgrip's Hydra maps forgotten hosts and subdomains as part of each test.
  • Reduce blanket trust. Avoid cookies scoped to the whole parent domain and wildcard allowlists such as *.acme.test where a specific hostname will do.

How it differs from domain hijacking

In domain hijacking, the attacker takes control of the domain registration itself, for example by breaking into the registrar account. A subdomain takeover is narrower and needs no access to any of your accounts. The attacker only claims a resource you abandoned.

See what an attacker would find.

Give us a URL and two test logins. If there’s something to find, your first exploited findings land within 24 hours.

You talk to the people who build Hydra and Cerberus. No sales script.

or write to founders@cloudgrip.ai