Pattern: Passwords and login

Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.

Search terms: password, login, hashing, argon2id, bcrypt, breached password, credential stuffing, lockout, rate limit, uniform error, timing

Last reviewed:

For agents

1. Problem

Login is attacked constantly: guessed passwords, passwords leaked from other sites (credential stuffing), and probing to learn which accounts exist. Weak rules, fast hashes and informative error messages each make this easier.

2. Options

Topic Option Upside Downside
Rules Length minimum, no composition rules (recommended) Matches NIST SP 800-63B-4; people choose passphrases Needs a blocklist check to catch common choices
Rules “One letter, one digit, one symbol” Familiar NIST says verifiers shall not impose composition rules; users pick predictable patterns
Hash Argon2id OWASP first choice; memory-hard Needs memory budget; library availability
Hash bcrypt Widely available 72-byte input limit; OWASP lists it for legacy systems
Blocklist Local list of common passwords No third-party call Smaller coverage
Blocklist k-anonymity range query to a breach service Very large coverage; only a hash prefix leaves your server Third-party dependency and availability
Attempts Account lockout Stops guessing on one account An attacker can lock real users out (practitioner experience)
Attempts Throttling plus layered limits No lockout abuse More tuning

Password rules

Hashing

Login

Credential stuffing

4. Scenarios and edge cases

5. Common mistakes

6. How to audit

Sources