Case Study: Cookie Based XSS to Reflected XSS
The login page stored the redirect URL parameter in a cookie and later wrote that cookie value into an inline script without sanitisation, so a crafted redirect value could break out of the string and run script. By first setting the cookie through the redirect parameter and then loading the login page without that parameter, the attacker could turn a cookie-based XSS into a reflected XSS that fires in the victim's browser.
In the following post, a Cookie Based Cross-Site-Scripting vulnerability was converted into a Reflected Cross-Site-Scripting vulnerability. A cookie-based XSS is generally considered Out Of Scope because an attacker has to physically insert the malicious cookie, which is very less likely.
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 application wrote the redirectTo cookie value directly into an inline script string without escaping or validation, allowing a quote to break out of the string.
Impact
An attacker could execute arbitrary JavaScript in a victim's browser, but the exploit required two sequential requests and the report notes the bug was still in triage.
What the attacker needed
Victim visits attacker-controlled page; login page accessible
How it was found
- Send a request to the login page with a redirect parameter containing a script payload.
- Observe that the redirect parameter value is stored in the redirectTo cookie.
- Send a second request to the login page without the redirect parameter so the page uses the cookie value.
- The payload in the cookie executes as script in the browser.
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 copied a value from the URL into a cookie, then put that cookie value into a script on the page without cleaning it. An attacker could make the page run their own JavaScript, which is called cross-site scripting (XSS).
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.