Skip to content
XSS Write-up Advanced

Exploiting Session Fixation via Stored XSS and Cookie Jar Overflo

A session fixation flaw in a PHP application allowed an attacker to set a victim's session ID before login. Chained with stored XSS and a cookie jar overflow, the attacker could evict the HttpOnly PHPSESSID cookie and replace it with their own, hijacking the victim's session after re-login.

Akash c Follow

Published on akashc99.medium.com

As a Pentester, I know that sometimes finding a vulnerability isn’t enough you also need to demonstrate the real impact to get it taken seriously. During Bug hunt, I came across a session fixation vulnerability in a PHP web application.

Akash c, on akashc99.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

Root cause

Likely the application did not generate a new session ID after login, and the XSS allowed script execution to overflow the cookie jar and replace the HttpOnly session cookie.

Impact

An attacker could hijack a victim's session and take control of their account, including generating a private API key, without needing the victim's password.

What the attacker needed

Stored XSS vulnerability; victim visits malicious page; victim logs in again

The fix

The developers patched both the XSS and session fixation vulnerabilities.

How it was found

  1. The attacker injects a stored XSS payload that runs JavaScript in the victim's browser.
  2. The JavaScript creates many cookies to fill the browser's cookie jar.
  3. The overflow evicts the legitimate PHPSESSID cookie.
  4. The script sets a new PHPSESSID cookie with the attacker's session ID.
  5. The victim logs in again, authenticating with the attacker's session ID.
  6. The attacker uses the known session ID to access the victim's account.

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 session ID is like a temporary ticket a website gives you after you log in, so it knows who you are. Session fixation means an attacker can give you their own ticket before you log in, so when you do, the website thinks you are the attacker. The attacker also used a trick to force the browser to forget your real ticket and accept theirs, even though the ticket was supposed to be protected from scripts.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Akash c

View all

2 more disclosed reports, best first.

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.