Go Backend API Evidence for React Native SMS OTP Recovery (3 Suppression Controls)
Consider the page a property-management platform should be able to raise: a React Native mobile app completed SMS OTP administrator recovery, but its backend sent the security notice to an email address already marked in
Consider the page a property-management platform should be able to raise: a React Native mobile app completed SMS OTP administrator recovery, but its backend sent the security notice to an email address already marked invalid. The on-call needs the challenge identifier, notice identifier, destination version, and suppression decision together. A green SMS delivery indicator cannot explain why an invalid mailbox was selected.
TL;DR: use a server-owned SMS OTP challenge and a versioned suppression ledger, joined by one recovery event identifier. For a mobile app, autofill is a convenience; verification, resend eligibility, and evidence of the notice decision belong in the backend. The least complex useful design is an existing transactional database plus an outbox, with three explicit controls: challenge validity, recipient eligibility, and recorded dispatch authorization. Treat these as proposed controls, not evidence that a deployment already meets a legal obligation.
Preserve the evidence.
The property-management case makes the distinction practical: restoring access for a SaaS administrator may trigger a security notice, while that administrator's email address may have a previous permanent delivery failure. Suppressing that address must not silently mark the notice delivered, and an email bounce must not automatically invalidate the administrator's separately enrolled telephone number. Those are different destinations with different evidence.
What signal should have fired before the recovery page?
Work backward from that hypothetical page. The earlier signal is a notice authorized against an obsolete recipient decision, or an unprocessed delivery event old enough that the eligibility check cannot be trusted. Counting bounced messages alone misses both conditions, especially if no new send occurs after an address becomes invalid.
SMTP distinguishes temporary failures from permanent failures; enhanced status codes add a class, subject, and detail. RFC 5321 and RFC 3463 provide the vocabulary, but a broad permanent-failure class does not prove that a mailbox is nonexistent. A policy rejection and an invalid destination require different operational treatment. Persist the original status and its normalized interpretation, and make the rule that creates a suppression reviewable. Google's sender guidelines also make bounce handling and recipient hygiene relevant to deliverability, though those guidelines do not establish compliance for an administrator recovery workflow.
A useful proposed record links property account property-17, administrator admin-42, challenge challenge-8, notice notice-9, and email destination version 4. These are illustrative identifiers. Record the delivery event's source identifier, event time, ingestion time, classification rule version, and the resulting eligibility decision. Avoid putting the OTP or complete destination into logs; use an internal destination identifier and restrict access to the underlying contact record.
The evidence is the decision history. A dashboard total is only an index into it.
A compliance reviewer needs to distinguish a notice never requested, a notice deliberately suppressed, a submission accepted for delivery, and an outcome reported later. None of those states proves that the administrator read the notice. Define the retention period, access permissions, and correction process with the people who own the applicable obligations instead of treating an indefinitely retained log as inherently sufficient.
How should a React Native mobile app authorize SMS OTP recovery?
The mobile app can request a challenge, submit the entered code, and request a resend. Its UI should show the backend's retry time and a masked destination already enrolled for the administrator. React Native exposes text-input properties for OTP autofill, with platform-specific behavior documented in its TextInput reference. Autofill supplies input; it must travel through the same verification operation as a code typed by hand. Don't turn receipt of a message into automatic administrative access.
For a concrete backend API example, define three operations in prose: create a recovery challenge, verify a challenge, and request another delivery for that challenge. A successful create response carries an opaque challenge identifier, an expiry time, and a retry time. A verification request carries that identifier and the submitted code. A resend response updates the delivery state and retry time without extending the original recovery window. Keep account-existence responses generic, including the path where no eligible destination exists.
Use server time.
For this example, the challenge expires after five minutes, and a repeat SMS request must wait 60 seconds; validate both policies against delivery latency and the administrator support process. They aren't measured performance or universal safe defaults. NIST's authentication guidance treats PSTN-based out-of-band authentication as restricted and calls for controls including rate limiting and one-time acceptance; an organization must assess whether this channel is appropriate for privileged recovery at all. A lost-phone recovery route needs separate identity assurance and audit evidence. Allowing an unauthenticated caller to replace the enrolled number defeats the boundary.
The backend should generate codes with a cryptographically secure random source and protect the stored verifier against offline guessing; a keyed verifier with its key held separately is one possible design. Verification must atomically consume the challenge on success, reject expiration, and debit the attempt budget on failure. Resending must not reset that budget. Limit both verification and issuance across the account, destination, and network signals, because an attacker can distribute requests across challenge identifiers or IP addresses.
Make the three checks visible in the Go backend
The following Go example isolates the resend policy so its inputs can be logged as a decision. It assumes an authenticated internal caller has loaded the challenge and the eligibility of its enrolled SMS destination. Email suppression is evaluated separately when authorizing the recovery notice. The function neither verifies an OTP nor provides a complete abuse limiter.
package recovery
import "time"
type Challenge struct {
ExpiresAt time.Time
NextSendAt time.Time
Consumed bool
AttemptsLeft int
SendsLeft int
}
type ResendDecision struct {
Allowed bool
Reason string
}
func DecideResend(
now time.Time,
c Challenge,
smsEligible bool,
abuseAllowed bool,
) ResendDecision {
switch {
case c.Consumed:
return ResendDecision{Reason: "challenge_consumed"}
case !now.Before(c.ExpiresAt):
return ResendDecision{Reason: "challenge_expired"}
case c.AttemptsLeft <= 0 || c.SendsLeft <= 0:
return ResendDecision{Reason: "budget_exhausted"}
case !smsEligible:
return ResendDecision{Reason: "destination_ineligible"}
case now.Before(c.NextSendAt):
return ResendDecision{Reason: "retry_later"}
case !abuseAllowed:
return ResendDecision{Reason: "abuse_limit"}
default:
return ResendDecision{Allowed: true, Reason: "authorized"}
}
}
The dangerous gap is between returning authorized and submitting a message. Two workers can both pass this function against the same snapshot. In the real handler, serialize the challenge update, reserve the applicable abuse budgets, decrement the send budget, set the next retry time, and insert the outbound intent in one transaction or an equivalent coordinated reservation protocol. An outbox worker can then process that intent. Record the destination version and policy version used for authorization so a later reviewer can reconstruct the decision.
An outbox doesn't by itself create exactly-once external delivery. A timeout can leave submission ambiguous, so use transport idempotency where supported and otherwise retain an explicit unknown state for reconciliation. Blindly retrying an ambiguous SMS submission can deliver duplicates and spend the administrator's remaining patience.
Delivery feedback needs its own boundary: authenticate incoming events using the transport's documented mechanism, deduplicate by source event identity, and preserve both occurrence and receipt times. A delayed success must not erase a newer suppression decision merely because its webhook arrived last. Define precedence for conflicting events and retain corrections as new decisions. For an email recipient correction, verify the corrected address under the account's recovery policy before lifting suppression; repeating a failed send isn't verification.
Instrument evidence before choosing an operating model
Add a structured authorization event to each outbound intent, then connect it to subsequent delivery feedback. Measure the age of the oldest unprocessed feedback, the count of notices blocked by suppression, and the fraction of dispatch decisions with complete evidence. Keep account and challenge identifiers in access-controlled logs or traces rather than metric labels; unrestricted identifier cardinality makes capacity planning harder while exposing unnecessary detail.
A proposed evidence SLO is that 99.9% of recovery notice decisions become queryable with their policy and destination versions within 60 seconds. That is a design target, not a reported result. Define the denominator to include suppressed decisions and processing failures, or the system can appear healthy while the most interesting records disappear. Separately monitor delivery and successful verification. Evidence availability cannot stand in for either.
For capacity planning, estimate event ingestion from peak authorized sends multiplied by observed feedback events per send, then account for retries and replay. Size the backlog for an outage and measure the drain rate before adopting the SLO. The example's resend interval alone cannot bound traffic across a portfolio of properties or distributed attackers.
| Operating choice | Evidence boundary to verify | On-call and ownership trade-off |
|---|---|---|
| Managed delivery with an application-owned ledger | Submission identifiers, feedback authentication, retention and export guarantees | Less transport work; the platform still owns suppression policy and reconciliation |
| Self-hosted delivery and an application-owned ledger | Queue durability, delivery-status processing, retained decision history | More control over raw events; transport operations and reputation become team responsibilities |
| Managed delivery with periodic evidence exports | Export delay, missing-event detection, correction history | Simpler ingestion initially; the evidence SLO is constrained by export behavior |
Buy versus build starts with who can explain a missing notice during an audit. Evaluate operational staffing, integration maintenance, retention costs, and the ability to move the ledger without losing event meaning. No transport purchase transfers the application's responsibility for authorizing recovery.
Before deployment, replay synthetic duplicate, delayed, and out-of-order feedback; run concurrent resend requests; and verify the exact expiry boundary. Test that a permanently invalid email blocks the email notice without altering SMS eligibility, and that a suppressed notice still produces a queryable decision. Roll out classification changes against recorded events before letting them change recipient eligibility. A rule that increases suppression should be explainable by status category and reviewed examples.
Close the alert loop carefully. Page on an evidence gap that threatens the agreed SLO, while routing isolated suppression decisions into a review queue unless the business impact justifies waking someone. An aggressive bounce threshold can suppress valid contacts after temporary failures; an aggressive SMS abuse threshold can strand an administrator during recovery. Those false positives create manual identity checks and delayed access, so measure review volume and confirmed erroneous suppressions alongside the original alert. The threshold is acceptable only when the team can defend both the missed-event risk and the cost of blocking a legitimate administrator.
References
The SMTP specifications support delivery classification; the sender guidelines cover deliverability expectations. Authentication and client-input references support separate parts of the recovery flow. The transaction design, sample identifiers, intervals, and SLO above are proposed implementation choices.
- SMTP delivery and reply semantics: https://www.rfc-editor.org/rfc/rfc5321
- Enhanced mail system status codes: https://www.rfc-editor.org/rfc/rfc3463
- Email sender guidelines: https://support.google.com/a/answer/81126
- Authentication and out-of-band requirements: https://pages.nist.gov/800-63-4/sp800-63b.html
- Mobile text input and autofill properties: https://reactnative.dev/docs/textinput
Further reading
- SMTP delivery and reply semantics: https://www.rfc-editor.org/rfc/rfc5321
- Enhanced mail system status codes: https://www.rfc-editor.org/rfc/rfc3463
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.