Fastly Subdomain Takeover $2000
A subdomain pointed to a Fastly service that was not claimed by any customer, allowing the attacker to register it and serve content on the subdomain. The attacker could host arbitrary content on the subdomain, potentially phishing or stealing cookies.
Published on medium.com
After enumerating subdomains, removed duplicate entries and merged them into a single file (subdomains.txt) using the Anew tool.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This is a write-up of a Fastly subdomain takeover found on a private bug bounty program. The researcher, Alexandar Thangavel (ValluvarSploit), refers to the target throughout as redacted.com. The asset involved is a subdomain, next.redacted.com, which was serving a Fastly error page.
A subdomain takeover happens when a DNS record for a hostname points at a third-party service that no longer has a matching resource configured for that hostname. If the service lets anyone register that hostname, an attacker can claim it and serve their own content under the victim's domain. Fastly is a CDN and edge cloud provider; a customer creates a delivery service and attaches hostnames to it. The takeover is only possible when the hostname is not already claimed by another Fastly customer.
Setup
The researcher was working from a laptop tethered to a mobile hotspot. The tools used were:
- Google Dorking for passive enumeration
- OWASP Amass for passive enumeration
- Gobuster for DNS brute force
- Anew to merge and deduplicate results
- A custom
cname.shshell script to enumerate CNAME records - HTTPX to probe live servers and to collect CNAMEs
digfor manual DNS lookups- A VPS server to host the proof of concept
- A Fastly account, which the researcher created after deleting an older one
The target was an old private program the researcher had worked on before. He makes the point that he revisits old private programs at least once every six months.
Finding it
Enumeration started with passive and active subdomain discovery. The commands, as written in the report:
The Google dorks look for subdomains of redacted.com while excluding www, www1 and blog, and a second dork looks for deeper subdomains while excluding product. Amass runs in passive mode against redacted.com and writes to amass_passive_subs.txt. Gobuster performs DNS brute force with a wordlist, requests CNAME display, disables colour and writes to gobuster_subs.txt.
The three result files were merged and deduplicated into subdomains.txt:
# Merging subdomains into one filecat google_subs.txt amass_passive_subs.txt gobuster_subs.txt | anew subdomains.txt
CNAME records were then enumerated with the custom script, with HTTPX given as an alternative:
# Enumerate CNAME records./cname.sh -l subdomains.txt -o cnames.txt# We can use HTTPX tool as wellhttpx -l subdomains.txt -cname cnames.txt
Live servers were probed on ports 80, 443, 8080 and 3000, capturing status code and title:
# Probe for live HTTP/HTTPS servershttpx -l subdomains.txt -p 80,443,8080,3000 -status-code -title -o servers_details.txt
While analysing cnames.txt, one subdomain stood out because it pointed to two different CNAME records. A manual lookup was run:
dig next.redacted.com CNAME
The first CNAME pointed to a webflow.io domain and the second pointed to fastly.net. The researcher explains the chain: with multiple CNAME records, the first redirects to the next and so on until the last record is reached.
In servers_details.txt the corresponding line was:
https://next.redacted.com [500] [246] [Fastly error: unknown domain next.redacted.com]
The status code was 500 and the page title was Fastly error: unknown domain next.redacted.com. Combined with the CNAME to redacted.fastly.net, this is the classic Fastly takeover fingerprint. The researcher is careful to note that he had seen this fingerprint many times before without it being exploitable: it is only vulnerable when certain conditions are met, so it is an edge case. Most of the time a Fastly service cannot be taken over. The exploitable case is when the domain is not already taken by another customer, in which case it can be claimed and the subdomain taken over completely.
Exploitation
Step 1: Create a Fastly account
The researcher went to fastly.com and created an account. He notes he had an account two years earlier but had deleted it six months before because he believed Fastly was secure, a belief he says was wrong.
Step 2: Create a delivery service
Logged in to the Fastly Dashboard, he clicked the "Create a Delivery Service" button.
Step 3: Add the target hostname
He entered the target subdomain, next.redacted.com, and clicked Add. He expected an error saying the domain was already taken by another customer. No error appeared; he was redirected to the Hosts page. That absence of an error is the confirmation that the hostname was unclaimed.
Step 4: Build the PoC content on a VPS
On his VPS he created a directory and an HTML file:
mkdir hostingcd hostingnano index.html
The file contained:
<h1>ValluvarSploit PoC</h1>
Step 5: Serve it
A simple Python web server was started on port 80 in the current working directory:
python3 -m http.server 80
Step 6: Point Fastly at the VPS
Back in the Fastly dashboard, he added the public IP address of his VPS in the Hosts page.
Step 7: Verify
After a few seconds he opened a new browser window and visited http://next.redacted.com/index.html. The PoC file rendered successfully, which proves the subdomain was serving content controlled by him. A detailed report was written and submitted on HackerOne.
Step 8: Monitor logs
He kept the Fastly service running for three days and monitored server logs for sensitive information. He describes watching other bug hunters' methodology as fun.
Root cause
The DNS for next.redacted.com still pointed, through a chain of CNAMEs, at a Fastly service (redacted.fastly.net) that no longer had a delivery service configured for that hostname. Fastly answers requests for an unknown hostname with the Fastly error: unknown domain page and a 500 status. Because the hostname was not claimed by any existing customer, the Fastly dashboard accepted it when the researcher added it to a new delivery service. He expected an error saying the domain was already taken by another customer, but none appeared. It does nothing for a dangling hostname, which is exactly the case here.
Impact
An attacker who claims the hostname can serve arbitrary content under the victim's subdomain. In this case the researcher demonstrated a static HTML page. An attacker who claims the hostname can serve arbitrary content under the victim's subdomain; the report does not go into specific attack scenarios. The report does not go into specific attack scenarios beyond the PoC page and the log monitoring. The impact is conditional: it only applies when the hostname is unclaimed at Fastly, which the researcher stresses is the exception rather than the rule.
Fix
Variants to test
- Other CDN and edge providers with the same dangling-hostname pattern. Look for CNAMEs to provider domains where the hostname is no longer configured. A positive result is a provider error page naming the hostname, followed by the provider's dashboard accepting that hostname on a new service without an "already taken" error.
- CNAME chains. The report found the issue because one subdomain had two CNAME records. Enumerating CNAMEs and flagging hosts with more than one record is a cheap way to surface chains that end at a third-party service. A positive result is a chain whose final target is a provider that answers with an unknown-domain error.
- Fingerprint matching at scale. Feed HTTPX output with status codes and titles into a search for provider error strings such as
Fastly error: unknown domain. A positive result is a 500 with the provider's unknown-domain title, which then needs manual confirmation at the provider. - Revisiting old programs. The researcher's own takeaway is to revisit old targets at least once every six months, since DNS records drift and services get decommissioned. A positive result is a hostname that resolved to a live service on the previous visit and now returns a provider error page.
What happened, in plain words
A security researcher found a way to put his own web page on a subdomain belonging to a company, without that company's permission. The company ran a bug bounty program, which is a scheme where organisations invite outside people to look for security mistakes in their systems and pay them for reporting the mistakes responsibly. The researcher was paid $2000 for this one.
The trick is called a subdomain takeover. To understand it, you need to know two everyday things: what a domain name is, and what a DNS record is.
A domain name is the address you type into a browser, like example.com. A subdomain is a name that sits in front of it, like shop.example.com or next.example.com. Companies use subdomains to run different services under one main name.
DNS (Domain Name System) is the internet's phone book. When you type a name into your browser, your computer asks DNS "what is the numeric address for this name?" and DNS answers with an IP address, which is the numeric location of a server, something like [redacted]. A CNAME record (Canonical Name record) is a special kind of DNS entry that says "this name is really just another name for that other name". It is like a mail forwarding note: you write to one address, and the post office sends it on to a second address.
Many companies do not run every service themselves. They rent space from a CDN (Content Delivery Network), a company that stores and serves website content from servers all over the world so pages load quickly. Fastly is one such CDN and edge cloud provider. A Fastly customer creates something called a delivery service inside their Fastly account and attaches their own hostnames to it. Fastly then answers requests for those hostnames on the customer's behalf.
The problem appears when a company stops using a Fastly delivery service but leaves the DNS record pointing at Fastly. The DNS still says "go to Fastly", but Fastly no longer has anything configured for that name. Fastly responds with an error page saying it does not know the domain. If Fastly then lets anyone add that hostname to a new delivery service, the first person to do so controls what visitors to that subdomain see. That is the takeover.
The researcher, Alexandar Thangavel, known online as ValluvarSploit, found exactly this situation on a subdomain called next.redacted.com. He refers to the real company's domain as redacted.com throughout to keep it private. The subdomain was showing a Fastly error page.
One important detail: this only works when the hostname is not already claimed by another Fastly customer. He expected Fastly to refuse a hostname already taken by another customer, but no error appeared. The protection fails only for a hostname that nobody is using any more, which the researcher calls an edge case, meaning an unusual situation rather than the common one.
Setup
The researcher worked from a laptop connected to the internet through a mobile phone hotspot. He lists the tools he used. You do not need to install any of them to follow the story, but here is what each one does:
- Google Dorking: using specially crafted Google search queries to find pages and subdomains that ordinary searches do not surface. It is passive, meaning you ask a search engine rather than touching the target directly.
- OWASP Amass: a tool that gathers subdomain names from many public sources. In passive mode it only collects what is already publicly known.
- Gobuster: a tool that tries a long list of common names (a wordlist) against a domain to see which ones exist. This is called brute force, meaning trying many possibilities systematically.
- Anew: a small utility that adds new lines to a file while skipping lines that are already there, so you end up with a clean list without duplicates.
- A custom
cname.shshell script: a small program the researcher wrote himself to look up CNAME records for a list of names. A shell script is a text file of commands that the computer runs in order. - HTTPX: a tool that visits each name in a list over HTTP or HTTPS and reports what came back, such as the status code and the page title.
dig: a standard command-line tool for asking DNS questions directly.- A VPS server: a Virtual Private Server, a rented computer in a data centre that you control remotely. He used it to host the proof of concept page.
- A Fastly account: which he created for this test.
The target was an old private program he had worked on before. A private program is a bug bounty scheme you can only join by invitation. He makes the point that he revisits old private programs at least once every six months, because systems change over time and something that was safe last year may not be safe now.
Finding it
Subdomain enumeration is the process of discovering which subdomains exist for a domain. You cannot test what you do not know about, so this is the first step. He combined passive discovery (asking public sources) with active discovery (guessing names). The commands, as written in the report:
Line by line:
site:*.redacted.com -www -www1 -blogis a Google search query.site:restricts results to a particular site, and the*wildcard means any subdomain. The-www,-www1and-blogparts tell Google to leave out those three common names, because they are obvious and he wanted to find less obvious ones.site:*.*.redacted.com -productis a second query looking for deeper subdomains, two levels down, while excluding anything containingproduct.amass enum -passive -d redacted.com -config config.ini -o amass_passive_subs.txtruns Amass.enummeans enumerate,-passivemeans only use public sources,-d redacted.comsets the domain,-config config.inipoints at a settings file, and-o amass_passive_subs.txtwrites the results to that file.gobuster dns -d redacted.com -w wordlist.txt - show-cname - no-color -o gobuster_subs.txtruns Gobuster in DNS mode.-dis the domain,-w wordlist.txtis the list of names to try,- show-cnameasks it to display CNAME records,- no-colorturns off coloured output so the text file is clean, and-owrites the results to a file.
The three result files were then merged and deduplicated into subdomains.txt:
# Merging subdomains into one filecat google_subs.txt amass_passive_subs.txt gobuster_subs.txt | anew subdomains.txt
catprints the contents of the three files one after another.- The
|symbol is a pipe: it takes the output of the command on the left and feeds it as input to the command on the right. anew subdomains.txtreads that stream and appends only lines that are not already insubdomains.txt. The result is one combined list with no repeats, which saves time later because every name is checked only once.
Next, CNAME records were enumerated with the custom script, with HTTPX given as an alternative:
# Enumerate CNAME records./cname.sh -l subdomains.txt -o cnames.txt# We can use HTTPX tool as wellhttpx -l subdomains.txt -cname cnames.txt
./cname.sh -l subdomains.txt -o cnames.txtruns his script.-lgives it the list of names to look up, and-owrites the CNAME answers tocnames.txt. The reason for this step: a CNAME tells you where a name really points, and a name pointing at a third-party provider is the precondition for a takeover.httpx -l subdomains.txt -cname cnames.txtdoes the same job with HTTPX:-lis the input list and-cnamecollects the CNAME records into the named file.
Live servers were then probed on ports 80, 443, 8080 and 3000, capturing status code and title:
# Probe for live HTTP/HTTPS servershttpx -l subdomains.txt -p 80,443,8080,3000 -status-code -title -o servers_details.txt
-l subdomains.txtis the list of names to visit.-p 80,443,8080,3000tells it which ports to try. A port is a numbered door on a server; web traffic normally uses 80 for plain HTTP and 443 for encrypted HTTPS, while 8080 and 3000 are common alternates used by development servers.-status-coderecords the HTTP status code, the three-digit number a server sends back to say how the request went. 200 means fine, 404 means not found, 500 means the server had an internal error.-titlerecords the page title, the text shown in the browser tab.-o servers_details.txtwrites it all to a file.
While analysing cnames.txt, one subdomain stood out because it pointed to two different CNAME records. A manual lookup was run:
dig next.redacted.com CNAME
digasks a DNS server a question.next.redacted.comis the name being asked about, andCNAMEsays which type of record he wants back. Running it by hand lets him see the full answer rather than a summary.
The first CNAME pointed to a webflow.io domain and the second pointed to fastly.net. The researcher explains the chain: with multiple CNAME records, the first redirects to the next and so on until the last record is reached. Think of it as a series of forwarding notes, each one sending you to the next address, until you arrive at the final destination.
In servers_details.txt the corresponding line was:
https://next.redacted.com [500] [246] [Fastly error: unknown domain next.redacted.com]
https://next.redacted.comis the address that was visited.[500]is the status code: the server reported an internal error.[246]is the size of the response in bytes, as recorded by the tool.[Fastly error: unknown domain next.redacted.com]is the page title. Fastly is saying, in effect, that it does not recognise this domain.
The status code was 500 and the page title was Fastly error: unknown domain next.redacted.com. Combined with the CNAME to redacted.fastly.net, this is the classic Fastly takeover fingerprint. A fingerprint here means a recognisable sign: a particular error message plus a particular DNS target that together suggest a specific weakness. The researcher is careful to note that he had seen this fingerprint many times before without it being exploitable: it is only vulnerable when certain conditions are met, so it is an edge case. Most of the time a Fastly service cannot be taken over. The exploitable case is when the domain is not already taken by another customer, in which case it can be claimed and the subdomain taken over completely.
Exploitation
Step 1: Create a Fastly account
The researcher went to fastly.com and created an account. He notes he had an account two years earlier but had deleted it six months before because he believed Fastly was secure, a belief he says was wrong. The reason for creating an account is simple: to test whether a hostname can be claimed, you have to try claiming it yourself, and that requires being a customer.
Step 2: Create a delivery service
Logged in to the Fastly Dashboard, he clicked the "Create a Delivery Service" button. The dashboard is the web control panel where a customer manages their services. A delivery service is the container to which hostnames are attached.
Step 3: Add the target hostname
He entered the target subdomain, next.redacted.com, and clicked Add. He expected an error saying the domain was already taken by another customer. No error appeared; he was redirected to the Hosts page. That absence of an error is the confirmation that the hostname was unclaimed. In other words, the test is not whether an error appears, but whether it fails to appear.
Step 4: Build the PoC content on a VPS
A PoC, or proof of concept, is a minimal demonstration that a weakness is real. It does not need to be harmful; it only needs to show that the researcher controls what is served. On his VPS he created a directory and an HTML file:
mkdir hostingcd hostingnano index.html
mkdir hostingmakes a new folder calledhosting.cd hostingchanges into that folder, so the following commands act inside it.nano index.htmlopens a simple text editor to create a file calledindex.html.index.htmlis the conventional name for the first page a web server hands out when someone visits a folder.
The file contained:
<h1>ValluvarSploit PoC</h1>
<h1>and</h1>are HTML tags marking a top-level heading. The text between them is what the browser displays, in this case the researcher's handle and the words PoC. It is deliberately trivial: the point is to prove control, not to build a real page.
Step 5: Serve it
A simple Python web server was started on port 80 in the current working directory:
python3 -m http.server 80
python3runs the Python interpreter.-m http.servertells Python to run its built-in web server module.80is the port to listen on, the standard port for plain HTTP.
Because he ran it inside the hosting folder, the server offers the files in that folder, including index.html, to anyone who asks. This gives Fastly something to fetch from.
Step 6: Point Fastly at the VPS
Back in the Fastly dashboard, he added the public IP address of his VPS in the Hosts page. This tells Fastly: when a visitor asks for next.redacted.com, fetch the content from this server. The public IP address is the numeric address of his rented server as seen from the internet.
Step 7: Verify
After a few seconds he opened a new browser window and visited http://next.redacted.com/index.html. The PoC file rendered successfully, which proves the subdomain was serving content controlled by him. A detailed report was written and submitted on HackerOne, a platform where bug bounty reports are filed and tracked.
Step 8: Monitor logs
He kept the Fastly service running for three days and monitored server logs for sensitive information. Server logs are the records a server keeps of every request it receives. He describes watching other bug hunters' methodology as fun.
Root cause
The DNS for next.redacted.com still pointed, through a chain of CNAMEs, at a Fastly service (redacted.fastly.net) that no longer had a delivery service configured for that hostname. Fastly answers requests for an unknown hostname with the Fastly error: unknown domain page and a 500 status. Because the hostname was not claimed by any existing customer, the Fastly dashboard accepted it when the researcher added it to a new delivery service. He expected an error saying the domain was already taken by another customer, but none appeared. It does nothing for a dangling hostname, which is exactly the case here. A dangling record is one that points at something that is no longer there, like a signpost to a shop that has closed.
Impact
An attacker who claims the hostname can serve arbitrary content under the victim's subdomain. In this case the researcher demonstrated a static HTML page. An attacker who claims the hostname can serve arbitrary content under the victim's subdomain; the report does not go into specific attack scenarios. Phishing means tricking people with a page that looks legitimate so they hand over information. Cookie scoping refers to the rules that decide which parts of a site a browser will send a stored cookie to; a cookie is a small piece of data a site stores in your browser, often to keep you logged in, and a subdomain under the same parent may be treated as part of the same site. The report does not go into specific attack scenarios beyond the PoC page and the log monitoring. The impact is conditional: it only applies when the hostname is unclaimed at Fastly, which the researcher stresses is the exception rather than the rule.
Fix
Variants to test
- Other CDN and edge providers with the same dangling-hostname pattern. Look for CNAMEs to provider domains where the hostname is no longer configured. A positive result is a provider error page naming the hostname, followed by the provider's dashboard accepting that hostname on a new service without an "already taken" error.
- CNAME chains. The report found the issue because one subdomain had two CNAME records. Enumerating CNAMEs and flagging hosts with more than one record is a cheap way to surface chains that end at a third-party service. A positive result is a chain whose final target is a provider that answers with an unknown-domain error.
- Fingerprint matching at scale. Feed HTTPX output with status codes and titles into a search for provider error strings such as
Fastly error: unknown domain. A positive result is a 500 with the provider's unknown-domain title, which then needs manual confirmation at the provider. - Revisiting old programs. The researcher's own takeaway is to revisit old targets at least once every six months, since DNS records drift and services get decommissioned. A positive result is a hostname that resolved to a live service on the previous visit and now returns a provider error page.
Glossary
- Anew: a small utility that appends new lines to a file while skipping duplicates.
- Brute force: trying many possibilities systematically, such as testing a long list of common subdomain names.
- Bug bounty program: a scheme where organisations invite outside researchers to find security mistakes and pay them for valid reports.
- CDN (Content Delivery Network): a company that serves website content from servers in many locations so pages load quickly.
- CNAME record: a DNS entry saying one name is an alias for another name.
- Cookie: a small piece of data a website stores in your browser, often used to keep you logged in.
- Cookie scoping: the rules deciding which parts of a site a browser sends a given cookie to.
- Dangling record: a DNS record pointing at a service or resource that no longer exists.
- Dashboard: a web control panel for managing an account or service.
- Delivery service: Fastly's term for the configuration that attaches hostnames to a customer's account.
- dig: a command-line tool for asking DNS questions.
- DNS (Domain Name System): the internet's phone book, translating names into numeric addresses.
- Domain name: the address you type into a browser, such as
example.com. - Edge case: an unusual situation rather than the common one.
- Fingerprint: a recognisable sign, such as a particular error message, that suggests a specific weakness.
- Gobuster: a tool that tries a wordlist of names against a target to find which exist.
- Google Dorking: using specially crafted search queries to find pages or names ordinary searches miss.
- Hostname: a name for a machine or service on a network, such as
next.example.com. - HTTP status code: the three-digit number a server returns to say how a request went, such as 200 for success or 500 for a server error.
- HTTPX: a tool that visits a list of names over HTTP or HTTPS and reports details such as status code and title.
- HTTPS: the encrypted version of HTTP, the protocol browsers use to fetch web pages.
- IP address: the numeric address of a machine on a network.
- OWASP Amass: a tool that gathers subdomain names from public sources.
- Passive: gathering information from public sources without touching the target directly.
- Phishing: tricking people with a fake page that looks legitimate so they give away information.
- Pipe (
|): a shell symbol that feeds the output of one command into another. - PoC (proof of concept): a minimal demonstration that a weakness is real.
- Port: a numbered door on a server; 80 is plain HTTP, 443 is HTTPS.
- Private program: a bug bounty scheme you can only join by invitation.
- Public IP address: the address of a machine as seen from the internet.
- Server logs: records a server keeps of the requests it receives.
- Shell script: a text file of commands the computer runs in order.
- Subdomain: a name in front of a domain, such as
shop.example.com. - Subdomain takeover: claiming a subdomain whose DNS points at a third-party service that no longer has it configured, so you control what it serves.
- VPS (Virtual Private Server): a rented computer in a data centre that you control remotely.
- Wordlist: a file of candidate names or words used for guessing.