WWWRedirect/NonWWWRedirect Middlewares · V5: Echo has Arbitrary Scheme Injection
Affects github.com/labstack/echo/v5Source GCVE Database
Not known to be exploited · CVSS 4.7 Medium : upgrade to 5.1.1 when convenient.
Data as of 28 Oct 2026, 22:12 UTC
- Patch
- Available – fixed in 5.1.1, 4.15.2
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:NExploitation evidence
Disclosed: evidence found.
CVE published 28 Oct 2026
Detectable: no evidence on record.
No public nuclei template indexed
Weaponised: no evidence on record.
No public exploit code indexed in Metasploit or Exploit-DB
Exploited in the wildExploited: no evidence on record.
Not in CISA KEV and no source reports exploitation
Observed by OffSeq MirageSeen by Mirage: no evidence on record.
No attack traffic recorded by OffSeq Mirage sensors
A missing step is not evidence of safety. Sources: cve.org (opens in a new tab), the Metasploit, Exploit-DB and nuclei-templates index as of 26 Oct 2026.
What to do
Upgrade github.com/labstack/echo/v5 to 5.1.1; github.com/labstack/echo/v4 to 4.15.2.
Affected software
| Product | Affected | Fixed in |
|---|---|---|
| Gogithub.com/labstack/echo/v5 | Affected
| Fixed in
|
| Gogithub.com/labstack/echo/v4 | Affected
| Fixed in
|
Check your own hosts for these packages with threat-finder (opens in a new tab), our free open-source scanner.
Description
## 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 verbatim - `middleware/redirect.go:172-184` - `redirectWWW`/`redirectNonWWW` use 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`: ```go 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.
References
- github.com/labstack/echo/security/advisories/GHSA-23wf-92cp-8pcj (opens in a new tab)
- github.com/labstack/echo/pull/2953 (opens in a new tab)
- github.com/labstack/echo/commit/ca4f38a474302aabee93c66bdd0052359882e181 (opens in a new tab)
- github.com/labstack/echo/commit/d1d8ad3f99dd9b80542cd0c357d56a8916c515df (opens in a new tab)
- github.com/labstack/echo (opens in a new tab)
- github.com/labstack/echo/releases/tag/v4.15.2 (opens in a new tab)
- github.com/labstack/echo/releases/tag/v5.1.1 (opens in a new tab)