All vulnerabilities

Go

CVE-2026-118266

Echo has CSRF Protection Bypass via MethodOverride Rewriting POST to Safe Method

Severity
Medium 5.3
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 7% of CVEs. EPSS by FIRST, 24 Nov 2026
Weakness
Cross-site request forgery (CWE-352)
Attack
Over the network · Only under certain conditions · No login needed · Needs someone to click or open something
Attacker can
Change data
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N
Also known as
GHSA-r7w9-592q-9vg4, GO-2026-6877
Sources
OSV.dev and GitHub

Description

The MethodOverride middleware accepts any non-empty string as the override target method — including safe methods (GET, HEAD, OPTIONS, TRACE) — when rewriting a POST request. When MethodOverride is registered before CSRF in the post-routing middleware chain (e.Use()), it rewrites the request method to a safe method before CSRF evaluates it. The CSRF middleware then skips token validation for the now-safe method, allowing state-changing POST handlers to execute without any CSRF check. Both the legacy token path and the modern Sec-Fetch-Site protection path are bypassed simultaneously.

MethodOverrideConfig.ToMiddleware() (method_override.go:55-71) restricts the source method (only POST requests are overrideable) but applies no whitelist to the target:

The docstring's security claim — "For security reasons, only POST method can be overridden" — refers only to the source-method restriction. There is no guard preventing POST from being rewritten to GET, HEAD, OPTIONS, or TRACE.

From the GitHub Advisory Database, CC BY 4.0. Shortened; the full text is there.

Workarounds

Register MethodOverride with Echo#Pre (as documented), register CSRF before MethodOverride, or use the default header getter (X-HTTP-Method-Override), which a cross-site form cannot set.

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
  • From 5.0.0 before 5.4.0

About github.com/labstack/echo/v4

About github.com/labstack/echo/v5

References