YsoL8
YsoL8

Reputation: 2214

$_session security

Currently I autheticatic user sessions by matching a key in the session to the same key in a MySQl database. I regenerate the session with a random number that is MD5 protected on every page load. I am aware that sessions are not inherently secure and I'm looking for further security options that can be attached to this method in a speedy manner.

Any Ideas?

Upvotes: 2

Views: 149

Answers (2)

symcbean
symcbean

Reputation: 48357

You're already jumping through hoops which do nothing to enhance the security, and potentially compromise the functionality of your site.

I autheticatic [sic] user sessions by matching a key in the session to the same key in a MySQl database

Even leaving aside the spelling mistakes, this is nonsense. Do you mean you authenticate requests by this method? If so, it's still not helping your security. You've already authenticated the request by de-referencing the session. Whether the request is authorized is completely different - if you need to authenticate the user then you should flag this in the session data.

It sounds like you're trying to prevent a CSRF, but getting this all mixed up with whether you're authenticating a user, a session or a request.

I regenerate the session...on every page load

Again, this is semantic nonsense. You can't "regenerate the session". Do you mean you create a new sessionId? If so then all you are achieving is creating errors when users try to open a second window or use the back button. It provides very little CSRF protection.

is MD5 protected

Just using random cryptographic functions doesn't make your application secure. It doesn't matter what the mapping between the real data and a surrogate identifier is, on its own it provides no protection against MITM.

Either you've done a very bad job describing your current security measures, or you've written lots of code which serves no useful purpose.

Go and read a lot of Stefan Esser's and/or Chriss Schiflet's stuff.

Upvotes: 0

Gumbo
Gumbo

Reputation: 655129

Since the session data is stored on the server side and the session ID is used to associate a client’s request with a certain session, it’s the session ID that needs to be protected. And the only viable measure to protect that session ID is to encrypt the connection between the client and server using TLS/SSL.

So you can use sessions as long as the data transfer between client and use is secured. Additionally, you can fix the PHP session to the TLS/SSL session so that the PHP session is only usable within that specific TLS/SSL session.

Upvotes: 3

Related Questions