Skip to content
XSS Write-up Intermediate

Day 10:Turned Cookie-Based XSS into Account Takeover

A cookie named customer_name was reflected into the page without sanitisation, allowing script execution when combined with a step cookie. By hosting a malicious page on the provider's own S3-style bucket subdomain, an attacker could set cookies for the parent domain and redirect victims, eventually capturing login credentials and achieving account takeover.

medium.com

Published on medium.com

One evening, he began hunting on the Terrahost Bug Bounty program, testing the terrahost.no main domain. He could choose a service, register an account, and place an order.

dani3l, on medium.com

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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application stored unsanitised user input in a cookie and later rendered it into the page without encoding, and it also trusted a client-controlled step cookie to decide which view to show.

Impact

An attacker could capture login credentials and, because the same credentials were used for the management panel, achieve full account takeover; the report notes that stealing existing cookies was blocked because legitimate cookies took priority.

What the attacker needed

Victim clicks a link; attacker can host a page on a subdomain; victim logs in on the page

How it was found

  1. Register an account and notice that entered details are displayed and stored in cookies.
  2. Clear cookies and set the customer_name cookie to a script payload, then also set the step cookie to reach the data view.
  3. Create a bucket on the provider's S3-style storage to get a subdomain under the target domain.
  4. Upload a page that sets the customer_name and step cookies for the parent domain and redirects to the order page.
  5. Send the bucket URL to a victim; the script runs on the main site.
  6. Modify the payload to reveal the hidden login form and send entered credentials to an external server.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Cookies are small pieces of data a website stores in your browser. This site put user-supplied text into a cookie and later displayed it on the page without cleaning it, so a script hidden in that text would run. Because the attacker could host a page on a subdomain of the same site, they could set that cookie for the main site and trick a logged-in user into running the script.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.