News Feed

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

Rob Allen: SSL certificate verification on PHP 5.6 Write an Ajax-driven Login Application in PHP Using SSL/TLS

Tobias Schlitt's Blog: Randomized Pi calculation

Zend Developer Zone: Zend Weekly Summaries Issue #322 Security Techniques: Part 2

Community Events

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

extension threedevsandamaybe development podcast opinion laravel5 laravel release interview series unittest framework library voicesoftheelephpant language api wordpress introduction community feature

All content copyright, 2015 :: - Powered by the Solar PHP Framework