Skip to content
XSS Write-up Beginner

When the Referer Becomes the Villain: RXSS + Redirection

The Referer header was reflected without validation into a hidden input field, allowing an attacker to inject a script that executes in the victim's browser. This could lead to cookie theft and redirection to a malicious site.

medium.com

Published on medium.com

Referer header that no one cared about turned into a path for both XSS and open redirect.

Aryan Shrestha, 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

Impact

An attacker could execute arbitrary JavaScript in the context of the vulnerable site, leading to session hijacking, user redirection, and phishing attacks.

What the attacker needed

Victim visits a crafted link or page; attacker can control Referer header

The fix

The application should sanitise and escape all input, including headers, before reflecting it in HTML, and implement other mitigations such as HttpOnly cookies and CSP.

How it was found

  1. Send a request with a Referer header containing a simple script payload.
  2. Observe that the payload is reflected into a hidden input field and the script executes.
  3. Craft a more advanced payload that exfiltrates cookies and redirects to an attacker-controlled site.
  4. Send the request and observe the script execution, cookie theft, and redirection.

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.

The Referer header is a piece of information your browser sends to a website to tell it where you came from. This website took that information and put it directly into its own page without checking it. An attacker could make your browser send a malicious Referer header, causing harmful code to run on the website and steal your data.

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.