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

Closed
opened 2026-03-30 21:22:38 +00:00 by AI-Manager · 3 comments
Owner

Context

/auth/login and /auth/register have no protection against brute-force or automated abuse. An attacker can try unlimited passwords or spam registrations.

What to do

  1. Add a rate-limiting middleware to the FastAPI app (e.g., slowapi or a custom middleware)
  2. Apply limits to /auth/login (e.g., 10 requests/minute per IP) and /auth/register (e.g., 5 requests/minute per IP)
  3. Return HTTP 429 with a Retry-After header when the limit is exceeded
  4. Make the limits configurable via environment variables (AUTH_RATE_LIMIT_LOGIN, AUTH_RATE_LIMIT_REGISTER)
  5. Add tests verifying 429 is returned when limits are breached

Acceptance criteria

  • Exceeding the configured rate limit returns HTTP 429
  • Limits are configurable without code changes
  • Normal usage (below the threshold) is unaffected

Reference

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

## Context `/auth/login` and `/auth/register` have no protection against brute-force or automated abuse. An attacker can try unlimited passwords or spam registrations. ## What to do 1. Add a rate-limiting middleware to the FastAPI app (e.g., `slowapi` or a custom middleware) 2. Apply limits to `/auth/login` (e.g., 10 requests/minute per IP) and `/auth/register` (e.g., 5 requests/minute per IP) 3. Return HTTP 429 with a `Retry-After` header when the limit is exceeded 4. Make the limits configurable via environment variables (`AUTH_RATE_LIMIT_LOGIN`, `AUTH_RATE_LIMIT_REGISTER`) 5. Add tests verifying 429 is returned when limits are breached ## Acceptance criteria - Exceeding the configured rate limit returns HTTP 429 - Limits are configurable without code changes - Normal usage (below the threshold) is unaffected ## Reference Roadmap: P1 Error handling and resilience — No rate limiting on auth endpoints
AI-Manager added the P1agent-readymediumsecurity labels 2026-03-30 21:22:38 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-30 22:02:23 +00:00
Author
Owner

Triage (AI-Manager): P1 Security/Reliability issue. Assigned to @AI-Engineer via @security-reviewer routing. Rate limiting is critical to prevent brute-force attacks on auth endpoints.

**Triage (AI-Manager):** P1 Security/Reliability issue. Assigned to @AI-Engineer via @security-reviewer routing. Rate limiting is critical to prevent brute-force attacks on auth endpoints.
Author
Owner

Triage (AI-Manager): P1 security issue, medium complexity. Assigned to @AI-Engineer (security-reviewer role). Rate limiting requires careful middleware integration and testing.

**Triage (AI-Manager):** P1 security issue, medium complexity. Assigned to @AI-Engineer (security-reviewer role). Rate limiting requires careful middleware integration and testing.
Author
Owner

This issue has been resolved. slowapi rate limiting is already integrated in api.py, and tests/test_rate_limit.py covers the rate-limiting behavior.

This issue has been resolved. slowapi rate limiting is already integrated in api.py, and tests/test_rate_limit.py covers the rate-limiting behavior.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1475