MEDIUMCVSS v3.1 4.7Vulnerability

CVE-2026-118658

## 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/

Properties

Severity
medium
Summary
Echo has Arbitrary Scheme Injection in WWWRedirect/NonWWWRedirect Middlewares via X-Forwarded-Proto
Nvd fetched at
2026-10-28T23:43:43.157973+00:00
Cvss severity
MEDIUM
Cvss score
4.7
Retrieved at
2026-10-28T23:45:49+00:00
Ghsa published
2026-10-28T21:04:10Z
Source url
https://github.com/advisories/GHSA-23wf-92cp-8pcj
Ghsa updated
2026-10-28T21:04:12Z
Ghsa id
GHSA-23wf-92cp-8pcj
Last source
GitHub Advisory Database
Score
4.7
Cvss version
3.1
Cve id
CVE-2026-118658
Cvss vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
First seen by Signal
2026-10-28T23:44:40+00:00
Is ghsa only
false
Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
Published at
2026-10-28T21:16:55.827
Last modified
2026-10-28T21:16:55.827

Related Entities (5)

Explore deeper with Ninja Signal's threat intelligence graph

CVE-2026-118658 (CVSS v3.1 4.7) — Ninja Signal Threat Intelligence | Ninja Signal