Description
Applying SHA-256 directly to a password or setting too few iterations in a password hasher makes guesses cheap to check against leaked hashes.
Potential impact
A recovered password can give someone access to the user’s account and its privileges.
Remediation
Use ASP.NET Core PasswordHasher or a dedicated scheme such as bcrypt, Argon2id, scrypt or PBKDF2. Use a fresh salt per password and set an adequate work factor.
Examples
Before
csharp
return SHA256.HashData(Encoding.UTF8.GetBytes(password));
After
csharp
var hasher = new PasswordHasher<User>();
return hasher.HashPassword(user, password);
PasswordHasher<User>.HashPassword generates a fresh salt and includes it in the result. Store the returned value.