You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code uses the function rand() in HTTP/Request2/Adapter/Socket.php:
$challenge['cnonce'] = 'Req2.' . rand();
This function does not produce secure random numbers, and it might be predictable in certain situations. It would therefore be better to avoid it.
One can get practically the same behavior using PHP's random_int. However, in this case, according to the RFC the cnonce value can contain any base64 characters. So maybe just use something like base64enc(random_bytes(15)). (The random_bytes() function generates cryptographically secure random numbers, usually that's wired to the operating system's random number generator.)
The text was updated successfully, but these errors were encountered:
hannob
changed the title
Use of insecre random number generation function rand()
Use of insecure random number generation function rand()
Dec 19, 2023
Dunno whether it makes sense to fix Digest authentication at this point. Using that essentially requires storing unencrypted passwords, which is a lot more insecure than using a bad random number generator.
The code uses the function rand() in HTTP/Request2/Adapter/Socket.php:
This function does not produce secure random numbers, and it might be predictable in certain situations. It would therefore be better to avoid it.
One can get practically the same behavior using PHP's random_int. However, in this case, according to the RFC the cnonce value can contain any base64 characters. So maybe just use something like
base64enc(random_bytes(15))
. (The random_bytes() function generates cryptographically secure random numbers, usually that's wired to the operating system's random number generator.)The text was updated successfully, but these errors were encountered: