Domain/Subdomain takeover | HackTricks (2024)

Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert)!

Other ways to support HackTricks:

Use Trickest to easily build and automate workflows powered by the world's most advanced community tools.Get Access Today:

Domain takeover

If you discover some domain (domain.tld) that is being used by some service inside the scope but the company has lost the ownership of it, you can try to register it (if cheap enough) and let know the company. If this domain is receiving some sensitive information like a sessions cookie via GET parameter or in the Referer header, this is for sure a vulnerability.

Subdomain takeover

A subdomain of the company is pointing to a third-party service with a name not registered. If you can create an account in this third party service and register the name being in use, you can perform the subdomain take over.

There are several tools with dictionaries to check for possible takeovers:

Scanning for Hijackable Subdomains with BBOT:

Subdomain takeover checks are included in BBOT's default subdomain enumeration. Signatures are pulled directly from https://github.com/EdOverflow/can-i-take-over-xyz.

bbot -t evilcorp.com -f subdomain-enum

Subdomain Takeover Generation via DNS Wildcard

When DNS wildcard is used in a domain, any requested subdomain of that domain that doesn't have a different address explicitly will be resolved to the same information. This could be an A ip address, a CNAME...

For example, if *.testing.com is wilcarded to 1.1.1.1. Then, not-existent.testing.com will be pointing to 1.1.1.1.

However, if instead of pointing to an IP address, the sysadmin point it to a third party service via CNAME, like a github subdomain for example (sohomdatta1.github.io). An attacker could create his own third party page (in Gihub in this case) and say that something.testing.com is pointing there. Because, the CNAME wildcard will agree the attacker will be able to generate arbitrary subdomains for the domain of the victim pointing to his pages.

You can find an example of this vulnerability in the CTF write-up: https://ctf.zeyu2001.com/2022/nitectf-2022/undocumented-js-api

Exploiting a subdomain takeover

Subdomain takeover is essentially DNS spoofing for a specific domain across the internet, allowing attackers to set A records for a domain, leading browsers to display content from the attacker's server. This transparency in browsers makes domains prone to phishing. Attackers may employ typosquatting or Doppelganger domains for this purpose. Especially vulnerable are domains where the URL in a phishing email appears legitimate, deceiving users and evading spam filters due to the domain's inherent trust.

Check this post for further details

SSL Certificates

SSL certificates, if generated by attackers via services like Let's Encrypt, add to the legitimacy of these fake domains, making phishing attacks more convincing.

Cookie Security and Browser Transparency

Browser transparency also extends to cookie security, governed by policies like the Same-origin policy. Cookies, often used to manage sessions and store login tokens, can be exploited through subdomain takeover. Attackers can gather session cookies simply by directing users to a compromised subdomain, endangering user data and privacy.

Emails and Subdomain Takeover

Another aspect of subdomain takeover involves email services. Attackers can manipulate MX records to receive or send emails from a legitimate subdomain, enhancing the efficacy of phishing attacks.

Higher Order Risks

Further risks include NS record takeover. If an attacker gains control over one NS record of a domain, they can potentially direct a portion of traffic to a server under their control. This risk is amplified if the attacker sets a high TTL (Time to Live) for DNS records, prolonging the duration of the attack.

CNAME Record Vulnerability

Attackers might exploit unclaimed CNAME records pointing to external services that are no longer used or have been decommissioned. This allows them to create a page under the trusted domain, further facilitating phishing or malware distribution.

Mitigation Strategies

Mitigation strategies include:

  1. Removing vulnerable DNS records - This is effective if the subdomain is no longer required.

  2. Claiming the domain name - Registering the resource with the respective cloud provider or repurchasing an expired domain.

  3. Regular monitoring for vulnerabilities - Tools like aquatone can help identify susceptible domains. Organizations should also revise their infrastructure management processes, ensuring that DNS record creation is the final step in resource creation and the first step in resource destruction.

For cloud providers, verifying domain ownership is crucial to prevent subdomain takeovers. Some, like GitLab, have recognized this issue and implemented domain verification mechanisms.

References

Use Trickest to easily build and automate workflows powered by the world's most advanced community tools.Get Access Today:

Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert)!

Other ways to support HackTricks:

Domain/Subdomain takeover | HackTricks (2024)

FAQs

Is subdomain takeover illegal? ›

Subdomain takeover can have severe legal implications, as attackers may engage in illegal activities or host malicious content on compromised subdomains.

What is subdomain takeover? ›

A subdomain takeover occurs when an attacker gains control over a subdomain of a target domain. Typically, this happens when the subdomain has a canonical name (CNAME) in the Domain Name System (DNS), but no host is providing content for it.

What is the best tool for subdomain takeover? ›

Tool Comparison
ToolRun Time
Subjack2 Hours, 30 Minutes, 2 Seconds
Subdover2 hours, 33 minutes, 27 seconds
Subdominator19 minutes, 8 seconds

How do you mitigate a subdomain takeover? ›

Regularly Audit and Clean DNS Records

Regular DNS configuration reviews, especially CNAME and TXT records, are crucial. Removing or updating any outdated or irrelevant subdomain entries that point to third-party services that are no longer in use prevents vulnerable subdomains that attackers could take advantage of.

What is subdomain hijacking? ›

It's a cyber threat executed when an attacker gains control of a legitimate subdomain that's no longer in use, then cleverly exploits the forgotten or misconfigured dangling DNS to host their own content on the previously used zone.

Do I own a subdomain if I own a domain? ›

Yes. When you purchase the root domain, you can set up any subdomain you want on that root domain. Before you use Google Search Console (used to be Google Webmaster Tool), you should set up your site so that all traffic going to the root domain gets redirected to the www version.

What is hostile subdomain takeover? ›

One of the subdomains of the scanned domain is pointing to an external service but the external service account was cancelled or has expired. Because the account is not in use anymore, an attacker can claim this account and takeover your subdomain. The attacker can use this subdomain for phishing or to spread malware.

Is a subdomain bad for SEO? ›

While subdomains can work well for some companies, depending on their goals, a subdirectory is often a better choice for SEO.

Why do owners use subdomains? ›

Subdomains are best for content that is too distinct from your main website. For example, if the topic has a different purpose or requires a specific CMS or design.

What is second level subdomain takeover? ›

Second-order subdomain takeovers

This means that a resource is being imported on the target page, for example, via a blob of JavaScript and the hacker can claim the subdomain from which the resource is being imported.

Can a subdomain be anything the domain owner wants? ›

You can call your subdomain anything you like and it need have nothing to do with the main domain.

What is subdomain stripping? ›

Subdomain stripping is the process of removing the subdomains from the main domain and delivering the emails to the main domain directly.

How does a subdomain takeover happen? ›

A subdomain takeover can occur when you have a DNS record that points to a deprovisioned Azure resource. Such DNS records are also known as "dangling DNS" entries. CNAME records are especially vulnerable to this threat.

What is the difference between DNS takeover and subdomain takeover? ›

A subdomain takeover occurs when you take over the service that some DNS records are pointing to. A DNS takeover occurs when you take over the DNS server that is assigned to that host. DNS takeovers are typically more severe because they give the attacker more control.

What can hackers do with subdomains? ›

Data Breaches: Subdomain takeover can lead to unauthorized access to sensitive data or user information. Attackers could exploit the subdomain to trick users into divulging confidential information, such as login credentials, personal data, or financial details.

Can I transfer a subdomain? ›

When using a subdomain setup, you can have your child subdomain as a separate zone within the same account as the parent domain or within a different account. If you have already created a standalone subdomain zone within the same account, you still can move it to a separate account.

Is it bad to use subdomains? ›

Subdomains aren't inherently bad for SEO, but they can impact your site's SEO strategy if not used wisely. Since subdomains are treated as separate entities by search engines, they may dilute the overall authority of your main site if not managed properly.

References

Top Articles
Latest Posts
Article information

Author: Van Hayes

Last Updated:

Views: 5237

Rating: 4.6 / 5 (46 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Van Hayes

Birthday: 1994-06-07

Address: 2004 Kling Rapid, New Destiny, MT 64658-2367

Phone: +512425013758

Job: National Farming Director

Hobby: Reading, Polo, Genealogy, amateur radio, Scouting, Stand-up comedy, Cryptography

Introduction: My name is Van Hayes, I am a thankful, friendly, smiling, calm, powerful, fine, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.