Welcome Guest, Not a member yet? Register   Sign In
Authentication and Sessions
#18

[eluser]Peng Kong[/eluser]
if db is used, the hash is pointless, since session data is stored in the db and not on the cookie, the hash would just be taking up db space. tempering with the cookie just means losing access to the session (row in session table), the best someone could do is try to do fixation or spoofing.

Michael concern was regarding distributed auth libraries where there was a possibility of a non db, non-encrypt session configuration, by putting a hash in the cookie the risk is mitigated.

To be secure ALL custom data in the cookie, ALL custom data has to be in the hash together with a non-guessable, non-public viewable piece of data (i thinking the user's password is a perfect candidate of this).

Maybe something like this?

When storing...
Code:
if ( ! sess_db_in_use)
{
    cookie_data['id'] = db_id;
    cookie_data['name'] = db_name;
    cookie_data['hash'] = sha1(db_id.db_name.db_password);
}

Before using session data
Code:
if ( ! sess_db_in_use)
{
    if (cookie_hash == sha1(cookie_id.cookie_name.db_password)
    {
        // we can trust that the cookie data wasn't tampered
    }
}
else
{
    // we can always trust that db custom data isn't tampered
}

what do you guys think?


Messages In This Thread
Authentication and Sessions - by El Forum - 02-04-2010, 10:14 PM
Authentication and Sessions - by El Forum - 02-04-2010, 10:27 PM
Authentication and Sessions - by El Forum - 02-05-2010, 01:58 AM
Authentication and Sessions - by El Forum - 02-05-2010, 02:05 AM
Authentication and Sessions - by El Forum - 02-05-2010, 06:53 AM
Authentication and Sessions - by El Forum - 02-05-2010, 08:31 AM
Authentication and Sessions - by El Forum - 02-05-2010, 09:24 AM
Authentication and Sessions - by El Forum - 02-05-2010, 09:38 AM
Authentication and Sessions - by El Forum - 02-05-2010, 09:52 AM
Authentication and Sessions - by El Forum - 02-05-2010, 10:10 AM
Authentication and Sessions - by El Forum - 02-05-2010, 10:16 AM
Authentication and Sessions - by El Forum - 02-05-2010, 10:18 AM
Authentication and Sessions - by El Forum - 02-05-2010, 10:25 AM
Authentication and Sessions - by El Forum - 02-05-2010, 11:00 AM
Authentication and Sessions - by El Forum - 02-05-2010, 11:15 AM
Authentication and Sessions - by El Forum - 02-05-2010, 02:00 PM
Authentication and Sessions - by El Forum - 02-05-2010, 04:56 PM
Authentication and Sessions - by El Forum - 02-05-2010, 10:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB