SMS OTP Abuse Explained: Country Limits and Template Control Against Login Toll Fraud
Application-owned templates give a commerce team control over login messages, but that control prevents SMS OTP abuse only when the application also owns permission to send. TL;DR: enforce destination-country allowlists
Application-owned templates give a commerce team control over login messages, but that control prevents SMS OTP abuse only when the application also owns permission to send. TL;DR: enforce destination-country allowlists and shared rate limits before dispatch, bind each login challenge to a fixed template, and keep email bounce suppression separate from SMS eligibility. Template editing rights alone cannot stop toll fraud.
For a bounded incident rehearsal, I'd start with this hypothetical: a store serves US and EU shoppers, a login page requests a phone challenge, and an email receipt to the same shopper later bounces. The exercise asks whether repeated login requests can trigger more SMS sends, whether a client can select a different message template, and whether the receipt bounce incorrectly changes phone eligibility. These are proposed test conditions, not a report of a production incident.
What page fired?
That question matters more than a delivery dashboard. A postmortem needs the decision that authorized each send, the policy revision in effect, and evidence that recipient feedback reached the right suppression record. The invariant is straightforward: every dispatch must pass the same application policy, regardless of which template or recovery screen initiated it.
How do send limits prevent SMS OTP abuse and toll fraud?
A template supplies message content. It should not supply authority to send a challenge. For this design, the application selects a fixed login template after identifying the challenge purpose; the browser cannot submit arbitrary text, a template identifier, a destination country, or a delivery-channel override. That keeps a content change from becoming an accidental escape route around the login controls.
There are two distinct budgets here. RFC 4226 describes throttling verification attempts against a one-time password. The proposed dispatch budget below limits the requests that cause messages to be sent. A correct code-verification limit does not establish a bound on messages sent before verification, so the review must trace both paths. A retry button, an enrollment form, and a recovery flow all deserve that trace.
Consider a proposed commerce policy with 3 admitted dispatches per account and 10 per destination in a rolling 15-minute window, plus a separate country-wide ceiling set by the operator. These numbers are illustrative configuration, not a standard or an observed safe threshold. Account limits constrain one login; destination limits constrain repeated requests involving the same number; the country ceiling bounds aggregate authorized traffic for that market. Shared counters should reserve all applicable budgets atomically, or a concurrent burst can pass several individually correct-looking checks.
IP limits can supplement those checks. They cannot replace destination and account budgets in this design, because the store should not make the safety of a phone destination depend entirely on the request's network origin. A shared network also makes an aggressive IP ceiling a customer-access trade-off.
Own the template without giving it dispatch privileges
For template ownership, compare three arrangements: the application stores the whole message, the delivery system stores a template selected by the application, or the client supplies a template selector. The first gives the commerce team direct review of content alongside login code, with deployment work whenever that content changes. The second lets content follow a separate release process, but the application still needs an approved identifier and a record of the revision used. The third gives an untrusted caller a choice that this design does not need. Reject it. A message editor should not be able to alter country eligibility or retry policy as a side effect of publishing copy. Conversely, a security rule should not require rewriting every receipt and login template. Keep those responsibilities independently reviewable, then join their evidence at dispatch: challenge purpose, approved template revision, recipient reference, and admission decision. There is a concrete trap in the receipt path. A permanent failure for an email address can justify suppressing future email to that address under the store's policy; it does not establish anything about a phone number belonging to the same customer. RFC 3463 distinguishes success, persistent transient failure, and permanent failure in enhanced mail status codes. Treat those categories as input to an email policy, rather than collapsing every unsuccessful event into a customer-wide invalid flag.
Email feedback must stay inside the email recipient's scope.
The proposed suppression key is tenant, channel, and normalized destination. A duplicate feedback event must produce the same suppression outcome, and an older event must not silently undo a later correction. Those are requirements for the feedback consumer and its storage, not properties conferred by a template.
Put the preventative gate before dispatch
The following Go example isolates the admission decision. It deliberately delegates durable state to interfaces: the budget implementation must reserve all relevant counters atomically across workers, and the recipient implementation must use the destination's delivery country rather than an IP-country guess. Country codes and phone normalization belong to that trusted resolver. The code returns errors so the caller can stop before dispatch.
package admission
import (
"context"
"errors"
)
type Recipient struct {
Ref string // Opaque reference; keep the phone number out of logs.
Country string // Trusted, normalized destination country code.
}
type Recipients interface {
ResolveSMS(context.Context, string, string) (Recipient, error)
Suppressed(context.Context, string, string, string) (bool, error)
}
type Budgets interface {
// Atomically reserve account, destination, and country capacity.
ReserveSMS(context.Context, string, string, Recipient) (bool, error)
}
type Gate struct {
Recipients Recipients
Budgets Budgets
Countries map[string]bool // Immutable policy snapshot.
}
type Permit struct {
RecipientRef string
Template string
}
func (g Gate) Admit(ctx context.Context, tenant, account string) (Permit, error) {
if tenant == "" || account == "" {
return Permit{}, errors.New("missing identity scope")
}
r, err := g.Recipients.ResolveSMS(ctx, tenant, account)
if err != nil {
return Permit{}, err
}
if r.Ref == "" || r.Country == "" || !g.Countries[r.Country] {
return Permit{}, errors.New("destination not eligible")
}
blocked, err := g.Recipients.Suppressed(ctx, tenant, "sms", r.Ref)
if err != nil {
return Permit{}, err
}
if blocked {
return Permit{}, errors.New("recipient suppressed")
}
allowed, err := g.Budgets.ReserveSMS(ctx, tenant, account, r)
if err != nil {
return Permit{}, err
}
if !allowed {
return Permit{}, errors.New("dispatch budget exhausted")
}
return Permit{RecipientRef: r.Ref, Template: "login-otp-v1"}, nil
}
The account passed here must come from a trusted server-side login transaction, and the recipient lookup must enforce its tenant scope. The example is an admission function, not a complete authentication service: it neither generates nor verifies an OTP. It also cannot protect a sender that bypasses it. Place the gate inside the shared dispatch path and keep the permit internal.
Reservation failure stops dispatch.
That is an explicit availability trade-off: during a budget-store outage, this design refuses a new SMS rather than sending without an enforceable bound. An already enrolled alternative factor can preserve access only if its own authorization rules allow it; falling back to another paid message channel should require its own admission decision.
A successful reservation consumes capacity even if the next step fails. Releasing capacity on every ambiguous transport error would make the bound depend on whether the sender could prove what happened remotely. For a real deployment, bind a reservation and an outbound job to a challenge identifier in durable storage, define how duplicates are handled, and bound retry attempts. The small function does not implement that transaction.
Reconstruct the incident from decisions, not delivery charts
In the rehearsal, use a synthetic account and a controlled recipient reference. Exercise the fourth request after the illustrative account allowance of 3 has been consumed; it should produce a denial and no outbound job. Then attempt concurrent requests through two workers. A test that calls one process sequentially cannot establish that the shared reservation is atomic.
The feedback tests need a different assertion. Deliver a permanent email-failure fixture twice, then verify that the email suppression remains stable while SMS eligibility is unchanged. Follow with a temporary-failure fixture and check the configured retry rule. Finally, change a template revision and verify that the same admission gate still executes. This is where template ownership becomes an operational test instead of an organizational label.
Record admission and denial counts by policy reason and destination country, queue age for feedback processing, and the relationship between admitted challenges and outbound jobs. Use opaque recipient references for restricted incident investigation; avoid placing phone numbers or OTP values in metric labels. A dashboard showing completed deliveries cannot demonstrate that the application refused disallowed sends, because that question concerns decisions before delivery.
The page should identify an actionable breach: for example, a country budget exhausting while allowed traffic is being denied, or suppression feedback falling behind the team's chosen processing objective. Pick thresholds from the store's traffic and response capacity. An alert with no decision to make is another incident-response burden.
Roll out a country-policy revision as a versioned change with a rollback path, and inspect denial reasons before expanding it. Store the explicit countries served; โEUโ is a business-region description, not an individual destination-country entry. IP geolocation and destination-country policy answer different questions, so a shopper's travel location should not silently rewrite the destination's eligibility.
Where this policy stops helping
A country allowlist deliberately refuses destinations outside the supported market. It is a poor fit if the store's stated service requires those destinations, unless the access design supplies a suitable alternative. Suppression also needs a correction path: an invalid email address should lead to address correction under the email policy, not permanent loss of every login channel.
These controls bound dispatch under a chosen policy; they do not prove that a requester is the account owner or that a phone number is trustworthy. Challenge verification, enrollment, and recovery still need their own review. Keep the postmortem question narrow enough to answer: which approved template was used, which policy authorized the send, and did recipient feedback affect only the intended destination? That evidence is the useful outcome of owning the template.
References
RFC 4226 supplies the distinction between OTP verification and verification throttling. RFC 3463 supplies email delivery-status categories. The email-service overview and messaging-industry resource provide channel context; they do not establish the illustrative limits or the proposed architecture.
- RFC 4226: https://www.rfc-editor.org/rfc/rfc4226
- RFC 3463: https://www.rfc-editor.org/rfc/rfc3463
- Email service overview: https://docs.aws.amazon.com/ses/latest/dg/Welcome.html
- Messaging interoperability and compliance: https://www.ctia.org/the-wireless-industry/industry-commitments/messaging-interoperability-sms-mms
Sources
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.