phanalist

E0057: MD5 or SHA1 Used for a Password

In plain English: MD5 and SHA1 are fast hash functions. Password hashes need to be slow, so an attacker cannot try billions of guesses quickly. MD5 and SHA1 are also unsalted by default, which makes them cheaper to crack.

Why it matters: If a password database leaks, fast unsalted hashes can be reversed or cracked at scale.

Bad

return md5($password);
return sha1($user->password);
return hash('md5', $password);

Good

$hash = password_hash($password, PASSWORD_DEFAULT);

if (password_verify($password, $hash)) {
    // Password is correct.
}

password_hash() adds a salt and uses a deliberately slow algorithm. password_verify() checks the password without re-hashing it yourself.

What the rule checks

When it does not report

How to fix

Model limits

Configuration

E0057 has no configuration options and is enabled by default.