Re: [PHP4BETA] CVS update: php4/ext/session

From: Date: Tue, 08 Jun 1999 06:48:24 +0000
Subject: Re: [PHP4BETA] CVS update: php4/ext/session
References: 1 2 3 4  Groups: php.version4 
Request: Send a blank email to php-version4+get-1390@lists.php.net to get a copy of this message
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. > 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. 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. Kristian -- Kristian Köhntopp, NetUSE Kommunikationstechnologie GmbH Siemenswall, D-24107 Kiel, Germany, +49 431 386 436 00 Using PHP3? See our web development library at http://phplib.shonline.de/ (GPL)

« previous php.version4 (#1390) next »