CertaDNS
Skip to lesson

Records That Outlive Their Services · lesson 1 of 2

Three kinds of dangling

After this lesson you can

Rank a dangling CNAME, NS and MX by what each one hands an attacker.

Assumes you have read An open transfer.

A dangling record points at infrastructure that no longer exists. Three record types do it, and they hand an attacker very different things.

Ranked by what they give away

RecordPoints atWhat claiming it gives an attacker
NSA nameserver that no longer serves the zoneControl of everything under that name — every record, including the ability to pass an ACME DNS-01 challenge and obtain a valid certificate. The most severe of the three and the least often looked for.
CNAMEA SaaS platform where the account was closedA web presence on your hostname, a valid certificate for it, and cookies scoped to your domain. The common one.
MXA mail service no longer in useMail addressed to that name, including password resets and anything a supplier sends to an address nobody monitors.

The dangling NS

Delegating internal.example.com to a provider and later closing the account leaves the delegation in place. Whoever obtains that nameserver name becomes authoritative for the whole subtree.

internal.example.com.  NS  ns1.some-provider.example.

The account is closed. The name becomes available.
An attacker registers it.

They now answer for:
   anything.internal.example.com
   _acme-challenge.internal.example.com   <- certificates
   internal.example.com  MX               <- mail

It is worse than a CNAME takeover by a wide margin, because it is a whole namespace rather than one hostname, and a CAA record at the apex does not prevent issuance for names the attacker now controls unless it explicitly constrains them.

Finding all three

# CNAMEs whose target does not resolve
for name in $(list of names in the zone); do
  target=$(dig +short CNAME $name)
  [ -n "$target" ] && ! dig +short A $target >/dev/null     && echo "DANGLING CNAME: $name -> $target"
done

# NS delegations whose servers do not answer
dig +short NS sub.example.com | while read ns; do
  dig +short A $ns || echo "DANGLING NS: $ns"
done

# MX hosts that do not resolve
dig +short MX example.com | awk '{print $2}' | while read h; do
  dig +short A $h || echo "DANGLING MX: $h"
done

The hard part is the first line — enumerating the names in your zone. That comes from the zone file itself if you hold it, from your provider’s API, or, unhelpfully, from anyone who can walk your NSEC records.

NXDOMAIN is not the same as safe

A target that does not resolve is dangling. Whether it is exploitable depends on whether the name can be claimed — an available domain registration, or a subdomain at a provider with open sign-up. Treat every one as exploitable until you have established the target cannot be obtained, because that is much quicker than being wrong.

Knowledge check

Which dangling record type is the most severe, and why?

Last reviewed