Skip to content
PHASE 07/16OP DANGLING

Subdomain takeover checks

Noise
Light active
Reads
subs/all.txtdns/cnames.txtdns/dead.txt
Writes
takeover/subzy.txttakeover/nuclei.txttakeover/candidates.md

Scope checkActive phase. Check the program policy first. Send traffic only to in-scope assets, at the rate the program allows.

6 min readRecon Atlas

A subdomain takeover happens when shop.example.com has a CNAME record (an alias) to example-shop.myshopify.com, but nobody owns that Shopify store any more. Anyone who claims the store name now serves content on shop.example.com. That means phishing on the real domain, cookie theft if cookies are scoped to .example.com, and sometimes OAuth or Content Security Policy (CSP) bypasses.

This phase finds those dangling records and tells you which services can still be claimed.

Tool Noise Role Status
can-i-take-over-xyz Passive Community list of which services are vulnerable and how to check Maintained reference
subzy Light active Checks hosts against known fingerprints Maintained
subjack Light active Older fingerprint checker, still catches a few names subzy misses Rarely updated
dnsReaper Light active Fingerprint-based checks, can read DNS zones from cloud providers Maintained
Nuclei takeover templates Light active Template checks, tagged takeover Maintained

A CNAME such as blog.example.com to example-blog.herokuapp.com affects that one name, and only if the service still lets a stranger create the resource.

An NS delegation is worse. If dev.example.com delegates to Route 53 or Azure DNS and that zone is gone, recreating the zone lets you publish every record under dev.example.com, not one hostname.

An MX aimed at a mail host nobody owns lets you receive mail for that name.

Many providers now refuse the claim unless you can edit DNS. GitHub Pages and Azure App Service want a TXT token such as _github-pages-challenge-org or asuid on the name. CloudFront wants an AWS Certificate Manager certificate that already covers the custom domain. A fingerprint match on those services is not a takeover. Older string-match services, including some S3 layouts and neglected SaaS apps, still bind a custom domain with no proof.

docs.example.com. 300 IN CNAME example-docs-bucket.s3.amazonaws.com.
HTTP/1.1 404 Not Found
x-amz-error-code: NoSuchBucket
x-amz-request-id: 9ABCD1234EFGH567
Content-Type: application/xml
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>
<BucketName>example-docs-bucket</BucketName>
</Error>

docs.example.com points at example-docs-bucket.s3.amazonaws.com, and S3 says that bucket does not exist. It does not mean you can create it. A dotted bucket name, a name AWS has reserved, or the same name already taken in another region will make CreateBucket fail.

dev.example.com. 3600 IN NS ns1.cloudprovider.net.
dev.example.com. 3600 IN NS ns2.cloudprovider.net.
Terminal window
dig @ns1.cloudprovider.net dev.example.com SOA
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 48192
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

The parent zone delegates all of dev.example.com to ns1.cloudprovider.net, and that server has no zone for it. REFUSED does not mean the provider will let you register dev.example.com without proving you control example.com.

assets.example.com shows 403 ERROR: The request could not be satisfied and an X-Amz-Cf-Id header. The CNAME points at d123456.cloudfront.net, and that distribution is disabled or does not list this name. Adding the name to your own distribution fails until AWS Certificate Manager has a certificate for assets.example.com. No certificate, no takeover.

docs.example.com shows 404: There isn't a GitHub Pages site here. The CNAME points at exampleorg.github.io and no repo publishes that custom domain. If the org turned on domain verification, your repo will reject the name. Look for a _github-pages-challenge TXT record before you write the report.

portal.example.com returns 404 Web Site not found. The CNAME points at example-portal.azurewebsites.net, and that app was deleted. Azure will not bind the custom domain until asuid.portal.example.com holds their verification string. You cannot add that TXT record, so you cannot finish the claim.

  1. List the CNAMEs and dead names. You already have them from phase 4. Read dns/cnames.txt and look for third-party services.

    Terminal window
    # Count CNAME targets by provider domain to see which services the target uses
    awk '{print $2}' dns/cnames.txt | tr ',' '\n' | awk -F. '{print $(NF-1)"."$NF}' | sort | uniq -c | sort -rn
  2. Run subzy across all names. It fetches each host and compares the response to known “unclaimed” fingerprints.

    Terminal window
    # Check every name, show only likely vulnerable results
    subzy run --targets subs/all.txt --hide_fails --concurrency 20 | tee takeover/subzy.txt
    Terminal window
    # subjack as a second fingerprint set; -ssl probes HTTPS
    subjack -w subs/all.txt -ssl -c ~/go/pkg/mod/github.com/haccer/subjack*/fingerprints.json -o takeover/subjack.txt

    Check Elastic Beanstalk manually, because automated tools often miss it. Look for a CNAME pointing to *.elasticbeanstalk.com or *.<region>.elasticbeanstalk.com whose environment was torn down. If the name is free, you can reclaim it by creating an environment with the same name in that region.

  3. Run Nuclei takeover templates. A second fingerprint set catches services subzy misses.

    Terminal window
    # Takeover templates only, at 20 requests per second
    nuclei -l subs/all.txt -tags takeover -rl 20 -silent -o takeover/nuclei.txt
  4. Run dnsReaper for a third opinion. It runs from Docker, so mount your target folder.

    Terminal window
    # Check every name in the list with dnsReaper
    docker run -it --rm -v "$(pwd):/etc/dnsreaper" punksecurity/dnsreaper file --filename /etc/dnsreaper/subs/all.txt
  5. Check each hit against can-i-take-over-xyz. Open the can-i-take-over-xyz table for the service. Some services that once allowed takeovers now verify domain ownership. Others need conditions the scanner cannot see, such as the right region.

  6. Check NS and MX delegations too. A subdomain delegated with NS records to a DNS provider zone that no longer exists can be the worst kind of takeover. You would control all DNS for that name.

    Terminal window
    # Show NS records for names that return SERVFAIL or NXDOMAIN
    dnsx -l dns/dead.txt -ns -resp -silent

    For a name that lists someone else’s nameservers, ask that server for the SOA:

    Terminal window
    # Query the delegated nameserver directly
    dig @ns1.cloudprovider.net dev.example.com SOA +short

    REFUSED or NXDOMAIN from that server means the zone is not there. The provider can still require proof that you control the parent domain before it lets you create the zone.

    For mail, read the MX records and check whether the mail host still exists. An MX pointing at a hostname that no longer resolves, or at a SaaS mailbox nobody owns, lets you receive mail for the name.

    Terminal window
    # Mail servers for the domain, then resolve each one
    dig +short MX example.com | awk '{print $2}' | dnsx -a -resp -silent
  7. Check for second-order takeovers. A page can load a script, image or iframe from a host that is itself dangling. Claim that host and your code runs in the target’s page, even though the target’s own DNS is clean. Pull every external resource host out of the collected URLs and JavaScript, then run them back through the checks above.

    Terminal window
    # Extract hosts referenced by src/href in downloaded JS and pages, dedupe
    grep -Ehuo 'https?://[a-z0-9.-]+' js/files/*.js urls/clean.txt | sed -E 's#https?://##; s#/.*##' | sort -u > takeover/external-hosts.txt
    Terminal window
    # Fingerprint those third-party hosts for takeover too
    subzy run --targets takeover/external-hosts.txt --hide_fails --concurrency 20 | tee takeover/subzy-external.txt
  8. Write up candidates in takeover/candidates.md: name, CNAME target, service, evidence (response body or DNS output), and the can-i-take-over-xyz status.

  • Read the program policy first. Some programs want only the DNS evidence and say “do not claim”. Some accept a claimed resource.
  • If claiming is allowed, create the resource with a name that matches the CNAME, and serve a single static page at an unguessable path, such as /takeover-proof-<random>.html, containing your handle and the date.
  • Leave the root path empty or as the service default, so normal visitors see nothing new.
  • Take a screenshot of the proof page on the target subdomain, then report.
  • Delete the proof resource once you have the screenshot and the report is filed, so no page lingers on the target’s name. Hold the resource only if the program asks you to keep it live while they verify.
  • Ask the program whether you should release the resource name, and when. Releasing it too early lets someone else claim it before the target fixes the DNS.
  • Confirmed takeovers go straight to a report. They do not need the rest of the pipeline.
  • Names that look like takeovers but are not still tell you which SaaS the target uses. Note them for OSINT in phase 14.
  • Reporting scanner output without checking can-i-take-over-xyz. A “vulnerable” fingerprint on a service that now verifies ownership is a false positive.
  • Claiming a resource on a program that bans it.
  • Serving JavaScript or a full page as proof.
  • Missing NS delegations because you only looked at CNAMEs.
  • Forgetting to recheck. Dangling records appear whenever the target deletes a cloud resource and forgets DNS, so takeovers belong in continuous monitoring.
What to look for
  • CNAMEs to *.s3.amazonaws.com, *.elasticbeanstalk.com, *.azurewebsites.net, *.cloudapp.net, *.trafficmanager.net, *.herokuapp.com, *.github.io, *.netlify.app, *.ghost.io
  • Scripts, images or iframes loaded from a third-party host that itself no longer resolves, which is a second-order takeover
  • Error bodies like NoSuchBucket, There isn't a GitHub Pages site here, No such app, 404 Web Site not found
  • NXDOMAIN on a CNAME target
  • NS records pointing at a DNS provider that returns REFUSED or SERVFAIL for the zone

Next, collect every path and query string the live hosts expose in phase 8.

Connections6 backlinks · 4 outgoingFull graph →
Open local graph around this page
Open full graph →
Click a node to open · Drag to reposition · Scroll to zoom

Recon AtlasFor authorized testing only. Your scope is the map edge.