Notes
Why subdomains
Why subdomains? Because each name is a separate system. Development, staging and test environments, often with weaker settings and real data. Old and legacy versions. Remote access points such as VPN and single sign-on. Internal tools exposed by accident: build servers, dashboards, ticket systems. APIs. Names left over from acquisitions and old campaigns. Each has different software, a different owner and a different patch level. The weakest one sets your security.
- dev., staging., test., uat.
- old., legacy., v1., beta.
- vpn., remote., mail., sso.
- jenkins., gitlab., grafana., jira., admin.
- api., internal-api.
- names from acquisitions and old campaigns
- each: different software, owner and patch level
Certificate logs
The fastest source is certificate transparency. Every public certificate is logged with the hostnames it covers, and the site c r t dot s h lets you search those logs. One request returns every name under a domain that ever received a certificate. You will see the obvious ones, and then names like staging API and Grafana internal. It is completely passive. Note the lesson for defenders too: a certificate for an internal name publishes that name to the world.
curl -s "https://crt.sh/?q=%25.example.com\ &output=json" | jq -r ".[].name_value" \ | sort -u # www.example.com # api.example.com # staging-api.example.com # vpn.example.com # grafana.internal.example.com # passive: the target sees nothing
Passive tools
Tools combine many sources. Subfinder and Amass query certificate logs, passive DNS databases, which record what names resolved to over time, search engines, web archives and security datasets, then merge the results. Both have a passive mode that never contacts the target. Adding free API keys for the data providers increases coverage considerably. Run two tools and merge the output, because each finds names the other misses.
subfinder -d example.com -silent \ -o subs.txt amass enum -passive -d example.com # sources: CT logs, passive DNS, # search engines, web archives, # threat-intel and DNS datasets # API keys add more sources
Active discovery
Some names have never appeared in any public source, so you ask DNS directly. Brute forcing resolves a wordlist of likely names. Permutation tools take known names and try variations, such as API dev and API two. A zone transfer, which hands over the whole zone, is rarely permitted but takes one command to check. First test for wildcard DNS, where every name resolves and results are meaningless. This is active: the target's DNS servers see the queries.
- brute force: resolve a wordlist of likely names (dnsx, puredns, massdns)
- permutations: api-dev, api-stg, api2 from known names
- zone transfer (AXFR): rarely open, always worth one try
- check for wildcard DNS first
- this is visible to the target
Which are alive
A list of names is not yet useful. Next you check which are alive and what they run. A tool called httpx requests each one and reports the status, the page title and the detected technology. Now the interesting items stand out: an old site on a PHP version that stopped receiving fixes years ago, and a build server that answers on the internet. Screenshot tools give a visual overview of hundreds of hosts in minutes. This step is active and must be in scope.
httpx -l subs.txt -title \ -status-code -tech-detect # https://api.example.com [200] # [API docs] [nginx] # https://old.example.com [200] # [Welcome] [Apache 2.4.29, PHP 5.6] # https://jenkins.example.com [403] # [Jenkins]
Subdomain takeover
Discovery also reveals one of the most common cloud-era weaknesses: subdomain takeover. A subdomain points, with a CNAME record, to an application on a cloud or hosting platform. Later the application is deleted, but the DNS record stays. An attacker registers that same application name on the platform, and now controls what your subdomain serves. They can obtain a valid certificate, host phishing pages on your real domain, and sometimes read cookies scoped to the parent domain.
- shop.example.com is a CNAME to an app on a cloud or SaaS platform
- the app is deleted; the DNS record is forgotten
- an attacker registers that same app name on the platform
- now they serve content on YOUR subdomain, with a valid certificate
Prevent takeover
Prevention is mostly discipline. Delete the DNS record before deleting the resource it points to, never after. Manage DNS and cloud resources in the same infrastructure code, so they are removed together. Scan your own zones regularly for records pointing at resources that no longer exist. The same issue affects name server and mail records, and addresses released back to a cloud provider. Cloud providers publish guidance and tools for auditing your own zones.
- delete the DNS record BEFORE deleting the resource
- manage DNS and cloud resources in the same code (Terraform)
- scan for dangling CNAMEs regularly
- also: dangling NS, MX, and released cloud IP addresses
- tools exist for defenders to audit their own zones
Beyond subdomains
Assets are more than subdomains. Address ranges you own, and addresses in cloud accounts. Cloud storage buckets, often named after the company or product, and sometimes publicly readable. Other root domains for brands and acquisitions. Mobile applications, which contain the hostnames of the APIs they call. Public code repositories and container images. And software service tenants, such as a helpdesk or wiki, that may allow public sign-up. A full inventory covers all of these.
- IP ranges: your ASN, cloud elastic IPs
- cloud storage: buckets and blobs named after you
- other root domains: brands, acquisitions, typos
- mobile apps and their API hosts
- code repos, container images
- SaaS tenants: helpdesk, wiki, status pages
Make it continuous
A one-time list is out of date within a week, so make discovery continuous. Start from your sources of truth: DNS zones, cloud provider APIs and the registrar. Add outside-in discovery every day. Compare with yesterday and alert on anything new. Give every asset a named owner. And scan a new host before anyone else does. Commercial attack surface management products do this, and so does the open-source chain from this episode, on a schedule.
- sources of truth: DNS zones, cloud APIs, registrar
- plus outside-in discovery, daily
- diff against yesterday: alert on anything new each asset has an owner
- new host: scanned before it is announced
- tools: commercial ASM, or the open-source chain here
What to look at first
With hundreds of hosts, where do you look first? Testers have a consistent order. Anything old: outdated versions, expired certificates. Non-production names that appear to hold production data. Administration and developer tools reachable from the internet. Login pages without multi-factor authentication. Default installation pages, which signal an unfinished setup. Dangling records. And anything for which nobody in the company can name an owner.
- anything old: outdated versions, expired certs
- non-production names with production-looking data
- admin and developer tools reachable from the internet
- login pages without MFA
- default pages: "It works!"
- dangling records
- things nobody can name an owner for
Common mistakes
Mistakes. Trusting the official asset list. Using one tool and one source. Actively probing a discovered host without confirming it belongs to the client and is in scope. Ignoring wildcard DNS and drowning in false results. Deleting a cloud resource while leaving its DNS record. Putting internal names into public certificates, which publishes them. And running discovery once a year, when the environment changes every day.
- trusting the official asset list
- one tool, one source
- brute forcing or probing hosts outside the scope
- ignoring wildcard DNS
- deleting a cloud resource and leaving its DNS record
- internal names in public certificates
- discovery once a year
Say it like this
In the interview: I start passively with certificate transparency and passive DNS, using tools such as Subfinder and Amass. Then, within scope, DNS brute forcing and permutations, and probing for live hosts and technologies. I add address ranges, cloud storage and other root domains. I check for dangling records that allow subdomain takeover. As a defender, I combine that with our DNS and cloud APIs in a daily job that alerts on anything new and assigns an owner.
- "Passive first: certificate
- transparency, passive DNS and tools like Subfinder and Amass. Then DNS brute force
- and permutations, probe live
- hosts with httpx, and add IP
- ranges and cloud assets. I
- check dangling records and run it daily with diffs."