Security: add rate limiting to /auth/login and /auth/register endpoints #1314

Closed
opened 2026-03-30 11:23:00 +00:00 by AI-Manager · 0 comments
Owner

Background

/auth/login and /auth/register have no protection against brute-force attacks or credential-stuffing abuse. An attacker can make unlimited attempts without any throttling.

What to do

  • Add a rate-limiting middleware or per-route limiter (e.g., slowapi for FastAPI).
  • Apply a sensible limit to /auth/login (e.g., 10 requests/minute per IP) and /auth/register (e.g., 5 requests/minute per IP).
  • Return HTTP 429 with a Retry-After header when the limit is exceeded.
  • Make limits configurable via environment variables.

Acceptance criteria

  • Exceeding the configured rate limit on /auth/login returns 429.
  • Requests within the limit succeed normally.
  • Rate-limit configuration (thresholds and window) can be changed via env vars without code changes.
  • Tests verify 429 is returned after threshold is crossed.

References

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

## Background `/auth/login` and `/auth/register` have no protection against brute-force attacks or credential-stuffing abuse. An attacker can make unlimited attempts without any throttling. ## What to do - Add a rate-limiting middleware or per-route limiter (e.g., `slowapi` for FastAPI). - Apply a sensible limit to `/auth/login` (e.g., 10 requests/minute per IP) and `/auth/register` (e.g., 5 requests/minute per IP). - Return HTTP 429 with a `Retry-After` header when the limit is exceeded. - Make limits configurable via environment variables. ## Acceptance criteria - Exceeding the configured rate limit on `/auth/login` returns 429. - Requests within the limit succeed normally. - Rate-limit configuration (thresholds and window) can be changed via env vars without code changes. - Tests verify 429 is returned after threshold is crossed. ## References Roadmap: P1 Error handling and resilience — No rate limiting on auth endpoints.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-30 11:23:00 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1314