fix: per-IP auth rate limiting instead of one global bucket
A single global token bucket let one attacker at the sustained rate 429 every user's login/register/change-password. Key buckets by client IP: the SvelteKit proxy now stamps the real peer address onto X-Forwarded-For (overriding any client-supplied value, anti-spoof), and axum reads it via a ClientIp extractor — but only when AUTH_TRUSTED_PROXY is set, else it falls back to the shared bucket (today's behavior). The per-IP map is bounded (10k IPs, idle buckets pruned) so a spoofed-IP spray can't grow it. AUTH_TRUSTED_PROXY defaults false (safe for a directly-exposed backend); compose sets it true since the proxy is the single trusted hop. Bump to 0.124.12. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,13 @@ SESSION_TTL_DAYS=30
|
||||
# rate-limiting reverse proxy that already enforces a budget).
|
||||
AUTH_RATE_PER_SEC=5
|
||||
AUTH_RATE_BURST=10
|
||||
# Trust a proxy-supplied X-Forwarded-For as the client IP for per-IP auth
|
||||
# rate limiting. Enable ONLY when the backend sits behind a trusted proxy
|
||||
# that overrides the header (the compose deploy: SvelteKit forwards the real
|
||||
# peer IP). When false, the header is ignored and a single shared bucket is
|
||||
# used — a directly-exposed backend MUST keep this off or clients could spoof
|
||||
# their IP to dodge the limit.
|
||||
AUTH_TRUSTED_PROXY=false
|
||||
|
||||
# ----- CORS -----
|
||||
# Comma-separated origins allowed to call the API with credentials.
|
||||
|
||||
Reference in New Issue
Block a user