Fix it in your stack

Tested fixes for CWE-916 in Express, Flask, Spring Boot, ASP.NET Core, FastAPI, Django, net/http and Laravel: the vulnerable code, the fix, a plausible fix that still fails, and the regression tests.

Definition

MITRE’s description of CWE-916: The product generates a hash for a password, but it uses a scheme that does not provide a sufficient level of computational effort that would make password cracking attacks infeasible or expensive.

Common consequences MITRE lists

  • Access Control: Bypass Protection Mechanism; Gain Privileges or Assume Identity

Why it matters

After a database leak, fast hashes let attackers test billions of guesses per second on GPUs, recovering most passwords and enabling credential stuffing elsewhere.

How to prevent it

  • Use a slow, salted password hashing function. OWASP’s Password Storage Cheat Sheet recommends Argon2id with at least 19 MiB of memory, 2 iterations and parallelism 1.
  • Where Argon2id is unavailable, OWASP gives minimums for scrypt (N=2^17, r=8, p=1), bcrypt (work factor 10 or more, with input limited to 72 bytes) and, for FIPS-140, PBKDF2-HMAC-SHA-256 with 600,000 iterations.
  • Store the algorithm and parameters with each hash, benchmark them on your hardware, and upgrade old hashes when users next sign in.

Guides on this site

Practice

References

  1. CWE-916 in the MITRE CWE list (version 4.20)
  2. OWASP Password Storage Cheat Sheet

List data from MITRE; the name, definition and consequences are from MITRE’s CWE 4.20 catalogue. A guide is listed as the main subject when the weakness is what the guide is about, and as covering it when a dedicated section or worked example addresses it.

CWE content: Copyright © 2006–2026, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. CWE™ is free to use by any organization or individual for any research, development, and/or commercial purposes, per these CWE Terms of Use. Accordingly, The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. Any copy you make for such purposes is authorized on the condition that you reproduce MITRE’s copyright designation and this license in any such copy. CWE is a trademark of The MITRE Corporation. CWE Terms of Use.