Re: Random number generation security problem
| From: | Christian Weiske | Date: | Sun, 21 Sep 2008 15:34:06 +0000 |
| Subject: | Re: Random number generation security problem | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-50791@lists.php.net to get a copy of this message | ||
Hello all,
> See
>
> http://www.suspekt.org/2008/08/17/mt_srand-and-not-so-random-numbers/
>
> Quote:
> > I just grepped through PEAR. 11 times srand() dangerously used and 4
> > times mt_srand() dangerously used. So if srand() would become an
> > alias of mt_srand() the situation is obviously worse than before.
>
> If someone has time, please check which packages this are and how we
> can fix this.
I grepped through pear cvs and the following files seed the random
number generator:
./Auth_SASL/SASL/DigestMD5.php:
mt_srand((double)microtime()*10000000);
./Crypt_CBC/CBC.php:
srand((double)microtime()*1000000);
./Cache/Cache.php:
srand((double) microtime() * 1000000);
./Crypt_CHAP/CHAP.php:
mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
./HTML_Crypt/HTML/Crypt.php:
srand((float) microtime() * 10000000);
./HTML_Table_Matrix/Matrix/Filler/Random.php:
srand(microtime());
./HTTP_Upload/Upload.php:
srand((double) microtime() * 1000000);
./Mail_Mime/mimePart.php:
srand((double)microtime()*1000000);
./Math_BigInteger/demo/ssh_demo.php:
mt_srand((float) $sec + ((float) $usec * 100000));
./Payment_Process/Process/Dummy.php:
srand(microtime());
./XML_Transformer/Transformer/Namespace/Anchor.php:
srand((double)microtime()*1000000);
The short version of Stefan Esser's post is that seeding the random
number generator makes your application more vulnerable since the
random tokens used can be predicted better.
Since php 4.2.0 we don't need to seed anymore since that's
automatically done. Removing mt_srand() and srand() calls should
suffice in most/all cases.
Now we need bug reports for those packages.
--
Regards/Mit freundlichen Grüßen
Christian Weiske
-= Geeking around in the name of science since 1982 =-
Attachment: [application/pgp-signature] signature.asc
Attachment: [application/pgp-signature] signature.asc