Weak randomness (ARCH7115)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key php.security.weak-random · Severity warning · Category security · CWE CWE-338
Non-cryptographic generators like rand() or mt_rand() are predictable. Using them for values such as tokens, password reset keys, salts, or session ids lets attackers guess those values.
Incorrect
Section titled “Incorrect”<?php$token = '';for ($i = 0; $i < 16; $i++) { $token .= dechex(mt_rand(0, 15));}Correct
Section titled “Correct”<?php$token = bin2hex(random_bytes(16));Use the cryptographically secure random_bytes() or random_int() for security-sensitive values instead of mt_rand().