Description
Fast hashes such as SHA-2 and SHA-3 remain unsuitable for password storage even when they resist collisions. Their low computational cost makes offline password guessing inexpensive.
Potential impact
- Lower password-cracking costs
- Increased chance of recovering passwords from leaked hashes
- Account takeover and authentication bypass
Remediation
Use Argon2id, scrypt or PBKDF2 for password storage, or bcrypt where an existing system requires it. Give each password hash a fresh, cryptographically random salt. Set the work factor for your environment and review it periodically. Keep general integrity hashes separate.
Examples
Before
swift
let passwordHash = SHA512.hash(data: passwordData)
After
swift
let result = try Argon2Swift.hashPasswordString(password: password, salt: salt)
Argon2Swift.hashPasswordString takes the password and a salt. The call leaves the Argon2 variant and cost at the library defaults. Set them explicitly to match your policy.