Session Not Invalidated on Logout
Logging out does not end the session on the server, so a session token captured earlier keeps working after the user has logged out.
| Severity | Low |
| CVSS 3.1 | 3.7 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N Open in the calculator |
| CVSS 4.0 | 6.3 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-613: Insufficient Session Expiration |
| OWASP Top 10 | A07:2025 Authentication Failures |
| MITRE ATT&CK | T1550.004 Web Session Cookie |
| Category | Broken Access Control |
Description
When a user logs out, the application clears or replaces the session cookie in the browser but does not invalidate the session on the server. The old session identifier or token therefore stays valid until it expires naturally. The same pattern is common with stateless tokens such as JSON Web Tokens, where logging out only deletes the token from browser storage and the server has no way to reject it before its expiry time.
Any copy of the token can still be used to access the account: one obtained by other means, for example from a shared or public computer, browser history, proxy or server logs, or through script injection, remains usable after the user has logged out believing their session is closed, and the attacker can continue to use it until it expires. The weakness does not expose tokens itself; it extends the window in which a token captured through another weakness or through physical access remains useful, so its impact depends heavily on how long sessions last.
The finding is confirmed by capturing an authenticated request, logging out through the application, and replaying the request with the original session cookie or token; if authenticated content is still returned, the session was not invalidated. Related variants include sessions that survive a password change or the disabling of the account, refresh tokens that remain usable after logout, and single sign-on logouts that end the identity provider's session but leave the application's own session active, or the reverse.
Remediation
- Invalidate the session on the server when the user logs out, for example with
HttpSession.invalidate()in Java,session_destroy()in PHP or the framework's equivalent, so that the old identifier is rejected on any later request. - Clear the session cookie in the logout response by setting an empty value with an expiry date in the past, and consider sending
Clear-Site-Data: "cache", "cookies", "storage"to remove other data held by the browser. - For token-based authentication, keep access tokens short-lived and revoke the refresh token at logout; where immediate revocation is needed, check tokens against a server-side denylist or use opaque tokens that can be deleted.
- End all of a user's sessions when their password is changed or reset or their account is disabled, and give users a way to log out of their other sessions.
- Where single sign-on is used, implement the logout protocol of the identity provider so that logging out ends both the application and identity provider sessions as intended.
Confirm the fix by replaying a request with a session token captured before logout and confirming that it is rejected.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.