Ruby on Rails isn't exactly known for a strong stance on security, and the new soon-to-be-released version uses a rather controversial feature from a security perspective.
Many sites were having performance problems storing user sessions. There were several ways this could be accomplished: in flat files, in a database, in memcached...
Rails 2.0 chose a rather... interesting way of storing sessions: in cookies.
Rails serializes your complete session and stores it in plaintext in a cookie.
This has obvious security concerns: sessions often store the user ID you're logged in as in the session. If you can set or change this value you can log in as any user in the system.
To try to add some security to this approach, the Rails core team added HMAC hashing to CookieStore. The session cookie ends up being the serialized session object plus the HMAC hash of your session data and a server-side secret.
This seems stupid for a number of reasons. The first is that you are handed your entire session in plaintext. If there is any sensitive data in the session, anyone can read it. It also lets any user probe the session for anything that looks vulnerable and gain insight into the way the application works that they probably shouldn't have. The second is that every session cookie's length is increased by the full length of the hash. That's 32-bytes with a hash algorithm like SHA-256.
It seems like it'd make a whole shitton more sense to just encrypt the entire session. Sessions would be shorter and unreadable by clients. Overall this whole approach seems like poor use of encryption.
This was recently compounded by the fact that Rails' default server secret generator was discovered to be rather lousy...
Many sites were having performance problems storing user sessions. There were several ways this could be accomplished: in flat files, in a database, in memcached...
Rails 2.0 chose a rather... interesting way of storing sessions: in cookies.
Rails serializes your complete session and stores it in plaintext in a cookie.
This has obvious security concerns: sessions often store the user ID you're logged in as in the session. If you can set or change this value you can log in as any user in the system.
To try to add some security to this approach, the Rails core team added HMAC hashing to CookieStore. The session cookie ends up being the serialized session object plus the HMAC hash of your session data and a server-side secret.
This seems stupid for a number of reasons. The first is that you are handed your entire session in plaintext. If there is any sensitive data in the session, anyone can read it. It also lets any user probe the session for anything that looks vulnerable and gain insight into the way the application works that they probably shouldn't have. The second is that every session cookie's length is increased by the full length of the hash. That's 32-bytes with a hash algorithm like SHA-256.
It seems like it'd make a whole shitton more sense to just encrypt the entire session. Sessions would be shorter and unreadable by clients. Overall this whole approach seems like poor use of encryption.
This was recently compounded by the fact that Rails' default server secret generator was discovered to be rather lousy...
Comment