JAVA-051 / Advanced
Plaintext password-reset tokens with no expiry
Why is this a problem?
A DB leak enables immediate account takeover, and tokens without expiry can be reused for a long time.
How to fix it
java
String raw = randomToken(32);
resetRepo.save(new ResetToken(email, sha256(raw), Instant.now().plus(Duration.ofMinutes(15))));
// Include only the raw token in email; delete immediately after use