CSRF validation bypass through HTTP method overrides in go-bananas (GO-2026-6978)

CSRF validation bypass through HTTP method overrides in go-bananas (GO-2026-6978)

Description

Before v1.0.2, middleware.MutateMethod in github.com/mikehelmick/go-bananas can override the HTTP method with a value supplied in the request. If it runs after the router selects a handler and before middleware.HandleCSRF, the CSRF middleware can see a different method from the one used for routing and skip token validation.

Potential impact

A cross-site request from a signed-in user’s browser can change application data with that user’s permissions without a valid CSRF token.

Remediation

Update github.com/mikehelmick/go-bananas to v1.0.2 or later. Verify that requests to state-changing handlers are rejected when they lack a valid CSRF token.

Examples

Update the dependency declaration in go.mod.

Before

go
require github.com/mikehelmick/go-bananas v1.0.1

After

go
require github.com/mikehelmick/go-bananas v1.0.2

References