Skip to content
Subdomain takeover Write-up Intermediate

Subdomain Takeover leading to Full Account Takeover

A subdomain pointed to an unclaimed Azure website, allowing the author to claim it. Because the ASP session cookie was shared across all subdomains, anyone visiting the claimed subdomain had their session cookie logged, enabling account takeover.

hacktus Follow

Published on hacktus.tech

Bounty$3,000 View original

·May 8, 2023·

Hacktus, on hacktus.tech

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

The target was redacted.com, a web application whose main domain and subdomains all shared the same ASP.NET authentication cookie, AspNetCore.Cookies. Because the cookie was issued for the parent domain and sent to every subdomain, the authentication state of a logged-in user was effectively valid across the whole subdomain estate. That design decision is what turned an ordinary subdomain takeover into a full account takeover.

Subdomain Takeover leading to Full Account Takeover
Subdomain Takeover leading to Full Account Takeover From the original on hacktus.tech

The write-up was published on 8 May 2023 by Hacktus.

Setup

The researcher was working against the main domain of redacted.com with a normal logged-in account. No special roles or tooling are described beyond a shell with dig available and a browser session. The precondition that matters is the shared cookie: after logging in on the main domain, the AspNetCore.Cookies value was being sent in requests to all other subdomains of the main domain.

Finding it

While hacking on the main domain, the researcher logged in and noticed that AspNetCore.Cookies was shared in requests everywhere across the other subdomains. That observation reframed the objective: a subdomain takeover alone would not just be a defacement or phishing primitive, it would hand over a valid session cookie for any user who visited the taken-over host. In the author's words, only a subdomain takeover was needed to take over other users' accounts.

A subdomain takeover was then found on test.redacted.com. The host was a CNAME pointing at test-redacted.azurewebsites.net, an Azure Websites endpoint that could be claimed. The researcher used godiego's blog post on subdomain takeover in Azure to claim it.

Exploitation

Step 1: Confirm the dangling CNAME

A DNS lookup on the subdomain returned a CNAME to the Azure Websites host:

Text
root@hacktus:~# dig test.redacted.com

DiG 9.16.1-Ubuntu <<>> test.redacted.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 64344
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;test.redacted.com.     IN      A
;; ANSWER SECTION:
test.redacted.com. 300  IN      CNAME   test-redacted.azurewebsites.net.

The answer section shows the CNAME target, and the query status is NXDOMAIN. The record has a 300 second TTL.

Step 2: Claim the Azure Websites app

Following the Azure subdomain takeover technique from godiego's blog post, the researcher claimed the subdomain. Once claimed, traffic to test.redacted.com reached the researcher's app.

Step 3: Capture session cookies

On the claimed subdomain the researcher checked the logs and found that visitors' cookies were being logged there. Because the browser sends AspNetCore.Cookies to every subdomain, any logged-in user who loaded test.redacted.com/ handed their authentication cookie to the attacker-controlled host. The request the researcher shows for this is:

HTTP
GET / HTTP/1.1
Host: test.redacted.com
Cookie: AspNetCore.Cookies=[redacted]

The Host header is the taken-over subdomain, and the Cookie header carries the shared ASP.NET authentication cookie. With that value in hand, the attacker can present it to the main application and act as the victim.

Root cause

The design flaw is the scope of the authentication cookie. AspNetCore.Cookies was shared across all subdomains of the main domain, so the security of every account depended on the security of every subdomain. A single dangling CNAME to a claimable Azure Websites app was therefore enough to harvest valid sessions. The takeover itself is a classic dangling DNS record: the CNAME still pointed at a platform name that anyone could register. The cookie was scoped broadly across subdomains, and the CNAME still pointed at a claimable Azure Websites name.

Impact

An attacker who claims the subdomain can take over any user's account by getting that user to navigate to the claimed host, then reading the sensitive information available through the shared ASP session. The author frames the consequences as unauthorised access, data theft and other malicious activities. The condition is that the victim visits test.redacted.com/ while holding a valid session; the attacker does not need credentials.

Fix

The report's timeline records the issue as reported on 30 January 2023 at 7:40pm and fixed the same day at 9:52pm. The specific change is not described.

Variants to test

  1. Enumerate subdomains and resolve each one; look for CNAMEs to cloud platforms such as Azure Websites, and treat NXDOMAIN on the target name as a candidate for takeover.
  2. After logging in, inspect which cookies are sent to sibling subdomains. A session cookie scoped to the parent domain means any subdomain compromise becomes account takeover.
  3. Check whether any subdomain, including staging and test hosts, is claimable on its cloud provider, then load it in a logged-in browser and watch the request logs for cookie values.
  4. Review DNS records for hosts that were decommissioned but never removed, since these are the usual source of dangling CNAMEs.

A positive result is a subdomain whose CNAME target can be registered by you, followed by a request to that host carrying a valid session cookie for the main application.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

A security researcher was testing a website (called redacted.com in the write-up) and found a chain of two problems that, combined, let them log in as any user of the site. Neither problem on its own would have been this serious. The first was a subdomain takeover: one of the site's smaller addresses (a subdomain) pointed at a cloud service that nobody was using any more, so anyone could sign up for that cloud service and quietly start answering requests sent to the subdomain. The second was that the site's login cookie was shared across all of its subdomains. A cookie is a small piece of data your browser stores for a website and sends back on every request; here it was the thing that proved you were logged in. Because the cookie was sent to every subdomain, including the hijacked one, every logged-in visitor who opened the hijacked subdomain handed their login cookie to the researcher. With that cookie, the researcher could act as that user on the main site.

Subdomain Takeover leading to Full Account Takeover
Subdomain Takeover leading to Full Account Takeover From the original on hacktus.tech

The write-up was published on 8 May 2023 by Hacktus. The report was filed on 30 January 2023, fixed the same day, rated Critical (9.5), and paid a bounty of 3000 USD.

Background you need first

Before the steps make sense, here are the ideas involved, explained from zero.

  • Domain and subdomain. A domain is a name people type to reach a site, like redacted.com. A subdomain is a name placed in front of it, like test.redacted.com, and it is usually a separate service (a test environment, a blog, a support portal) run by the same organisation. Think of the domain as a building's street address and subdomains as different flats inside it.
  • DNS and CNAME. DNS is the internet's address book: it turns names into the actual servers that answer for them. A CNAME record is a kind of DNS entry that says "this name is really just another name, go look there instead". It is like a mail forwarding note: post sent to the old address is redirected to a new one.
  • Cloud hosting platforms. Services such as Azure Websites let you register a name and get a ready-made web app on the internet. When a company stops using one of these apps but leaves the DNS record pointing at it, the name on the platform becomes free for anyone to register. That is the setup for a subdomain takeover.
  • Subdomain takeover. If a subdomain's DNS record still points at a cloud name that is no longer claimed, an attacker can claim that name on the cloud platform. From then on, requests to the company's subdomain are answered by the attacker's app. The company's name is still in the address bar, but the content comes from the attacker.
  • Cookie. A cookie is a small label your browser keeps for a site and attaches to requests to that site. Login systems use a cookie to remember who you are, so you do not have to type your password on every page.
  • Session and session cookie. A session is the period you stay logged in. The session cookie is the value that proves it. If someone else gets a copy of your session cookie, they can often use it to act as you without knowing your password. It is like a cloakroom ticket: whoever holds the ticket can collect the coat.
  • ASP.NET and AspNetCore.Cookies. ASP.NET is a framework for building web applications. AspNetCore.Cookies is the name of the cookie ASP.NET Core's cookie authentication handler uses to carry the logged-in user's authentication ticket. The name matters here because it is the exact cookie that was shared.
  • Cookie scope. When a site sets a cookie, it decides which names the browser should send it to. A cookie set for redacted.com can be sent to redacted.com and to every subdomain under it. That is convenient for the company, but it means every subdomain must be as trustworthy as the main site.
  • HTTP request and headers. When your browser loads a page, it sends an HTTP request. The request has a first line (the method and path, such as GET /) and then headers, which are labelled lines of extra information. Host says which site name you asked for; Cookie carries the cookies.
  • dig. A command-line tool that asks DNS a question and prints the answer. It is how you look up what a name points to.
  • NXDOMAIN. A DNS answer meaning "this name does not exist". In a takeover hunt it is a useful signal: if the subdomain's CNAME points at a cloud name that returns NXDOMAIN, the cloud name is probably unclaimed.
  • TTL. Time to live, the number of seconds a DNS answer may be cached before it should be looked up again.
  • Bounty. A reward a company pays a researcher for reporting a security problem responsibly.

The setup

The researcher was working against the main domain of redacted.com with a normal logged-in account. Nothing exotic is described: a shell with dig available and a browser session. The important precondition is the shared cookie. After logging in on the main domain, the AspNetCore.Cookies value was being sent in requests to all the other subdomains of the main domain.

Finding it

While testing the main domain, the researcher logged in and noticed that AspNetCore.Cookies was shared in requests everywhere across the other subdomains. That observation changed the goal. A subdomain takeover on its own is usually treated as a nuisance: a fake page under the company's name, useful for phishing. Here it would be much more: it would hand over a valid session cookie for any user who visited the taken-over host. In the author's words, only a subdomain takeover was needed to take over other users' accounts.

A subdomain takeover was then found on test.redacted.com. The host was a CNAME pointing at test-redacted.azurewebsites.net, an Azure Websites endpoint that could be claimed. The researcher used godiego's blog post on subdomain takeover in Azure to claim it.

Exploitation

Step 1: Confirm the dangling CNAME

A DNS lookup on the subdomain returned a CNAME to the Azure Websites host:

Text
root@hacktus:~# dig test.redacted.com

DiG 9.16.1-Ubuntu <<>> test.redacted.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 64344
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;test.redacted.com.     IN      A
;; ANSWER SECTION:
test.redacted.com. 300  IN      CNAME   test-redacted.azurewebsites.net.

Line by line, in plain words:

  1. root@hacktus:~# dig test.redacted.com is the command being run: ask DNS about test.redacted.com. The root@hacktus:~# part is just the shell prompt, showing the user and machine.
  2. DiG 9.16.1-Ubuntu <<>> test.redacted.com repeats the tool name and version and the name being queried.
  3. ;; Got answer: says a reply came back.
  4. status: NXDOMAIN says the name being asked about does not exist.
  5. ;; QUESTION SECTION: shows what was asked: an A record (an address) for test.redacted.com.
  6. ;; ANSWER SECTION: shows the reply: test.redacted.com. 300 IN CNAME test-redacted.azurewebsites.net. In words, "for 300 seconds, this name is an alias for test-redacted.azurewebsites.net". The 300 is the TTL, the number of seconds the answer may be cached.

Why this step: before claiming anything, you confirm the subdomain really does point at a cloud name, and that the cloud name looks unclaimed. Without that, there is nothing to take over.

Step 2: Claim the Azure Websites app

Following the Azure subdomain takeover technique from godiego's blog post, the researcher claimed the subdomain. Once claimed, traffic to test.redacted.com reached the researcher's app.

Why this step: the DNS record is the forwarding note, and the cloud app is the new address. Registering the cloud app means the forwarding note now leads to a place the researcher controls. Visitors still type the company's subdomain, but the page they get is the researcher's.

Step 3: Capture session cookies

On the claimed subdomain the researcher checked the logs and found that visitors' cookies were being logged there. Because the browser sends AspNetCore.Cookies to every subdomain, any logged-in user who loaded test.redacted.com/ handed their authentication cookie to the attacker-controlled host. The request the researcher shows for this is:

HTTP
GET / HTTP/1.1
Host: test.redacted.com
Cookie: AspNetCore.Cookies=[redacted]

Line by line:

  1. GET / HTTP/1.1 is the request line: GET means "give me a page", / means the front page, and HTTP/1.1 is the version of the protocol.
  2. Host: test.redacted.com says which site name the browser asked for. This is the taken-over subdomain.
  3. Cookie: AspNetCore.Cookies=[redacted] carries the shared ASP.NET authentication cookie. In the write-up this value is a long string; it has been replaced here with [redacted] because it is a live secret.

Why this matters: the browser attaches the cookie automatically, without asking the user. The user does nothing wrong; simply opening the subdomain is enough. With that value in hand, the attacker can present it to the main application and act as the victim.

Root cause

The design flaw is the scope of the authentication cookie. AspNetCore.Cookies was shared across all subdomains of the main domain, so the security of every account depended on the security of every subdomain. A single dangling CNAME to a claimable Azure Websites app was therefore enough to harvest valid sessions. The takeover itself is a classic dangling DNS record: the CNAME still pointed at a platform name that anyone could register. The cookie was scoped broadly across subdomains, and the CNAME still pointed at a claimable Azure Websites name.

Impact

An attacker who claims the subdomain can take over any user's account by getting that user to navigate to the claimed host, then reading the sensitive information available through the shared ASP session. The author frames the consequences as unauthorised access, data theft and other malicious activities. The condition is that the victim visits test.redacted.com/ while holding a valid session; the attacker does not need credentials.

Fix

The report's timeline records the issue as reported on 30 January 2023 at 7:40pm and fixed the same day at 9:52pm. The specific change is not described.

Variants to test

If you want to look for the same pattern on a site you are allowed to test, these checks follow from the write-up:

  1. Enumerate subdomains and resolve each one; look for CNAMEs to cloud platforms such as Azure Websites, and treat NXDOMAIN on the target name as a candidate for takeover.
  2. After logging in, inspect which cookies are sent to sibling subdomains. A session cookie scoped to the parent domain means any subdomain compromise becomes account takeover.
  3. Check whether any subdomain, including staging and test hosts, is claimable on its cloud provider, then load it in a logged-in browser and watch the request logs for cookie values.
  4. Review DNS records for hosts that were decommissioned but never removed, since these are the usual source of dangling CNAMEs.

A positive result is a subdomain whose CNAME target can be registered by you, followed by a request to that host carrying a valid session cookie for the main application.

Glossary

  • ASP.NET: a framework for building web applications, made by Microsoft.
  • AspNetCore.Cookies: the default cookie name ASP.NET uses to store a logged-in user's session.
  • Authentication: proving who you are, usually by logging in.
  • Browser: the program you use to visit websites, such as Chrome or Firefox.
  • Cloud hosting platform: a service that runs websites for you on its own servers, such as Azure Websites.
  • CNAME record: a DNS entry saying one name is an alias for another name.
  • Cookie: a small piece of data a browser stores for a site and sends back on requests to that site.
  • Critical (9.5): a severity rating on a 0 to 10 scale, where 9.5 is very severe.
  • dig: a command-line tool that looks up DNS records.
  • DNS: the internet's address book, turning names into the servers that answer for them.
  • Domain: a name people type to reach a site, such as redacted.com.
  • Dangling DNS record: a DNS record that still points at a cloud name nobody has claimed.
  • Header: a labelled line of extra information in an HTTP request or response, such as Host or Cookie.
  • HTTP: the protocol browsers and servers use to exchange web pages and requests.
  • NXDOMAIN: a DNS answer meaning the name asked about does not exist.
  • Request: the message a browser sends to a server asking for a page or other resource.
  • Session: the period during which you stay logged in to a site.
  • Session cookie: the cookie value that proves you are logged in; whoever holds it can often act as you.
  • Subdomain: a name placed in front of a domain, such as test.redacted.com.
  • Subdomain takeover: claiming a cloud name that a company's subdomain still points at, so the attacker's app answers for the company's subdomain.
  • TTL (time to live): how many seconds a DNS answer may be cached before it should be looked up again.
  • Unauthorised access: getting into an account or data without permission.

More by hacktus

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Subdomain takeover

The lesson behind this report.

A company's DNS still points at a cloud service it no longer uses, so anyone can claim it and serve content on the company's domain.