Echoのmiddleware.Staticに認証を回避される脆弱性
概要
Echoのmiddleware.Staticで、%2Fでエンコードしたパスによりルートやグループのミドルウェアによる保護を回避され、静的ルート配下のファイルに届く可能性があります。影響を受けるのは4.16.0より前と5.4.0より前のEchoで、4.16.0および5.4.0で修正されています。修正版への更新を優先してください。global mountの構成で保護が効くかは資料内で食い違っているため、詳しい条件は公表されていません。最新の情報を確認してください。
AI要約
外部の AI が作成した要約です。誤りを含むことがあります。重要な判断の前に、下の原文と参照URLを確認してください。
Echoのmiddleware.Staticで、%2Fでエンコードしたパスによりルートやグループのミドルウェアによる保護を回避され、静的ルート配下のファイルに届く可能性があります。影響を受けるのは4.16.0より前と5.4.0より前のEchoで、4.16.0および5.4.0で修正されています。修正版への更新を優先してください。global mountの構成で保護が効くかは資料内で食い違っているため、詳しい条件は公表されていません。最新の情報を確認してください。
影響パッケージ
| 種類 | パッケージ | 影響を受ける版 | 直った版 |
|---|---|---|---|
| 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 |
原文の説明 取得元が公開している説明をそのまま載せています (多くは英語)。
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)…
出典: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory