No, not remotely. You have no guarantee that cookies are not saved as plain text (and, in fact, most do implementations save them as plain text).
Remember that “remember me” is inherently unsafe, since anyone who intercepts a cookie gets access to the application. But by exposing the user's password, he takes a step further up the ladder of insecurity. :-) And, probably, makes the user really crazy if they find out.
I use an encrypted cookie string that includes the user account name in combination with a token, which has no other way associated with the user account, except for the table on my server. When the user returns to the site, we decrypt the cookie and check whether this token is really associated with this account. The token (and therefore cookie) changes each automatic login and invalidates the one used for automatic login. (There is a multi-valued connection between tokens and an account that allows you to automatically enter a login from several places. You can limit this if you want.) Tokens will time out if they are not used for X days. (This is done not only by limiting the duration of the cookie, but also on the server side.) There are several other things that I throw there to make life a little difficult for someone trying to decode a cookie (successfully decrypted it) or use a stolen file cookie (which does not require decryption), but it makes no sense to sort out the excess (again, “remember me” is inherently unsafe).
I use this on a site where reliable protection is not really needed (obviously) and has a large number of clients with a dynamic IP address, so I am not trying to block it to an IP address. But even blocking it before IP does not make it safe; it slightly reduces the attack surface.
You might be wondering why I have a cookie username. For direct purposes, "remember me" I would not recommend it there, even if it is encrypted (in the end, this is half the authentication pair in the system with a username and password). I was a little surprised to see it in our cookie, when I looked at the format, reminding myself how we did this for this issue; but then I saw comments explaining why this is and there are reasons not related to “remember me” (not necessarily convincing reasons, in hindsight, but reasons).
In conclusion, the fact that “remember me” is inherently insecure is one of the many reasons why site logs are very important and why you should require a password re-check in the process of allowing changes to important account information (to make it harder for anyone someone who stole the cookie to take responsibility for the account).
TJ Crowder Jan 20 '10 at 10:06
source share