Live › vulnerability › CVE-2026-118658
Go to dashboardEcho's WWWRedirect and NonWWWRedirect middlewares build the Location header from the X-Forwarded-Proto request header without validating it. An attacker can make the server return a redirect to a javascript, data, file or similar scheme URL, enabling open redirects and possible cache poisoning behind a CDN.
Summary written from the sources below. Check the originals before acting.
First seen by InfraStack 2026-10-28 21:07 UTC, 0h before NVD. All times on this page are UTC.
Applications written in Go that use Echo v4 below 4.15.2 or Echo v5 below 5.1.1 and register the WWWRedirect or NonWWWRedirect middleware (or their WithConfig variants). HTTPSRedirect, HTTPSWWWRedirect and HTTPSNonWWWRedirect hardcode https:// and are not affected. Exposure is greatest when the app is not behind a proxy that strips the forwarded-scheme headers.
| Product | Ecosystem | Affected | Fixed in |
|---|---|---|---|
| github.com/labstack/echo/v5 | go | < 5.1.1 | 5.1.1 |
| github.com/labstack/echo/v4 | go | < 4.15.2 | 4.15.2 |
go list -m github.com/labstack/echo/v5 and go list -m github.com/labstack/echo/v4 to read the Echo versions in the module graph.WWWRedirect( or NonWWWRedirect( to see whether the affected middleware is in use.github.com/labstack/echo/v5 to 5.1.1 or later.github.com/labstack/echo/v4 to 4.15.2 or later.X-Forwarded-Proto, X-Forwarded-Protocol and X-Url-Scheme request headers.Each row is the first time that source carried this signal. The analyst’s rows are its own findings.
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.
This page as .md · .json · in your agent: get_signal("CVE-2026-118658")
GitHub Advisory Database, CC-BY 4.0 · NVD data is provided by NIST and is public domain. Posts quoted belong to their authors.