Skip to content
Subdomain takeover Write-up Beginner

$4500 bounty - How I got lucky

A subdomain had a dangling CNAME pointing to an unclaimed AWS CloudFront distribution, allowing the author to claim it and serve content. The author could set cookies for the entire domain, which could enable further attacks.

Eray Mitrani Follow

Published on medium.com

Bounty$4,500 View original

{{media:0}}

Eray Mitrani, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

This is a short account of a subdomain takeover found through recon done at the right moment, and of what the traffic captured during the takeover revealed about competition in public bug bounty programmes. The vulnerable host was a subdomain of a company's domain that had been pointed at AWS CloudFront through a CNAME record. The company had forgotten to remove the CNAME, so anyone who claimed the corresponding CloudFront distribution could serve content on the company's subdomain.

Setup

The only tool used to identify the vulnerable subdomain was Aquatone by Michael Henriksen. The author describes it as well suited to recon and worth using to scout a target. The vulnerable domain turned up on the first day after cloning the Aquatone repository, which the author attributes to luck rather than method.

No accounts, roles or versions are given beyond that.

Finding it

The scan was run with the takeover check built into Aquatone:

Bash
aquatone-takeover — domain {{target}}.com

This reported a domain vulnerable to takeover on AWS CloudFront. The initial reaction was not excitement, because in most cases attempting to claim a subdomain returns a CNAME already in use error. Here the company had forgotten to remove the CNAME, so the claim succeeded.

The screenshot shows what a vulnerable CloudFront domain looks like. The author notes that the other domains visible in the same view are in use by Uber and impossible to claim.

As a side note, a quick way to check whether a finding is false is to navigate to the host over both http and https. If both return the same error page, the domain can probably be taken over and it is worth logging on to AWS.

Exploitation

Step 1: claim the CloudFront distribution

With the CNAME still pointing at CloudFront, the author was able to claim the subdomain. This is the point at which most attempts fail with the CNAME already in use error; here it did not.

Step 2: serve proof-of-concept content off the root path

The author's stated best practice is to host content under a path other than / so as not to damage the company's reputation. A simple HTML file was placed in an AWS bucket and the domain was pointed at it.

The screenshot shows the proof of concept: a simple title carrying the researcher's username, which the author says is sufficient.

Step 3: report and observe

The report was quickly validated by HackerOne staff and fixed within 4 days. The more interesting part came from the data collected over the weekend while the domain was still held.

The screenshot shows the request count: 1235 requests. Around 1200 requests reached the subdomain over the weekend. Analysing them showed that most of the traffic came from other hackers running dirsearch or otherwise probing for vulnerabilities. That was the moment the author saw how much competition exists in public bug bounty programmes, and noted being lucky to be invited to private ones where competition seems a lot less intense.

The screenshot shows the variety of requests sent to the site. Most were basic recon against the target, looking for reflected XSS, open redirects or exposed directories. The author's conclusion is that finding that sort of low-hanging fruit takes a great deal of luck, but trying costs nothing.

Root cause

The mistake is a dangling DNS record: the subdomain's CNAME still pointed at a CloudFront distribution that the company no longer controlled, and the company had not removed the record. Because CloudFront lets an account claim a distribution for a hostname that no other distribution is using, whoever creates the matching distribution inherits the hostname. The CNAME already in use error that normally blocks this did not occur here.

Impact

The bounty was $4500, awarded because the subdomain could be used to set valid cookies on the entire domain. That is the impact the author states: cookie scope across the parent domain, not merely defacement of one host. The author's stated best practice is to host content under a path other than / to avoid damaging the company's reputation.

Fix

The report was resolved within 4 days of submission. The specific change made is not described; removing the dangling CNAME, or otherwise ensuring the hostname no longer resolves to an unclaimed CloudFront distribution, is what closes this class of issue.

Variants to test

  1. Run the Aquatone takeover check across a target's subdomains and look for hosts reported as vulnerable on CloudFront. A positive result is a hostname whose CNAME points at a distribution nobody has claimed.
  2. For any candidate, request the host over both http and https. If both return the same error page, treat it as probably claimable and try creating the distribution in your own AWS account. A successful claim, rather than a CNAME already in use error, confirms it.
  3. Check whether the claimed host sits under a parent domain that sets cookies, since that is what drove the severity here.
  4. While holding a claimed host, log the requests that arrive. As this case shows, a large share will be other researchers running dirsearch and probing for reflected XSS, open redirects and exposed directories, which is useful for understanding who else is working the programme.

Timeline

Date Event
April 12, 2018 Report submitted and triaged
April 16, 2018 Report resolved
May 3, 2018 $4500 bounty awarded

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

What happened, in plain words

A security researcher found that one of a company's web addresses (a subdomain) could be taken over by anyone. He claimed it, put a harmless page on it, and reported it. The company fixed it within four days and paid him $4500. While he held the address over a weekend, he watched the requests coming in and discovered that most of them were from other security researchers probing the same target. This article explains, from scratch, what a subdomain takeover is, how he found it, how he claimed it, and what he learned.

Background: what is a subdomain and why does it matter?

Every website has a name, like example.com. A subdomain is a name that sits in front of it, like shop.example.com or blog.example.com. Companies use subdomains to separate different services: one for the shop, one for support, one for a marketing campaign. To the outside world, all of these look like part of the same company.

When you type a subdomain into your browser, your computer asks a directory service (DNS) where that name points. The answer is often an IP address, but it can also be another name. A CNAME record is a DNS entry that says "this name is an alias for that other name". For example, shop.example.com might be a CNAME pointing to example-shop.cloudfront.net.

CloudFront is Amazon's content delivery network: a service that stores copies of a website's files on servers around the world so pages load faster. When a company uses CloudFront, it creates a "distribution" in its AWS account and tells CloudFront which hostname (like shop.example.com) should be served by that distribution.

Here is the problem: if a company stops using a CloudFront distribution but forgets to remove the CNAME record, the subdomain still points at CloudFront. CloudFront will happily let anyone else create a distribution for that hostname, as long as no other distribution is currently using it. So an attacker can sign up for AWS, create a distribution, claim the hostname, and now the company's subdomain serves the attacker's content. This is called a subdomain takeover.

The tool and the lucky find

The researcher used a tool called Aquatone, created by Michael Henriksen. Aquatone is designed for reconnaissance: it scans a list of subdomains and takes screenshots, and it includes a check for subdomain takeover vulnerabilities. The author says it is perfect for recon and every hacker should consider using it.

He cloned the Aquatone repository and encountered the vulnerable domain on the first day. He attributes the find to luck rather than method.

The command he ran was:

Bash
aquatone-takeover — domain {{target}}.com

Line by line:

  • aquatone-takeover is the name of the program inside Aquatone that checks for takeover issues.
  • — domain is an option telling the tool to check a specific domain. (The dash looks unusual; it is copied exactly as in the original.)
  • {{target}}.com is a placeholder for the company's domain name. In a real run, you would replace it with the actual domain.

The tool reported that a subdomain was vulnerable to takeover on AWS CloudFront. At first the researcher was not excited, because in most cases when you try to claim a subdomain you get an error saying the CNAME is already in use. That error means someone else (usually the company itself) still has a CloudFront distribution for that hostname, so you cannot claim it. But this time the company had forgotten to remove the CNAME, and no distribution was using it, so the claim succeeded.

The screenshot shows what a vulnerable CloudFront domain looks like. The author notes that the other domains visible in the same view are in use by Uber and impossible to claim.

As a quick tip, the author says you can check whether a finding is false by visiting the host over both http and https. If both return the same error page, the domain can probably be taken over, and it is worth logging on to AWS to try.

Claiming the subdomain

With the CNAME still pointing at CloudFront, the researcher was able to claim the subdomain. This is the step where most attempts fail with the "CNAME already in use" error; here it did not.

Serving proof-of-concept content

The author's best practice is to host your content under a path other than / (the root of the website) so as not to damage the company's reputation. He placed a simple HTML file in an AWS bucket and pointed the domain at it.

The screenshot shows the proof of concept: a simple title carrying the researcher's username, which the author says is sufficient.

Reporting and watching the traffic

The report was quickly validated by HackerOne staff and fixed within 4 days. HackerOne is a platform where companies receive vulnerability reports from researchers. "Validated" means the company confirmed the issue was real. "Fixed" means the company removed the vulnerability.

The more interesting part came from the data collected over the weekend while the domain was still held.

The screenshot shows the request count: 1235 requests. Around 1200 requests reached the subdomain over the weekend. Analysing them showed that most of the traffic came from other hackers running dirsearch or otherwise probing for vulnerabilities. Dirsearch is a tool that tries many common file and directory names on a website to find hidden pages. That was the moment the author saw how much competition exists in public bug bounty programmes, and he noted being lucky to be invited to private ones where competition seems a lot less intense.

The screenshot shows the variety of requests sent to the site. Most were basic reconnaissance against the target, looking for reflected XSS, open redirects or exposed directories. Reflected XSS is a flaw where a website takes something you typed and shows it back on the page without cleaning it, which can let an attacker run their own code in your browser. An open redirect is a link on a site that sends you to another site you did not intend to visit. An exposed directory is a folder on the server that is not protected and lists its files. The author's conclusion is that finding that sort of low-hanging fruit takes a great deal of luck, but trying costs nothing.

Why it happened

The mistake is a dangling DNS record: the subdomain's CNAME still pointed at a CloudFront distribution that the company no longer controlled, and the company had not removed the record. Because CloudFront lets an account claim a distribution for a hostname that no other distribution is using, whoever creates the matching distribution inherits the hostname. The "CNAME already in use" error that normally blocks this did not occur here.

Impact

The bounty was $4500, awarded because the subdomain could be used to set valid cookies on the entire domain. A cookie is a small piece of data a website stores in your browser to remember you, for example to keep you logged in. Cookies have a scope: a cookie set for example.com is sent to all subdomains of example.com. So if an attacker controls one subdomain, they can set a cookie that the browser will send to the main site and all other subdomains. That is the impact the author states: cookie scope across the parent domain. That is the impact the author states: cookie scope across the parent domain, not merely defacement of one host. The author's stated best practice is to host content under a path other than / to avoid damaging the company's reputation.

Fix

The report was resolved within 4 days of submission. The specific change made is not described; removing the dangling CNAME, or otherwise ensuring the hostname no longer resolves to an unclaimed CloudFront distribution, is what closes this class of issue.

Variants to test

  1. Run the Aquatone takeover check across a target's subdomains and look for hosts reported as vulnerable on CloudFront. A positive result is a hostname whose CNAME points at a distribution nobody has claimed.
  2. For any candidate, request the host over both http and https. If both return the same error page, treat it as probably claimable and try creating the distribution in your own AWS account. A successful claim, rather than a "CNAME already in use" error, confirms it.
  3. Check whether the claimed host sits under a parent domain that sets cookies, since that is what drove the severity here.
  4. While holding a claimed host, log the requests that arrive. As this case shows, a large share will be other researchers running dirsearch and probing for reflected XSS, open redirects and exposed directories, which is useful for understanding who else is working the programme.

Timeline

Date Event
April 12, 2018 Report submitted and triaged
April 16, 2018 Report resolved
May 3, 2018 $4500 bounty awarded

Glossary

  • Subdomain: a name that sits in front of a main domain, like shop.example.com in front of example.com.
  • DNS: the directory service that translates domain names into addresses or other names.
  • CNAME record: a DNS entry that says one name is an alias for another name.
  • CloudFront: Amazon's content delivery network, which stores copies of a website's files on servers around the world.
  • Distribution: a CloudFront configuration that serves a particular hostname.
  • Subdomain takeover: when an attacker claims a subdomain by taking control of the service it points to, because the company left a dangling record.
  • Aquatone: a tool for reconnaissance that scans subdomains and checks for takeover vulnerabilities.
  • Reconnaissance (recon): the information-gathering phase of security testing, where you learn about a target's systems.
  • CNAME already in use error: an error from CloudFront when you try to claim a hostname that another distribution is already using.
  • Proof of concept (PoC): a harmless demonstration that a vulnerability is real, often a simple page.
  • HackerOne: a platform where companies receive vulnerability reports from researchers.
  • Dirsearch: a tool that tries many common file and directory names on a website to find hidden pages.
  • Reflected XSS: a flaw where a website shows back something you typed without cleaning it, letting an attacker run their own code in your browser.
  • Open redirect: a link on a site that sends you to another site you did not intend to visit.
  • Exposed directory: a folder on a server that is not protected and lists its files.
  • Cookie: a small piece of data a website stores in your browser to remember you, for example to keep you logged in.
  • Cookie scope: the set of domains and paths for which a cookie is sent; a cookie set for example.com is sent to all its subdomains.
  • Bounty: a payment made by a company to a researcher who reports a valid vulnerability.

More by Eray Mitrani

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Subdomain takeover

The lesson behind this report.

A company's DNS still points at a cloud service it no longer uses, so anyone can claim it and serve content on the company's domain.