Skip to content
Subdomain takeover Write-up Intermediate

Incident Response during Christmas

The author found subdomains of four Fortune 500 companies that pointed via CNAME to unused cloud services or an expired domain, allowing takeover. By claiming those services, the author controlled over 30 subdomains and could serve malicious content or phishing pages.

TMO Follow

Published on tmosh.medium.com

2020 has been a tough year for all of us. Digital transformation was driven by COVID-19 and we increasingly seeing security incidents and ransomware attacks coming up in the news.

TMO, on tmosh.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. 7 min read.

Context

This is a write-up about subdomain takeover, used here as a probe of how four large companies handle a reported vulnerability over the Christmas period. The author picked four companies at random, described only by sector and disclosure posture:

Target Sector Disclosure posture
Company A Chemical Responsible Disclosure Policy
Company B Consumer Goods No SIRT/RDP
Company C Multi-Industry (mainly tech) Private VDP
Company D Multi-Industry (mainly tech) Responsible Disclosure Policy

The author deliberately avoided companies with large bug bounty programmes, on the reasoning that this would raise the chance of finding a higher risk bug, and instead looked at companies that might at least have a Security Incident Response Team or a Responsible Disclosure Policy (Company B being the exception).

The feature under test is DNS: specifically CNAME records on the companies' main domains, both the local domain and the international .com, that point at services which are no longer claimed. The title claims 30 subdomains of four global Fortune 500 companies were taken over.

Setup

The scope was limited on purpose: subdomain takeovers only, because they are easy to demonstrate, have a high impact, and are also quite easy to fix and mitigate. The author lists the impact of a takeover as:

  • serving malicious content with the impersonation of the company (reputation risk)
  • setting up phishing pages targeting employees and/or customers (implicit trust of the domain)
  • stealing cookies bound to the top-level domain

The list is described as non-exhaustive. The point made about timing is that a domain taken over in the first Christmas week and held until New Year's Eve would give roughly two weeks of control.

Only the two main domains of each company were in scope, the local domain and the international .com, so every takeover shown was found on the domain with the highest risk and impact to the company.

Subdomain enumeration used the author's usual toolchain:

  • amass (no brute option)
  • Sublister
  • Subfind3r
  • Assetfinder
  • Domains from crt.sh
  • Domains from certspotter
  • AltDNS over all the unique domains (236 entries)
  • Custom wordlist (2.7M entries)
  • MassDNS over all unique domains found so far

MassDNS was pointed at a local resolver running Unbound. The author notes that if a company runs its own DNS servers this is quite easy to detect: the request goes first to the IANA root servers, then down to the top-level domain name server, then to the company's authoritative name server. The resolver was sending around 40K packets per second, so this is not a technique for running undetected.

Finding it

When MassDNS finished, the output was a list in this format (example):

Text
subdomain1.company.com. A 192.0.2.1subdomain2.company.com. A 192.0.2.2subdomain3.company.com. CNAME subdomain4.company.com.subdomain4.company.com. A [redacted]

For a takeover the interesting records are the CNAME entries, and the question for each is whether it points to a service that is unused or unclaimed. The author started aquatone for visual identification of the targets and, in parallel, grepped out all CNAME entries and ran a quick for loop with dig to find domains that do not resolve correctly (NXDOMAIN):

Bash
for domain in `cat massdns.txt | grep CNAME | cut -d" " -f1 | sed 's/\.$//'`do  echo -n "Subdomain: $domain";  dig $domain | "grep status"done | grep NXDOMAIN

This multi-liner prints all CNAMEs that exist in the DNS system but do not resolve to an actual IP. Each of those was then analysed manually with dig <subdomain> to check which service it points to.

One caveat is called out explicitly: a takeover is also possible when the domain does not resolve as NXDOMAIN but succeeds with NOERROR, and that case can only be detected through visual identification.

From the original on tmosh.medium.com

Three different services turned up, and the author describes taking over each.

Exploitation

Step 1: CNAME to .cloudapp.azure.com

The CNAME pointed to <servicename>.<region>.cloudapp.azure.com, but that subdomain did not resolve to any service, so the service was unused in Microsoft Azure. The author deployed a new virtual machine in Microsoft Azure, installed nginx, and claimed the unused DNS name.

Subdomain takeover of cloudapp.azure.com From the original on tmosh.medium.com

Subdomain takeover of cloudapp.azure.com

Step 2: CNAME to .azurewebsites.net

Several services pointed to <servicename>.azurewebsites.com, which is used by Microsoft Azure App Services. The author quotes Microsoft's description of the service: it lets you build and host web apps, mobile back ends and RESTful APIs in the language of your choice without managing infrastructure, with auto-scaling and high availability, on Windows and Linux, and automated deployments from GitHub, Azure DevOps or any Git repo.

A virtual machine is not enough here: an Azure Service has to be deployed. The author followed the original Microsoft Quickstart Guide to deploy a Hello World application as a proof of concept, then added the custom domain to the App Service and was able to control the subdomain.

Subdomain takeover of azurewebsites.com From the original on tmosh.medium.com

Subdomain takeover of azurewebsites.com

Step 3: CNAME to an unregistered domain

The last case was a CNAME from subdomain.company.com to company-abc.com. That domain was not registered, probably expired, and the author was able to register it directly with a preferred domain registrar. The domain was pointed at a personal server as a proof of concept.

Root cause

In each case the company's DNS still contained a CNAME pointing at an unused Azure cloud service name, an Azure App Service name, or a third-party domain that had lapsed and could be bought. Because the company controls the CNAME but not the target, whoever claims the target inherits the company subdomain. The author's framing is that the subdomain is by definition not in use, which is exactly why it could be taken over, so nothing is lost by mitigating it.

Impact

An attacker controlling such a subdomain can serve malicious content under the company's name, host phishing pages that exploit the implicit trust in the domain, and steal cookies bound to the top-level domain. The author stresses that all takeovers demonstrated were on the companies' main domains, the ones with the highest risk and impact.

Response times

This is the part the exercise was built around. No company names are disclosed.

Response Time From the original on tmosh.medium.com

Response Time

Only one company had fixed the subdomain takeover of two domains by the time of writing, and that was the company running a private VDP on a crowd-sourcing platform. The two companies with a CERT team confirmed the vulnerability and forwarded it internally, but the subdomains were still pointing at the author's services and the bugs were not fixed. The company without a CERT team had not reached out at all, despite contact attempts through different channels and directly to some contacts on LinkedIn.

All actions and responses happened only after the Christmas period; none of the companies responded or acted on the actual Christmas days. The author suggests one reason might be that a reported bug is not assigned the same criticality as an actual security incident.

Fix

Mitigation is simple and the author is explicit that it is the company's job: if the subdomain is not in use, delete it, or at least point it to the primary domain. That change can be executed within minutes, though it takes hours until the TTL times out, and it secures the environment while the question of who ordered the subdomain is clarified in the background. Companies have full access to their DNS zone records and should either monitor subdomains automatically or review them on a regular basis.

Variants to test

  1. Grep the MassDNS output for CNAMEs and resolve each one with dig, looking for NXDOMAIN. A positive result is a CNAME whose target does not resolve, which then needs a manual check of which service it belongs to.
  2. Run a visual crawler such as aquatone over the resolved hosts, since the NOERROR cases can only be detected through visual identification.
  3. For each CNAME target, identify the provider and try to claim the name in that provider's console (a VM with a public DNS name, an App Service custom domain, and so on). A positive result is the provider accepting the name and the company subdomain then serving your content.
  4. Check CNAME targets that are themselves domains rather than provider hostnames, and look up their registration status. A positive result is an expired or unregistered target domain that can be bought at a registrar and pointed at your own server.
  5. Repeat the enumeration against both the local domain and the international .com, since the author scoped the exercise to those two and found takeovers on them.

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. 14 min read.

What happened, in plain words

Over the Christmas holidays at the end of 2020, a security researcher took over 30 subdomains belonging to four large global companies. A subdomain is a smaller name that sits under a company's main web address, for example shop.example.com under example.com. The researcher then reported the problem to each company and watched how quickly they reacted. The point of the exercise was not the takeover itself but the timing: would these big companies respond during the Christmas break, when many staff are away?

The answer was disappointing. Nobody acted on the actual Christmas days. Only one company fixed the problem by the time the researcher wrote it up. Two companies confirmed the report and passed it on internally but left the subdomains pointing at the researcher's servers. One company never replied at all.

The technique used is called a subdomain takeover. To understand it, imagine you rent a flat and put a sign on the street saying "deliveries for me go to flat 12". Later you move out of flat 12 but forget to take the sign down. Anyone who moves into flat 12 now receives your deliveries. In the same way, a company's web address can contain a forwarding note (a CNAME record) that says "this name really lives at some other service". If the company stops using that other service but leaves the forwarding note in place, a stranger can sign up for that service and start answering under the company's name.

Target selection

The researcher wanted to test one idea: that companies respond more slowly to security reports during the Christmas break, so an attacker has a better chance of going unnoticed and succeeding. A report sent to a company is not the same as a real break-in, but the researcher wanted to see how companies react when you tell them about a serious bug.

The researcher deliberately did not pick companies with big bug bounty programmes. A bug bounty programme is a scheme where a company publicly invites researchers to find bugs and pays them for it. The researcher reasoned that avoiding them would make it more likely to find a higher-risk bug. Instead the researcher looked at companies that might at least have a Security Incident Response Team (a dedicated team that handles security incidents) or a Responsible Disclosure Policy (a public statement of how to report a security problem to them).

Four companies were chosen at random, described only by sector and by what kind of reporting channel they offer:

Target Sector Disclosure posture
Company A Chemical Responsible Disclosure Policy
Company B Consumer Goods No SIRT/RDP
Company C Multi-Industry (mainly tech) Private VDP
Company D Multi-Industry (mainly tech) Responsible Disclosure Policy

A VDP is a vulnerability disclosure programme, a formal channel for receiving bug reports; a private one is not open to the general public. Company B is the odd one out: it had neither a security incident response team nor a disclosure policy.

Scope

The researcher set a clear scope, meaning the boundary of what would be tested. The advice is not to hunt every possible bug but to pick one class and do it well. Here the class was subdomain takeover, chosen because such bugs are easy to demonstrate, have a high impact, and are also quite easy to fix and mitigate.

With a subdomain takeover, an attacker can for example:

  • serve malicious content with the impersonation of the company (reputation risk)
  • set up phishing pages and target employees and/or customers (implicit trust of the domain)
  • steal cookies (cookies which are bound to the top-level domain)

A cookie is a small piece of data a website stores in your browser so it can recognise you on your next visit, for example to keep you logged in. The report lists stealing cookies bound to the top-level domain as one possible impact. Phishing means building a fake page that looks like the real company's page so that people type in passwords or card details. The list above is described as non-exhaustive, just well-known examples.

The timing point is worth spelling out: a domain taken over in the first Christmas week and held until New Year's Eve would give roughly two weeks of control. Only the two main domains of each company were in scope, the local domain and the international .com, so every takeover shown was found on the domain with the highest risk and impact to the company.

Methodology

To find subdomains, the researcher used a set of tools that collect names from many sources. The toolchain was:

  • amass (no brute option)
  • Sublister
  • Subfind3r
  • Assetfinder
  • Domains from crt.sh
  • Domains from certspotter
  • AltDNS over all the unique domains (236 entries)
  • Custom wordlist (2.7M entries)
  • MassDNS over all unique domains found so far

Some of these tools gather names from public records. crt.sh and certspotter are services that log certificates, the digital identity documents websites use to prove who they are; every certificate lists the names it covers, which makes them a good source of subdomains. A wordlist is simply a long list of common words that tools try in front of the domain name, hoping to guess real subdomains. MassDNS is a tool for looking up very large numbers of names at once.

MassDNS was pointed at a local resolver running Unbound. A DNS resolver is the part of the internet that turns a name like example.com into the numeric address of a server, much like a phone book turning a name into a number. Unbound is a piece of software that performs that lookup.

The researcher notes that if a company runs its own DNS servers, this kind of mass lookup is quite easy to detect. The request goes first to the IANA root servers, then down to the top-level domain name server, then to the company's authoritative name server. In plain terms: to find the address for something.example.com, the resolver first asks the internet's top-level directory, which points it to the directory for .com, which points it to the company's own name server, which finally gives the answer. The company's name server therefore sees every question. The resolver was sending around 40K packets per second, so this is not a technique for running undetected.

Finding it

When MassDNS finished, the output was a list in this format (example):

Text
subdomain1.company.com. A 192.0.2.1subdomain2.company.com. A 192.0.2.2subdomain3.company.com. CNAME subdomain4.company.com.subdomain4.company.com. A [redacted]

Each line is one answer from the name server. The A entries give a numeric address directly. The CNAME entry is a forwarding note: it says that this name is really another name, here subdomain4.company.com. The addresses shown are documentation examples, not real ones.

For a takeover the interesting records are the CNAME entries, and the question for each is whether it points to a service that is unused or unclaimed. The researcher started aquatone for visual identification of the targets and, in parallel, grepped out all CNAME entries and ran a quick for loop with dig to find domains that do not resolve correctly (NXDOMAIN):

Bash
for domain in `cat massdns.txt | grep CNAME | cut -d" " -f1 | sed 's/\.$//'`do  echo -n "Subdomain: $domain";  dig $domain | "grep status"done | grep NXDOMAIN

Line by line, in plain words:

  1. cat massdns.txt reads the results file produced by MassDNS.
  2. grep CNAME keeps only the lines that contain a CNAME entry, because those are the forwarding notes of interest.
  3. cut -d" " -f1 takes the first space-separated field of each line, which is the subdomain name.
  4. sed 's/\.$//' removes the trailing dot that DNS uses at the end of names, so the name can be used as a normal command argument.
  5. The for loop then runs once per name. echo -n "Subdomain: $domain" prints the name being checked.
  6. dig $domain asks the name server about that name, and the pipe into grep status keeps the line that reports the lookup status.
  7. Finally grep NXDOMAIN keeps only the results where the answer was NXDOMAIN, meaning the name does not exist.

dig is a command-line tool for asking DNS questions. NXDOMAIN is the DNS answer that means "this name does not exist". So the whole multi-liner prints all CNAMEs that exist in the DNS system but do not resolve to an actual IP. Each of those was then analysed manually with dig <subdomain> to check which service it points to. The reason for the manual step is that the automated loop only tells you a name is broken; a person has to look at where it points and decide whether that service can be claimed by anyone.

One caveat is called out explicitly: a takeover is also possible when the domain does not resolve as NXDOMAIN but succeeds with NOERROR, and that case can only be detected through visual identification. NOERROR means the name exists and the name server answered, but the answer may still lead to a page that says the service is unclaimed. That is why a visual crawler such as aquatone, which takes screenshots of the pages it finds, was run alongside the text-based loop.

From the original on tmosh.medium.com

Three different services turned up, and the researcher describes taking over each.

Exploitation

Step 1: CNAME to .cloudapp.azure.com

The CNAME pointed to <servicename>.<region>.cloudapp.azure.com, but that subdomain did not resolve to any service, so the service was unused in Microsoft Azure. Azure is Microsoft's cloud platform, where customers rent computers and services over the internet. The researcher deployed a new virtual machine in Microsoft Azure, installed nginx, and claimed the unused DNS name. A virtual machine is a rented computer running in a data centre; nginx is web server software that serves pages. Claiming the name means registering that same service name in Azure, so that the company's forwarding note now leads to the researcher's machine.

Subdomain takeover of cloudapp.azure.com From the original on tmosh.medium.com

Subdomain takeover of cloudapp.azure.com

Step 2: CNAME to .azurewebsites.net

Several services pointed to <servicename>.azurewebsites.com, which is used by Microsoft Azure App Services. The researcher quotes Microsoft's description of the service: it lets you build and host web apps, mobile back ends and RESTful APIs in the language of your choice without managing infrastructure, with auto-scaling and high availability, on Windows and Linux, and automated deployments from GitHub, Azure DevOps or any Git repo.

An API is a way for one program to talk to another over the internet, like a waiter taking your order to the kitchen and bringing back the food. Auto-scaling means the service adds more capacity automatically when traffic grows. High availability means it is built to keep running even when parts fail.

A virtual machine is not enough here: an Azure Service has to be deployed. The researcher followed the original Microsoft Quickstart Guide to deploy a Hello World application as a proof of concept, then added the custom domain to the App Service and was able to control the subdomain. A Hello World application is the simplest possible program that just displays a greeting, used here only to prove the point. Adding the custom domain is the step that ties the company's name to the researcher's app.

Subdomain takeover of azurewebsites.com From the original on tmosh.medium.com

Subdomain takeover of azurewebsites.com

Step 3: CNAME to an unregistered domain

The last case was a CNAME from subdomain.company.com to company-abc.com. That domain was not registered, probably expired, and the researcher was able to register it directly with a preferred domain registrar. A domain registrar is a company that sells domain names, like a shop that sells addresses. The domain was pointed at a personal server as a proof of concept. In this case the forwarding note led to a name nobody owned, so buying that name was enough to take control.

Root cause

In each case the company's DNS still contained a CNAME pointing at an unused Azure cloud service name, an Azure App Service name, or a third-party domain that had lapsed and could be bought. The DNS zone is the company's own set of records describing which names exist and where they lead. Because the company controls the CNAME but not the target, whoever claims the target inherits the company subdomain. The researcher's framing is that the subdomain is by definition not in use, which is exactly why it could be taken over, so nothing is lost by mitigating it.

Impact

An attacker controlling such a subdomain can serve malicious content under the company's name, host phishing pages that exploit the implicit trust in the domain, and steal cookies bound to the top-level domain. The researcher stresses that all takeovers demonstrated were on the companies' main domains, the ones with the highest risk and impact.

Response times

This is the part the exercise was built around. No company names are disclosed.

Response Time From the original on tmosh.medium.com

Response Time

Only one company had fixed the subdomain takeover of two domains by the time of writing, and that was the company running a private VDP on a crowd-sourcing platform. A crowd-sourcing platform here means a website where many independent researchers submit reports to companies. The two companies with a CERT team confirmed the vulnerability and forwarded it internally, but the subdomains were still pointing at the researcher's services and the bugs were not fixed. A CERT team is a computer emergency response team, the group that handles security incidents. The company without a CERT team had not reached out at all, despite contact attempts through different channels and directly to some contacts on LinkedIn.

All actions and responses happened only after the Christmas period; none of the companies responded or acted on the actual Christmas days. The researcher suggests one reason might be that a reported bug is not assigned the same criticality as an actual security incident.

Fix

Mitigation is simple and the researcher is explicit that it is the company's job: if the subdomain is not in use, delete it, or at least point it to the primary domain. That change can be executed within minutes, though it takes hours until the TTL times out, and it secures the environment while the question of who ordered the subdomain is clarified in the background. TTL stands for time to live: the number of seconds other name servers are allowed to keep a cached copy of a DNS answer before asking again, so an old answer can linger for a while after the record is changed. Companies have full access to their DNS zone records and should either monitor subdomains automatically or review them on a regular basis.

Variants to test

  1. Grep the MassDNS output for CNAMEs and resolve each one with dig, looking for NXDOMAIN. A positive result is a CNAME whose target does not resolve, which then needs a manual check of which service it belongs to.
  2. Run a visual crawler such as aquatone over the resolved hosts, since the NOERROR cases can only be detected through visual identification.
  3. For each CNAME target, identify the provider and try to claim the name in that provider's console (a VM with a public DNS name, an App Service custom domain, and so on). A positive result is the provider accepting the name and the company subdomain then serving your content.
  4. Check CNAME targets that are themselves domains rather than provider hostnames, and look up their registration status. A positive result is an expired or unregistered target domain that can be bought at a registrar and pointed at your own server.
  5. Repeat the enumeration against both the local domain and the international .com, since the researcher scoped the exercise to those two and found takeovers on them.

Glossary

  • Subdomain: a name that sits under a main domain, such as shop.example.com under example.com.
  • Subdomain takeover: claiming an unused service that a company's subdomain still points to, so the company's name now serves your content.
  • CNAME record: a DNS entry that says one name is really another name, a forwarding note.
  • DNS: the internet's name system that turns names into server addresses.
  • DNS resolver: the software that performs DNS lookups, like a phone book.
  • Unbound: a DNS resolver program.
  • Authoritative name server: the server that holds the official records for a domain and answers questions about it.
  • IANA root servers: the top-level servers that start every DNS lookup.
  • Top-level domain: the ending of a name such as .com.
  • A record: a DNS entry that gives a numeric address directly.
  • NXDOMAIN: the DNS answer meaning the name does not exist.
  • NOERROR: the DNS answer meaning the name exists and was answered, even if the page behind it is unclaimed.
  • dig: a command-line tool for asking DNS questions.
  • MassDNS: a tool for looking up very large numbers of domain names at once.
  • amass, Sublister, Subfind3r, Assetfinder: tools that collect subdomain names from various sources.
  • crt.sh, certspotter: services that log certificates and therefore reveal the names they cover.
  • Certificate: a digital identity document a website uses to prove who it is.
  • Wordlist: a long list of common words a tool tries in front of a domain to guess subdomains.
  • AltDNS: a tool that generates variations of known subdomain names.
  • aquatone: a tool that takes screenshots of web hosts for visual inspection.
  • Bug bounty programme: a scheme where a company invites researchers to find bugs and pays them.
  • VDP: vulnerability disclosure programme, a formal channel for receiving bug reports; a private one is not open to the public.
  • Responsible Disclosure Policy: a public statement of how to report a security problem to a company.
  • Security Incident Response Team (SIRT) / CERT: a dedicated team that handles security incidents.
  • Scope: the agreed boundary of what may be tested.
  • Cookie: a small piece of data a website stores in your browser to recognise you later.
  • Phishing: a fake page that imitates a real one to steal credentials or payment details.
  • API: a way for one program to talk to another over the internet.
  • Virtual machine: a rented computer running in a data centre.
  • nginx: web server software that serves pages.
  • Azure: Microsoft's cloud platform.
  • App Service: an Azure service for hosting web apps and APIs without managing servers.
  • Auto-scaling: automatically adding capacity when traffic grows.
  • High availability: being built to keep running when parts fail.
  • Hello World application: the simplest possible program, which just displays a greeting.
  • Domain registrar: a company that sells domain names.
  • DNS zone: a company's own set of DNS records.
  • TTL: time to live, how long a DNS answer may be cached before it is asked for again.
  • Crowd-sourcing platform: a website where many independent researchers submit reports to companies.

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.