A password is hashed with a fast general-purpose hash
What it finds
md5($password): MD5 and SHA-1 are fast, so an attacker who gets the stored hashes can try billions of passwords per second, and unsalted ones fall to lookup tables. Passwords belong in password_hash. A hash is reported when what it hashes is named like a password. Code that checks or upgrades old hashes uses these on purpose, so the rule is not in the default set.
From the rule's source, weak_password_hash.rs.
<?phpfunction store($password, $file){ $a = md5($password);tx0 reports: a password is hashed with md5 $b = hash('sha1', $password . 'salt');tx0 reports: a password is hashed with sha1 $c = md5_file($file); $d = sha1($file); $e = password_hash($password, PASSWORD_DEFAULT); return [$a, $b, $c, $d, $e];} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/php:weak-password-hash" = "error"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/php:weak-password-hash] reason="..."tx0 explain tx0/php:weak-password-hash shows the same in the terminal. Found a false positive? Report it.