$_SESSION issues - possible security hole?
am 10.08.2008 19:34:58 von Darron Butler------=_Part_16764_11568300.1218389698330
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
I have built an application where users have to log in (the user data is
stored in MySQL). I have 3 levels of rights for users; 1-"normal" rights,
2-"admin" rights, and 3-"super" user rights. When a user logs in, I set the
$_SESSION['rights'] variable accordingly so I can reference it thru out the
site. I have around a dozen pages where the login session information and
the user rights piece work just fine. However, I'm creating an
administration page where admins have some functionality but super users
have all functionality and I've run into issues. I was using the session
rights variable in a number of different IF statements to display and during
a simple test I hit the "refresh" button on my browser and found that when I
did so it CHANGED my session rights to those of a different user!?!? I have
looked thru my code until I'm blue in the face and have even boiled the code
down to the simpest display possible, yet when I hit refresh, it still
changes the user and rights info (note all the other pages work fine).
I have been able to determine that there must be something in my USERS query
that is causing the issue. I changed the query to get data from a completely
different table and show it in a select list and hitting refresh does NOT
change the user or the user rights! So.....does this mean querying the very
table that lists users information (with data like "rights" and "user" in
it) somehow can change the $_SESSION variables?? That appears to be what's
going on, but I thought you had to explicitly assign the $_SESSION variables
before they could be changed. Help!!! I have included my code and the
database table structure below:
/*********************************************************** ********************
Program is only available to admins and super users. This page
allows for the adding/editing of user accounts and priveledges
as well as allowing for application messages, application
lockdown/shutdown, and standard parts administration.
************************************************************ ********************/
include ("php_header.inc");
if ($_SESSION['rights'] != "super")
{
header("location: landing.php");
exit ();
}
/****************** ADMINISTER USERS *********************/
$query1 = "select * from USERS order by user";
$result1 = mysql_query($query1) or die ("Couldn't select all users -
super");
include ("html_header.inc");
echo "
{$_SESSION['user']}, {$_SESSION['rights']}
\n\n