All vulnerabilities

Go

CVE-2026-118656

Echo has Open Redirect via Control-Character Prefix Defeating sanitizeURI

Severity
Medium 6.1
Published
28 Oct 2026
Last changed
5 Nov 2026
Added to UpHeron
23 Nov 2026
Fixed in
4.16.0, 5.4.0
Exploit chance
0.2% in the next 30 daysHigher than 9% of CVEs. EPSS by FIRST, 24 Nov 2026
Weakness
Open redirect (CWE-601)
Attack
Over the network · No login needed · Needs someone to click or open something
Attacker can
Read some data · Change some data
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Also known as
GHSA-v753-g4cw-jm48, GO-2026-6883
Sources
OSV.dev and GitHub

Description

Echo's dedicated open-redirect guard, sanitizeURI, decides whether a redirect target is a local path by inspecting exactly two byte positions: uri[0] and uri[1]. If the value begins with a control character such as a tab or a newline, followed by a separator pair, the guard does not fire and the value is written to the Location header unchanged.

Browsers remove tab and newline characters from URLs before parsing them, and treat a backslash as a forward slash for HTTP and HTTPS URLs. A Location value of /\t/attacker.example is therefore resolved by the browser as an absolute URL on attacker.example. Confirmed end to end in a headless browser.

middleware/slash.go:144 (duplicated verbatim at echo.go:958):

The condition is anchored at absolute offsets 0 and 1. It cannot see a separator that has been shifted by one byte.

  • RemoveTrailingSlash (middleware/slash.go:112-140) reads url.Path, which net/http has already percent-decoded, strips the trailing slash, and appends the raw query…
From the GitHub Advisory Database, CC BY 4.0. Shortened; the full text is there.

Workarounds

Use the trailing slash middlewares without RedirectCode (the default rewrites the path internally instead of redirecting), or reject request paths that contain control characters before these middlewares.

Workarounds as given by the GitHub Advisory Database, CC BY 4.0.

Affected software

SoftwareAffected versions
github.com/labstack/echo/v4Go · osv:Go:github.com/labstack/echo/v4
  • Every version before 4.16.0
github.com/labstack/echo/v5Go · osv:Go:github.com/labstack/echo/v5
  • Every version before 5.4.0

About github.com/labstack/echo/v4

About github.com/labstack/echo/v5

References