News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Pádraic Brady:
Predicting Random Numbers In PHP - It's Easier Than You Think!
March 26, 2013 @ 09:54:15

Pádraic Brady has a new post to his site about "randomness" in PHP and how, depending on the method used, you might not be as random as you think.

The Zend Framework team recently released versions 2.0.8 and 2.1.4 to address a number of potential security issues including advisory ZF2013-02 "Potential Information Disclosure and Insufficient Entropy vulnerabilities in ZendMathRand and ZendValidateCsrf Components". Quite the mouthful! In short, Zend Framework used the mt_rand() function to generate random numbers in situations where neither openssl_pseudo_random_bytes() nor mcrypt_create_iv() were available. This is possible when the openssl and mcrypt extensions are not installed/compiled with PHP.

He talks some about the mt_rand function and how it generates its "random numbers" (designed for speed, not ultimate randomness). He notes that all of PHP's internal randomization functions use the concept of "seeds" to prime the random number/string generation. Unfortunately, the seeding method is known inside PHP, so it is possible - if the method of generation is weak, as it is with mt_rand - that an attacker could brtute force their way into a correct value. You can find more about randomness in PHP in this chapter of his PHP security handbook including a mention of Anthony Ferrara's randomness library.

0 comments voice your opinion now!
randomness seed mtrand openssl mcrypt randomlib


blog comments powered by Disqus

Similar Posts

Scott MacVicar's Blog: Accessing pseudo random data with PHP

Christopher Kunz's Blog: Building PHP with cURL and libmysqlclient5

PHP-Security.net: X.509 PKI login with PHP and Apache

Pádraic Brady: Predicting Random Numbers In PHP - Itís Easier Than You Think!

Mark Karpeles' Blog: PHP can do anything, what about some ssh?


Community Events











Don't see your event here?
Let us know!


security introduction unittest hack language podcast hhvm opinion code component application package facebook symfony2 release series threedevsandamaybe framework composer install

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework