SECURITY: realIP trusts X-Forwarded-For/X-Real-IP headers unconditionally #44
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/upaas#44
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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?
Severity: MEDIUM
File:
internal/middleware/middleware.golines ~105-125 (realIP function)Description
The
realIPfunction trustsX-Real-IPandX-Forwarded-Forheaders from any client, not just trusted reverse proxies. This is used for:An attacker can bypass the login rate limiter by sending a spoofed
X-Forwarded-Forheader with a different IP on each request, getting unlimited login attempts.Suggested Fix
RemoteAddrfor untrusted connectionsAlternatively, use chi's built-in
middleware.RealIPwhich can be configured with trusted proxies, or always rate-limit onRemoteAddrin addition to the extracted IP.assume any request from an RFC1918 IP is a trusted proxy. if the request has an x-real-ip or x-forwarded-for and isn't coming from an rfc1918 ip, fail closed.