CVE-2026-118265: Echo: X-Real-IP extractor trusts the header value instead of the sending peer
Echo v5 (github.com/labstack/echo/v5, v5.0.0 through v5.4.0) lets an untrusted client spoof its IP address. The ExtractIPFromRealIPHeader extractor trusts the value of the X-Real-IP header instead of the connecting peer. Apps that use it for allowlists, rate limits or audit logs can be fooled. Upgrade to v5.4.1.
Published Oct 23, 2026 · Updated Oct 28, 2026 · Analysis Nov 2, 2026
What an attacker can do
ExtractIPFromRealIPHeader is meant to accept X-Real-IP only when the request comes from a trusted proxy. In v5 it checked the wrong address: it tested whether the IP written in the header sat inside a trusted range, not whether the direct network peer did. With the default trust options, loopback and private ranges count as trusted. A client could therefore send X-Real-IP: 127.0.0.1 and c.RealIP() would return it.
The attacker needs no account and no user interaction. They need only to reach Echo directly, or to sit behind a proxy that passes their X-Real-IP value through. The gain is a forged identity. An IP allowlist that admits loopback or internal addresses can be bypassed. Per-IP rate limits can be dodged by rotating the header. Audit logs and forwarded headers record a false address. The flaw does not give code execution or data access by itself, so the CVSS impact is limited to integrity. Echo v4 and apps using the default direct extractor are not affected.
Who is affected
Every Echo v5 release from v5.0.0 up to and including v5.4.0 is affected, but only if the app uses ExtractIPFromRealIPHeader (for example through e.IPExtractor). Apps on the default direct extractor, and all Echo v4 apps, are unaffected. Check the module version in your project:
go list -m github.com/labstack/echo/v5Also search your code for ExtractIPFromRealIPHeader.
github.com/labstack/echo/v5
- Ecosystem
- Go
- Affected
- >= 5.0.0, < 5.4.1
- Fixed in
- 5.4.1
- Check
go list -m github.com/labstack/echo/v5
How to fix it
Upgrade to v5.4.1:
go get github.com/labstack/echo/[email protected]The fix in ip.go parses the remote address of the connection first. If that peer is missing, unparseable or untrusted, the header is ignored and the direct IP is returned. Only a trusted peer's X-Real-IP is honored.
Until you upgrade, switch to ExtractIPDirect. Or make sure only trusted proxies can reach Echo, that they overwrite any client-supplied forwarding headers, and that your trusted proxy ranges are narrow.
How to tell if you were hit
Look in access logs for requests whose recorded client IP is loopback or a private address but which arrived on a public interface. Compare the logged IP with the source address in your load balancer or network logs. Watch for external requests that carry an X-Real-IP header with a 127.0.0.1 or 10.x value, and for allowlisted admin routes hit from unexpected networks. A unit test with an untrusted RemoteAddr and a spoofed header should return the RemoteAddr after the fix.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
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.
Credited to rm-Umar, Duodum.
Questions
- Is Echo v4 affected by CVE-2026-118265?
No. The advisory says this is a regression in v5 only. The v4 trust model checked the direct peer, and the v5.4.1 patch restores that behavior.
- Am I affected if I use Echo's default IP extractor?
No. Applications using the default direct IP extractor are unaffected. The risk applies only when ExtractIPFromRealIPHeader is configured, and an attacker can reach Echo directly or through a proxy that forwards their X-Real-IP header.
- Can I mitigate without upgrading?
Yes. Switch to ExtractIPDirect, or ensure only trusted proxies reach Echo and that they replace client-supplied forwarding headers. Keep the trusted proxy ranges as narrow as the deployment allows.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Go vulnerabilities
All Go entriesCVE-2026-118266
Echo has CSRF Protection Bypass via MethodOverride Rewriting POST to Safe Method
medium5.3Oct 28, 2026CVE-2026-118650
Echo's middleware.Static: `%2F`-encoded path bypasses route/group middleware guarding a statically-served path
high7.5Oct 28, 2026CVE-2026-118651
Echo: Reverse Proxy Forwards Attacker-Supplied X-Real-IP to Upstream by Default
medium5.3No fixOct 28, 2026CVE-2026-118652
Echo vulnerable to Reflected Cross-Site Scripting (XSS) via unsanitized JSONP callback in Context.JSONP / Context.JSONPBlob
medium6.1Oct 28, 2026CVE-2026-118653
Echo has Rate Limiter Bypass via Spoofed X-Forwarded-For Header in Default Configuration
medium5.3No fixOct 28, 2026CVE-2026-118654
Echo static file middleware route protection bypass via encoded dot-dot traversal
medium5.9Oct 28, 2026
