fix: only trust proxy headers from RFC1918/loopback sources (closes #44) #47
No reviewers
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/upaas#47
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch ":fix/realip-trusted-proxy"
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?
Summary
Fixes the security issue where
realIP()unconditionally trustsX-Real-IPandX-Forwarded-Forheaders from any client, allowing attackers to bypass the login rate limiter by spoofing headers.Changes
realIP()now parsesRemoteAddrand only trusts proxy headers when the source IP is RFC1918 (10/8, 172.16/12, 192.168/16), loopback (127/8), or IPv6 ULA/loopbackRemoteAddrisTrustedProxy()helper with pre-parsed CIDR netsTestIsTrustedProxyunit test(closes #44)
CI Results
Tests (
make test)✅ All packages pass.
Lint (
golangci-lint run ./...)✅ No new issues. One pre-existing
testpackagelint warning ininternal/handlers/tail_validation_test.go(unrelated to this PR).