TL;DR: A secure SMS OTP login flow should decide whether a recipient is eligible before it creates more delivery work. For an edtech SaaS operating in the US and EU, that means one durable suppression record for invalid destinations, layered rate limits for sends and guesses, one current challenge per login intent, and an atomic consume operation that makes replay lose. Retries can improve delivery reliability, but only inside those boundaries; otherwise every delayed or failed message becomes a reason to increase traffic precisely when the delivery path is least trustworthy.

Consider a bounded, hypothetical enrollment incident. At 08:00, guardian logins rise sharply, a batch of imported phone numbers includes malformed or unreachable destinations, and delayed messages cause people to press Resend. The visible symptom is “codes are not arriving,” but treating the event as a transport shortage is the wrong diagnosis. More sends increase queue depth, duplicate late codes, and spend capacity on recipients already known to be invalid. The invariant is eligibility before issuance: a request may produce a new challenge only after suppression, lockout, and rate-limit decisions agree that another attempt is allowed.

I use that invariant because it gives the on-call engineer a decision that remains valid during partial failure. It also changes the order of the design. Start with the evidence that should stop a send, then allocate scarce send capacity, and only then discuss code verification. Authentication state still matters, but it cannot repair an admission policy that keeps feeding bad work into the system.

How should a secure SMS OTP login flow treat retries?

“Bounce” is email vocabulary, yet the operational problem applies to SMS: an asynchronous delivery outcome can show that a destination is invalid or unreachable after the application accepted the request. That outcome is transport evidence. It does not prove who owns an account, and it must never grant or deny a session by itself, but it can make another immediate send ineligible.

Keep three records separate: the login intent, the OTP challenge, and the destination’s delivery eligibility. A login intent identifies the subject and purpose. A challenge carries the verifier state, expiry, remaining attempts, and consumed status. The eligibility record holds normalized delivery outcomes and the policy decision derived from them. Combining these records makes a callback capable of corrupting authentication state; ignoring the third record makes Resend a bypass around known failure evidence.

The external response should not reveal whether a number exists, is suppressed, is locked, or was accepted for delivery. Internally, those reasons must remain distinct enough to operate. A terminal invalid-destination result can suppress future sends until a controlled correction or revalidation changes the record. A transient or unknown outcome should not be promoted to permanent suppression, but neither should uncertainty automatically launch a duplicate message. Callback processing must be idempotent because repeated evidence should not repeatedly mutate counters or reopen eligibility. Walk the enrollment example through that rule: the first request creates an intent only after admission; a later terminal outcome closes delivery eligibility for that normalized destination; the learner's next button press receives the same non-enumerating response but creates no transport job; and a correction workflow, operating under separate authorization, can replace the destination and record why eligibility changed. None of those steps treats a carrier callback as proof of identity. That separation is tedious to model, yet it prevents the tempting shortcut in which a callback handler edits the active challenge, resets its attempt counter, or quietly issues another code.

Stop there.

This is where delivery reliability becomes a stricter concept than provider acceptance. The useful outcome is an eligible learner or guardian completing one authorized login, not the application accumulating accepted send requests. An SLO based only on request acceptance rewards the system for producing traffic. An SLO based on successful verification, with suppression and retry reasons alongside it, exposes the failure mode that users actually experience.

Budget capacity for abuse and bad data

Capacity planning should begin with denied work. For every successful login, the system may receive initial send requests, resend requests, incorrect guesses, delivery callbacks, suppression lookups, and replays. During enrollment, legitimate bursts and hostile automation can look similar at the front door, so a single per-IP counter is not an adequate boundary.

Use independent budgets for the destination, account or login intent, source, and regional system. The exact numbers are policy inputs, not universal security constants. A concrete planning example can still be useful: if a region is provisioned for 100 send decisions per second and the admission layer reserves all 100 for fresh messages, there is no headroom for callback processing or verification traffic during a burst. That is a capacity allocation error, not evidence that every learner needs a more generous retry count.

The failure policy deserves an explicit SLO review. If the distributed limiter is unavailable, failing open removes the bound on message generation and guesses; failing closed can block legitimate access. I would allow verification of already-issued challenges only while the authoritative challenge store can still enforce attempts and atomic consumption, while deferring new issuance when its rate and suppression controls cannot be trusted. The trade-off is deliberate: preserve bounded work already admitted, but do not create unbounded downstream work.

Bursts happen.

Budgets still apply.

Measure send decisions, suppressed decisions, transient and terminal delivery outcomes, invalid submissions, lockouts, expirations, successful consumes, and rejected replays separately. “Sends per successful verification” is a useful saturation signal because it rises when retry amplification outruns completed authentication. Do not use full phone numbers as metric labels or put OTP values in logs. High-cardinality recipient labels make operations harder and expose data that the reliability dashboard does not need.

Decision Build in the application External dependency may supply SLO question
Recipient eligibility Suppression policy, audit, reactivation Delivery outcome evidence Are known-invalid destinations creating sends?
Admission Account, destination, source, and regional budgets Network or reputation signals Can loss of a limiter create unbounded work?
Verification Purpose binding, attempts, expiry, atomic consume None Can two submissions grant two sessions?
Transport Idempotent request identity and normalized outcomes Carrier delivery path Does retry traffic crowd out fresh logins?

Make replay a losing database transaction

SMS codes have a small output space, so guessing must be rate-limited. NIST SP 800-63B requires rate limiting when an authenticator output has less than 64 bits, requires an out-of-band secret to be accepted only once, and treats PSTN out-of-band authentication as restricted. Those requirements point to server-side state, not a self-contained token the client can replay until it expires.

Store a keyed digest of the code rather than the code itself. Bind it to a server-selected challenge identifier, subject, purpose, expiry, attempt budget, and status. The client may present the opaque challenge identifier and submitted code; it must not choose the account, purpose, or counter scope during verification. Compare digests in constant time, update failed-attempt state atomically, and make success a conditional transition from pending to consumed.

The critical path is deliberately small:

package otp import ( "context" "errors" "time" ) var ErrDenied = errors.New("verification denied") type Store interface { DestinationEligible(ctx context.Context, normalized string) (bool, error) AllowIssue(ctx context.Context, subjectID, normalized string, now time.Time) (bool, error) ConsumeIfValid(ctx context.Context, challengeID, subjectID, purpose, digest string, now time.Time) (bool, error) } type Service struct { store Store now func() time.Time } func (s *Service) Verify(ctx context.Context, id, subject, purpose, code string) error { digest := keyedDigest(code) // Implement with a protected server key. ok, err := s.store.ConsumeIfValid(ctx, id, subject, purpose, digest, s.now()) if err != nil { return err } if !ok { return ErrDenied } return nil } 

ConsumeIfValid must be one database decision: pending, unexpired, correctly bound, within the attempt budget, digest matched, then consumed. Reading a row, checking it in application memory, and later writing consumed leaves a race in which two correct submissions can both appear successful. Replacing a challenge on resend must likewise invalidate the older pending challenge within the same authoritative boundary. Late code A should not regain validity merely because it arrived after replacement code B.

Test the races, not only the happy-path screen. Submit the same correct code concurrently; submit the old code after replacement; cross the expiry boundary; rotate sources while targeting one destination; repeat the same terminal delivery event; and confirm that a suppressed destination creates no transport work. The expected result in each test should be a state transition and an audit reason, not a provider response string.

Buying transport does not outsource the security boundary

The buy-versus-build question is narrower than it first appears. A managed transport can connect to carriers and report delivery evidence, while a self-hosted gateway can change the cost, control, and on-call profile. Neither option knows the application’s subject, login purpose, active challenge, or session-grant rule. Those remain application-owned boundaries.

Choice On-call effect Lock-in surface What still must stay local
Managed transport Less carrier integration, more dependency semantics to learn Request, callback, and outcome vocabulary Admission, suppression policy, challenge state, replay defense
Self-hosted transport More carrier and delivery-path operations Infrastructure and telecom integrations Admission, suppression policy, challenge state, replay defense
Thin transport adapter Adds mapping and conformance tests Internal outcome schema Every authentication decision

The adapter earns its keep only if it normalizes outcomes without pretending they are identical. Preserve the original evidence for audit under appropriate retention and access controls, but let policy consume a small internal vocabulary such as terminal, transient, and unknown. For US and EU operation, minimize where phone data travels, protect destinations in storage and transit, restrict lookup access, and keep authentication audit events separate from raw delivery payloads. These are system design choices; switching a message sender does not make them disappear.

There is also a standards boundary worth stating plainly. DKIM, defined by RFC 6376, authenticates domains associated with email messages. It does not secure an SMS OTP flow. A platform that handles both email and SMS suppression should share policy concepts where useful, but it should not transfer an email authentication mechanism into the SMS threat model.

Where does this design stop?

This design does not make SMS phishing-resistant, and extra retries or longer lockouts cannot change the assurance properties of the channel. NIST identifies risks around PSTN delivery, including SIM changes and number porting, and its restricted classification means the risk assessment and available alternatives need active review. Where the required assurance exceeds what SMS can support, use an authenticator appropriate to that requirement instead of stretching the retry policy.

Nor should suppression become an irreversible punishment for a person who corrected a mistyped or recycled number. Reactivation needs an audited path that does not rely on the suppressed channel proving itself. The precise workflow depends on the account recovery model, but pressing the retry control is not that workflow.

Protect the send boundary first. Suppression removes known-bad work, layered admission keeps retries inside a capacity envelope, and atomic consumption makes a captured or duplicated code lose after first use. Together they support the operational goal that matters during enrollment: eligible users can complete one login while bad data, delayed transport, and hostile traffic remain bounded enough for the on-call team to reason about.

Sources