CVE-2026-118266
Echo: CSRF Protection Bypass via MethodOverride Rewriting POST to Safe Method
Echo is a Go web framework. Prior to 4.16.0 and 5.4.0, Echo's MethodOverride middleware accepts a safe HTTP method as the override target for a POST request. When MethodOverride is registered before CSRF in the post-routing middleware chain, route selection retains the original state-changing POST handler but the override changes the method before CSRF evaluates it, causing both token validation and Sec-Fetch-Site checks to be skipped. A cross-site exploit requires an authenticated victim and an override value that a browser-submitted request can control, such as the form getter used by the advisory reproducer; the default X-HTTP-Method-Override header getter is not settable by a cross-site form. This issue is fixed in 4.16.0 and 5.4.0.
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
- None
- Integrity
- High
- Availability
- None
Exploit likelihood
What each source reports
CVE List Score used
5.3
Echo: CSRF Protection Bypass via MethodOverride Rewriting POST to Safe Method
Echo is a Go web framework. Prior to 4.16.0 and 5.4.0, Echo's MethodOverride middleware accepts a safe HTTP method as the override target for a POST request. When MethodOverride is registered before CSRF in the post-routing middleware chain, route selection retains the original state-changing POST handler but the override changes the method before CSRF evaluates it, causing both token validation and Sec-Fetch-Site checks to be skipped. A cross-site exploit requires an authenticated victim and an override value that a browser-submitted request can control, such as the form getter used by the advisory reproducer; the default X-HTTP-Method-Override header getter is not settable by a cross-site form. This issue is fixed in 4.16.0 and 5.4.0.
- Record
CVE-2026-118266- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N - Weakness
- CWE-352
- Updated
- 2026-11-03
EUVDEUVD-2026-112403
5.3
Echo is a Go web framework. Prior to 4.16.0 and 5.4.0, Echo's MethodOverride middleware accepts a safe HTTP method as the override target for a POST request. When MethodOverride is registered before CSRF in the post-routing middleware chain, route selection retains the original state-changing POST handler but the override changes the method before CSRF evaluates it, causing both token validation and Sec-Fetch-Site checks to be skipped. A cross-site exploit requires an authenticated victim and an override value that a browser-submitted request can control, such as the form getter used by the advisory reproducer; the default X-HTTP-Method-Override header getter is not settable by a cross-site form. This issue is fixed in 4.16.0 and 5.4.0.
- Record
EUVD-2026-112403- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N - Updated
- 2026-11-03
GitHub AdvisoriesGHSA-r7w9-592q-9vg4
5.3
Echo has CSRF Protection Bypass via MethodOverride Rewriting POST to Safe Method
Summary
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.
Affected Component
middleware/method_override.go—MethodOverrideConfig.ToMiddleware()(lines 55–71): no whitelist on the override target methodmiddleware/csrf.go—CSRFConfig.ToMiddleware()(lines 188–189): safe-method bypass branch reads the already-rewritten methodmiddleware/csrf.go—checkSecFetchSiteRequest()(line 283):Sec-Fetch-Sitesafe check also reads the rewritten method
Description
MethodOverride accepts safe methods as override targets
MethodOverrideConfig.ToMiddleware() (method_override.go:55-71) restricts the source method (only POST requests are overrideable) but applies no whitelist to the target:
// method_override.go:61-67
req := c.Request()
if req.Method == http.MethodPost {
m := config.Getter(c)
if m != "" {
req.Method = m // ← any non-empty string accepted, including "GET"
}
}
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. The test suite (method_override_test.go) only tests POST→DELETE and POST→PUT; POST→GET is never tested or blocked.
CSRF safe-method branch reads the already-rewritten method
CSRFConfig.ToMiddleware() (csrf.go:188-189) makes its validation decision based on c.Request().Method at the time it runs:
// csrf.go:188-189
switch c.Request().Method {
case http.MethodGet, http.MethodHead, http.MethodOptions, http.MethodTrace:
// skip validation — no token check
default:
// validate CSRF token
If MethodOverride has already run and set req.Method = "GET", this switch falls into the skip branch regardless of the original HTTP method or what handler was matched.
The Sec-Fetch-Site-based path in checkSecFetchSiteRequest() (csrf.go:283) is identically vulnerable:
// csrf.go:283
isSafe := slices.Contains(safeMethods, c.Request().Method)
With req.Method = "GET" (already rewritten), isSafe = true and the function returns true — the request is allowed even when Sec-Fetch-Site is cross-site. Both CSRF protection paths are bypassed in a single step.
Execution chain
In echo.go:700, routing and middleware wrapping are performed in one step:
h = applyMiddleware(e.router.Route(c), e.middleware...)
e.router.Route(c)evaluates withreq.Method = "POST"→ matches and binds the POST/transferhandlerapplyMiddlewarewraps it:MethodOverride → CSRF → postHandler
At request execution time:
3. MethodOverride runs: req.Method == "POST" → reads form field _method = "GET" → req.Method = "GET" → calls next
4. CSRF runs: c.Request().Method = "GET" → case http.MethodGet → skips token validation → calls next
5. postHandler runs (the handler matched in step 1 — the original POST /transfer state-change handler)
The state-changing handler executes with no CSRF token validation and with no Sec-Fetch-Site check.
The missing target-method whitelist is the root cause
The legitimate use case for MethodOverride is allowing HTML forms (which only support GET/POST) to send PUT, DELETE, or PATCH requests. There is no legitimate scenario in which an HTML form needs to…
- Record
GHSA-r7w9-592q-9vg4- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N - Weakness
- CWE-352
- Updated
- 2026-11-02
NVD
5.3
Echo is a Go web framework. Prior to 4.16.0 and 5.4.0, Echo's MethodOverride middleware accepts a safe HTTP method as the override target for a POST request. When MethodOverride is registered before CSRF in the post-routing middleware chain, route selection retains the original state-changing POST handler but the override changes the method before CSRF evaluates it, causing both token validation and Sec-Fetch-Site checks to be skipped. A cross-site exploit requires an authenticated victim and an override value that a browser-submitted request can control, such as the form getter used by the advisory reproducer; the default X-HTTP-Method-Override header getter is not settable by a cross-site form. This issue is fixed in 4.16.0 and 5.4.0.
- Record
CVE-2026-118266- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N - Weakness
- CWE-352
- Updated
- 2026-11-03
OSV
5.3
Echo: CSRF Protection Bypass via MethodOverride Rewriting POST to Safe Method
Echo is a Go web framework. Prior to 4.16.0 and 5.4.0, Echo's MethodOverride middleware accepts a safe HTTP method as the override target for a POST request. When MethodOverride is registered before CSRF in the post-routing middleware chain, route selection retains the original state-changing POST handler but the override changes the method before CSRF evaluates it, causing both token validation and Sec-Fetch-Site checks to be skipped. A cross-site exploit requires an authenticated victim and an override value that a browser-submitted request can control, such as the form getter used by the advisory reproducer; the default X-HTTP-Method-Override header getter is not settable by a cross-site form. This issue is fixed in 4.16.0 and 5.4.0.
- Record
CVE-2026-118266- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N - Weakness
- CWE-352
- Updated
- 2026-11-06
OSVDEBIAN-CVE-2026-118266
5.3
Echo is a Go web framework. Prior to 4.16.0 and 5.4.0, Echo's MethodOverride middleware accepts a safe HTTP method as the override target for a POST request. When MethodOverride is registered before CSRF in the post-routing middleware chain, route selection retains the original state-changing POST handler but the override changes the method before CSRF evaluates it, causing both token validation and Sec-Fetch-Site checks to be skipped. A cross-site exploit requires an authenticated victim and an override value that a browser-submitted request can control, such as the form getter used by the advisory reproducer; the default X-HTTP-Method-Override header getter is not settable by a cross-site form. This issue is fixed in 4.16.0 and 5.4.0.
- Record
DEBIAN-CVE-2026-118266- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N - Updated
- 2026-11-04
OSVGHSA-r7w9-592q-9vg4
5.3
Echo has CSRF Protection Bypass via MethodOverride Rewriting POST to Safe Method
Summary
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.
Affected Component
middleware/method_override.go—MethodOverrideConfig.ToMiddleware()(lines 55–71): no whitelist on the override target methodmiddleware/csrf.go—CSRFConfig.ToMiddleware()(lines 188–189): safe-method bypass branch reads the already-rewritten methodmiddleware/csrf.go—checkSecFetchSiteRequest()(line 283):Sec-Fetch-Sitesafe check also reads the rewritten method
Description
MethodOverride accepts safe methods as override targets
MethodOverrideConfig.ToMiddleware() (method_override.go:55-71) restricts the source method (only POST requests are overrideable) but applies no whitelist to the target:
// method_override.go:61-67
req := c.Request()
if req.Method == http.MethodPost {
m := config.Getter(c)
if m != "" {
req.Method = m // ← any non-empty string accepted, including "GET"
}
}
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. The test suite (method_override_test.go) only tests POST→DELETE and POST→PUT; POST→GET is never tested or blocked.
CSRF safe-method branch reads the already-rewritten method
CSRFConfig.ToMiddleware() (csrf.go:188-189) makes its validation decision based on c.Request().Method at the time it runs:
// csrf.go:188-189
switch c.Request().Method {
case http.MethodGet, http.MethodHead, http.MethodOptions, http.MethodTrace:
// skip validation — no token check
default:
// validate CSRF token
If MethodOverride has already run and set req.Method = "GET", this switch falls into the skip branch regardless of the original HTTP method or what handler was matched.
The Sec-Fetch-Site-based path in checkSecFetchSiteRequest() (csrf.go:283) is identically vulnerable:
// csrf.go:283
isSafe := slices.Contains(safeMethods, c.Request().Method)
With req.Method = "GET" (already rewritten), isSafe = true and the function returns true — the request is allowed even when Sec-Fetch-Site is cross-site. Both CSRF protection paths are bypassed in a single step.
Execution chain
In echo.go:700, routing and middleware wrapping are performed in one step:
h = applyMiddleware(e.router.Route(c), e.middleware...)
e.router.Route(c)evaluates withreq.Method = "POST"→ matches and binds the POST/transferhandlerapplyMiddlewarewraps it:MethodOverride → CSRF → postHandler
At request execution time:
3. MethodOverride runs: req.Method == "POST" → reads form field _method = "GET" → req.Method = "GET" → calls next
4. CSRF runs: c.Request().Method = "GET" → case http.MethodGet → skips token validation → calls next
5. postHandler runs (the handler matched in step 1 — the original POST /transfer state-change handler)
The state-changing handler executes with no CSRF token validation and with no Sec-Fetch-Site check.
The missing target-method whitelist is the root cause
The legitimate use case for MethodOverride is allowing HTML forms (which only support GET/POST) to send PUT, DELETE, or PATCH requests. There is no legitimate scenario in which an HTML form needs to…
- Record
GHSA-r7w9-592q-9vg4- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N - Weakness
- CWE-352
- Updated
- 2026-11-06
OSVUBUNTU-CVE-2026-118266
5.3
Echo is a Go web framework. Prior to 4.16.0 and 5.4.0, Echo's MethodOverride middleware accepts a safe HTTP method as the override target for a POST request. When MethodOverride is registered before CSRF in the post-routing middleware chain, route selection retains the original state-changing POST handler but the override changes the method before CSRF evaluates it, causing both token validation and Sec-Fetch-Site checks to be skipped. A cross-site exploit requires an authenticated victim and an override value that a browser-submitted request can control, such as the form getter used by the advisory reproducer; the default X-HTTP-Method-Override header getter is not settable by a cross-site form. This issue is fixed in 4.16.0 and 5.4.0.
- Record
UBUNTU-CVE-2026-118266- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N - Updated
- 2026-11-05
OSVGO-2026-6877 No score
Echo has CSRF Protection Bypass via MethodOverride Rewriting POST to Safe Method in github.com/labstack/echo
Echo has CSRF Protection Bypass via MethodOverride Rewriting POST to Safe Method in github.com/labstack/echo
- Record
GO-2026-6877- Updated
- 2026-11-06
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
github.com/labstack/echo/v5Go |
5.0.0 up to 5.4.0 | 5.4.0 |
github.com/labstack/echo/v4Go |
before 4.16.0 | 4.16.0 |
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 | OSV | |
| facts | EUVD, NVD | |
| references | CVE List | |
| 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-118266 is a medium vulnerability (CVSS 5.3) 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.16%, the 5th percentile. Fixed in github.com/labstack/echo/v5 5.4.0.
References
github.com/labstack/echo/security/advisories/GHSA-r7w9-592q-9vg4
github.com/labstack/echo/commit/b838391e2eade87ae7e5a09d7bb5087bec271ec1
github.com/labstack/echo/commit/fc410094b2f3415cf2bf5204082137b205bfd5af
github.com/labstack/echo/releases/tag/v4.16.0
github.com/labstack/echo/releases/tag/v5.4.0
github.com/advisories/GHSA-r7w9-592q-9vg4
Left out here: the rest of 2 source descriptions. The JSON record has them.