Echo: Reverse Proxy Forwards Attacker-Supplied X-Real-IP to Upstream by Default
影響パッケージ
| 種類 | パッケージ | 影響を受ける版 | 直った版 |
|---|---|---|---|
| labstack | echo | — | — |
| go | github.com/labstack/echo/v5 |
5.4.0 未満 |
5.4.0 |
| go | github.com/labstack/echo/v4 |
4.0.0 〜 4.16.2 |
— |
原文の説明 取得元が公開している説明をそのまま載せています (多くは英語)。
Summary
The Echo proxy middleware (middleware/proxy.go) preserves an incoming X-Real-IP header verbatim and forwards it to the upstream service when Echo#IPExtractor is not configured — which is the default. Because any HTTP client can supply an arbitrary X-Real-IP value, an attacker can cause Echo to relay a spoofed client IP address to every upstream service behind the proxy, undermining upstream IP-based access controls, rate limiting, audit logging, and geo-restriction.
Affected Component
middleware/proxy.go—ProxyConfig.ToMiddleware(), header-rewriting block (lines 351–355)
Description
The header-preservation condition passes spoofed values to upstream
ProxyConfig.ToMiddleware() (proxy.go:338-405) prepares forwarding headers before dispatching each request. The X-Real-IP rewrite logic at lines 351-355 reads:
// proxy.go:351-355
// Basically it's not good practice to unconditionally pass incoming x-real-ip header to upstream.
// However, for backward compatibility, legacy behavior is preserved unless you configure Echo#IPExtractor.
if req.Header.Get(echo.HeaderXRealIP) == "" || c.Echo().IPExtractor != nil {
req.Header.Set(echo.HeaderXRealIP, c.RealIP())
}
The condition is TRUE (and therefore overwrites the header with a derived value) only when:
- The header is absent —
req.Header.Get(echo.HeaderXRealIP) == ""; or IPExtractoris explicitly configured —c.Echo().IPExtractor != nil
The condition is `FALS…
出典: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
参照URL
- package github.com
- web security-advisories@github.com
- web security-advisories@github.com
- web security-advisories@github.com
- web github.com