The interview problem

Practice prompt

Build account recovery links that remain safe under retries, simultaneous clicks and leaked application logs, without revealing whether an email address is registered.

Original practice, not a reported company interview. All scenarios and worked numbers are illustrative. Interview date: not applicable. Sources retrieved September 30, 2026.

1. Scope and assumptions

Assume an existing account and email-delivery system. This guide designs the token lifecycle; it does not solve compromised email accounts or identity proofing for account ownership disputes.

2. Worked approach

recovery request
  → token hash + expiry
  → approved delivery
  → atomic reset + token consumption

Return a uniform request response and bound abuse by account and source. Generate an unpredictable token with a cryptographic random generator, store only its hash with account, expiry and use state, and send the raw token through the approved recovery channel. Construct links from configured trusted origins, not an arbitrary Host header.

On password submission, validate the token and consume it in the same transaction that changes the password. Concurrent submissions cannot both commit. Rotate relevant session/recovery state according to policy and notify the account owner of the completed change. Avoid token-bearing URLs in analytics, referrers and logs; use a restrictive recovery page with no third-party resources.

3. Calculate the example

A uniformly random 128-bit token has 2^128 possibilities. One million independent guesses against one active token have probability approximately 10^6/2^128, or 2.94 × 10^-33, before throttling. This does not protect a token copied from logs. With a 15-minute lifetime and 120 requests/minute, about 1,800 tokens could be outstanding at steady state if every request creates a new token; account-level issuance policy changes that count.

4. Failure cases and trade-offs

Checking unused status and later updating it outside a transaction allows two successful resets. Automatic link scanners may visit URLs: merely viewing the link should not change the password or consume the final action. Expired links must fail without exposing account details.

Invalidating older links on each request simplifies active-token state but lets repeated requests disrupt a user's recovery. Allowing several links improves usability while increasing active-secret surface. Decide whether the final reset invalidates every outstanding token and test it.

5. Validate the result

Submit the same token concurrently, retry after a lost response, visit via a scanner and inspect logs for raw tokens. Verify uniform account-existence responses and practical rate limits without assuming perfect timing indistinguishability.

6. Interview follow-ups and self-review

How do you recover from email delivery delays? Which sessions are invalidated after reset?

Reward atomic consumption, safe token storage, scanner-aware flow and separation of guessing risk from token leakage.

Sources and related practice

Technical reference: cheatsheetseries.owasp.org — Recovery-token and response guidance; concurrency protocol and calculations are original.

Exact publication/update date not established in this review. Retrieved September 30, 2026. This reference supports the named technical concept; the proposed workflow and examples are original, not a documented vendor implementation or interview report.

Continue with Design a distributed rate limiter; Design a notification delivery service.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.