Skip to content
XSS Write-up Beginner

Stored XSS with arbitrary cookie installation

A URL parameter's value was stored in a cookie without sanitisation, and the application later inserted that cookie value into a script tag on every page. An attacker could send a crafted link to store a script payload in the victim's cookie, which would then execute on any page of the site.

Arbaz Hussain Follow

Published on medium.com

{{media:0}}

Arbaz Hussain, 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

The application trusted user input from a URL parameter and stored it in a cookie without sanitisation, then inserted the cookie value into a script tag without encoding.

What the attacker needed

Victim clicks a crafted link; victim visits any page on the site

The fix

The application should sanitise or encode the refclickid value before storing it in a cookie and before inserting it into a script tag.

How it was found

  1. Attacker sends the victim a URL with a script payload in the refclickid parameter.
  2. The server stores the payload in the Referral cookie.
  3. When the victim visits any page on the site, the cookie value is placed inside a script tag and the payload executes.

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.

A cookie is a small piece of data a website stores in your browser. Here, the site took a value from the web address and saved it in a cookie without cleaning it, then later put that cookie value directly into a script on every page. That let an attacker run their own code in the victim's browser.

What is XSS?

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

More by Arbaz Hussain

View all

14 more disclosed reports, best first.

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.