mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 21:24:10 +00:00
1.1 KiB
1.1 KiB
2026-04-25 Security: Fix login rate limiting and IP spoofing
Changes
- Add
RateLimitMiddleware(10, time.Minute)toPOST /loginendpoint (was unprotected, only register had rate limiting) - Fix
getRemoteIp()to usec.Request.RemoteAddrinstead of trustingX-Real-IP/X-Forwarded-Forheaders - Fix
RateLimitMiddlewareto useRemoteAddrdirectly, preventing IP-based rate limit bypass via header spoofing
Security Issue
- Login endpoint had zero rate limiting, enabling unlimited brute-force attempts
- Both IP extraction and rate limiter trusted client-supplied headers, allowing attackers to spoof IPs and bypass all rate limiting
Files Modified
web/controller/index.go— add rate limit middleware to login routeweb/controller/util.go— use RemoteAddr in getRemoteIp()web/middleware/ratelimit.go— use RemoteAddr in rate limiter
Note
- Trusts Cloudflare's
CF-Connecting-IPheader (CF overwrites it, clients cannot spoof) - Falls back to
RemoteAddrfor direct connections without CDN X-Real-IP/X-Forwarded-Forare NOT trusted (can be spoofed by clients)