Skip to content

Commit fdc1693

Browse files
committed
f
1 parent f3a3b51 commit fdc1693

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/pentesting-web/domain-subdomain-takeover.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ There are several tools with dictionaries to check for possible takeovers:
2626
- [https://github.com/PentestPad/subzy](https://github.com/PentestPad/subzy)
2727
- [https://github.com/Stratus-Security/Subdominator](https://github.com/Stratus-Security/Subdominator)
2828
- [https://github.com/NImaism/takeit](https://github.com/NImaism/takeit)
29+
- [https://github.com/projectdiscovery/nuclei](https://github.com/projectdiscovery/nuclei) (use `-tags takeover` with nuclei-templates)
30+
- [https://github.com/edoardottt/cariddi](https://github.com/edoardottt/cariddi) (takeover checks in crawling output)
2931

3032
### Subdomain Takeover Generation via DNS Wildcard
3133

3234
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...
3335

3436
For example, if `*.testing.com` is wildcarded to `1.1.1.1`. Then, `not-existent.testing.com` will be pointing to `1.1.1.1`.
3537

36-
However, if instead of pointing to an IP address, the sysadmin points it to a **third party service via CNAME**, like a G**ithub 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**.
38+
However, if instead of pointing to an IP address, the sysadmin points 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 GitHub 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**.
3739

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

@@ -65,7 +67,7 @@ It might be possible that the compromised subdomain is allowed to be used in the
6567

6668
### CSP Bypass
6769

68-
It might be possible that the compromised subdomain (or eveyr subdomain) is allowed to be used for example the `script-src` of the CSP. This could be exploited by an attacker to **inject malicious scripts** and abuse potential XSS vulnerabilities.
70+
It might be possible that the compromised subdomain (or every subdomain) is allowed to be used for example the `script-src` of the CSP. This could be exploited by an attacker to **inject malicious scripts** and abuse potential XSS vulnerabilities.
6971

7072
### **Emails and Subdomain Takeover**
7173

@@ -89,6 +91,25 @@ Mitigation strategies include:
8991

9092
For cloud providers, verifying domain ownership is crucial to prevent subdomain takeovers. Some, like [GitLab](https://about.gitlab.com/2018/02/05/gitlab-pages-custom-domain-validation/), have recognized this issue and implemented domain verification mechanisms.
9193

94+
## Detection techniques
95+
96+
- **Find dangling DNS records**: look for CNAME/A/AAAA/ALIAS/ANAME records pointing to non-existent resources (deleted buckets, apps, pages, load balancers).
97+
- **Check provider error signatures**: match HTTP responses, TLS certs, or DNS errors to known takeover patterns (see can-i-take-over-xyz).
98+
- **Look for orphaned cloud assets**: verify S3/CloudFront, Azure Websites, GCP App Engine/Storage, GitHub Pages, Heroku, Fastly, Netlify, Vercel, Zendesk, Shopify, Atlassian, and similar services.
99+
- **Passive DNS and historical records**: old CNAMEs often reveal previously used third-party services that may still be vulnerable.
100+
- **Wildcard pitfalls**: confirm wildcard DNS vs. explicit records to avoid false positives and understand takeover amplification.
101+
102+
## APIs and data sources
103+
104+
- [https://securitytrails.com/](https://securitytrails.com/) (historical DNS, passive DNS API)
105+
- [https://community.riskiq.com/](https://community.riskiq.com/) (PassiveTotal)
106+
- [https://www.farsightsecurity.com/solutions/dnsdb/](https://www.farsightsecurity.com/solutions/dnsdb/)
107+
- [https://www.domaintools.com/products/iris/](https://www.domaintools.com/products/iris/)
108+
- [https://search.censys.io/](https://search.censys.io/) (certs and host data)
109+
- [https://www.shodan.io/](https://www.shodan.io/) (host data)
110+
- [https://www.virustotal.com/](https://www.virustotal.com/) (historical DNS, URLs)
111+
- [https://chaos.projectdiscovery.io/](https://chaos.projectdiscovery.io/) (subdomains dataset)
112+
92113
## References
93114

94115
- [https://0xpatrik.com/subdomain-takeover/](https://0xpatrik.com/subdomain-takeover/)
@@ -98,4 +119,3 @@ For cloud providers, verifying domain ownership is crucial to prevent subdomain
98119
{{#include ../banners/hacktricks-training.md}}
99120

100121

101-

0 commit comments

Comments
 (0)