Field note · Session & token handling
Logging out is supposed to end your session. Surprisingly often, it only ends it in your browser — while the token you were handed stays valid on the server, ready for anyone who kept a copy. The session failures I keep finding, and the server-side patterns that actually close a session.
By Martin Mwathi, Orvantis Security · Published 21 October 2026 · Original research · 5 min read
A session is a promise: this request is coming from someone who proved who they are, recently enough to trust. Every part of that promise can quietly break — the token can live forever, it can keep working after you log out, it can be impossible to revoke when you need to. And unlike a flashy exploit, a broken session leaves no trace: the attacker’s requests look exactly like yours, because as far as the server is concerned, they are yours.
“Log out” often deletes the token from your browser and never tells the server a thing.
Stateless tokens — JWTs especially — are valid because they’re signed, not because the server is keeping a list. So the usual logout just discards the client’s copy. If anyone captured that token earlier — from a log, a shared machine, a proxy, a backup — it keeps working until it expires on its own, which brings us to the second problem: it may never expire.
An access token with no expiry, or one measured in months, means a single leak is permanent. The window an attacker gets isn’t “until you notice” — it’s “until the heat death of the token.” Short lifetimes are not an inconvenience to design around; they are the containment.
When a device is lost, an employee leaves, or a token leaks, you need a button that says this session is over, now. Purely stateless designs often don’t have one: the token is valid until it expires and nothing can stop it in between. “Change your password” frequently doesn’t invalidate already-issued tokens either.
The archetype above. If logging out doesn’t revoke the session server-side, it’s a cosmetic gesture — it reassures the user while leaving the real credential live.
A session token in a URL ends up in browser history, server logs, proxy logs, and the Referer header sent to every third party on the page. Tokens belong in headers or secure, HttpOnly cookies — never in a query string.
Session ids that are predictable can be guessed. Sessions that aren’t rotated after login invite fixation — an attacker sets the id beforehand and inherits the session once the victim authenticates. The id must be random, and must change at the moment privilege does.
If roles and permissions are carried inside a token that lives for hours, revoking access or demoting a user doesn’t take effect until it expires. The token keeps asserting a truth that is no longer true.
Teams often file these as low — “you’d need the token first.” But tokens leak constantly, through exactly the mundane channels above, and a session flaw turns a brief leak into durable, invisible access. There’s no payload, no anomaly, no broken thing in the logs — just the attacker being you, for as long as the token lives. That combination — high impact, zero noise — is why I treat session lifetime and revocation as core findings, not hygiene notes.
Only against systems I’m authorised to test, with accounts I control. I capture a token, log out, and try it again — does the server still accept it? I let tokens sit to see if they ever expire. I change the password and re-use the old token. I look for tokens in URLs, logs and redirects; I test whether the session id rotates on login and on privilege change; I check whether a “revoke all sessions” action genuinely revokes. Every result is reproduced and independently re-verified before it’s written down.
The durable fix is to stop treating a signed token as self-sufficient proof and give the server the final say. The common, robust shape: a short-lived access token paired with a revocable, rotating refresh token, and a server-side record the logout and revocation paths actually clear.
// Access tokens are SHORT (minutes), so a leak self-heals fast.
accessToken := issue(user, 10*time.Minute)
// Refresh tokens are server-side records — so they can be revoked.
func Logout(w http.ResponseWriter, r *http.Request) {
sessions.Revoke(currentSession(r).ID) // the server forgets you
clearCookie(w) // and so does the browser
}
// Every refresh checks the record still exists and is still valid.
func Refresh(sid string) (Token, error) {
s, ok := sessions.Get(sid)
if !ok || s.Revoked || s.Expired() {
return Token{}, ErrUnauthorized // logout / reset / lost device
}
sessions.Rotate(s) // new id each time — kills fixation & replay
return issue(s.User, 10*time.Minute), nil
}
Three moves cover most of the field: keep access tokens short, make sessions revocable and actually revoke them on logout and password change, and rotate the identifier whenever identity or privilege changes. Do that, and “log out” means what the user thought it meant.
Every finding is reproduced — at least twice, and independently re-verified — before it’s written down; what can’t be demonstrated is recorded as a negative, not carried as a vulnerability to pad a count. All live testing happens only against systems I’m authorised to test, on accounts I create for the purpose, with no bulk data harvesting and no destructive operations.
Related reading: the authentication failures behind the same APIs, broken object-level authorization, and the plain-English glossary.
Same rigor, your target. Independent, evidence-based, and never softened.