Orofold Labs

Launching soon

Notes Get in touch

Operations and security 4 min read Updated

Rate limiting that protects forms and logins

In short

Rate limiting caps how often a client may repeat an action, and a 429 response with Retry-After tells honest clients when to try again.

Every form, login page and API endpoint can be flooded with too many requests. Some of those requests are attacks, some come from broken clients and some are legitimate spikes. Rate limiting does not tell them apart, but it caps the damage from all three. Decide what to limit first, and only then choose the response.

Decide what to limit

OWASP’s API Security guidance treats unrestricted resource consumption as a risk, because serving requests uses bandwidth, CPU, memory and storage, and an attacker can exhaust them. Its prevention measures include a limit on how often a client may interact with the API within a defined timeframe, a maximum size for incoming parameters and payloads, and throttling of how often one client can run a single operation.

For a typical product, the first candidates are the login form, the password reset form, the contact form and any search or export that is expensive to run. Choose the key for each limit with care:

ActionSuitable keyWhy
LoginThe account, with the source address as a second signalThe OWASP authentication guidance ties the failure counter to the account rather than to the source address
Contact or enquiry formThe source address, with a short pause between submissionsStops simple scripted submissions from the same source
Export or heavy searchThe account or the API keyCaps the expensive work that one client can start

Answer with 429 and Retry-After

MDN describes status 429 Too Many Requests as the response that indicates a client has sent too many requests in a given amount of time, and it calls this mechanism rate limiting. The response may carry a Retry-After header that says how long the client should wait before trying again.

Retry-After takes one of two forms: an HTTP date, or a non-negative whole number of seconds. MDN gives the example of 3600, which tells the client to wait 60 minutes. The seconds form is the simpler choice for most limits. Keep the response body short, and do not reveal the exact threshold or the rule behind it, because that information helps an attacker tune their requests.

Working on something similar in your own product? A few honest sentences are enough – we read every enquiry and reply by email. Apply with your idea

Login limits without locking out customers

The OWASP Authentication Cheat Sheet describes login throttling as a control that stops an attacker from making too many password guesses. It names a maximum number of attempts, and it advises account lockout for a period after a set number of failed logins. Lockout has a cost, however. An attacker who knows a username can lock out its real owner, so the guidance warns against lockout rules that let others be denied access. It suggests letting users reach the forgotten-password route even while locked, and it describes growing delays after each failure as an alternative.

The same guidance calls CAPTCHA a defence-in-depth control that makes brute-force attacks more time-consuming and expensive, rather than a complete answer. It also says that multi-factor authentication is by far the best defence against most password attacks. Pair the limit with two-factor authentication for admin access, and with sessions and cookies done safely for what happens after a successful login.

Keep error messages generic

The same cheat sheet advises that login responses stay generic. The message should not say whether the user ID or the password was wrong, and it should not reveal that an account does not exist or is locked. Status codes and response times can leak the same information, because a different code or a noticeably slower reply for a real account tells an attacker that the account exists. Keep both consistent across the cases.

The guidance also notes that brute-force protection prevents an attacker from running enumeration at scale, which is one more reason to keep every message generic.

A checklist before you ship a limit

Check each limit before it goes live, and test it from outside your network. Log blocked requests with the key that triggered them, but never with the password or the token, as set out in logging: what to record and how long.

  • Choose the key for each limited action: the account, the API key or the address.
  • Set a maximum size for incoming parameters and uploads.
  • Return 429 with Retry-After for every limited request.
  • Keep login errors generic, with consistent status codes and timing.
  • Check that a locked account can still reset its password, and that one attacker cannot lock out other people’s accounts.
  • Review the log of blocked requests regularly, and include it in any incident review.

Common questions

What status code should a limited request receive?
MDN describes 429 Too Many Requests as the response for a client that has sent too many requests in a given amount of time. The response can include Retry-After to say how long to wait.
Should a failed login lock the account?
The OWASP Authentication Cheat Sheet advises lockout for a period after a set number of failed logins, but warns that lockout can be abused to deny access to other users. It describes growing delays after each failure as an alternative.
Should login errors say which part was wrong?
No. OWASP advises generic responses, so that a wrong user ID, a wrong password and a locked account produce the same kind of message, with consistent status codes and timing.

Sources

  1. 429 Too Many Requests, MDN Web Docs. Accessed 24 November 2026
  2. Retry-After, MDN Web Docs. Accessed 24 November 2026
  3. API4:2023 Unrestricted Resource Consumption, OWASP API Security Top 10 2023. Accessed 24 November 2026
  4. Authentication Cheat Sheet, OWASP Cheat Sheet Series. Accessed 24 November 2026

Further reading

Have an idea that should exist? Or a working product that needs more customers, a new website or a complete rework? Bring us anything. Apply with your idea

All notes