I have implemented stateless session cookie, something along the lines of this article:

Demystifying Web Authentication (Stateless Session Cookies)

The cookie contain an expiry time within the hashed value, and also the cookie is set with a session timeout in the browser. When the user logs out, the cookie is deleted. However, someone noted that an attacker can steal the cookie and essentially use it within the specified expiry time in the cookie even though the user has logged out. Is there a solution to this problem (beside ditching stateless session cookie and using standard server/framework session management)?

  • 4
    While it seems to be a new fad to create stateless sessions, "stateless session" is an oxymoron. If you have a session, by definition, you have state of that session. If you are stateless, you cannot maintain a session because you have nowhere to maintain the state of that session.
    – atk
    Commented Oct 27, 2014 at 20:21

2 Answers 2


The whole point of having a "stateless" thing is to avoid maintaining state (here, on the server side). Stateless servers are unavoidably subject to replay attacks, by definition. The problem you are envisioning is basically a replay attack.

If attackers can steal clients' cookies, then you already have bigger issues. If they cannot, then there is no problem. Use SSL.

(SSL is not the ultimate solution for everything, but it helps avoiding cookie-stealing, at least as long as the cookie is marked as secure and HTTP only.)


No, there really isn't. In order for this work, you need to have some form of session management in place to determine whether the token in a cookie is valid or not. They may mean maintaining a list of valid sessions as in traditional session management, or explicitly blacklisting tokens that have expired for some period of time. (Less overhead on the application, but significantly harder to do correctly.)

Ultimately, this is a generally low risk threat, an in my opinion, generally not worth mitigating. It's completely counter to the request-response model of the web, and you can protect against token theft adequately well by simply using TLS and HTTPS.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .