Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm not exactly sure how the $_SESSION work in PHP. I assume it is a cookie on the browser matched up with an unique key on the server. Is it possible to fake that and by pass logins that only uses sessions to identify the user.

If $_SESSION doesn't work like that, can someone potentially fake cookies and bypass logins?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
284 views
Welcome To Ask or Share your Answers For Others

1 Answer

Yes.

The only thing identifying a user is a pseudo-random value being sent along with each request. If an attacker can guess the right values to send, he can pose as somebody else.

There are different ways to make this harder:

  • make session ids longer (more entropy, harder to guess)
  • check additional information like the user agent (essentially more entropy)
  • obviously: use a good random number generator
  • expire sessions sooner to give a smaller set of valid session ids at any one time
  • renew session ids often, even for valid ids
  • use SSL to encrypt all communication to avoid outright cookie hijacking

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...