CVE-2026-118658
Echo: Arbitrary Scheme Injection in WWWRedirect/NonWWWRedirect Middlewares via X-Forwarded-Proto
Echo is a Go web framework. Prior to 4.15.2 and 5.1.1, Context.Scheme returns values from X-Forwarded-Proto, X-Forwarded-Protocol, or X-Url-Scheme without validating that they are supported web schemes. WWWRedirect and NonWWWRedirect use that value to construct a Location header, so an attacker controlling a forwarded scheme header can cause a redirect to use an arbitrary URI scheme. Exploitation requires an affected redirect middleware and user interaction with the response; the HTTPS-specific redirect variants hardcode HTTPS and are unaffected. This issue is fixed in 4.15.2 and 5.1.1.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- High
- Privileges needed
- None
- User interaction
- Required
What an attacker can affect
- Confidentiality
- Low
- Integrity
- Low
- Availability
- None
Exploit likelihood
What each source reports
CVE List Score used
4.7
Echo: Arbitrary Scheme Injection in WWWRedirect/NonWWWRedirect Middlewares via X-Forwarded-Proto
Echo is a Go web framework. Prior to 4.15.2 and 5.1.1, Context.Scheme returns values from X-Forwarded-Proto, X-Forwarded-Protocol, or X-Url-Scheme without validating that they are supported web schemes. WWWRedirect and NonWWWRedirect use that value to construct a Location header, so an attacker controlling a forwarded scheme header can cause a redirect to use an arbitrary URI scheme. Exploitation requires an affected redirect middleware and user interaction with the response; the HTTPS-specific redirect variants hardcode HTTPS and are unaffected. This issue is fixed in 4.15.2 and 5.1.1.
- Record
CVE-2026-118658- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Weakness
- CWE-601
- Updated
- 2026-11-03
EUVDEUVD-2026-112465
4.7
Echo is a Go web framework. Prior to 4.15.2 and 5.1.1, Context.Scheme returns values from X-Forwarded-Proto, X-Forwarded-Protocol, or X-Url-Scheme without validating that they are supported web schemes. WWWRedirect and NonWWWRedirect use that value to construct a Location header, so an attacker controlling a forwarded scheme header can cause a redirect to use an arbitrary URI scheme. Exploitation requires an affected redirect middleware and user interaction with the response; the HTTPS-specific redirect variants hardcode HTTPS and are unaffected. This issue is fixed in 4.15.2 and 5.1.1.
- Record
EUVD-2026-112465- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Updated
- 2026-11-03
GitHub AdvisoriesGHSA-23wf-92cp-8pcj
4.7
Echo has Arbitrary Scheme Injection in WWWRedirect/NonWWWRedirect Middlewares via X-Forwarded-Proto
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.
- Record
GHSA-23wf-92cp-8pcj- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Weakness
- CWE-601
- Updated
- 2026-11-02
NVD
4.7
Echo is a Go web framework. Prior to 4.15.2 and 5.1.1, Context.Scheme returns values from X-Forwarded-Proto, X-Forwarded-Protocol, or X-Url-Scheme without validating that they are supported web schemes. WWWRedirect and NonWWWRedirect use that value to construct a Location header, so an attacker controlling a forwarded scheme header can cause a redirect to use an arbitrary URI scheme. Exploitation requires an affected redirect middleware and user interaction with the response; the HTTPS-specific redirect variants hardcode HTTPS and are unaffected. This issue is fixed in 4.15.2 and 5.1.1.
- Record
CVE-2026-118658- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Weakness
- CWE-601
- Updated
- 2026-11-03
OSV
4.7
Echo: Arbitrary Scheme Injection in WWWRedirect/NonWWWRedirect Middlewares via X-Forwarded-Proto
Echo is a Go web framework. Prior to 4.15.2 and 5.1.1, Context.Scheme returns values from X-Forwarded-Proto, X-Forwarded-Protocol, or X-Url-Scheme without validating that they are supported web schemes. WWWRedirect and NonWWWRedirect use that value to construct a Location header, so an attacker controlling a forwarded scheme header can cause a redirect to use an arbitrary URI scheme. Exploitation requires an affected redirect middleware and user interaction with the response; the HTTPS-specific redirect variants hardcode HTTPS and are unaffected. This issue is fixed in 4.15.2 and 5.1.1.
- Record
CVE-2026-118658- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Weakness
- CWE-601
- Updated
- 2026-11-06
OSVDEBIAN-CVE-2026-118658
4.7
Echo is a Go web framework. Prior to 4.15.2 and 5.1.1, Context.Scheme returns values from X-Forwarded-Proto, X-Forwarded-Protocol, or X-Url-Scheme without validating that they are supported web schemes. WWWRedirect and NonWWWRedirect use that value to construct a Location header, so an attacker controlling a forwarded scheme header can cause a redirect to use an arbitrary URI scheme. Exploitation requires an affected redirect middleware and user interaction with the response; the HTTPS-specific redirect variants hardcode HTTPS and are unaffected. This issue is fixed in 4.15.2 and 5.1.1.
- Record
DEBIAN-CVE-2026-118658- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Updated
- 2026-11-03
OSVGHSA-23wf-92cp-8pcj
4.7
Echo has Arbitrary Scheme Injection in WWWRedirect/NonWWWRedirect Middlewares via X-Forwarded-Proto
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.
- Record
GHSA-23wf-92cp-8pcj- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Weakness
- CWE-601
- Updated
- 2026-11-06
OSVUBUNTU-CVE-2026-118658
4.7
Echo is a Go web framework. Prior to 4.15.2 and 5.1.1, Context.Scheme returns values from X-Forwarded-Proto, X-Forwarded-Protocol, or X-Url-Scheme without validating that they are supported web schemes. WWWRedirect and NonWWWRedirect use that value to construct a Location header, so an attacker controlling a forwarded scheme header can cause a redirect to use an arbitrary URI scheme. Exploitation requires an affected redirect middleware and user interaction with the response; the HTTPS-specific redirect variants hardcode HTTPS and are unaffected. This issue is fixed in 4.15.2 and 5.1.1.
- Record
UBUNTU-CVE-2026-118658- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Updated
- 2026-11-05
OSVGO-2026-6878 No score
Arbitrary Scheme Injection in WWWRedirect/NonWWWRedirect Middlewares via X-Forwarded-Proto in github.com/labstack/echo
Arbitrary Scheme Injection in WWWRedirect/NonWWWRedirect Middlewares via X-Forwarded-Proto in github.com/labstack/echo
- Record
GO-2026-6878- Updated
- 2026-11-06
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
github.com/labstack/echo/v5Go |
before 5.1.1 | 5.1.1 |
github.com/labstack/echo/v4Go |
before 4.15.2 | 4.15.2 |
golang-github-labstack-echoDebian:12 |
All versions, plus listed versions 4.11.1-14.11.1-24.12.0-14.2.1-3 |
None known |
golang-github-labstack-echoDebian:13 |
All versions, plus listed versions 4.12.0-1 |
None known |
golang-github-labstack-echoDebian:14 |
All versions, plus listed versions 4.12.0-1 |
None known |
golang-github-labstack-echo.v2Ubuntu:20.04:LTS |
All versions, plus listed versions 2.2.0-1 |
None known |
golang-github-labstack-echo.v3Ubuntu:20.04:LTS |
All versions, plus listed versions 3.3.5-1 |
None known |
golang-github-labstack-echoUbuntu:22.04:LTS |
All versions, plus listed versions 4.2.1-2 |
None known |
golang-github-labstack-echo.v2Ubuntu:22.04:LTS |
All versions, plus listed versions 2.2.0-2 |
None known |
golang-github-labstack-echo.v3Ubuntu:22.04:LTS |
All versions, plus listed versions 3.3.10-1 |
None known |
golang-github-labstack-echoUbuntu:24.04:LTS |
All versions, plus listed versions 4.11.1-2 |
None known |
golang-github-labstack-echoUbuntu:26.10 |
All versions, plus listed versions 4.12.0-1 |
None known |
golang-github-labstack-echoUbuntu:26.04:LTS |
All versions, plus listed versions 4.12.0-1 |
None known |
History
| Recorded | Changed | Sources |
|---|---|---|
| affected, aliases, references | OSV | |
| facts | EUVD, OSV | |
| references | CVE List, NVD | |
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2026-118658 is a medium vulnerability (CVSS 4.7) in Labstack Echo, published October 28, 2026. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.19%, the 8th percentile. Fixed in github.com/labstack/echo/v5 5.1.1.
References
github.com/labstack/echo/security/advisories/GHSA-23wf-92cp-8pcj
github.com/labstack/echo/commit/ca4f38a474302aabee93c66bdd0052359882e181
github.com/labstack/echo/commit/d1d8ad3f99dd9b80542cd0c357d56a8916c515df
github.com/labstack/echo/releases/tag/v4.15.2
github.com/labstack/echo/releases/tag/v5.1.1
github.com/labstack/echo/pull/2953
Show 7 moreShow less
github.com/advisories/GHSA-23wf-92cp-8pcj
github.com/CVEProject/cvelistV5/tree/main/cves/2026/118xxx/CVE-2026-118658.json
nvd.nist.gov/vuln/detail/CVE-2026-118658
security-tracker.debian.org/tracker/CVE-2026-118658
github.com/labstack/echo
ubuntu.com/security/CVE-2026-118658
cve.org/CVERecord?id=CVE-2026-118658