target://weak-crypto-reset
mediumOPEN
Predictable Reset Tokens
weak-cryptoprngauthentication
// Scenario
ResetService issues and verifies password reset tokens for user emails via create_token(email, now_ts) / createToken(email, nowTs) and verify_token(email, token, now_ts) / verifyToken(email, token, nowTs).
// The Vulnerability
- Tokens are derived from
hash(email + str(now_ts))or a predictable non-CSPRNG generator — any attacker who knows the target email and approximate request timestamp can compute the exact reset token! - Tokens never expire and can be replayed multiple times.
- Token comparison uses non-constant-time equality, and stores/checks plaintext tokens directly.
// Your Task
- Generate high-entropy CSPRNG tokens (
secrets.token_urlsafe(32)/crypto.randomBytes(32).toString("base64url")). - Store only a SHA-256 hash of the token along with
emailandexpires_at = now_ts + 900(15 minutes). - Verify using constant-time comparison on the hash, enforce expiration (
now_ts < expires_at), and invalidate the token after first successful use (single-use).
Sample Sanity Checks (1)
- Create and verify valid tokenToken created at t=1000 verifies at t=1050
Hints (0/3)
initializing editor...
[idle] Press RUN to execute visible sample checks, or SUBMIT to run hidden exploit & functionality suites.