Skip to content

fix(security): reject universal TRUSTED_PROXY_IPS catch-all CIDRs - #127

Merged
AlexanderWagnerDev merged 2 commits into
mainfrom
cursor/bug-scanning-automation-24d8
Aug 20, 2026
Merged

fix(security): reject universal TRUSTED_PROXY_IPS catch-all CIDRs#127
AlexanderWagnerDev merged 2 commits into
mainfrom
cursor/bug-scanning-automation-24d8

Conversation

@cursor

@cursor cursor Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Bug-scan pass on config.py found that TRUSTED_PROXY_IPS=0.0.0.0/0 or ::/0 was accepted at startup. These catch-all CIDRs make every direct TCP peer look like a trusted proxy, so client_ip_for_rate_limit() buckets by spoofed X-Forwarded-For values and the /login rate limit can be bypassed.

Bug and impact

  • Scenario: Operator enables TRUSTED_PROXY_COUNT=1 with TRUSTED_PROXY_IPS=0.0.0.0/0 (or ::/0). Attacker connects directly to port 8000 with a forged X-Forwarded-For header and rotates spoofed IPs to bypass the 5/min login cap.
  • Impact: Login brute-force protection bypass; the proxy-trust pinning added in Fix proxy-trust rate-limit bypass and secure-cookie defaults #85 is voided by this misconfiguration.

Fix

Reject universal (/0) networks in _parse_trusted_proxy_networks() with a clear startup error. Added parametrized regression tests for 0.0.0.0/0 and ::/0.

Validation

CI should run pytest (non-integration) including new tests in tests/test_proxy_rate_limit_security.py.

Open in Web View Automation 

Note

Medium Risk
Touches trusted-proxy and rate-limit IP selection, which is security-sensitive, but the change is a fail-closed config check with tests and does not alter the happy-path trust logic.

Overview
Startup now rejects TRUSTED_PROXY_IPS values that are universal CIDRs (0.0.0.0/0, ::/0). Those ranges made every direct client look like a trusted proxy, so spoofed X-Forwarded-For could bypass per-IP /login rate limits.

_parse_trusted_proxy_networks() fails closed with a clear config error. Regression tests cover both IPv4 and IPv6 catch-alls.

Reviewed by Cursor Bugbot for commit 9139371. Bugbot is set up for automated code reviews on this repo. Configure here.

cursoragent and others added 2 commits August 20, 2026 03:04
TRUSTED_PROXY_IPS=0.0.0.0/0 or ::/0 makes every direct TCP peer look like
a trusted proxy, so client_ip_for_rate_limit() buckets by spoofed
X-Forwarded-For values and the /login rate limit can be bypassed.

Co-authored-by: Alexander Wagner <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@AlexanderWagnerDev
AlexanderWagnerDev marked this pull request as ready for review August 20, 2026 18:39
@AlexanderWagnerDev
AlexanderWagnerDev merged commit 90e663d into main Aug 20, 2026
12 checks passed
@AlexanderWagnerDev
AlexanderWagnerDev deleted the cursor/bug-scanning-automation-24d8 branch August 20, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants