github.com/labstack/echo/v4: Echo: WebSocket proxy can retain connections and handlers after client disconnect
What fixes it
- 4.16.1github.com/labstack/echo/v4, goGitHub
go get github.com/labstack/echo/v4@v4.16.1 - 5.4.1github.com/labstack/echo/v5, goGitHub
go get github.com/labstack/echo/v5@v5.4.1 - 4.16.1github.com/labstack/echo/v4, GoOSV
go get github.com/labstack/echo/v4@v4.16.1 - 5.4.1github.com/labstack/echo/v5, GoOSV
go get github.com/labstack/echo/v5@v5.4.1
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
Impact
Echo's Proxy middleware could retain a handler, copy goroutines and network connections after a WebSocket client disconnected if the upstream kept its connection open. The raw proxy waited for both copy directions to finish without reliably closing the other connection when one direction ended. Rejected upgrade responses with HTTP keep-alive were one way to trigger this behavior.
Repeated connections can accumulate resources and cause denial of service. The impact depends on the proxy route's accessibility, upstream behavior and configured connection deadlines. This is a medium-severity resource-retention issue; no confidentiality or integrity impact is claimed.
Affected versions and patch
Affected versions are v4.15.0 through v4.16.0 and v5.0.0 through v5.4.0. The regression was introduced by commit e2133320c7, merged in #2852.
Upgrade to v4.16.1 or v5.4.1. The patch uses Go's HTTP reverse proxy, preserves ordinary HTTP handling for rejected upgrades, and closes both sides of a WebSocket tunnel when either direction ends. It also covers an upstream that receives client EOF but deliberately keeps its side open.
Workarounds
Disable WebSocket proxy routes until upgrading, or apply bounded connection lifetimes and resource limits at the frontend and upstream. Server idle timeouts alone may not cover hijacked WebSocket connections.
Credits
Reported by @irisitymichaelgrundberg.
Text from GitHub Advisory Database
Affected versions 4
- github.com/labstack/echo/v4, go>= 4.15.0, < 4.16.1GitHub
- github.com/labstack/echo/v5, go>= 5.0.0, < 5.4.1GitHub
- github.com/labstack/echo/v4, Gofrom 4.15.0, fixed in 4.16.1OSV
- github.com/labstack/echo/v5, Gofrom 5.0.0, fixed in 5.4.1OSV
References 6
- github.com/labstack/echo/commit/1855061e572ae9dab727c811d8382f266bfbaaecFixvia GitHub
- github.com/labstack/echo/commit/3fb0ba7e17645bb65611e2a08875d0a2f65c421fFixvia GitHub
- github.com/labstack/echo/releases/tag/v4.16.1Fixvia GitHub
- github.com/labstack/echo/releases/tag/v5.4.1Fixvia GitHub
- github.com/labstack/echo/security/advisories/GHSA-9969-6676-49h5Advisoryvia GitHub
- github.com/advisories/GHSA-9969-6676-49h5Advisoryvia GitHub