Repository navigation
Conversation
vybe
force-pushed
the
fix/181-xff-rate-limit-bypass
branch
from
March 30, 2026 14:05
d18f54b to
409b0b0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_get_client_iptrusted the client-suppliedX-Forwarded-Forheader unconditionally, allowing an attacker to rotate spoofed IPs and bypass the per-IP rate limit entirely (pentest finding 3.2.4, CVSS 5.1)_get_client_ipnow validates whether the direct TCP peer is a trusted proxy (RFC-1918 ranges by default) before readingX-Real-IP/X-Forwarded-For; public-IP connections use their raw TCP IP as the rate-limit keyChanges
src/backend/routers/public.py_get_client_ip; added trusted-proxy allowlist; added per-token rate limitsrc/backend/db/public_links.pycount_recent_messages_by_token()src/backend/database.pyDatabasefacadetests/test_ip_rate_limit_fix.pyTest plan
pytest tests/test_ip_rate_limit_fix.py -v— 14/14 passX-Forwarded-For: 10.0.0.$iall resolve to the same real IPTRUSTED_PROXIESenv var override testedRisk
Low for default Docker Compose deployments (all traffic via nginx in RFC-1918). Medium for deployments behind an external CDN/proxy — operators must set
TRUSTED_PROXIES=<cidr>.Closes #181
🤖 Generated with Claude Code