Weak Password Hashing

User passwords are stored with a fast or unsalted hash such as MD5, SHA-1 or SHA-256, so they can be recovered quickly by offline cracking from a copy of the database.

SeverityHigh
CVSS 3.17.4 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N Open in the calculator
CVSS 4.09.1 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-916: Use of Password Hash With Insufficient Computational Effort
OWASP Top 10A04:2025 Cryptographic Failures
MITRE ATT&CKT1110.002 Password Cracking, T1078 Valid Accounts
CategoryCryptographic Failures

Description

Passwords should be stored with a deliberately slow, salted password hashing function, so that recovering them from a stolen copy of the database is costly. The application stores them with a general-purpose hash function such as MD5, SHA-1 or the SHA-2 family, without a salt, with one salt shared by all accounts or with too few iterations, or it uses a suitable function such as bcrypt or PBKDF2 with a work factor far below current guidance.

General-purpose hashes are designed to be fast, and current graphics hardware can test billions of MD5 or SHA-1 candidates per second. An attacker who obtains the password hashes, through SQL injection, a backup, a compromised server or an insider, can therefore recover a large proportion of real passwords offline with dictionary and rule-based attacks, with no interaction with the application that could be detected or rate limited. Without a unique salt per password, identical passwords produce identical hashes and precomputed tables can be used.

Recovered passwords give access to the corresponding accounts, including administrative ones, and, because passwords are widely reused, often to the same users' accounts on other services and on the organisation's other systems. The weakness needs a separate compromise of the stored hashes first, but it decides how much damage such a breach does.

The weakness is usually identified when password hashes become visible during testing: through database access gained by another finding, backups or exports, API responses, the configuration of the identity store, or source code review. Hash formats are recognisable by length and prefix: 32 hexadecimal characters for MD5, 40 for SHA-1 and 64 for SHA-256, compared with self-describing formats such as $2b$ for bcrypt or $argon2id$ for Argon2id. Cracking a sample with a tool such as hashcat or John the Ripper shows the practical risk.

Remediation

Move to a password hashing function designed for the purpose, with a unique salt per password and a work factor set from current guidance:

  • Use Argon2id where it is available; otherwise scrypt, bcrypt (which uses only the first 72 bytes of a password), or PBKDF2 with HMAC-SHA-256 where a FIPS-approved algorithm is required. Use the parameters recommended in the OWASP Password Storage Cheat Sheet, and raise them over time as hardware improves.
  • Use the platform's maintained implementation, such as password_hash() in PHP, the ASP.NET Core Identity password hasher, Spring Security's password encoders or a maintained Argon2 or bcrypt library, rather than building a scheme from hash primitives.
  • Protect existing hashes without waiting for users: wrap each legacy hash in the new function (for example, store the Argon2id hash of the existing MD5 hash), then replace it with a direct hash of the password the next time the user signs in.
  • Optionally add a pepper, a secret key held outside the database, for example in a hardware security module or key vault.

If the existing hashes may have been exposed, require password resets and treat the passwords as compromised. Confirm the fix by checking that newly stored hashes use the chosen algorithm, a unique salt and the intended work factor, and that no unwrapped legacy hashes remain.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Authentication and Sessions Findings

Every Authentication and Sessions finding