Rate limits are not security
Rate limiting reduces abuse and protects capacity. It does not replace authentication, authorization, or input validation.
A rate limit is a capacity control. It answers "how much may this caller do?" It does not answer "may this caller do it at all?"
Treating the two as the same creates a false sense of safety.
What a rate limit does well
- Stops a single caller from exhausting a shared resource.
- Makes brute force and enumeration expensive.
- Limits the blast radius of a buggy client.
- Gives operators a lever during an incident.
What it does not do
A rate limit does not authenticate a request. It does not check ownership. It does not validate a JSON body. It does not stop an attacker who stays under the threshold while targeting one account.
An endpoint with a generous limit and no authorization check is still broken.
Layer the controls
- Authentication establishes identity.
- Authorization decides whether that identity may perform the action.
- Validation rejects malformed or out-of-range input.
- Rate limiting bounds volume.
- Monitoring makes the pattern visible.
Each layer assumes the previous one works. Skipping one and compensating with another is how gaps appear.
Choose the right key
IP is a blunt key. It is shared behind NAT and easy to rotate. Better keys depend on the endpoint:
- Per account for login and password reset.
- Per token or tenant for API traffic.
- Per account plus IP for sensitive actions.
- Per destination for outbound calls.
Make rejection useful
A 429 should include Retry-After and a stable error code. Log the bucket, the key, and a request ID. Do not leak whether an account exists through different limits or error bodies.
The uncomfortable question
If the rate limit disappeared tomorrow, what would break?
If the answer is "nothing, because authorization still holds", the limit is doing its job as a capacity control. If the answer is "everything", the limit is carrying security weight it was never designed to carry.