Session fixation is the attack where the attacker chooses the session identifier before the victim logs in, so the session the victim ends up using is one the attacker already knows. This sub-skill lives under auth-sso-integration-review because SSO makes fixation a multi party problem: an identifier can be planted at the IdP, at the SP, or in the handoff between them, and rotation must happen at every party. It is a deep dive, not a repeat of session-management-security: that skill covers session handling in general, while this one tests fixation specifically, step by step, including the SSO and recovery variants. Test only with test accounts, and plant identifiers only in your own browser sessions.
Quick Workflow
- Map every session identifier: SP cookie, IdP cookie, SSO state tokens, remember me tokens, and API tokens issued at login.
- Get an anonymous identifier: visit the app without logging in and record what session values it sets.
- Plant and log in: log in while presenting the planted value, and check whether the authenticated session keeps it.
- Test rotation at every transition: login, privilege change, password change, MFA enrolment, and SSO re-authentication.
- Test fixation through SSO: plant at the IdP, at the SP, and in the callback handoff, one at a time.
- Test fixation through recovery: a planted identifier must not survive a password reset.
- Test fixation through subdomains: a cookie planted from a less trusted subdomain must not be accepted by the main app.
- Prove exploitation end to end on a test account: plant, victim login simulated by your second test session, then use the planted identifier to reach the account.
1. The core fixation test
This is the test everything else varies. Run it first, exactly as written, before testing the exotic variants.
# Step 1: get an anonymous session identifier from the app.
curl -s -i -c /tmp/fix-anon.txt 'https://target.example/' | grep -i '^set-cookie:' | head -5
cat /tmp/fix-anon.txt
# Step 2: log in WITH the anonymous identifier presented, using a
# test account. Use the cookie jar from step 1 so the planted value
# is the one sent at login.
curl -s -i -b /tmp/fix-anon.txt -c /tmp/fix-authed.txt -X POST 'https://target.example/login' \
-d 'user=fixation-test@example.com&pass=TestPass123!' | grep -i '^set-cookie:' | head -5
echo "Compare the two jars:"
echo "Anonymous jar:"; cat /tmp/fix-anon.txt
echo "Authenticated jar:"; cat /tmp/fix-authed.txt
# Finding: the authenticated session identifier equals the planted
# anonymous identifier. Fix: the server must issue a fresh,
# unpredictable identifier at login and invalidate the old one.
# Step 3: prove the planted identifier is usable. With the value
# from the anonymous jar, request an authenticated page, as the
# attacker would after the victim logs in.
curl -s 'https://target.example/api/me' -H 'Cookie: session=PLANTEDVALUE' | head -c 300
echo
echo "A 200 here with the planted value after login is exploitation"
If the app sets no session cookie before login, fixation through a cookie is not possible that way, but do not stop: test URL based session identifiers, custom headers, and tokens set by the SSO callback next, because the identifier can arrive by other means.
2. Fixation through SSO
SSO adds identifiers at both ends. Plant at each end separately.
# SSO fixation probes, one login each, on test accounts:
# 1. SP side: plant an SP session identifier, then complete an SSO
# login in the same browser session. Does the SP keep the planted
# identifier for the authenticated session?
# 2. IdP side: plant an IdP session identifier, then log in at the
# IdP as a test account. Does the IdP session keep the planted
# identifier, and does the SP then trust it?
# 3. Callback handoff: capture the SSO callback request and check
# whether the SP session identifier in the callback response is
# fresh, or whether it matches the pre login identifier.
# 4. RelayState and state: can a state value be fixed before login
# and then honoured after login, carrying attacker chosen data
# into the authenticated session?
curl -s -i -b /tmp/fix-anon.txt -c /tmp/fix-sso.txt \
'https://target.example/login/sso' | grep -i -E '^(set-cookie|location):' | head -10
Also test silent re-authentication: when the IdP session already exists, the SP may log the user in with no interaction. If that silent login reuses a planted SP identifier, the fixation window extends to every return visit, not just the first login.
3. Fixation through password reset and privilege change
Rotation must happen at every privilege transition, not just at login. Test each transition with a planted identifier.
# Reset survival test on test accounts:
# 1. Log in as test account A and record the session identifier.
# 2. Trigger a password reset for test account A and complete it.
# 3. Replay the pre reset session identifier: it must be rejected.
# 4. Repeat for MFA enrolment change, email change, and role change
# where the app offers them: each must rotate or revoke.
curl -s 'https://target.example/api/me' -H 'Cookie: session=PRE-RESET-SESSION' | head -c 300
echo
echo "200 after reset means the old session survived the reset"
# Privilege change test:
# 1. Log in as a low privilege test account and record the session.
# 2. Step up authentication or switch to an admin role in the same
# session, where the app offers that.
# 3. Check whether the session identifier changed at the step up.
# A high privilege session reusing a low privilege identifier is
# a fixation window for privilege escalation.
# 4. Check logout and login again: a fresh login must never reuse
# an identifier from a previous login, even for the same account.
curl -s -i -X POST 'https://target.example/admin/step-up' \
-H 'Cookie: session=LOWPRIVSESSION' | grep -i '^set-cookie:' | head -5
4. Subdomain and URL based planting
An attacker who controls, or can inject content into, a subdomain can plant cookies for the parent domain. Test whether the main app accepts them.
# Subdomain planting probes:
# 1. Set a cookie with Domain=.target.example from a less trusted
# subdomain in scope, then log in on the main app and check
# whether the main app adopts that cookie value as its session.
# 2. Check cookie scope on the main app: does it set its session
# cookie with a Domain attribute that makes it visible to
# subdomains, and does it use the __Host- prefix, which forbids
# a Domain attribute and requires Secure?
# 3. Test URL session identifiers: if the app accepts a session ID
# in the URL, a link can plant it. Log in through a URL carrying
# a chosen identifier and check whether it survives login.
curl -s -i 'https://target.example/login;jsessionid=PLANTEDVALUE' | grep -i '^set-cookie:' | head -5
curl -s -i 'https://target.example/?sessionid=PLANTEDVALUE' | grep -i '^set-cookie:' | head -5
echo "Adoption of a URL supplied identifier after login is fixation"
Also test cookie tossing defences: if the app reads the first cookie with a given name and an attacker can inject a second cookie with the same name from a subdomain, the app may read the attacker's value instead of its own. Test by sending two cookies with the same name and different values, and record which one the app honours.
5. Token fixation beyond cookies
Modern apps have identifiers beyond the session cookie. Test each one for the same flaw.
# Token fixation probes:
# 1. Remember me: plant a remember me token value before login, if
# the app accepts a caller supplied value, and check whether it
# becomes a valid long lived token after login.
# 2. API tokens: if the app issues API tokens at login, check
# whether a pre login token request can fix the token value.
# 3. OAuth codes: a code fixed before login that is honoured after
# login can bind an attacker client to the victim account.
# 4. CSRF tokens: a CSRF token that does not rotate at login is a
# weaker variant of the same flaw, worth reporting alongside
# session fixation when both are present.
# 5. Device trust: a device identifier planted before login that
# becomes trusted after login skips future MFA challenges.
curl -s -i -X POST 'https://target.example/login' \
-H 'Cookie: rememberme=PLANTEDVALUE' \
-d 'user=fixation-test@example.com&pass=TestPass123!' | grep -i '^set-cookie:' | head -5
Edge cases
- Anonymous sessions with no identifier: some apps set no cookie until login, which closes the classic cookie vector but leaves SSO state, callback, and URL vectors open. Test those before declaring fixation absent.
- Session identifier in local storage: single page apps that store tokens in local storage can be fixated by script injection or by a subdomain page writing the same storage key. Test storage key scope alongside cookie scope.
- Load balancer stickiness cookies: a stickiness cookie is not a session identifier, but confusing the two in a report weakens it. Verify that the planted value is the authenticated session, not a routing cookie, before reporting.
- Concurrent sessions: when several sessions are valid at once, rotation must invalidate the planted one, not just issue a new one alongside it. Check that the old identifier is dead, not merely unused.
- Fixation after logout: logging out must invalidate the session server side. A logout that only clears the browser cookie leaves the identifier reusable, which is fixation in reverse.
- Mobile and native apps: tokens stored in app storage follow the same rule. A token planted through a deep link or a custom scheme that survives login is a mobile fixation finding.
- Shared machines: fixation matters most where the attacker can touch the victim browser first. Note the attack prerequisites honestly in the report, and grade severity by them.
Key references
- OWASP Session Management Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html
- OWASP Testing Guide, Testing for Session Fixation: https://owasp.org/www-project-web-security-testing-guide/
- OWASP Authentication Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html
- CWE-384, Session Fixation: https://cwe.mitre.org/data/definitions/384.html
- PortSwigger Web Security Academy, Session fixation: https://portswigger.net/web-security/authentication
