Dangling DNS: AWS EC2
Several subdomains of a private program had DNS records pointing to AWS EC2 IP addresses that had been released back to the AWS pool, creating dangling DNS records. An attacker could claim those IPs with a new EC2 instance and serve content under the trusted subdomains.
Published on medium.com
{{media:0}}
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This is a story about dangling DNS records on AWS EC2, told across a private bug bounty program referred to as Private Program #1 with the asset scope *.example.com. The subdomains in question (fig.example.com, github.example.com, goose.example.com) had CNAME records pointing at AWS EC2 hostnames. When an EC2 instance is terminated without an elastic IP, its address returns to the AWS IP pool and can be reassigned to another AWS customer, while the DNS record still points at it. That is the dangling record.
The write-up is by Mohamed Elbadry, also known as melbadry9. The timeline runs from 3 October 2019 to 10 July 2020, with payment on 16 June 2020.
Setup
The tools used were:
- Sublist3r for subdomain enumeration.
- Dirsearch for directory brute forcing.
- A CNAME filtering tool the author wrote, published at
https://github.com/melbadry9/cname/. - Shodan, for archived SSL certificate data.
- Google dorks and Bing, for searching by IP.
No accounts, roles or versions are described beyond the private program scope *.example.com.
Finding it
The first subdomain
Enumeration with Sublist3r surfaced fig.example.com. The author says he had no idea why it was interesting, but it was. Opening http;//fig.example.com/ in a browser showed a blank page with empty HTML code. Dirsearch then found http://fig.example.com/includes/ with directory listing enabled.

He reported it and received a response.
Two more subdomains
Looking for the same issue on the rest of the subdomains, he found github.example.com and goose.example.com. The tell was that they redirected to a totally different site.

He then checked the DNS records to see whether they would help identify other subdomains with the same issue.

What the three had in common was Amazon Web Service. He filtered subdomains by their CNAME records using the tool he had written. An hour of checking for similar issues produced nothing, so he set it aside for the moment. His own summary of what he had missed: check for open ports.
Second and third reports
On 24 November 2019 he filed another report against *.example.com.
The response:
At this point he knew the program had a serious issue with dangling DNS records. On 26 November 2019 he filed a third report against the same asset.
Exploitation
Step 1: confirm the record is really dangling
By 26 December 2019 he had a list of possible subdomains with dangling DNS and no way to be sure. The first check was the SSL certificate.

As the caption puts it, it is definitely not the target.
The second check was Shodan, for the archived SSL certificate.

That settled it: a dangling DNS for sure.
Step 2: search by IP
He also suggests Google dorks or Bing with the query ip: [redacted].
Step 3: ask
Sometimes all you have to do is ask.
He notes it is great when you build trust with the security team.
Step 4: report the full set
On 16 June 2020 came payment. The write-up also records a report against *.example.com under that date.
After monitoring subdomains and confirming that every subdomain had a dangling DNS record before reporting, the program asked him to supply every possible dangling record and said they would confirm them all at once.

They all turned out to have dangling DNS records.
Root cause
The write-up traces the issue to a 7 October 2015 blog post by Matt Bryant, "Fishing the AWS IP Pool for Dangling Domains", about the AWS IP pool:
"What happened to that IP tied to that EC2 instance that you just killed? Well, when you terminate an instance, that IP address isn't put to waste. Instead, it's reused by other AWS customers. There is a massive pool of IP addresses that are constantly being recycled and trusted by various organizations and people."
The issue happens when a company uses an EC2 instance without an elastic IP. If the instance is killed or terminated and the DNS is not updated, the subdomain is left with a dangling DNS record. The EC2 IP is released back to the AWS IP pool, which means it is possible to assign that IP to a new EC2 instance.
Impact
The report does not spell out a specific attacker capability beyond the dangling record itself. What it establishes is that the subdomains pointed at AWS addresses that had been released to the pool and could be reassigned to another AWS customer, and that the records were confirmed dangling rather than merely suspected. The author stresses confirming the dangling state before reporting, to avoid an N/A.
Fix
The report does not describe a fix applied by the program. The implied remedy is to keep DNS records in step with EC2 lifecycle: update or remove the record when an instance is terminated, and use elastic IPs so the address is not returned to the shared pool.
Variants to test
- Check for
compute.amazonaws.comorcompute-1.amazonaws.comin CNAME records. A positive result is a subdomain whose CNAME resolves to one of those hostnames. - Confirm that the record is dangling before reporting, as described above. Confirm that the record is dangling before reporting, as described above, using the SSL certificate and Shodan checks.
- Search by IP with a dork such as
ip: [redacted]on Google or Bing. - Filter an enumerated subdomain list by CNAME, as the author did with his own tool.
- The author notes that what he had missed was checking for open ports.
The author also lists case studies of the same class of issue at Transloadit, Avast and Amazon itself, and in private programs.
His closing advice: do not ignore old research, it might be old but not dead, and building trust with security teams is a two-way street.
What happened, in plain words
A company owned a set of subdomains under its main domain, example.com. Some of those subdomains, such as fig.example.com, were set up to point at computers rented from Amazon Web Services (AWS), specifically its EC2 service, which lets anyone rent a virtual computer in the cloud. When the company stopped renting one of those computers, the address of that computer went back into Amazon's shared pool of addresses, ready to be handed to somebody else. But the company's DNS record, the entry that tells the internet "this subdomain lives at this address", was never updated. It kept pointing at an address that no longer belonged to the company. That leftover entry is called a dangling DNS record.
Mohamed Elbadry, known online as melbadry9, found several of these on a private bug bounty program (a company that pays people for reporting security problems, but does not let the reports be published with the company's name). Over several months he confirmed that the records really were dangling, reported them, and was paid. The timeline in his write-up runs from 3 October 2019 to 10 July 2020, with payment on 16 June 2020.
This article walks through the same steps he did, explaining each idea from scratch. You only need a browser and a computer to follow along.
The ideas you need first
Before the story makes sense, here are the basic pieces, in everyday terms.
- A domain and a subdomain. A domain is a name people type, like
example.com. A subdomain is a name in front of it, likefig.example.com. Companies use subdomains for different services: one for the shop, one for support, one for internal tools. - DNS. DNS is the internet's address book. When you type a name into your browser, DNS translates it into a numeric address (an IP address) so your computer knows which machine to talk to. A DNS record is one line in that address book.
- CNAME record. A CNAME (canonical name) is a DNS record that says "this name is another name for that name". It is like a note in an address book saying "ask the person at this other address instead". Companies often use CNAMEs to point their own subdomain at a service run by somebody else, such as a cloud provider.
- IP address and IP pool. An IP address is the numeric label of a machine on the internet. Cloud providers own huge ranges of them and rent them out. When a customer stops using one, it goes back into a pool and can be given to a different customer later.
- AWS EC2. Amazon Elastic Compute Cloud is a service where you rent a virtual computer (an "instance") by the hour. Each instance gets an IP address. If you do not reserve a fixed address (an elastic IP), the address is temporary and returns to Amazon's pool when the instance is shut down.
- Dangling DNS record. A DNS record that still points at something that no longer exists or no longer belongs to you. It is like leaving a forwarding note on your door that sends visitors to an apartment where somebody else now lives.
- Subdomain takeover. The risk that follows from a dangling record: if the address is reassigned to a stranger, that stranger's machine now answers for your subdomain. Visitors who trust your name end up talking to someone else.
- Bug bounty program. A company that invites outside researchers to look for security problems and pays for valid reports. A private program is invitation-only, and its details are not public.
- N/A. Short for "not applicable". In bug bounty work it means the report was rejected as not a real issue.
- SSL certificate. The digital document a website presents to prove it is who it claims to be, and to encrypt traffic. Certificates are tied to names, so looking at a certificate can tell you which name a machine was set up to serve.
- Shodan. A search engine for internet-connected machines. It records what services and certificates machines were offering, including historical data.
- Directory listing. A web server setting that, instead of showing a normal page, shows a list of files in a folder, like opening a drawer and seeing everything inside.
- Brute forcing directories. Trying a long list of common folder and file names against a website to see which ones exist.
- Google dork. A search query with special operators, used to find specific things on the web.
ip:is one such operator. - Open port. A numbered door on a machine that accepts connections. Checking which doors are open tells you what services a machine runs.
The tools he used
- Sublist3r, to collect subdomain names from public sources.
- Dirsearch, to try many folder names on a website.
- A CNAME filtering tool he wrote himself, published at
https://github.com/melbadry9/cname/, to pick out subdomains whose DNS records share a pattern. - Shodan, to look at archived SSL certificate data.
- Google dorks and Bing, to search the web by IP address.
Finding it
The first subdomain
He started by collecting subdomains with Sublist3r. That surfaced fig.example.com. In his words he had no idea why it was interesting, but it was. He opened http;//fig.example.com/ in a browser and got a blank page with empty HTML code. (Note the semicolon in that URL: it is written that way in the write-up.)
He opened the subdomain and got a blank page with empty HTML code, so he tried Dirsearch. That is why he then tried Dirsearch: if the server is there but the front page is empty, maybe other folders exist behind it.
Dirsearch found http://fig.example.com/includes/, a folder with directory listing enabled. That means anyone visiting that address sees a list of the files inside, rather than a proper page. It is like a shop leaving its stockroom door open with an inventory sheet taped to it.

He reported it and received a response.
Two more subdomains
He then looked for the same kind of problem on the rest of the subdomains. Soon he found github.example.com and goose.example.com behaving the same way. How did he know? Because they redirected to a totally different site. A redirect is when a website sends your browser somewhere else automatically. If your company's subdomain sends visitors to an unrelated site, something is wrong with where that subdomain points.

He then checked the DNS records, on the idea that they might help him spot other subdomains with the same problem.

What the three had in common was Amazon Web Service. That is the clue: all three subdomains were set up to point at machines rented from AWS.
He filtered his subdomain list by their CNAME records, using the tool he had written for the purpose. The idea is simple: if one subdomain points at AWS and is broken, other subdomains pointing at AWS are worth a look. After an hour of checking he found nothing more, so he set it aside for the moment.
His own summary of what he had missed at that point: check for open ports.
Second and third reports
On 24 November 2019 he filed another report against the same scope, *.example.com. The * is a wildcard meaning "any subdomain of example.com".
The response:
At this point he knew the program had a serious issue with dangling DNS records. On 26 November 2019 he filed a third report against the same asset.
Confirming the problem
Step 1: is the record really dangling?
By 26 December 2019 he had a list of subdomains that might have dangling DNS records, but no way to be sure. A guess is not a report; if you send a bug bounty program a suspected dangling record that turns out to be fine, you get an N/A. So he needed evidence.
The first check was the SSL certificate. Remember that a certificate is tied to a name. If the certificate a machine presents is for a completely different site, that machine is not the company's.

As the caption puts it, it is definitely not the target.
The second check was Shodan, looking at the archived SSL certificate. Shodan keeps records of what machines were serving in the past, so even if the machine has changed hands, you can see what it used to look like.

That settled it: a dangling DNS for sure.
Step 2: search by IP
He also suggests Google dorks or Bing with this query:
ip: [redacted]
Line by line: ip: is a search operator that asks the search engine for pages that mention a particular IP address. [redacted] is the address in question. The point of the search is to find other hostnames that share the same recycled address, which would show that the address has moved on to someone else.
Step 3: ask
Sometimes all you have to do is ask.
He notes it is great when you build trust with the security team. In plain terms: a good relationship with the people who run the program means you can ask a question and get a straight answer, instead of guessing.
Step 4: report the full set
On 16 June 2020 came payment. The write-up also records a report against *.example.com under that date.
After monitoring subdomains and confirming that every subdomain had a dangling DNS record before reporting, the program asked him to supply every possible dangling record and said they would confirm them all at once.

They all turned out to have dangling DNS records.
Why it happens
The write-up traces the issue to a blog post by Matt Bryant on 7 October 2015, "Fishing the AWS IP Pool for Dangling Domains", about the AWS IP pool. Here is the quoted explanation:
"What happened to that IP tied to that EC2 instance that you just killed? Well, when you terminate an instance, that IP address isn't put to waste. Instead, it's reused by other AWS customers. There is a massive pool of IP addresses that are constantly being recycled and trusted by various organizations and people."
In plain words: when you shut down a rented computer, its address does not disappear. Amazon hands it to the next customer. If your DNS record still points at that address, your subdomain now leads to that next customer's machine.
The issue happens when a company uses an EC2 instance without an elastic IP. If the instance is killed or terminated and the DNS is not updated, the subdomain is left with a dangling DNS record. The EC2 IP is released back to the AWS IP pool, which means it is possible to assign that IP to a new EC2 instance.
What it means for security
The report does not spell out a specific attacker capability beyond the dangling record itself. What it establishes is that the subdomains pointed at AWS addresses that had been released to the pool and could be reassigned to another AWS customer, and that the records were confirmed dangling rather than merely suspected. The author stresses confirming the dangling state before reporting, to avoid an N/A.
How to fix it
The report does not describe a fix applied by the program. The implied remedy is to keep DNS records in step with the EC2 lifecycle: update or remove the record when an instance is terminated, and use elastic IPs so the address is not returned to the shared pool.
How to look for the same thing
- Check for
compute.amazonaws.comorcompute-1.amazonaws.comin CNAME records. A positive result is a subdomain whose CNAME resolves to one of those hostnames. In plain words: look in the address book for entries that point at Amazon's compute hostnames. - Confirm that the record is dangling before reporting, as described above. Confirm that the record is dangling before reporting, as described above, using the SSL certificate and Shodan checks.
- Search by IP with a dork such as
ip: [redacted]on Google or Bing. - Filter an enumerated subdomain list by CNAME, as the author did with his own tool.
- The author notes that what he had missed was checking for open ports.
The author also lists case studies of the same class of issue at Transloadit, Avast and Amazon itself, and in private programs.
His closing advice: do not ignore old research, it might be old but not dead, and building trust with security teams is a two-way street.
Glossary
- AWS EC2: Amazon's service for renting virtual computers in the cloud.
- Bug bounty program: a company that pays outside researchers for valid security reports.
- CNAME record: a DNS entry saying one name is another name for a different name.
- Dangling DNS record: a DNS record that points at something that no longer exists or no longer belongs to the owner.
- Directory listing: a web server setting that shows the files in a folder instead of a normal page.
- DNS: the internet's address book, translating names into IP addresses.
- Elastic IP: a fixed IP address reserved in AWS so it does not return to the shared pool.
- Google dork: a search query using special operators to find specific things.
- IP address: the numeric label of a machine on the internet.
- IP pool: a shared collection of IP addresses that a provider rents out and recycles.
- N/A: "not applicable", a rejected bug bounty report.
- Open port: a numbered door on a machine that accepts network connections.
- Private program: a bug bounty program that is invitation-only and not publicly named.
- Redirect: when a website automatically sends your browser to another address.
- Shodan: a search engine for internet-connected machines, including historical data.
- SSL certificate: a digital document proving a site's identity and enabling encryption.
- Subdomain: a name in front of a domain, like
fig.example.com. - Subdomain takeover: the risk that a dangling record lets a stranger answer for your subdomain.
- Wildcard scope: a scope written with
*, meaning any subdomain of the domain.