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

Categories

0 votes
294 views
in Technique[技术] by (71.8m points)

php - Faking Session/Cookies?

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

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

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...