1,744 verification codes for 3 real sign-ins (my first real bill as a solo dev)

by•

Let's start from the fact that I build my app alone and people sign in with their phone number, which looked like the simplest choice (it was, until the bill). In nine days the verification SMS cost me €57: 1,744 code requests and only 3 of them from real people. The rest was SMS pumping, bots asking codes for numbers that earn on every message.

The problem was in how my backend validated the SMS requests. Now there are limits per number, prefix and origin and the codes go only to the countries where I have users. I got the €57.24 back (this time I was lucky).

What still bothers me is the next step, every new country I open is one more door to watch. Anyone running SMS verification on a small product: what check saved you?

18 views

Add a comment

Replies

Best

The check that saved me was putting a cheap invisible challenge (Turnstile or similar) in front of the send-code endpoint, so a script has to load the page before it can ask for an SMS. Pair that with a cooldown that grows per number and per IP, and alert yourself when code requests per hour jump past what your real sign-up rate could ever explain. If most of your users can use email, offering a magic link as the default and SMS as the fallback also shrinks the door you have to watch with every new country.

We don't use SMS at all: sign in is an emailed link, Google or Apple, so an abused request costs us an email rather than a paid message. The endpoint that sends the link still has guards, though. Five mails per address per hour, and the request is expected to carry proof that it comes from our real app (Firebase App Check). We couldn't make that proof mandatory, because some real Android phones never get an attestation token and the link is their only way in. So a request without it still goes through, but all such requests share one budget of 100 a day, which means a script holding our keys can never get more than that, however many addresses it tries. For SMS I'd copy that split: traffic that proves it's your app gets the normal per number limits, anything that can't prove it shares one small daily budget, and you get told when that budget runs out.

Ouch, €57 in nine days for 3 real people. Glad you got it back.

Every login screen I build counts attempts by account and by IP and locks after 5 tries. Your per-number limit is the same idea. Mine waits 1 minute after the first lock, then 5, 15, 60, so a bot gets slower every round.