InBrott
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

  1. 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!
  2. Tokens never expire and can be replayed multiple times.
  3. Token comparison uses non-constant-time equality, and stores/checks plaintext tokens directly.

// Your Task

  1. Generate high-entropy CSPRNG tokens (secrets.token_urlsafe(32) / crypto.randomBytes(32).toString("base64url")).
  2. Store only a SHA-256 hash of the token along with email and expires_at = now_ts + 900 (15 minutes).
  3. 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 token
    Token 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.