Menu

How to Rate-Limit OTP Requests for SMS-Based 2FA in Node.js: Delivery Reliability
📰

How to Rate-Limit OTP Requests for SMS-Based 2FA in Node.js: Delivery Reliability

DEV Community: backend·SolomonFletcher5872·16 days ago
#O4cCHlU2
#devtobackend#devto#dev#self#request
Reading 0:00
15s threshold

Short answer: to rate-limit OTP requests for SMS-based 2FA in Node.js, put the limit in your backend before you ask an SMS provider to send anything. Count requests by normalized phone number and login session, enforce a fixed window, then add progressive backoff for repeated denials. The provider route is the delivery boundary; it should never be your abuse-control system.

For a password-reset message with a short expiry, delivery reliability is the decision axis. A fast SMS that can be requested 40 times in a minute is not reliable for the account, the carrier, or the bill. In a Node.js service, I model the workflow as two separate decisions: may this identity request another code, and did the delivery service accept the permitted request? Keeping those decisions separate makes provider changes much less disruptive.

Infrai belongs at that second boundary, not in the security policy.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.