All vulnerabilities

Go

CVE-2026-118651

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

Severity
Medium 5.3
Published
28 Oct 2026
Last changed
5 Nov 2026
Added to UpHeron
23 Nov 2026
Fixed in
5.4.0
Exploit chance
0.2% in the next 30 daysHigher than 10% of CVEs. EPSS by FIRST, 24 Nov 2026
Weakness
Origin validation error (CWE-346)
Attack
Over the network · No login needed · No user action needed
Attacker can
Change some data
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
Also known as
GHSA-99jh-6h7p-pp36, GO-2026-6875
Sources
OSV.dev and GitHub

Description

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.

ProxyConfig.ToMiddleware() (proxy.go:338-405) prepares forwarding headers before dispatching each request. The X-Real-IP rewrite logic at lines 351-355 reads:

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
From the GitHub Advisory Database, CC BY 4.0. Shortened; the full text is there.

Workarounds

Configure Echo#IPExtractor for your deployment, for example e.IPExtractor = echo.ExtractIPDirect() when there is no proxy in front of the application, or echo.ExtractIPFromXFFHeader() / echo.ExtractIPFromRealIPHeader() (with TrustIPRange for proxies on public addresses). With an extractor set, the Proxy middleware overwrites X-Real-IP in v4 too.

Workarounds as given by the GitHub Advisory Database, CC BY 4.0.

Affected software

SoftwareAffected versions
github.com/labstack/echo/v4Go · osv:Go:github.com/labstack/echo/v4
  • From 4.0.0 up to 4.16.2
github.com/labstack/echo/v5Go · osv:Go:github.com/labstack/echo/v5
  • Every version before 5.4.0

About github.com/labstack/echo/v4

About github.com/labstack/echo/v5

References