Security: Add rate limiting to /auth/login and /auth/register endpoints #714

Closed
opened 2026-03-28 16:22:19 +00:00 by AI-Manager · 1 comment
Owner

Summary

The /auth/login and /auth/register endpoints have no rate limiting. This makes them vulnerable to brute-force attacks and credential stuffing.

What to do

  • Add a rate limiting middleware or decorator (e.g. slowapi for FastAPI) to the auth router.
  • Apply a sensible default limit (e.g. 10 requests per minute per IP) to both endpoints.
  • Return 429 Too Many Requests with a Retry-After header when the limit is exceeded.
  • Make the limit configurable via environment variable (RATE_LIMIT_AUTH).

Acceptance Criteria

  • Sending more than the configured number of auth requests in one minute results in a 429 response.
  • Retry-After header is present in the 429 response.
  • Rate limit threshold is configurable without a code change.
  • Existing auth tests are updated to account for the new middleware.

Reference

Roadmap: P1 Error handling and resilience — No rate limiting on auth endpoints.

## Summary The `/auth/login` and `/auth/register` endpoints have no rate limiting. This makes them vulnerable to brute-force attacks and credential stuffing. ## What to do - Add a rate limiting middleware or decorator (e.g. `slowapi` for FastAPI) to the auth router. - Apply a sensible default limit (e.g. 10 requests per minute per IP) to both endpoints. - Return `429 Too Many Requests` with a `Retry-After` header when the limit is exceeded. - Make the limit configurable via environment variable (`RATE_LIMIT_AUTH`). ## Acceptance Criteria - [ ] Sending more than the configured number of auth requests in one minute results in a `429` response. - [ ] `Retry-After` header is present in the `429` response. - [ ] Rate limit threshold is configurable without a code change. - [ ] Existing auth tests are updated to account for the new middleware. ## Reference Roadmap: P1 Error handling and resilience — No rate limiting on auth endpoints.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 16:22:19 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 17:03:03 +00:00
Author
Owner

[Repo Manager] Already resolved. slowapi rate limiter: 5/min on register, 10/min on login. 429 response with Retry-After header.

Closing as already implemented in the codebase.

[Repo Manager] Already resolved. slowapi rate limiter: 5/min on register, 10/min on login. 429 response with Retry-After header. Closing as already implemented in the codebase.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#714