The Session That Never Dies: Session Fixation & Hijacking on a Re
The application kept the same session identifier across logins, logouts, password changes, email changes and 2FA, and it accepted a client-supplied session value as a valid session. An attacker who could plant or guess a session identifier could therefore keep reusing it to hijack the victim's session and pull a JWT from an API endpoint.
Published on medium.com
“While recon session on a self-hosted web application , I normally start with mapping authentication flow to identify if app works with cookie session , jwt or other mechanism.
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 server never regenerated the session identifier on login or on sensitive actions, and it trusted a client-supplied session value instead of only issuing its own.
Impact
An attacker who fixates or obtains the session could hijack the victim's session, regain it after every login, and use it to reach API functions that return a valid JWT; the text notes the victim cannot kick the attacker out.
What the attacker needed
Attacker can plant or know the session id; victim logs in with that session id
The fix
The server should issue a fresh session identifier on login and after sensitive actions such as logout, password or email change and 2FA changes, and should never accept a client-chosen session value.
How it was found
- Map the authentication flow and note the session cookie used by the app.
- Log in and out repeatedly and compare the session cookie across requests.
- Enable 2FA, log out, log in and complete 2FA, then check whether the cookie changed.
- Change the password and email, then check whether the cookie changed.
- Observe the API endpoint that returns a JWT and refresh token using the session cookie.
- Set a custom session value of the same length and log in as a normal user to see it accepted.
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 identifier is a short code a website gives your browser after you log in so it can recognise you on later requests. Normally the site should throw that code away at logout or after sensitive changes and issue a fresh one. Here the site kept the same code forever and even let the tester choose their own code, so anyone who knew or planted that code could act as the victim.
What is Account takeover?
Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.