ECSEXCELON CYBER SOLUTIONS

Missing Rate Limiting: How Login, OTP and Reset Endpoints Get Brute-Forced

Why endpoints without rate limits fall to brute force and OTP abuse, how testers prove it safely, and how to add per-account and per-IP limits that hold up.

By Excelon Cyber Solutions Security Team4 min read

Rate limiting is the control that stops an attacker from asking the same question a million times. When a login, OTP or password-reset endpoint has no limit, a four-digit code is a ten-thousand-guess puzzle, and a script solves it in minutes. This post explains how the gap appears, how a tester demonstrates it without harming anyone, and how to fix it properly.

Key takeaways

  • A secret with a small search space (a 4 or 6 digit OTP, a short reset code) is only safe if the server limits how many guesses are allowed.
  • Limit by the account being attacked as well as by IP address; attackers rotate IPs but cannot rotate the victim.
  • Return 429 Too Many Requests with a Retry-After header, and make the code expire after a few failed attempts.
  • Limits belong on the server. A CAPTCHA or a disabled button in the browser is not a control.

Where missing limits show up

  • Login forms, which allow password guessing and credential stuffing.
  • OTP and verification codes for sign-in, payments or phone and email confirmation.
  • Password reset codes and "forgot password" email triggers.
  • Coupon, promo-code and gift-card checks, which let an attacker enumerate valid codes.
  • Public search and lookup APIs, which allow bulk scraping of user data.

How a tester proves it

The aim is to show that the server keeps answering, not to take over a real account.

  1. Create two test accounts you own.
  2. Request an OTP for the first account and note the code length.
  3. Send a short burst of wrong guesses against that account, for example 50 requests, and watch the status codes and response times.
  4. If every response is the same "invalid code" message with no 429, no delay and no lockout, the endpoint has no effective limit. Stop there and report; you do not need to guess the real code.

Also check whether the limit can be bypassed:

  • Changing headers such as X-Forwarded-For or X-Real-IP to look like a new client, which works when the application trusts them blindly.
  • Adding trailing characters or changing letter case in the identifier (for example the email address) so each request looks like a new account.
  • Switching between equivalent endpoints (/v1/verify and /v2/verify), or between HTTP and a mobile API, that share the same check but not the same limit.
  • Sending many guesses in parallel inside one request or in one burst, before the counter updates.

How to fix it

  1. Count attempts per account and per IP. Use both; a limit on one alone is easy to dodge.
  2. Use a shared, atomic counter. Redis with an increment and an expiry works well and avoids the race where parallel requests slip past a read-then-write check.
  3. Lock or slow down after repeated failures. Use exponential back-off or a temporary lock, and expire an OTP after a small number of wrong tries (commonly 3 to 5).
  4. Never trust client-supplied IP headers. Read the client address from your own proxy or load balancer, and only accept forwarded headers from it.
  5. Respond clearly. Return 429 with Retry-After, and log the event so repeated hits raise an alert.
  6. Make codes harder to guess. Use longer codes and short lifetimes, so even a slow attacker has little time.
  7. Add bot protection as a second layer, not the only one.

Frequently asked questions

Is rate limiting the same as account lockout?

No. Lockout stops further attempts on one account after repeated failures. Rate limiting caps how many requests any client can make in a time window. You usually want both.

Can a CAPTCHA replace rate limiting?

No. A CAPTCHA raises the cost of automation but is often bypassed or not applied to the API behind the form. Keep the limit on the server.

Which OWASP category covers this?

The OWASP API Security Top 10 lists it as API4:2023 Unrestricted Resource Consumption, and missing limits on authentication flows also fall under authentication weaknesses in the web Top 10.

Further reading

Need this tested?

Have our senior analysts test your application

Excelon Cyber Solutions runs web application, API and network penetration tests across India, with every finding reproduced and documented before it reaches your report.

WHATSAPP