Concurrency & payments · Design under changing requirements
The one-time code that wasn't
Design sign-in with a 6-digit code sent by SMS. Then: what does your design do when someone attacks it, or the SMS provider fails?
Design review · auth-serviceIllustrative scenario, not a real incident
Security review: the sign-in code design is blocked until six findings are answered
Today POST /otp/send makes a code with new Random().nextInt(1_000_000), stores it in the otp_codes table with a 5-minute expiry, and calls one SMS provider directly. POST /otp/verify reads the code, compares it, then deletes it.
Product wants WhatsApp and email next month. The big sale is in three weeks, and the last one came with a 20-minute SMS provider outage.
What the dashboards and logs show
- Code
- 6 digits from java.util.Random, valid 5 minutes
- Storage
- otp_codes table: phone, code in plain text, expires_at
- Limits
- 10 verify requests a second per IP at the gateway
- Delivery
- one SMS provider, called inside the request
Clarify · optional · scored under "Hypothesis before change"
Ask the interviewer
0 of 3 asked
Each question reveals a fact. What you ask before you act is part of your score.
First move · scored under "Mitigate before root cause"
The sale is in three weeks and the review is blocking. What do you change first?
Your rubric score, the model answer, the follow-up questions and the related lessons appear once you have answered the last step.