Security & Reliability · Paper-to-Production

Subdomain Takeovers and Orphaned Records

How dangling DNS pointers to third party services allow adversaries to commandeer official government domains for pocket change.

Key Thesis

Dangling CNAME records occur when a resource is deleted from a third party provider without cleaning up the corresponding DNS pointer. Adversaries can register the orphaned target identifier on the provider platform to hijack the parent domain for pennies. Engineering teams must automate reconciliation between cloud resource inventories and DNS zone files to prevent this vulnerability.

The Mechanics of Dangling Pointers

Modern web infrastructure relies heavily on third party SaaS, cloud hosting, and content delivery networks. When an organization provisions a service, engineers typically map an external domain to an internal resource using a Canonical Name or CNAME record. This record acts as a pointer in the Domain Name System, translating a human friendly address into an external provider endpoint [E3].

The failure mode emerges during resource decommissioning. When an engineer deletes an AWS S3 bucket, a Heroku app, or a GitHub Pages site, the external provider releases the underlying subdomain namespace back into a global pool. However, the authoritative DNS server often retains the corresponding CNAME record pointing to that exact decommissioned identifier [E3].

[Authoritative DNS Server] 
      │
      ├── CNAME: analytics.treasury.gov ──► [External Provider Endpoint]
      │                                             │
      │                                     (Resource Deleted)
      │                                             │
      └── (Pointer Now Dangling)                    ▼
                                         [Namespace Available]
                                                    │
                                            (Purchased for $3)

Exploiting the Namespace Vacuum

An adversary scanning corporate or government assets discovers the dangling CNAME record by querying DNS zones and observing NXDOMAIN or specific error pages returned by the third party provider. The attacker then registers an account on the target provider and claims the exact subdomain or bucket name that the enterprise just abandoned [E3].

Because the CNAME record remains active, any user resolving the parent domain is routed directly to the infrastructure now controlled by the attacker [E3]. This enables credential harvesting, session hijacking, and phishing campaigns backed by the legitimate SSL certificates or trust anchors of the original organization.

Metric / ParameterValueEngineering Implication
DNS TTL Default300 to 86400 secondsCached records delay the propagation of fixes
Acquisition Cost$3.00 USDMinimal economic barrier for threat actors
Verification ScopeAutomated ScannersContinuous enumeration exposes orphan windows
Trust InheritanceValid Parent DomainBrowsers render content under trusted enterprise context

Falsification test for this vulnerability model: if cloud providers implemented mandatory ownership validation tokens that automatically revoked DNS mappings upon resource deletion, the exploit window would shrink to zero.

Automated Mitigation Strategies

Defending against subdomain takeovers requires treating infrastructure configuration and DNS records as a single unified state machine. Manual audits inevitably fail because infrastructure provisioning happens dynamically via CI/CD pipelines while DNS records are frequently managed statically [E4].

Engineering teams must implement continuous reconciliation checks between cloud asset inventories and DNS zone files. If a resource identifier disappears from the cloud provider API, the automated pipeline must purge the associated CNAME record before the namespace becomes available to the public [E4].

import boto3
import dns.resolver

def audit_cname_records(zone_files):
    for record in zone_files:
        if record.type == 'CNAME':
            target = record.target
            if "amazonaws.com" in target:
                if not bucket_exists_in_aws(target):
                    print(f"CRITICAL: Dangling CNAME found -> {record.name}")

Closing the Lifecycle Loop

The fundamental lesson from these recurring incidents is that decoupling resource lifecycle management from DNS management creates dangerous security gaps [E4]. When developers delete cloud resources, they operate inside an application mindset, ignoring global namespace collision risks.

Organizations must enforce strict infrastructure as code paradigms where DNS records are bound to the lifecycle of the underlying compute or storage resource. By eliminating manual DNS cleanups, engineering groups remove the human error vector that allows low cost domain takeovers to succeed.

References

Discussion (2)

Greg Miller Principal SRE / DBA · Reston, VA

What happens when a large org with thousands of CNAME records tries to reconcile them against cloud resource inventories - do you end up with a thundering herd of DNS updates that cause a temporary outage?

Tomasz Kowalski Principal Distributed Systems Architect · Chicago, IL

In 2021, a decommissioned S3 bucket with a CNAME to cdn.corp.example.com stayed in DNS for 14 days post-delete. We caught it via automated DNS-HA scans, only to find the namespace had been claimed by a fast-moving threat actor who’d pre-registered the bucket name. Fix propagation took 3.5 hours (TTL 300), but internal tooling didn't flag the gap until the first malformed 403 appeared in logs. The takeaway: inventory sync alone isn’t enough. You need active resolution validation, preferably with real-world DNS probes from multiple vantage points.