Jump to content

fake a $_SESSION?


freelance84

Recommended Posts

Good evening all,

 

I'm just going through my site checking for any security issues I may have missed...

 

Is it possible for someone to "fake" a $_SESSION variable?

There are several MySQL queries which are using the $_SESSION variables as part of the query... Therefore, if someone managed to "fake" a $_SESSION they could make some of the queries unsafe as I haven't run any of the $_SESSION variables through the mysql_real_escape_string.

 

I know the mysql_real_escape_string is designed to make safe any user input into MySQL, so this may apply if they "fake" the $_SESSION?

Link to comment
Share on other sites

$_SESSION variables will not be accessible from the browser so no you won't be able to alter the session values as they are stored on the server.  However If you're assigning user input to any session variables it is important you  sanitize this input so that is safe to use within your SQL queries.

Link to comment
Share on other sites

You cannot fake a session variable, but if register_globals are on, anyone can set one of your session variables to any value they want by simply supplying a same name cookie, post, or get variable when they request your page.

 

If the value you put into a session variable originally came from the visitor, such as their username from a form, as long as you escaped it when it was originally received, it would be safe to put the session variable directly into a query.

Link to comment
Share on other sites

Scenario:

A registered user logs in. Their username and userID are stored for the session as $_SESSION's.

These $_SESSION's are then used to determine what to delete and what to change in the SQL commands.

 

My concern was that a clever user would be able change the session variable some how after logging in, therefore making the mysql command unsafe.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.