…iddleware
Backport of the v5 fix (GHSA-vfp3-v2gw-7wfq) to the v4 line.
An encoded path separator (%2F or %5C) in a static file URL could bypass route-level
access control and disclose files. The router matches routes against the raw,
still-encoded request path, so %2F is not a segment separator -- /admin%2Fsecret.txt
never matches a protected /admin/* group and falls through to the static handler,
which then unescaped %2F back to "/" and served admin/secret.txt from disk.
Both static serving paths are affected and fixed:
- StaticDirectoryHandler (echo_fs.go), used by Static/StaticFS, and the static
middleware (middleware/static.go) now reject a wildcard containing an encoded
separator (%2F/%2f or %5C/%5c) with 404 before unescaping, via a shared internal
helper (internal/pathutil).
- StaticDirectoryHandler resolves the file name with path.Clean instead of the
OS-specific filepath.Clean, so a decoded backslash stays a literal character
rather than being treated as a separator on Windows. (The middleware already used
path.Clean.)
Tests cover %2F, %5C, double-encoded %252F, group StaticFS, and the static
middleware on a group, plus a unit test for the separator detector.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
v4 backport of #3009 (released in v5.2.0) for GHSA-vfp3-v2gw-7wfq.
Summary
An encoded path separator (%2F or %5C) in a static file URL could bypass route-level access control and disclose files. The router matches against the raw, still-encoded path, so %2F is not a separator — /admin%2Fsecret.txt skips a protected /admin/* group, falls through to static serving, which then unescaped %2F→/ and served admin/secret.txt.
v4 is affected on both static surfaces:
Fix
Tests
Targets the v4 branch for a v4.15.3 release; the advisory will be amended to add the github.com/labstack/echo (v4) affected product once tagged.
🤖 Generated with Claude Code