Account recovery does not leak user information
Why it matters
Predictable recovery tokens (generated with Math.random, timestamps, or sequential IDs) can be brute-forced or guessed, giving attackers account recovery capability without the victim's involvement. CWE-640 (Weak Password Recovery) and CWE-338 (Use of Cryptographically Weak PRNG) both apply. Disclosing account email or username on the reset confirmation page before the token is validated reveals account existence and PII to anyone with a guess-and-click workflow. OWASP A07 covers both weak token generation and information disclosure during recovery as authentication failures.
Severity rationale
Medium because successful exploitation requires either guessing a valid token or having prior access to a reset link, but weak random generation significantly reduces the guessing effort.
Remediation
Use crypto.randomBytes for all recovery tokens — this is the only acceptable random source for security-sensitive values:
// Correct: 256 bits of cryptographic randomness
const token = crypto.randomBytes(32).toString('hex')
// Wrong — do not use either of these:
const token = Date.now().toString() // Predictable
const token = Math.random().toString(36).slice(2) // Not cryptographically secure
On the reset confirmation page, show only a generic 'Enter your new password' form — do not display the account email, name, or any other identifying information before the token is validated and the new password is submitted. Confirm success with a generic message, then redirect to login.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Authentication Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-640 — Weak Password Recovery Mechanism for Forgotten Password
- cwe · CWE-338 — Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
- owasp:2021 · A07
- nist:rev4 · SP-800-63B §5.1.1.2 — Memorized Secret Verifiers
Taxons
History
- 2026-04-18·v1.0.0·Initial import from saas-authentication·automated