Quote:
|
Originally Posted by Tyhm
My only concern is the poor buggers on dialup who connect, sign in, then their IP changes when they have to reconnect so they have to sign in again...
|
If the issue is a hash that is stolen by say, following a link, perhaps the best way is a rotating hash. When I have written user control systems, I usually check the username/password at log in, assign a randomized token (not really a hash as I generally used random char generators not tied to the password) and stored a copy both on the server and on the client as a cookie.
As the user views each page, the server compares the cookie token to the user's db token, and if they match, assign a new randomized token to both the database and the broswer.
If you follow an evil link and have the token stolen, it is invalid the very next link you click in the forums. If a person steals your hash and uses it before you view another forum page, you'll be forced to relogin (and it could easily tell you its for an invalid security token, alerting you that someone may be trying to hijack your session). Once you go to login again, it is not comparing the tokens at all - just username and password, and generating a fresh token - thus invalidating the hijacker's session immediately.
The down side is that if you are on a page that crashes before it tries to produce the HTML headers and after the new token is generated and stored in the database, the new cookie is never set, the database and client are out of sync, and you are forced to log in again.
I guess if you really got into it, you could store 'prev Token' on the server too, and if the current token failed, but it matched the prev token,
AND the IPs matched, you could prevent the logout on that sort of crash, if it was really worth it (not that pages crash that often I would hope).
Secondary question:
This 'steal your cookie by an evil link' thing - does that use special browser HTML/JS/ETC or is it all serverside?
If it is serverside, then I would worry that any image in any sig could be used with a source="abc.pl" etc, and do the same thing silently, but I don't know the mechanics of this type of cookie stealing.