How do you prevent subdomain takeover from dangling DNS records?
AdvancedScenarioDNS & Service Discovery
Answer
Situation read → A CNAME pointing to a deleted cloud resource can be claimed by an attacker.
What I'd do →
- Inventory all DNS records through exports from Route 53:
aws route53 list-resource-record-sets --hosted-zone-id Z123 - Scan CNAMEs for NXDOMAIN or provider takeover fingerprints with tools like
subjackornuclei - Make decommission steps delete DNS first
- Put DNS in Terraform so resource and record share a lifecycle
- Alert on new CNAMEs to third-party domains
Why → The record outlives the resource, and anyone who can claim the target name gets your domain's trust.
Interview tip → Say DNS belongs in the same pull request as the infrastructure it points to.
More on DNS & Service Discovery
A customer types www.example.com in a browser. Walk through how DNS resolves it.BeginnerWhat is the difference between an A record and a CNAME, and when do you use each?BeginnerWhy can't you put a CNAME at the zone apex, and what do you use instead?BeginnerYou are moving a site to a new server. What do you do with DNS to make the cutover smooth?BeginnerHow do you find which nameservers are authoritative for a domain and query them directly?BeginnerWhat DNS records do you set up for company email?Beginner