← All lessons Stage 4 · Lesson 5
15 min

Rate limits, enumeration and abuse

Stage 4 · Lesson 5 · 15 minutes · Requires Lesson 1


The one-line answer

When an API doesn't limit how often it can be called, attackers can try thousands of passwords or OTPs, discover which accounts exist, scrape all its data, or run up huge bills — using nothing but normal-looking requests.

The boundary: testing rate limits means sending many requests, which can degrade or crash a real service and costs its owner money. Labs and your own local apps only, and keep request counts small even there.


Why you should care

Many API bugs aren't one bad request — they're one ordinary request sent 100,000 times. OWASP lists API4: Unrestricted Resource Consumption in the API Security Top 10 for this reason.

It's very relevant in India: OTP-based login and payments are everywhere. A 6-digit OTP has only 1,000,000 possibilities. With no limit on attempts, guessing one is a matter of automation, not luck.


How it actually works

What a rate limit is

A rate limit is a rule like "at most 5 login attempts per account per 15 minutes" or "100 requests per minute per API key". When exceeded, the server responds with something like:

HTTP/2 429 Too Many Requests
Retry-After: 60

429 is the standard status code for this. Without any such rule, the only limit is how fast the attacker's tools can send.

What goes wrong without limits

1. Brute force. Trying many passwords against one account, or every possible OTP or PIN. Recall Stage 2 Lesson 2: this is exactly what Intruder automates — and why Community's throttling makes it slow. Attackers use tools without that throttle.

2. Credential stuffing. Trying leaked email/password pairs from other breaches across many accounts (Stage 3 Lesson 5). Each account gets only one or two attempts, so per-account limits alone may not catch it — per-IP and global signals matter.

3. User enumeration. An endpoint like "check if this phone number is registered" or "forgot password" that answers differently for existing and non-existing users. Called millions of times, it reveals the whole user list — useful for phishing and targeted attacks.

4. Scraping. Combined with BOLA (Lesson 2) or a public endpoint, no limits means an attacker can download the entire dataset quickly.

5. Cost and denial of service.

  • Endpoints that send SMS or email (OTP, invitations) can be abused to send huge volumes — the company pays for every message.
  • Expensive operations (search, report generation, file processing, large page sizes like ?limit=100000) can exhaust the server.

Bypasses to know about (concept)

Rate limits are often implemented weakly. Common gaps, which PortSwigger labs explore safely:

  • limits keyed only on an IP address — easily spread across many addresses, or sometimes spoofed if the server trusts headers like X-Forwarded-For from anyone,
  • limits on the web login but not the mobile API login,
  • limits that reset after one successful request (e.g. logging into your own account resets the counter),
  • limits per request when one request can contain many attempts (batching — you'll see this with GraphQL in Lesson 6).

See it yourself

  1. Read OWASP API4: Unrestricted Resource Consumption (link below).
  2. On PortSwigger, do the authentication lab on broken brute-force protection, IP block (practitioner) or start with the apprentice brute-force/enumeration labs. Notice how the protection works and where it falls short.
  3. Run OWASP Juice Shop on your own machine. Try 10 wrong logins in a row with Repeater. Does anything stop you? What would a good response be?
  4. Write down: the endpoint, the limit (if any), and what should happen after repeated failures.

How attackers abuse this

Attackers find the endpoints that matter — login, OTP verification, password reset, "check if user exists", search, SMS-sending — and automate them across many IPs and accounts. Because each request is individually valid, a system with no limits and no monitoring sees only "lots of traffic".

The defensive fix:

  • Rate-limit sensitive endpoints, keyed on several things together: per account, per IP, per device/API key, and globally. Return 429 with Retry-After.
  • Lock or slow down after repeated failures — progressive delays, temporary lockouts, CAPTCHA — balanced so attackers can't use lockouts to block real users.
  • Strong OTP handling: limited attempts per OTP (e.g. 3–5), short expiry, invalidate after use, and limit how often new OTPs can be requested.
  • Generic responses for login, reset and sign-up checks, so they don't reveal whether an account exists.
  • Limit resource use: maximum page sizes, request body sizes, upload sizes, timeouts, and quotas on SMS/email sending.
  • Apply limits on every client — web, mobile and internal APIs share the same backend rules.
  • Only trust proxy headers like X-Forwarded-For from your own load balancer.
  • Monitor and alert on spikes of failed logins, 429s, OTP requests and enumeration patterns — core Stage 5 SOC work.

Common mistakes

  • No limit on OTP verification because "it's only 6 digits".
  • Limits only by IP.
  • Different rules for web and mobile endpoints.
  • Revealing account existence in error messages or response timing.
  • Unbounded limit/page size parameters.
  • Load-testing someone else's API. Labs only, small numbers.

Check yourself

  1. Why is a 6-digit OTP with no attempt limit weak?
  2. What status code signals "too many requests", and what header can accompany it?
  3. Why isn't limiting by IP address alone enough?
Answers
  1. There are only 1,000,000 possible values. Without limits, automation can try them all — or enough of them — quickly. OTPs need a small attempt limit and a short expiry.
  2. 429 Too Many Requests, often with a Retry-After header.
  3. Attackers can spread requests across many IP addresses, and some servers can be tricked by spoofed headers. Limits should combine account, IP, device/key and global signals.

Your lab

  • OWASP API Security Top 10 — API4 (and API6 on sensitive business flows): https://owasp.org/API-Security/
  • PortSwigger Authentication labs (brute-force protection): https://portswigger.net/web-security/authentication

Writeup: the endpoint, observed limit behaviour, the risk, and the specific limits you'd recommend.


Summary in your language

தமிழில் சுருக்கம்

ஒரு API எத்தனை முறை அழைக்கப்படலாம் என்பதற்கு வரம்பு இல்லையென்றால், attackers ஆயிரக்கணக்கான கடவுச்சொற்கள் அல்லது OTP-களை முயற்சிக்கலாம், எந்தக் கணக்குகள் உள்ளன என்று கண்டறியலாம், தரவை scrape செய்யலாம், SMS செலவுகளை அதிகரிக்கலாம். 6 இலக்க OTP-க்கு 10 லட்சம் சாத்தியங்கள் மட்டுமே. தீர்வு: கணக்கு, IP, சாதனம் என பல அடிப்படையில் rate limiting, 429 response, OTP முயற்சி வரம்பு மற்றும் குறுகிய காலாவதி, பொதுவான பதில்கள், page size வரம்புகள், monitoring.

हिंदी में सारांश

अगर API को बुलाने की कोई सीमा नहीं है, तो attackers हज़ारों passwords या OTPs आज़मा सकते हैं, पता लगा सकते हैं कि कौन-से accounts मौजूद हैं, data scrape कर सकते हैं और SMS का खर्च बढ़ा सकते हैं। 6 अंकों के OTP में सिर्फ़ 10 लाख संभावनाएँ होती हैं। इलाज: account, IP और device — कई आधारों पर rate limiting, 429 response, OTP पर कोशिशों की सीमा और छोटी expiry, एक जैसे जवाब, page size की सीमा और monitoring।

Want this summary in Malayalam, Telugu, Kannada or another language? Tell us — the most requested languages get added next.


What's next

One more API style, with its own way of exposing too much: GraphQL introspection & exposure