forked from 0xWheatyz/SPARC
Add rate limiting to /auth/login and /auth/register endpoints #1198
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The
/auth/loginand/auth/registerendpoints currently have no protection against brute-force attacks or credential-stuffing. An attacker can attempt unlimited logins or spam registrations.Roadmap reference: ROADMAP.md > P1 > Error handling and resilience > No rate limiting on auth endpoints
What to do
slowapior a custom Redis-backed counter)./auth/loginto a reasonable number of attempts per IP per minute (e.g., 10/min)./auth/registersimilarly (e.g., 5/min per IP).Retry-Afterheader when the limit is exceeded.RATE_LIMIT_LOGIN, etc.) inconfig.py.Acceptance criteria
This issue has been resolved on main. Rate limiting is implemented in
SPARC/api.py(using slowapi), andtests/test_rate_limit.py(97 lines) validates the rate limiter behavior on auth endpoints. Closing as complete.