Free security runbook · DNS inventory

Subdomain takeover: the CNAME still points at a service you deleted

A subdomain that resolves is not a subdomain you control. When a CNAME still points at a SaaS hostname whose account was closed, or an A record still points at an address that was released, the name keeps answering traffic that nobody on your team can see or fix. The person who claims the abandoned resource inherits your name, your cookies and your certificate.

This page is free. It covers how to find records that outlived the service behind them, how to separate a real dangling target from a harmless 404, and the decommissioning checklist that stops the next one.

Scope: reviewed from the OWASP guidance and the DNS standards, no live reproduction
Verified against the OWASP WSTG and Subdomain Takeover Prevention Cheat Sheet, and RFC 1034, on 2026-11-26. Command output below is the expected shape, not a capture from a live zone. Provider fingerprints and claim protection change over time; confirm against the provider's current documentation before you act.
The shape of it

Why a deleted service still answers

The record outlives the account

Closing a SaaS account removes the resource, not the DNS record you created to point at it. The CNAME keeps resolving to the provider's edge, which now has no tenant for that name.

Claimable is not the same as broken

A dangling target often returns a provider 404, a 403, or a generic holding page. The name still resolves and the provider may still hand it to the next account that asks for it.

More than CNAME

An A record to a released address, an NS delegation to a closed DNS account, and an MX record to a retired mail host are all the same class of failure with different blast radius.

The parent domain decides the impact

A taken-over host can receive parent-domain cookies, satisfy a wildcard certificate, send mail as your domain and appear inside your content security policy.

Detect

Find the records nobody owns

Command or viewWhat it tells you
dig +short CNAME sub.$DOMAINThe target the name delegates to. No output means there is no CNAME, not that the record is safe.
dig +short A sub.$DOMAIN and dig +short AAAA sub.$DOMAINWhether the name resolves directly. An address you cannot map to an inventory entry is a candidate.
while read -r h; do printf '%-40s %s\n' "$h" "$(dig +short CNAME "$h")"; done < hosts.txtOne pass over your name list. Pipe the output to a file and diff it week over week.
curl -sS -o /dev/null -w '%{http_code} %{url_effective}\n' "https://sub.$DOMAIN"The status the target returns now. Record it: a provider 404 or 403 is a lead, not a verdict.
curl -sS "https://sub.$DOMAIN" | grep -i -m1 'NoSuchBucket\|no such app\|404 Web Site not found\|There isn.t a GitHub Pages site here'Known provider error pages. Match on the provider's current text, and confirm manually; scanners produce false positives.
curl -sS "https://crt.sh/?q=%25.$DOMAIN&output=json" | jq -r '.[].name_value' | sort -uNames that once had a certificate, including ones missing from your DNS inventory.
dig +short TXT _provider-verification.sub.$DOMAINWhether a provider verification TXT record is present. Some providers refuse a claim without it; do not treat it as a guarantee.
Failure modes

Seven ways a name gets left behind

#Failure modeWhat you seeWhat to do
1A decommissioned site keeps its CNAMEThe name resolves to the old host and returns a provider error page; the CNAME is still in the zone.Delete the record in the same change that closes the account, not in a cleanup ticket for later.
2An A record to a released addressThe address now belongs to another customer, who serves whatever they like under your name.Track static addresses as owned resources with a release step; remove the record before the address is released.
3NS delegation to a closed DNS accountAn entire child zone answers from a provider you no longer pay for, or stops resolving entirely.Inventory delegations with the parent zone; remove the NS set before closing the child account.
4A wildcard makes one record unboundedAny name under the parent resolves, so a single dangling target covers names you never created.Use wildcards only where a catch-all is intended, and point them at a resource you control and monitor.
5MX pointing at a retired mail hostMail for the domain is accepted by a service that no longer has your mailbox, or bounces unpredictably.Remove or repoint MX before cancelling the mail plan, and check SPF and DMARC alignment at the same time.
6Parent-domain cookies reach the taken-over hostA session cookie scoped to .$DOMAIN is sent to a host you do not control.Scope cookies to the exact host, and treat any subdomain as part of the session boundary.
7Detection that only looks for HTTP 200The scan reports clean because the dangling target returns 404, while the provider would still hand the name to a new account.Classify by target ownership, not by status code: does the CNAME destination still map to a resource you own?
Design

Make ownership a record, not a memory

DecisionQuestion to answer
InventoryDoes every record name an owner, a service and a review date, or is the zone file the only source?
Decommission orderDoes the runbook remove DNS before the account is closed, and who signs off that both are done?
Verification recordsWhich providers require a TXT or CNAME proof, and is it pinned to the account you still control?
WildcardsIs each wildcard deliberate, documented, and pointed at a target that cannot be claimed by someone else?
MonitoringWho runs the weekly dangling-record scan, and where does a hit become a ticket with an owner?
Verify

Four checks before the next cleanup

Resolve every name

Run the CNAME and A pass over the full list, not a sample, and store the output. A name missing from the list is the one that gets missed.

Map target to owner

For each target, name the account, the service and the person who would notice if it disappeared. No owner means no control.

Test a canary

Create one record you intend to remove, remove the backing resource, and confirm the scan flags it and the alert reaches a human.

Watch certificates

Subscribe to certificate transparency for the parent domain and review new names; a certificate for a name you cannot explain is an early signal.

FAQ

Questions from the DNS review

Does HTTPS protect a subdomain from being taken over?

No. The certificate is issued to whoever controls the name at that moment. HTTPS keeps the connection private; it does not prove that the operator is you.

The target returns 404. Is that safe?

Not by itself. A 404 means the provider has no resource for that host right now. The question is whether the provider will let another account claim the same hostname, which is a policy question, not a status code.

Can we just remove every unused record?

Yes, and that is the goal, but do it from an inventory that names the owner. Deleting a record that something still depends on is its own outage. Remove the record and the resource in one planned change.

What is the first thing to check after a decommission?

That the CNAME, A, NS and MX records for the retired name are gone, and that no parent-domain cookie or wildcard certificate still assumes the name exists.

Sources

Primary sources

Going deeper on exposed infrastructure?

The paid runbooks cover the surrounding failures: origin addresses that bypass the proxy, tunnel exposure that outlives the team, and edge rules that hide a deploy.

This page is free, no checkout. Paid runbooks are $9.99 each and covered by the 7-day refund policy at /runbooks/refund.