Weak random number generator used in concrete/authentication/concrete/controller.php
The authentication controller generates random strings using PHP's non-cryptographic rand() function, making the output predictable. An attacker could potentially guess tokens or values derived from this function, though the text does not demonstrate a concrete exploit.
Originally disclosed on HackerOne
- Triaged in under an hour
- Fixed in 26 hours
- Disclosed after 13 days
private function genString($a = 20)
{
$o = '';
$chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+{}|":<>?\'\\';
$l = strlen($chars);
while ($a--) {
$o .= substr($chars, rand(0, $l), 1);
}
return md5($o);
}
Using substr(rand()) then running md5() on the output would be better replaced by using bin2hex() and either openssl_random_pseudo_bytes($a) or mcrypt_create_iv($a, MCRYPT_DEV_URANDOM)
For example:
private function genString($a = 20)
{
if (function_exists('mcrypt_create_iv')) {
return bin2hex(mcrypt_create_iv($a, MCRYPT_DEV_URANDOM);
}
return bin2hex(openssl_random_pseudo_bytes($a));
}
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
What the attacker needed
None
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This code creates random-looking strings, but it uses a random number generator that is not safe for security. A predictable random number could let an attacker guess values derived from it. The fix is to use a generator designed for security, such as openssl_random_pseudo_bytes.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.