PHP : Weak random number generator
Classification
Overview
Used pseudorandom number generator (PRNG) is not secure, since it generates a predictable sequence. This can be exploited to bypass authentication and capture the user’s session, as well as to carry out the DNS cache poisoning attack.
PRNGs generate chains of numbers based on the initial value referred to as seed. There are two types of PRNGs: statistical and cryptographic. Statistical PRNGs generate predictable sequences that are similar to truly random according to the statistical characteristics. They must not be used for security purposes. On the contrary, it is impossible to predict the output of a cryptographic PRNG, if the seed value is derived from a source with high entropy. Using current time as seed value is insecure due to low entropy.
PHP functions rand, srand, mt_rand, mt_srand generate predictable sequences and must not be used in information security context.
Sensitive Data Exposure vulnerabilities take the third place in the “OWASP Top 10 2017” web-application vulnerabilities ranking.
References
- OWASP: Insecure randomness
- CWE-330: Use of Insufficiently Random Values
- CERT: MSC02-J. Generate strong random numbers
- Some SecureRandom Thoughts - Alex Klyubin / Android Developers Blog
- rand - php.net
- OWASP Top 10 2017-A3-Sensitive Data Exposure
- CWE-328
- CWE CATEGORY: OWASP Top Ten 2017 Category A6 - Security Misconfiguration
- CWE-338
DerScanner Severity Score
Check your PHP code for this vulnerability, free
Request a free pilot of DerScanner. We give you access and help with the first scan. It works in the cloud and on-premise.
Try it on your code, free
By submitting this form, I acknowledge that DerScanner may process my personal data I provided above for purposes explained above. More details about the processing.
