Echo has Arbitrary Scheme Injection in WWWRedirect/NonWWWRedirect Middlewares via X-Forwarded-Proto
Published 28 Oct 2026 · Updated 5 Nov 2026
Is your project on an affected github.com/labstack/echo/v5?
Look after several Go apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected packages
- Affected
- <5.1.1
- Fixed in
- 5.1.1
go get github.com/labstack/echo/v5@v5.1.1- Affected
- <4.15.2
- Fixed in
- 4.15.2
go get github.com/labstack/echo/v4@v4.15.2Details
Summary
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.
Affected Components
context.go:162-181-Scheme()method returns attacker-controlled value verbatimmiddleware/redirect.go:172-184-redirectWWW/redirectNonWWWuse unsanitized scheme
Proof of Concept
GET /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://).
Impact
- Open redirect to arbitrary scheme URLs when app is not behind a proxy that strips
X-Forwarded-Proto - Cache poisoning when behind a CDN that caches redirect responses keyed by path
file://scheme injection could trigger file access in some browser configurations
Suggested Fix
Whitelist 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"
}Disclosure
Source code review, manually verified with actual HTTP server. Tested on Echo v5.0.4 (latest master).
Patches
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).
Workarounds
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.
Is GHSA-23wf-92cp-8pcj in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected github.com/labstack/echo/v5, and gives you the command that fixes it.
More advisories for github.com/labstack/echo/v5
- LowCVE-2026-118653Rate Limiter Bypass via Spoofed X-Forwarded-For Header in Default Configuration in github.com/labstack/echo · 5 Nov 2026
- LowCVE-2026-118650URL-encoded path bypasses route/group middleware guarding a statically-served path in github.com/labstack/echo · 5 Nov 2026
- LowCVE-2026-118651Reverse Proxy Forwards Attacker-Supplied X-Real-IP to Upstream by Default in github.com/labstack/echo · 5 Nov 2026
- LowCVE-2026-118652Cross-Site Scripting (XSS) via unsanitized JSONP callback in github.com/labstack/echo · 5 Nov 2026
- LowCVE-2026-118266Echo has CSRF Protection Bypass via MethodOverride Rewriting POST to Safe Method in github.com/labstack/echo · 5 Nov 2026
- LowCVE-2026-118657Echo: HTTPS Redirect and HSTS Bypass via Unconditional Trust of Forwarded Scheme Headers in github.com/labstack/echo · 5 Nov 2026
References
- Linkgithub.com/labstack/echo/security/advisories/GHSA-23wf-92cp-8pcj
- Linkgithub.com/labstack/echo/pull/2953
- Linkgithub.com/labstack/echo/commit/ca4f38a474302aabee93c66bdd0052359882e181
- Linkgithub.com/labstack/echo/commit/d1d8ad3f99dd9b80542cd0c357d56a8916c515df
- Packagegithub.com/labstack/echo
- Linkgithub.com/labstack/echo/releases/tag/v4.15.2
- Linkgithub.com/labstack/echo/releases/tag/v5.1.1
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.