This repository was archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Weak PRNG used #132
Copy link
Copy link
Closed
Labels
Description
Insecure RNG:
stormpath-sdk-php/src/Util/UUID.php
Lines 167 to 181 in 15aee30
| /* | |
| * Generate an UUID version 4 (pseudo random) | |
| */ | |
| static private function generateRandom($ns, $node) { | |
| $uuid = self::$m_uuid_field; | |
| $uuid['time_hi'] = (4 << 12) | (mt_rand(0, 0x1000)); | |
| $uuid['clock_seq_hi'] = (1 << 7) | mt_rand(0, 128); | |
| $uuid['time_low'] = mt_rand(0, 0xffff) + (mt_rand(0, 0xffff) << 16); | |
| $uuid['time_mid'] = mt_rand(0, 0xffff); | |
| $uuid['clock_seq_low'] = mt_rand(0, 255); | |
| for ($i = 0; $i < 6; $i++) | |
| $uuid['node'][$i] = mt_rand(0, 255); | |
| return ($uuid); | |
| } |
Insecure RNG fallback:
stormpath-sdk-php/src/Authc/Api/ApiKeyEncryptionOptions.php
Lines 48 to 50 in 62698ea
| $salt = function_exists('openssl_random_pseudo_bytes') ? | |
| openssl_random_pseudo_bytes(16) : | |
| substr(md5(uniqid('', true)), -16); |
Background: https://paragonie.com/blog/2015/07/how-safely-generate-random-strings-and-integers-in-php
Might I recommend https://github.com/paragonie/random_compat instead?