Re: [PHP4BETA] CVS update: php4/ext/session
| From: | Sascha Schumann | Date: | Tue, 08 Jun 1999 11:36:02 +0000 |
| Subject: | Re: [PHP4BETA] CVS update: php4/ext/session | ||
| References: | 1 2 3 4 5 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-1391@lists.php.net to get a copy of this message | ||
On Tue, Jun 08, 1999 at 08:48:24AM +0200, Kristian Köhntopp wrote:
>
> Jim Winstead wrote:
> > Unless you are drawing your randomness from something
> > like /dev/random, it is deterministic, because all
> > you're doing then is using the "srand($deterministic_seed);
> > rand();" steps as a glorified hash function.
>
> /dev/random is not available widely (i.e. not on legacy UNIX
> systems), so PHPLIB takes another approach, involving a secret:
> $id = md5(uniqid("secret_setring")). The uniqid() is guessable,
> because it is time-based and you already know the approximate
> system time on the target system. But by introducing an component
> that is unknown to an attacker, the md5() result becomes
> unguessable.
Well, the obvious problem in a multi-user environment is that you
somehow need to protect the secret string.
> > The session id should be composed of both deterministic
> > and random components -- the deterministic part makes it
> > so you can guarantee there's no collisions, and the random
> > part to make it harder for people to hijack sessions.
>
> An md5() hash may have collisions, but the probability for such
> collisions is so incredibly low that we do not need to care about
> that. It is an evenly distributed 2^128 bit value. With a million
> simultaneously active sessions (2^20 sessions), this leaves you
> with a collision probability of 2^-108. This is zero for all
> practical purposes.
Where did you get the numbers from? Please quote your source.
MD5 violates one fundamental design principle of the algorithm as
described by Rivest. Boer and Bosselaers have shown that it is
possible to produce collisions using MD5's compression function.
The same attack is not possible against SHA. There are no known
cryptological attacks against SHA (some people trust the NSA in
this context) and brute force attacks become much more complex,
since SHA uses a 160-bit key instead of MD5's 128-bit keys.
So, we might as well drop MD5 as hash function and use SHA
instead. The only cause for the current choice is that PHP
always includes MD5.
> The important part with md5() hashes is to introduce a secret
> component (secret being defined as "unknown to the attacker") in
> addition to the variable component to protect against attacks
> guessing the variable part of the md5() input.
I agree that collisions are not our real problem. Our task is to
make it impossible to guess session ids even if the attacker has
almost all data about a) the client and b) the server state.
--
Regards,
Sascha Schumann
Consultant