Weak password hashing

Weak password hashing

Description

Storing passwords with fast hashes such as md5, sha1 or a general-purpose hash makes them vulnerable to offline guessing attacks.

Potential impact

If hashes are exposed, attackers may recover passwords quickly.

Remediation

Use password_hash and password_verify with PASSWORD_DEFAULT or supported PASSWORD_ARGON2ID.

Examples

Before

php
<?php
$hash = md5($password);

After

php
<?php
$hash = password_hash($password, PASSWORD_DEFAULT);

password_hash creates the stored hash using PASSWORD_DEFAULT. At login, use password_verify to check the submitted password against that hash.

References