forked from 0xWheatyz/SPARC
Add rate limiting middleware to auth endpoints to prevent brute-force attacks #785
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
/auth/loginand/auth/registerhave no request-rate controls. An attacker can make unlimited attempts to guess passwords or flood the registration endpoint.Roadmap reference: ROADMAP.md -- P1 Error handling and resilience -- "No rate limiting on auth endpoints"
What to do
slowapiwhich integrates cleanly with FastAPI) to the project dependencies.POST /auth/login(e.g., 10 requests per minute per IP).POST /auth/register(e.g., 5 requests per minute per IP).Retry-Afterheader when the limit is exceeded.Acceptance criteria
/auth/loginor/auth/registerreturns HTTP 429.Triage: Assigned to @developer. Reason: P1 security, small - add rate limiting middleware. Dispatching agent now.
Already implemented -- closing.
Rate limiting is implemented using
slowapiinSPARC/api.py:Limiterinitialized withget_remote_addresskey function (line 212)/auth/registerlimited to 5 requests/minute (line 241)/auth/loginlimited to 10 requests/minute (line 274)rate_limit_handlerreturns 429 withRetry-Afterheader (lines 216-224)tests/test_rate_limit.pycovering threshold behavior and Retry-After header.No further work needed.