CVE-2026-118265: Echo: X-Real-IP extractor trusts the header value instead of the sending peer
Impact
In Echo v5, ExtractIPFromRealIPHeader checked whether the address supplied in X-Real-IP belonged to a trusted range instead of checking the address of the direct network peer. An untrusted client could therefore supply a loopback or private address and have it returned by c.RealIP() with the extractor's default trust options.
Applications using this extractor for IP allowlists, IP-based rate limiting, audit logs or forwarding headers could accept a spoofed client identity. Exploitation requires that the attacker can reach Echo directly or that an intervening proxy passes through the attacker's X-Real-IP value. Applications using the default direct IP extractor are unaffected. Echo v4 is unaffected by this v5 regression.
Affected versions and patch
All v5 releases from v5.0.0 through v5.4.0 are affected. Upgrade to v5.4.1.
The patch validates the direct peer before accepting a syntactically valid X-Real-IP value, restoring the v4 trust model. Fix commit.
Workarounds
Use ExtractIPDirect until upgrading, or ensure that only trusted proxies can reach Echo and that they replace client-supplied forwarding headers. Configure trusted proxy ranges narrowly for the deployment.
Credits
Reported and patched by @rm-Umar. @Duodum independently reported the same issue in GHSA-c3r7-8j36-7mx8, which is tracked as a duplicate of this advisory.
Other sources
Echo is a Go web framework. From 5.0.0 until 5.4.1, Echo v5's ExtractIPFromRealIPHeader validates whether the client-supplied X-Real-IP value belongs to a trusted range instead of validating the direct network peer. A client reaching Echo directly, or through a proxy that preserves the header, can supply a loopback or private address and have Context.RealIP return that spoofed identity. Applications using the extractor for IP allowlists, rate limiting, audit logs, or forwarding headers can consequently trust an attacker-controlled address; the default direct extractor and Echo v4 are unaffected. This issue is fixed in 5.4.1.
— MITRE
Echo: X-Real-IP extractor trusts the header value instead of the sending peer in github.com/labstack/echo
— OSV
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
go/github.com/labstack/echo/v5to a version that resolves this vulnerability.Fixed in 5.4.1 - Upgrade
Upgrade
github.com/labstack/echoto a version that resolves this vulnerability.Fixed in 5.4.1 - Configuration
Use ExtractIPDirect until upgrading.
Echo v5 IP extractor = ExtractIPDirect - Compensating control
Configure trusted proxy ranges narrowly so that only trusted proxies can reach Echo, and ensure those proxies replace client-supplied forwarding headers.
Event History
Frequently Asked Questions
Which deployments are exposed?
Echo v5 deployments from 5.0.0 through 5.4.1 are exposed only when they use ExtractIPFromRealIPHeader. A client must be able to reach Echo directly or through a proxy that preserves the X-Real-IP header; the default direct extractor and Echo v4 are unaffected.
What does an attacker need to do to exploit this?
No authentication or user interaction is required. The attacker supplies an X-Real-IP value containing a loopback or private address, causing Context.RealIP to return the spoofed address when the vulnerable extractor is in use.
What application behavior makes the impact meaningful?
Applications are at risk when they use Context.RealIP from this extractor for IP allowlists, rate limiting, audit logging, or forwarding headers. Those controls may trust an attacker-controlled address rather than the actual network peer.
What should be done if the application cannot be upgraded immediately?
Do not use ExtractIPFromRealIPHeader in affected Echo v5 deployments. Use the default direct extractor instead, and ensure proxies do not preserve client-supplied X-Real-IP values.
How can I determine whether an application is affected?
Check whether it runs Echo v5 between 5.0.0 and 5.4.1 and is configured to use ExtractIPFromRealIPHeader. Test only in an authorized environment by sending a loopback or private X-Real-IP value directly or through the proxy path and checking whether Context.RealIP returns that supplied value.