Introduction A Subdomain takeovers

A Subdomain takeovers , you guessed it – refers to the hostile takeover of a subdomain by an attacker.

This vulnerability arises mainly when resources hosted on third-party hosting services/cloud providers are discontinued but the DNS records pointing to those cloud resources still remain.

Potential subdomain takeovers are a high-severity threat for organizations that frequently provision, and decommission resources, especially on cloud hosting service providers.

Subdomain takeovers can become a looming threat when an organization’s DNS record points to a currently non-existent or discontinued resource. Such DNS records are also known as “dangling DNS” or “stale DNS” entries. Commonly vulnerable to this threat are dangling CNAME records.

Common Scenario leading to subdomain takeovers

  1. The domain name (e.g., uses a CNAME record to another domain (e.g., CNAME great
  2. At some point in time, great expires or is deprovisioned and is available for registration by anyone using the hosting service.
  3. Since the CNAME record is not deleted from the DNS zone, anyone who is able to register has full control over until the CNAME record is present.


Note that HTTP redirects (301 or 302) could be also be used instead of CNAMEs to redirect from to

This method is less frequently used, as it will entirely replace the domain in the browser’s URL bar. CNAME records, on the other hand, do not change the domain in the URL bar of the browser as DNS resolution happens behind the scenes.

What’s in a CNAME?

A Canonical Name i.e. CNAME record is a category of DNS record that associates an alternate name to the canonical domain name.

The domain name (e.g., uses a CNAME record to another domain (e.g., CNAME great

Hosted services commonly provision a subdomain for individual organizations on the hosting provider’s domain (e.g., and use a CNAME to point to the customer’s domain (

Looking up the CNAME of a subdomain

Tools like nslookup can be used to find out the CNAME for a specific subdomain (if it exists). The resulting output indicates the hosting provider that is in use.

In this case, the CNAME record for source subdomain points to a resource ( hosted on the AWS S3 bucket.

Is there a dangling DNS record (CNAME) for the subdomain?

Browsing to the source subdomain in this example, an error message thrown by the cloud service provider (AWS S3) stating that the bucket (resource) does not exist.

This is in fact a dangling DNS record, wherein a CNAME record pointing to the AWS S3 bucket (resource) exists, however, the resource ( is no longer available. A subdomain takeover is likely in this instance.


The exploitation of subdomain takeover differs based on the service provider which was used to host the presently non-existent resource that existed earlier.

Taking over an AWS S3 bucket

In the case of AWS S3, the subdomain identifying the unique cloud resource (bucket) used for website hosting is named in the format of

The CNAME record of the source points to the resource The part before “.s3” is the bucket name.

All the attacker needs to do for successful exploitation is to create a bucket with the name as the CNAME record for this subdomain already exists.

If the bucket is successfully created then voila! The subdomain takeover is complete.

Note: If the bucket name were already in use, AWS would give an error and exploitation could not be possible in this case.

Taking over a github pages website

GitHub provides free web hosting using their GitHub Pages project. This web hosting is usually used for project documentation, technical blogs, or supporting web pages to open-source projects. GitHub Pages supports custom domain names in addition to the default domain name

The github page subdomain format for a user is like

The CNAME record for a source subdomain hosted on github looks something like this.

Verifying whether the github pages site on exists.

All the attacker needs to do for exploitation is to add the custom domain name to their github pages repository Takeover complete!

Note: If the custom domain were already in use, github would give an error and exploitation wouldn’t be possible in that case.

Side Note: GitHub uses virtual hosting like many cloud services and verifies the actual subdomain name based on the host header. So, if there were a dangling CNAME record for pointing to then subdomain takeover would still be possible. This is because all github pages website subdomains point to the same server. Check out the image below.


Manually browsing to a given subdomain and analyzing the server response usually gives a good indication regarding the possibility of subdomain takeover.

However, for determining potentially vulnerable subdomains from a bulk of domains – tools like subjack are very useful. Subjack scans a list of subdomains concurrently and identifies the ones which are potentially vulnerable based on the fingerprints in its database.

The fingerprints are basically the error messages associated with the respective hosting/service providers when a non-existing or deprovisioned resource is requested.


Once an attacker takes over a legitimate domain name, it is very difficult for a normal user to figure out whether the content hosted on that domain is controlled by a legitimate party or an attacker.

Mass phishing or targeted phishing campaigns can be run by the attacker, asking users to log in to and harvest credentials on the legitimate subdomain under their control. The probability of successful phishing attacks amplifies with control over legitimate domains.

If the base domain ( of the hijacked subdomain ( shares cookies across all its subdomains (* then cookie stealing is another possibility.

In the best-case scenario, a subdomain takeover leads to a loss of trust in the brand or organization.


The remediation steps for domain names vulnerable to subdomain takeover are simple enough:

  • Remove the dangling DNS entry — The easiest way is to remove the stale record from the DNS zone. If the organization concludes that the affected source domain name is no longer needed, this step solves the issue.
  • Take control of the domain name— This means registering the resource in the cloud hosting provider or in the case of a normal internet domain, rebuying the expired domain.

Further reading

If you would like to delve deeper into this topic, here are a few resources I recommend:

  1. – This community-driven repository maintains a list of vulnerable services and how-to steps for claiming subdomains with dangling DNS records on these services.
  2. – Super rich info involving subdomain discovery, enumeration, takeover, you name it!



Akshay Khilari

Attack & Pen Test Team

Varutra Consulting Pvt. Ltd.