Fix: sign-in and claim endpoints are rate limited, with limits shared across instances (0.140.16) #103
No reviewers
Labels
No labels
audit
bug
cleanup
docs
duplicate
enhancement
help wanted
invalid
new feature
P0
P1
P2
P3
question
roadmap
security
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
pyaniz/Thursday!103
Loading…
Reference in a new issue
No description provided.
Delete branch "staging"
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?
What
Closes audit item A-09. Sign-in, linking and claim endpoints now have rate limits that every Vercel instance shares, and the client IP is no longer taken from a caller-written
X-Forwarded-For.shared/client_ip.py): on Vercel, the lastx-forwarded-forentry (the one Vercel writes). Elsewhere the socket address, orCLIENT_IP_HEADER/TRUSTED_PROXY_HOPS. Non-public addresses are not counted (one warning in the log), so a wrong setup cannot block everybody. IPv6 counts per /64.shared/db_rate_limit.py, migration V64): fixed-window counters in an UNLOGGED Postgres table, keyed by an HMAC of the IP / handle / user id. If the check fails the request goes through./auth/loginand/register(per handle and per IP, since each login sends a Telegram message),/check,/verify,/email/verify,/discord/callback,/poll, Discord and Telegram link/merge, group and player claim, the Tabletop Time webhook,/games/local-search. Over the limit: 429 withRetry-Afterand "Try again in N minutes".docs/guides/Authentication.md.Verified
retry_afterand pruning checked; 20 parallel clients x 50 calls ended at exactly 1000 hits.test_client_ip.py,test_rate_limit.py); reverting to "trust the leftmost x-forwarded-for" makes 5 of them fail.npm run buildpasses.Not verified
python -m pytestinbackend./apirewrite.To test on staging
AUTH ... IP:lines should show real visitor addresses, not one shared or private address (if they do, a warning "is not a public IP" is logged and per-IP limits stay off)./auth/login6 times for one handle within an hour: the 6th should answer 429 "Try again in N minutes", and the login page should show that text.X-Forwarded-For: 1.2.3.4) while hammering/auth/check: it should still be limited after 20 calls in a minute.Versioned 0.140.16 (fix); release notes added.
🤖 Generated with Claude Code