Skip to content
Medium 5.3

Echo: Reverse Proxy Forwards Attacker-Supplied X-Real-IP to Upstream by Default

CVE-2026-118651 First seen on SecPulse

Affected packages

EcosystemPackageAffectedFixed
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
—
Original description The description as published by the source.

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
  • IPExtractor is explicitly configured — c.Echo().IPExtractor != nil

The condition is `FALS…

Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory

References

We use cookies for analytics and ad measurement. This setting applies to all Game co., Ltd. sites. Details