Wildcard DNS Records Hide Subdomain Takeover Risk
Overview
When a wildcard record answers a takeover scanner's probe for a non-existent label, some tools stop enumerating the zone, so dangling CNAMEs to deprovisioned S3, Heroku or Front Door endpoints can go unflagged while attackers find them in certificate transparency logs.
At a glance
- Symptom
- Takeover scanner sees wildcard resolve and abandons subdomain enumeration entirely
- Likely cause
- Wildcard A record combined with unaudited CNAMEs pointing at third-party PaaS endpoints
- Impact
- Attacker claims deprovisioned CNAME target, serving trusted-domain phishing pages that pass cookie, CSP, and SSO checks.
- Verification signal
- Re-run the detection test and a controlled negative-path test.
- Safe correction
- Enumerate via crt.sh, cross-check zone CNAMEs against live provider APIs, terminate wildcards at own LB with fail-closed 404
- Rollback or recovery
- Restore the exported configuration if the new control blocks required production traffic, then narrow the policy before redeployment.
The Trap
A wildcard record such as *.domain.com, added as an A record pointing at a load balancer or CDN, is meant to catch mistyped or dynamically provisioned subdomains. Subdomain enumeration and takeover tooling commonly uses a wildcard-detection heuristic: query a random non-existent label against the zone, and if it resolves, treat the domain as wildcarded and discard results that look like wildcard answers or, in some tools, skip further enumeration, to avoid false positives. That heuristic is the trap.
The Default State
Platform teams add the wildcard once, usually for a multi-tenant SaaS front door, and never revisit it. Meanwhile specific CNAME records already exist elsewhere in the same hosted zone, created months earlier for marketing microsites, staging apps, or partner integrations, pointing at third-party endpoints such as an S3 bucket website endpoint, a Heroku app, or an Azure Front Door hostname. DNS exact-match resolution always overrides the wildcard for those specific labels, so blog.domain.com or partner.domain.com still resolves to whatever the CNAME target says, even after that cloud resource has been deleted.
The Blast Radius
Internal scans and external bug bounty tooling see the wildcard hit, conclude the zone is uniformly wildcarded, and abandon enumeration or filter out what they find. The dangling CNAME to the deleted S3 bucket or Heroku app is never flagged. An attacker skips DNS brute-forcing altogether, pulls every historical hostname for domain.com from crt.sh certificate transparency logs, finds partner.domain.com pointing at an unclaimed Heroku app, claims that app name, and serves arbitrary HTML on a subdomain of the company’s own domain. Cookies scoped to domain.com, CSP allow-lists, and SSO redirect whitelists all trust the hostname, so the attacker inherits session context and can run credential-harvesting pages that pass every domain-based trust check the browser enforces.
The Lead Mechanic Fix
Stop relying on wildcard-detection heuristics for takeover scanning. Enumerate via certificate transparency instead: pull every issued hostname with a crt.sh query against the domain, then cross-reference each one against the live zone export with aws route53 list-resource-record-sets --hosted-zone-id Z123ABC | jq '.ResourceRecordSets[] | select(.Type=="CNAME")'. For every CNAME target, resolve it directly against the third-party provider’s API, not just DNS, to confirm the resource is still claimed. Fail CI on any target returning NXDOMAIN, a provider-specific “no such app” page, or an unclaimed bucket response. Never point a wildcard directly at a third-party PaaS CNAME; terminate wildcard traffic at your own load balancer with a default 404 vhost, and require unmapped tenant lookups to fail closed rather than silently resolving.
Related reading
Apply the safer control
Before you change production
Confirm the affected scope, export the current configuration, and test the replacement control in a non-production environment first.
Fix commands and configuration
aws route53 list-resource-record-sets --hosted-zone-id Z123ABC | jq '.ResourceRecordSets[] | select(.Type=="CNAME")'Verify, roll back or escalate
Verify
Re-run the detection test and a controlled negative-path test. Confirm the unsafe behaviour is blocked while approved traffic still succeeds.
Rollback
Restore the exported configuration if the new control blocks required production traffic, then narrow the policy before redeployment.
Escalate
Escalate when the blast radius is uncertain, the control cannot be tested safely, or remediation requires an outage or security exception.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Last updated
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.