mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 21:24:10 +00:00
- Add RateLimitMiddleware(10/min) to POST /login (previously unprotected) - Use RemoteAddr instead of X-Real-IP/X-Forwarded-For in getRemoteIp() and rate limiter - Prevents brute-force login and rate-limit bypass via spoofed headers
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
If the panel runs behind a reverse proxy, RemoteAddr will show the proxy IP. To restore header-based IP detection, configure engine.SetTrustedProxies() in web/web.go with the proxy's IP.