Jump to content

Session Security by passing salted hashed user agent string via url


calabiyau

Recommended Posts

There was a good topic about this a few pages ago and I wanted to continue it, regarding session security.  I came across what seemed like a good method of securing sessions and was wondering what others thought of it.  Basically it goes something like this on the log in page:

 

$query = "SELECT * FROM users WHERE first_name='$u' AND password='$p'";

$results_id = mysql_query($query, $connect);
$row = mysql_fetch_row ($results_id);

if ($row)
	{

	ini_set("session.gc_maxlifetime","300");
	ini_set("session.gc_probability","100");
	include('sessions_db.php');

	session_start();

	$string = "someword";
	$string .= $_SERVER['HTTP_USER_AGENT'];
	$string = md5($string);


					header("Location:http://www.mysite.com/admin.php?fingerprint=".$string);
	exit();
	}
else
	{
	echo "<h2>I'm sorry either your password or username is incorrect.</h2><br/>";
	}

 

So passing this variable via the url and in addition also setting some session variables which I haven't included here.  So even if someone can somehow trick someone into clicking there link and get a valid session id to work with, if they go to the admin page without having been properly validated fromt the database, they will not have the url parameter set and be directed back to the log in page.  I'm just curious, this seems pretty solid to me, but what are the holes in the logic.  ie. how could someone get into the secure area, aside from some pretty time consuming efforts to forge the salted hashed user agent in the address bar?  Anybody?

Link to comment
Share on other sites

If the malicous link/script is on your site (as in, if you have user content), this won't help, because they will have the refering URL in the request.

 

If the attacker got the session cookie from filesystem access, they can still look in the history.

 

But it does add another layer of work.

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.