OK, enough long winded babbling introduction. The tutorials I've read
about logging into an application all store the user ID in the
session. I presume that the "session" is a conceptual framework
wrapped around a cookie. Here is where my knowledge of the theory of
HTTP runs out. So I start to assume things. One thing that I assume
is that, when a server places a cookie in a client's browser, there
must be something inherent in the protocol that would allow the server
to retrieve that cookie.
Now I start to wonder how secure sessions are? If only the login page
is encrypted, what is to prevent somebody from sniffing the
unencrypted cookie request and response as they go whizzing by to
fetch later pages? Is there a provision for encrypted cookies? Do
the client and the server share a secret when the cookie is first
placed on the client (via the encrypted link) that is used to prevent
the cookie from being used by a malicious party?
I'm just curious about this, and, because I'm curious, and because I
am really supposed to be writing an annual report, I thought this
would be a good time to ask the experts about this burning issue.
:-)
--wpd
Thanks. I'll do that, although I've realized in hindsight that my
question is not specific to RoR. It's much broader. But
rorsecurity.info looks like a great place to start.
--wpd
> HTTP runs out. So I start to assume things. One thing that I assume
> is that, when a server places a cookie in a client's browser, there
> must be something inherent in the protocol that would allow the server
> to retrieve that cookie.
That is not exactly how cookies work. There is no separate request from
the server to get cookies. One request might store a cookie in a
client's browser. Any cookies a client has stored for the target domain
are sent along with every subsequent request. Meaning they are part of
the request not a separate transaction. And yes, they would get
encrypted in an SSL session.
> Now I start to wonder how secure sessions are? If only the login page
> is encrypted, what is to prevent somebody from sniffing the
> unencrypted cookie request and response as they go whizzing by to
> fetch later pages? Is there a provision for encrypted cookies? Do
> the client and the server share a secret when the cookie is first
> placed on the client (via the encrypted link) that is used to prevent
> the cookie from being used by a malicious party?
What you're referring to here is called session highjacking. See
http://en.wikipedia.org/wiki/Session_hijacking for more information
about that.
--
Posted via http://www.ruby-forum.com/.
Not being anywhere close to being a security expert, I think it would
be fairly trivial to solve this problem by encrypting an ever-changing
cookie (i.e. one that includes the current time, or even just some
random number, appended to the payload data) using a key that is set
by the server when the cookie is first created via a secured link.
This would, of course, require a change/enhancement to the cookie
protocol and would have to be approved by the appropriate folks.
Knowing the little bit I do know about security and encryption, I know
that the fairly trivial solutions are usually fairly trivially broken,
and that this issue is probably much more complex than I ever imagined
(as I have learned from reading the links to which some folks have
pointed me.)
I suppose the only solutions to the session hijacking problem are to
trust your neighbors (who can see all the packets you send) or to
encrypt everything. But, as
http://guides.rubyonrails.org/security.html points out, session
hijacking by somebody who can sniff your packets, is only the tip of
the iceberg when it comes to folks trying muck things up.
Thanks for the info.
--wpd
Yes, and besides all this, what is the point of worrying about session
key encryption, when all you need is to enforce use of SSL/TLS. Doing so
makes all this complication go away. If one is passing sensitive
information over a public wire in the clear, then session highjacking
becomes a minor issue in comparison. There's no point in reinventing
this wheel. Experts far smarter than most of use have already solved
this problem with SSL/TLS.