Security: fix HTTP rate-limit X-Forwarded-For trust behind reverse proxies#89
Closed
cursor[bot] wants to merge 1 commit into
Closed
Security: fix HTTP rate-limit X-Forwarded-For trust behind reverse proxies#89cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
When HTTP_TRUSTED_PROXIES is configured, use X-Real-IP or the rightmost X-Forwarded-For hop instead of the client-controlled leftmost entry. This closes a rate-limit bypass and DoS amplification path behind nginx-style reverse proxies that append the connecting address. Co-authored-by: Alexander Wagner <info@alexanderwagnerdev.com>
Contributor
|
Superseded by #90, which contains this PR's commit plus the clippy Generated by Claude Code |
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.
Security review (2026-07-17)
One new validated finding was reported and fixed on this branch.
Medium — Spoofed
X-Forwarded-Forbypasses HTTP rate limits behind trusted reverse proxiessrc/rate_limit.rsHTTP_TRUSTED_PROXIESis set (documented Docker/nginx deployment), the limiter used the leftmostX-Forwarded-Forhop. With nginx$proxy_add_x_forwarded_for, that hop is attacker-controlled, so clients could rotate synthetic IPs to bypass per-client buckets and amplify traffic up to the 10,000-entry tracking cap (including fail-closed denial for new legitimate clients).X-Real-IPwhen present; otherwise derive the client IP from the rightmostX-Forwarded-Forhop appended by the immediate trusted proxy. Added regression tests and clarified.env.example/ config docs.Closes #88
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.