I've got a novice question -
It is often said that you should not store plaintext passwords in a client-side cookie. (I'm imagining a web browser cookie, but I supposed this applies in general.) But in simple web apps we often store a plaintext session-ID in a cookie.
To elaborate, we often secure sites using this model:
- The user enters username and password on the client machine. These are sent to the server over a secure (HTTPS) connection.
- The server hashes the password and validates against the database. Assuming the password is correct, the server generates a session-ID and returns it to the client machine alongside the body of the response.
- The client stores the plaintext session-ID in a cookie. Every time the client makes another call to the server, the session-ID is sent back to the server over a secure connection.
- After x minutes of inactivity, the session expires and the session-ID is no longer considered valid for that user.
But we're strongly discouraged from using this model:
- The user enters a username and password on the client machine. These are stored, in plaintext, in a client-side cookie. Then, they are sent to the server over a secure (HTTPS) connection.
- The server hashes the password and validates against the database. Assuming the password is correct, the server returns a response.
- Every time the client makes another call to the server, the password is sent back to the server over a secure connection.
- After x minutes of inactivity, the cookie expires and the password is no longer saved on the client's machine.
Why is the second model considered insecure while the first model is secure? Granted, in the second model a nefarious cookie-reader could steal the password from the browser. But in either model a nefarious key-reader could steal the password from the IO subsystem. Is this the only reason that the second model is not used - to slightly decrease our attack vector by blocking cookie-readers? Or is there some larger problem with storing the password on the client, which I'm not seeing?