Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Pre-Login Risk Challenge Service

Design a low-latency service that evaluates pre-login risk, orchestrates versioned challenges, and issues a short-lived proof that a login flow can consume safely.

Problem statement

For this exercise, assume a first-party login flow sends a privacy-limited risk context before checking credentials.

The service creates a stable login attempt, evaluates bounded account, network, device, and recent-attempt signals, and returns an ordered plan of zero to three challenge instances selected from a versioned catalog; CAPTCHA is one supported challenge type. A zero-challenge plan is immediately satisfied.

Otherwise, the client completes the current challenge through the service, which advances the pinned plan or returns a stable failed, expired, or retryable outcome. When the plan is satisfied, the service issues a proof bound to that login attempt and account hint.

The login service consumes the proof at most once within five minutes. Authorized operators can register immutable challenge-definition versions and activate them through a versioned risk policy without deploying the service. Retries must not create a second attempt, skip a challenge, or mint a second usable proof.

Incomplete attempt state expires after one hour. Raw challenge answers, provider secrets, credentials, and precise device or network identifiers must not appear in logs or broad analytics. Credential verification, account recovery, challenge-provider internals, and downstream session issuance are outside scope.

What to build

  1. A pre-login client can idempotently create or recover one attempt and receive an ordered plan of zero to three challenge instances selected under one pinned policy and catalog snapshot.
  2. A client can submit the current challenge result and receive a stable passed, failed, expired, or retryable outcome without skipping or completing a challenge twice.
  3. A satisfied attempt, including an immediately satisfied zero-challenge plan, yields one account-bound proof that the login service can consume at most once before its five-minute expiry.
  4. Authorized operators can register immutable challenge-definition versions, activate compatible policies, disable unsafe definitions for new attempts, and audit every configuration change.

At scale

  • For this exercise, sustain 50,000 risk evaluations per second globally and return a healthy cached-policy selection within 100 milliseconds at p95.
  • For this exercise, complete an internal challenge-state transition within 300 milliseconds at p95, excluding time spent inside an external challenge provider.
  • For this exercise, retain incomplete attempt state for one hour, expire proofs after five minutes, and retain privacy-limited decision and configuration audit metadata for 30 days.
  • For this exercise, provide 99.99% monthly availability for evaluation and challenge-state APIs while preventing an unavailable or outcome-ambiguous verifier from producing a passing proof.