I\'m trying to understand more about PHP Session Fixation and hijacking and how to prevent these problems. I\'ve been reading the following two articles on Chris Shiflett\'s
Both session attacks have the same goal: Gain access to a legitimate session of another user. But the attack vectors are different:
In a Session Fixation attack, the attacker already has access to a valid session and tries to force the victim to use this particular session.
In a Session Hijacking attack, the attacker tries to get the ID of a victim’s session to use his/her session.
In both attacks the session ID is the sensitive data these attack are focused on. So it’s the session ID that needs to be protected for both a read access (Session Hijacking) and a write access (Session Fixation).
The general rule of protecting sensitive data by using HTTPS applies in this case, too. Additionally, you should to do the following:
To prevent Session Fixation attacks, make sure that:
true) and make it for HTTPS only if possible (set session.cookie_secure to true); you can do both with session_set_cookie_params.To prevent Session Hijacking attacks, make sure that:
true)To prevent both session attacks, make sure that:
true only on success) or a change of privileges and destroy the old session. (Make sure to store any changes of $_SESSION using session_write_close before regenerating the ID if you want to preserved the session associated to the old ID; otherwise only the session with the new ID will be affected by those changes.)