Echoのmiddleware.Staticに認証を回避される脆弱性
Summary
Echoのmiddleware.Staticで、%2Fでエンコードしたパスによりルートやグループのミドルウェアによる保護を回避され、静的ルート配下のファイルに届く可能性があります。影響を受けるのは4.16.0より前と5.4.0より前のEchoで、4.16.0および5.4.0で修正されています。修正版への更新を優先してください。global mountの構成で保護が効くかは資料内で食い違っているため、詳しい条件は公表されていません。最新の情報を確認してください。
AI summary
Written by an external AI model and may contain mistakes. Check the original description and references below before acting on it.
Echoのmiddleware.Staticで、%2Fでエンコードしたパスによりルートやグループのミドルウェアによる保護を回避され、静的ルート配下のファイルに届く可能性があります。影響を受けるのは4.16.0より前と5.4.0より前のEchoで、4.16.0および5.4.0で修正されています。修正版への更新を優先してください。global mountの構成で保護が効くかは資料内で食い違っているため、詳しい条件は公表されていません。最新の情報を確認してください。
Affected packages
| Ecosystem | Package | Affected | Fixed |
|---|---|---|---|
| labstack | echo | — | — |
| go | github.com/labstack/echo/v5 |
< 5.4.0 |
5.4.0 |
| go | github.com/labstack/echo/v4 |
< 4.16.0 |
4.16.0 |
Original description The description as published by the source.
Summary
When middleware.Static is mounted globally (e.Use(middleware.Static(...))) and an application relies on a route- or group-level middleware guard to restrict a path that also falls under the served static root, a %2F-encoded request bypasses that guard while the file is still served. This is the same encoding/decoding mismatch fixed for StaticFS/StaticDirectoryHandler in CVE-2026-55677 / GHSA-vfp3-v2gw-7wfq, but the fix did not cover the middleware.Static path. In addition, the StaticConfig.EnablePathUnescaping docstring states the default configuration prevents exactly this bypass, which is inaccurate for the global-mount case.
This is not path traversal: no file outside the static root is accessed. The served file lives inside the static root; the issue is that access-control expectations set by a route guard are inconsistent between the literal and %2F-encoded forms of the same path.
Details
Root cause — the router and the static handler disagree on how to interpret %2F:
- The router matches routes on the raw, still-encoded path, so
GET /admin%2Fsecret.txtdoes not match a/admin/...route or group; any middleware attached to that route/group is therefore skipped. middleware.Staticselects its path source inmiddleware/static.go(~L219): with a globale.Usemount there is no wildcard route, so it usesc.Request().URL.Path, whichnet/httphas already decoded (%2F→/). It thenpath.Cleans (~L235)…
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory