Forcing Firefox to Execute XSS Payloads during 302 Redirects
An open redirect parameter allowed injection of newlines into the Location header, enabling reflected XSS in the response body. Browsers normally do not execute scripts in a 302 response, but the author found that using a WebSocket URI scheme in the Location header made Firefox execute the payload.
During a recent engagement I identified an open redirect where a GET parameter would be reflected as-is in the HTTP response Location header without any kind of sanitization. Something similar to this:
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 reflected user input into the Location header without sanitising newline characters, allowing header injection and response body injection.
Impact
An attacker could execute JavaScript in the context of the vulnerable domain via a crafted redirect link.
What the attacker needed
Victim uses Firefox; victim clicks a crafted link
How it was found
- Identify an open redirect where a GET parameter is reflected in the Location header.
- Inject newline and carriage return characters to perform header injection.
- Inject newline characters to perform header injection and reflected XSS.
- Use a WebSocket URI scheme (ws:// or wss://) in the Location header to make Firefox execute the injected 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.
A website took a URL parameter and put it directly into a redirect response header without cleaning it. By adding special newline characters, an attacker could make the server send extra content, including a script, in the response body. Normally browsers ignore that body on a redirect, but the author found a trick to make Firefox run the script anyway.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.