Skip to content
XSS Write-up Intermediate

Transforming Self XSS to Exploitable XSS — Part 1

A login popup endpoint reflected the source_url parameter without encoding, but the application only allowed requests whose Referer header contained the target domain, making it a self-XSS at first. The researcher bypassed the Referer check by hosting a page on a domain whose path contained the target domain and setting a Referrer-Policy header that sends the full URL, turning it into an exploitable reflected XSS.

Preetham Bomma Follow

Published on infosecwriteups.com

I was testing an e-commerce application and noticed an endpoint reflecting the value of the parameter unencoded in the response.

Preetham Bomma, on infosecwriteups.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 endpoint reflected user input without encoding and relied on a weak substring check of the Referer header for protection.

Impact

An attacker could execute arbitrary JavaScript in a victim's browser when the victim clicks a crafted link, potentially leading to actions such as session theft or account compromise.

What the attacker needed

Victim clicks a crafted link; attacker controls a web server

The fix

The XSS should be fixed by encoding output, and the Referer check should be strengthened with a strict regular expression.

How it was found

  1. Host a malicious page on a server whose URL path contains the target domain string.
  2. Configure the server to send a Referrer-Policy header that includes the full URL in the Referer header.
  3. Place a link to the vulnerable endpoint with a crafted source_url parameter on the malicious page.
  4. Send the link to a victim; when clicked, the browser sends the full URL as the Referer, satisfying the check.
  5. The vulnerable endpoint reflects the payload unencoded, executing the script.

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.

Cross-site scripting (XSS) lets an attacker run their own JavaScript in a victim's browser on a website. A self-XSS only affects the person who types the code themselves, so it is usually not useful. Here the site tried to block other websites from linking to the vulnerable page by checking the Referer header, which tells the site where a visitor came from. The researcher found a way to make that header look acceptable, so a crafted link could run code in any visitor'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.

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.