22, November 2008

Vulnerability in session_handler.php? - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: Vulnerability in session_handler.php?
« previous next »
Pages: [1] Print

Author Topic: Vulnerability in session_handler.php?  (Read 973 times)
Metal slug addict
*
Posts: 19
126 credits
Members referred : 0


« on: Apr 29, 2007, 08:27:22 PM »

Hi Olaf,

You fixed a problem which someone reported as a possible SQL injection attack. i.e. an attacker could enter "administrator' or 'a'='a" for the username and get in without a password.

It looks like there is a similar although more difficult to exploit problem in session_handler.php function _read and others

    function _read($ses_id) {

        $session_sql = "SELECT * FROM " . $this->ses_table

                     . " WHERE ses_id = '$ses_id'";



$ses_id is used without being checked. I believe $ses_id is the session id provided from the users browser. A hacker could set this to any value, causing undesirable effects e.g. DROP sessions

I think the code should be

    function _read($ses_id) {

   $ses_id = mysql_real_escape_string($ses_id);
        $session_sql = "SELECT * FROM " . $this->ses_table

                     . " WHERE ses_id = '$ses_id'";


This also applies to other functions in session_handler.php

Mike


« Last Edit: Apr 29, 2007, 11:02:22 PM by Olaf »
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


Re: Vulnerability in session_handler.php
« Reply #1 on: Apr 29, 2007, 08:34:42 PM »

how do you wanna access the database via the browser while this class is accessed by the session handler?

will say that some hacker need to create a session id how do you do that?


Last blog : Just a better Internet portal provided by Google
Metal slug addict
*
Posts: 19
126 credits
Members referred : 0


« Reply #2 on: Apr 29, 2007, 09:03:50 PM »

Not sure what you are saying.

All I will say is I am not an expert in this area but I have come across snippets of code that perform the same function as yours. Where they don't use mysql_real_escape_string people have criticised them e.g. bottom of page here http://www.hardened-php.net/php_security_guide_considered_harmful.51.html Visit through proxy

Chris Shiflet uses mysql_real_escape_string  here http://shiflett.org/articles/storing-sessions-in-a-database Visit through proxy

I dont know how you would set the sessionid but I have read that it is possible.

Mike
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Apr 29, 2007, 09:53:02 PM »

only if the user can create the session id than its dangerous because of a SQL injection (via this ID).

sure you can protect this code but if you need this to do you have maybe more security issues because of a unsafe server configuration.

sure it's always important to protect you queries for sql injections but first of all if there is some user input and that not the case here...


Last blog : Just a better Internet portal provided by Google
Metal slug addict
*
Posts: 19
126 credits
Members referred : 0


« Reply #4 on: Apr 30, 2007, 11:32:32 AM »


only if the user can create the session id than its dangerous because of a SQL injection (via this ID).

sure you can protect this code but if you need this to do you have maybe more security issues because of a unsafe server configuration.

sure it's always important to protect you queries for sql injections but first of all if there is some user input and that not the case here...

Just wanted to say that I have found a hacking tool that allows modification of session id. I don't want to post a link as its not a good idea. I understand it is unlikely anyone would be vulnerable to this attack but my application has quite high security requirements so I am going to make the suggested modifications on my own.

Mike
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Apr 30, 2007, 12:42:14 PM »


only if the user can create the session id than its dangerous because of a SQL injection (via this ID).

sure you can protect this code but if you need this to do you have maybe more security issues because of a unsafe server configuration.

sure it's always important to protect you queries for sql injections but first of all if there is some user input and that not the case here...

Just wanted to say that I have found a hacking tool that allows modification of session id. I don't want to post a link as its not a good idea. I understand it is unlikely anyone would be vulnerable to this attack but my application has quite high security requirements so I am going to make the suggested modifications on my own.

Mike


Mike, please pm me the link


Last blog : Just a better Internet portal provided by Google
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6486
Tags : security Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: Vulnerability in session_handler.php?
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Nov 22, 2008, 03:28:13 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 37.736
Total Topics: 7.650
Total Members: 4.397
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: Janai

39 Guests, 5 Users online :

11 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.