go-chi chi before 5.3.0 IP Spoofing via RealIP Middleware
go-chi chi
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| github.com/go-chi/chi/middleware Go |
| No fix yet |
| github.com/go-chi/chi/v2/middleware Go |
| No fix yet |
| github.com/go-chi/chi/v3/middleware Go |
|
go-chi chi
| Product | Affected | Fixed in |
|---|---|---|
| github.com/go-chi/chi/middleware Go |
| No fix yet |
| github.com/go-chi/chi/v2/middleware Go |
| No fix yet |
| github.com/go-chi/chi/v3/middleware Go |
|
| github.com/go-chi/chi/v4/middleware Go |
| No fix yet |
| github.com/go-chi/chi/v5/middleware Go |
|
|
| github.com/go-chi/chi/v5 Go |
|
|
go-chi/chi through 5.2.1 contains an IP spoofing vulnerability in the RealIP middleware (middleware/realip.go). The realIP() function reads client-controlled headers (True-Client-IP, X-Real-IP, and X-Forwarded-For) and overwrites r.RemoteAddr without verifying that the request originated from a trusted proxy. Attackers can supply arbitrary IP addresses in these headers to bypass IP-based access controls, evade rate limiting and geo-IP restrictions, and pollute audit logs. Fixed in 5.3.0.
From the CVE record · VulnCheck
The RealIP middleware trusts client-supplied IP headers without checking whether a request came through a trusted proxy. A remote attacker can set those headers to bypass IP-based controls, rate limits, and geo-IP restrictions, or pollute audit logs. The input does not specify whether authentication is needed.
Engineers using github.com/go-chi/chi/v5 or its middleware before 5.3.0, or the listed affected older middleware packages, should check their deployments.