DNS Server Fundamentals Series

🪝 Understanding Subdomain Takeover (Dangling DNS) From a Top 1% Perspective — What Happens if You Forget to Delete the DNS Record Before Deleting the Cloud Resource

Introduction

This article is part of the Top 1% Series Complete Article Guide, and article 1.2 in the DNS Series.

Prerequisite Knowledge

Getting the Big Picture

It’s extremely common to configure a CNAME on a subdomain like blog.example.com, pointing it at a cloud service’s resource name, like example.herokuapp.com. But if you delete that Heroku app, S3 bucket, or Azure App Service and forget to delete the CNAME record on the DNS side, that CNAME keeps hanging around “dangling.” If an attacker re-registers that exact same resource name (the same bucket name, say) under their own cloud account, your company’s own legitimate subdomain starts serving the attacker’s content — and that’s subdomain takeover.

sequenceDiagram
    participant DNS as DNS CNAME record
    participant Cloud as Cloud resource
    participant Attacker as Attacker
    DNS->>Cloud: blog.example.com -> my-bucket.s3...
    Note over Cloud: Operations deletes my-bucket
    Note over DNS: Forgets to delete the CNAME record (dangling)
    Attacker->>Cloud: Re-registers the same name my-bucket under their own account
    DNS->>Attacker: Access to blog.example.com now reaches the attacker's content

Deep Dive Into the Fundamentals

Why Re-Registering a Cloud Resource Can Hijack Someone Else’s Domain

Cloud services like S3, Heroku, and Azure App Service often manage resource names (bucket names, app names) within a single namespace shared across every single user. The instant a resource under some name gets deleted, that name goes right back to being available for anyone to claim — so if an attacker finds a name still left behind as a CNAME on the DNS side and creates a brand-new resource under that exact same name, the cloud side forwards access from that DNS name straight through to the resource the attacker just created.

A Real-World Incident: Over 8 Million Requests to Deleted S3 Buckets

One study re-claimed around 150 deleted S3 buckets for research purposes, and received over 8 million requests in total, including requests looking for software updates. In 2025, a threat actor group known as Hazy Hawk was reported to be abusing dangling DNS records, attacking targets including government agencies and large enterprises. A hijacked subdomain gets treated as part of a domain your company legitimately owns, so it gets used for attacks that directly abuse the trust users place in that domain — phishing, malware distribution, cookie theft, and more.

A Clue for Detection: a Cloud Service's Own Distinctive Error Message

To detect a dangling CNAME, enumerate your subdomains and check whether each CNAME’s target actually resolves to anything. On top of that, a service’s own distinctive error message — like AWS’s NoSuchBucket — is itself an important clue: “this resource name hasn’t been claimed by anyone yet, and is available to be taken over.”

What a Pro Sees Here (Top 1% Understanding)

Always Treat Deleting a Resource and Deleting Its DNS Record as a Single, Inseparable Operation

Deleting a cloud resource and deleting the DNS record that pointed at it tend to happen on separate teams, or at separate times — and exactly that “dangling window” in between is an entry point for an attacker. The discipline of always deleting the DNS record first, or at the same time, before deleting the resource itself is the perspective a top-1% engineer uses to prevent a breach that isn’t even really a misconfiguration — just a simple thing forgotten.

Common Misconceptions and Pitfalls

Troubleshooting Perspective

  1. Your own subdomain is displaying unintended content: Check whether the cloud resource that subdomain’s CNAME points to has already been deleted and re-registered by someone else.
  2. You’re planning to delete a cloud resource: Before deleting it, inventory whether any DNS record points to it, and delete the DNS record first.
  3. You want to continuously monitor the state of every subdomain your company owns: Set up a system that enumerates subdomains and periodically checks whether each CNAME resolves, along with watching for each cloud service’s own distinctive error messages.

Summary

Takeaways to Apply Today

  1. When deleting a cloud resource, always treat deleting the DNS record that points to it as part of the same, single operation.
  2. Consider setting up a system to periodically inventory your company’s subdomains and what their CNAMEs actually point to.

References

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).