CVE-2026-118658Medium· 4.7▾ SunlitEcho has Arbitrary Scheme Injection in WWWRedirect/NonWWWRedirect Middlewares via X-Forwarded-Proto
▾ Sunlit zone — Low / medium · no exploitation signal
impact 25.9 · likelihood 0 · exploitation 0
Need a working PoC? Pro members can cast a request and our team develops one — it lands right here.
Exploit-prediction probability, daily snapshots since Oct 29.
Disclosure to exploitation, from the record and what we observed since indexing it.
Disclosed via GHSA
0.2%
Last analysed / modified upstream
The c.Scheme() method in Echo (context.go:162-181) trusts the X-Forwarded-Proto, X-Forwarded-Protocol, and X-Url-Scheme request headers without validating that the value is http or https. The WWWRedirect() and NonWWWRedirect() middlewares use this unsanitized scheme to construct redirect URLs, allowing an attacker to inject arbitrary URI schemes into the Location response header.
context.go:162-181 - Scheme() method returns attacker-controlled value verbatimmiddleware/redirect.go:172-184 - redirectWWW/redirectNonWWW use unsanitized schemeGET /path HTTP/1.1
Host: example.com
X-Forwarded-Proto: javascript
Response:
HTTP/1.1 301 Moved Permanently
Location: javascript://www.example.com/path
Confirmed injectable schemes: javascript, data, vbscript, file, ftp, ssh, telnet, gopher.
Only WWWRedirect() and NonWWWRedirect() (and WithConfig variants) are affected. HTTPSRedirect, HTTPSWWWRedirect, HTTPSNonWWWRedirect are NOT affected (they hardcode https://).
X-Forwarded-Protofile:// scheme injection could trigger file access in some browser configurationsWhitelist scheme in c.Scheme() to only return http or https:
func (c *Context) Scheme() string {
if c.IsTLS() {
return "https"
}
if scheme := c.request.Header.Get(HeaderXForwardedProto); scheme != "" {
scheme = strings.ToLower(strings.TrimSpace(scheme))
if scheme == "https" {
return "https"
}
}
return "http"
}
Source code review, manually verified with actual HTTP server. Tested on Echo v5.0.4 (latest master).
Fixed in github.com/labstack/echo/v5 v5.1.1 and github.com/labstack/echo/v4 v4.15.2. Context.Scheme() now accepts only http, https, ws or wss from the X-Forwarded-Proto, X-Forwarded-Protocol and X-Url-Scheme headers, and falls back to http for any other value (#2953).
Upgrade to a patched version. If you cannot upgrade, have your edge proxy overwrite or remove the X-Forwarded-Proto, X-Forwarded-Protocol and X-Url-Scheme request headers.
github.com/labstack/echo/v5 < 5.1.1github.com/labstack/echo/v4 < 4.15.2Upgrade to a patched release:
github.com/labstack/echo/v5 5.1.1github.com/labstack/echo/v4 4.15.2Connected by shared product, vendor, weakness, or advisory.
CVE-2026-118656Medium· 6.1Echo has Open Redirect via Control-Character Prefix Defeating sanitizeURI
CVE-2026-118654Medium· 5.9Echo static file middleware route protection bypass via encoded dot-dot traversal
CVE-2026-118655Medium· 5.9Echo has a Static Middleware Double-Unescape Path Traversal
CVE-2026-118657Medium· 5.9Echo: HTTPS Redirect and HSTS Bypass via Unconditional Trust of Forwarded Scheme Headers
CVE-2026-118651Medium· 5.3Echo: Reverse Proxy Forwards Attacker-Supplied X-Real-IP to Upstream by Default
CVE-2026-118653Medium· 5.3Echo has Rate Limiter Bypass via Spoofed X-Forwarded-For Header in Default Configuration