Referer XSS – Introduction
The error page reflected the Referer header into an anchor href without encoding, allowing script injection and link injection. An attacker could execute JavaScript in the victim's browser or redirect them to a malicious site, but only in older Internet Explorer versions.
doyler.net
Published on doyler.net
I wanted to share an example of referer XSS, as I’ve never been able to play with it before.
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 echoed the HTTP Referer header into an HTML attribute without encoding or validation.
Impact
An attacker could execute arbitrary JavaScript in the victim's browser or redirect them to a malicious site, but the exploit only worked against older versions of Internet Explorer.
What the attacker needed
Victim uses older Internet Explorer; victim visits attacker-controlled page; attacker can set Referer header
How it was found
- Create an attack page that links to the search page with a query containing a single quote.
- The search page redirects to the error page, which reflects the Referer header.
- Intercept the request and modify the Referer header to include a script payload.
- The error page renders the payload and the script executes.
- For automatic exploitation, use a page that redirects to the vulnerable site with a crafted URL.
- In older Internet Explorer, the payload is not URL-encoded and the exploit succeeds.
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 the browser sends to tell a website which page you came from. The error page put that information directly into a link without cleaning it, so an attacker who controls the previous page could make the link contain a script. When the victim visited the error page, the script ran in their browser.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.