GHSA-375p-5qhx-8wq4 - Echo's middleware.Static: `%2F`-encoded path bypasses route/group middleware guarding a statically-served path
## 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.txt` does **not** match a `/admin/...` route or group; any middleware attached to that route/group is therefore skipped.
- `middleware.Static` selects its path source in `middleware/static.go` (~L219): with a global `e.Use` mount there is no wildcard route, so it uses `c.Request().URL.Path`, which `net/http` has already **decoded** (`%2F` โ `/`). It then `path.Clean`s (~L235) and `Open`s (~L259) `admin/secret.txt`, serving the file.
Net effect: for the literal path the guard runs; for the `%2F`-encoded path the guard is skipped but the same file is served.
Relevant code:
- `middleware/static.go` ~L219 (`p := c.Request().URL.Path`), ~L235 (`path.Clean`), ~L259 (`currentFS.Open`)
- `StaticConfig.EnablePathUnescaping` docstring (`static.go` ~L60-67) โ claims the default prevents the `/admin%2fprivate.txt` โ `/admin/*` guard bypass; this is not true for the global moun
HIGH
Severity & confidence
Source severityhigh
Platform severityhigh
Confidencehigh
Exploitationunknown
CVSS7.5
Affected
Vendorsgithub
Productsgithub.com/labstack/echo/v5github.com/labstack/echo/v4
Reporting sources (2)
GitHub Security Advisories
NIST NVD - National Vulnerability Database
Timeline & provenance
Published2026-10-28T19:54:20
Last updated2026-10-31T20:12:43
Ingested2026-10-28T19:58:59
FreshnessNEAR-REAL-TIME
Threat typeadvisory
Recommended action
Review the advisory and upgrade affected packages to the first patched version.
Next steps
- Identify affected systems in your environment.
- Apply the vendor patch or mitigation guidance.
- Review logs for indicators described in the advisory.
- Follow the affected vendor/product to track updates.
Confidence explanation
Reported by a government or cert-grade source (CISA, NCSC, NVD, ENISA, MSRC).
Source type: vendor ยท Original: GitHub Security Advisories