Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP - Session fixation ( Stopping it )
Old 05-20-2011, 04:30 PM PHP - Session fixation ( Stopping it )
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Hi Guys,

Ive been doing some research on session fixation..

From what I understand...

If a hacker logs into my site ( getting a session ID ) and then somehow gets a user to visit my site with his PHPSESSID .. They will then login and they "both" be able to do the same thing.. IE: the hacker will now have their access level..

Im trying to stop this ( Albeit a small problem ).

Currently WHENEVER anyone auths or changes "permission levels"

I do this:
Code:
<?php
session_start(); // Start the Session
session_destroy(); // Destroy it..
session_start(); // Start a new one.
session_regenerate_id();  // regen the ID.
?>
Now,
With this im assuming that this can stop any kind of fixation hack?

The hacker will have one ID, Then if they try and get a user to use their ID.
It will fail because a new session with a new ID has been forced?


Am I thinking about this right?

Ive read a lot of documents and as far as I can tell, This would fix my issue. ( albeit a tiny issue )

Any thoughts?
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
 
Register now for full access!
Old 05-20-2011, 05:11 PM Re: PHP - Session fixation ( Stopping it )
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I doubt you'll need to destroy and recreate the session. Just generating a new ID should suffice. And yes, that should make it impossible for a hacker to make a fixation attack.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 05-20-2011, 05:17 PM Re: PHP - Session fixation ( Stopping it )
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Cool, TY.

Thought it might be the case.
At least it makes it that bit harder.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 05-20-2011, 10:09 PM Re: PHP - Session fixation ( Stopping it )
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
There is a good method to use to help prevent session hijacking is by using tokens. A token is a random unique string that is generated for each page request. Here is how it works:

1. Generate a new token and save it to the session:
$_SESSION['token'] = uniqid();

2. If the current page is a form page, pass the current token as a hidden form value:
<input type="hidden" name="token" value="<?php echo $token; ?>" />

3. When the user submits the form data, compare the $_POST['token'] with the session saved token (before a new one is generated and overwritten).

This will help keep sensitive tasks between the user and session.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 05-21-2011, 11:22 AM Re: PHP - Session fixation ( Stopping it )
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Ahh thats an idea.
I wondered why "tokens" appear on sites.. I suppose its for this..
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Reply     « Reply to PHP - Session fixation ( Stopping it )
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.35355 seconds with 12 queries