Описание
Caddy: Windows file_server path authorization bypass via encoded backslash
Summary
On Windows, Caddy path matchers treat /private\secret.txt as outside /private/*, but file_server later resolves the same request path as private\secret.txt on disk.
An unauthenticated remote client can request /private%5csecret.txt and bypass Caddy path-scoped auth/deny routes protecting /private/*.
Details
The mismatch is between two Caddy code paths:
MatchPath.MatchWithError()comparesr.URL.Pathusing URL path semantics and does not normalize\to/:modules/caddyhttp/matchers.go:429,:436,:490,:532.- If the route matcher misses, Caddy skips that route:
modules/caddyhttp/routes.go:271. file_serverthen maps the same request path to a filesystem path withSanitizedPathJoin(root, r.URL.Path):modules/caddyhttp/fileserver/staticfiles.go:294,modules/caddyhttp/caddyhttp.go:257,:263.- On Windows, Go filesystem path handling treats
\as a separator, so the default filesystem opens the file under the protected directory:internal/filesystems/os.go:18.
This is related to, but distinct from, GHSA-4xrr-hq4w-6vf4 / CVE-2026-27585. That advisory fixed backslash handling in the file matcher / try_files glob path. This report does not use try_files or the file matcher; it affects ordinary path route matchers in front of direct file_server serving and reproduces on current HEAD.
PoC
Tested on current HEAD 6c675e29f87cbe7326983ddb6d739175119d394c with a Windows caddy.exe built from this repository.
On Windows, create the test files and Caddyfile:
Start Caddy:
Baseline request, expected to be blocked:
Observed:
Bypass request:
Observed:
Uppercase %5C produces the same result.
Relevant debug log lines:
Impact
This is a Windows-only remote authorization bypass for deployments that protect static subtrees with Caddy path matchers before file_server.
This pattern is documented by Caddy itself, for example basic_auth /secret/* { ... } followed by file_server.
An attacker can read files that were intended to be protected by Caddy-side basic_auth, respond 403, or other path-scoped handlers. The issue does not escape the configured site root; ..%5c traversal is still blocked. The practical impact is sensitive file disclosure inside the protected subtree, with higher impact if that subtree contains backups, database files, exported admin data, credentials, or signing/session secrets.
Suggested Fix
Normalize Windows path separators consistently before MatchPath evaluates request paths, or reject request paths containing \ before file_server resolves them as filesystem separators.
The important invariant is that a request path used for route authorization must not later resolve to a different protected filesystem path.
AI Disclosure
LLM assistance was used for codebase analysis and report drafting. The PoC was manually validated, including an end-to-end reproduction on a Windows Server lab host using a Windows caddy.exe built from current HEAD.
Пакеты
github.com/caddyserver/caddy/v2
< 2.11.4
2.11.4
github.com/caddyserver/caddy
<= 1.0.5
Отсутствует
Связанные уязвимости
Caddy is an extensible server platform that uses TLS by default. Prior to 2.11.4, on Windows, Caddy path matchers treat /private\secret.txt as outside /private/*, but file_server later resolves the same request path as private\secret.txt on disk. An unauthenticated remote client can bypass Caddy path-scoped auth/deny routes protecting /private/*. This vulnerability is fixed in 2.11.4.
Caddy is an extensible server platform that uses TLS by default. Prior to 2.11.4, on Windows, Caddy path matchers treat /private\secret.txt as outside /private/*, but file_server later resolves the same request path as private\secret.txt on disk. An unauthenticated remote client can bypass Caddy path-scoped auth/deny routes protecting /private/*. This vulnerability is fixed in 2.11.4.
Caddy is an extensible server platform that uses TLS by default. Prior ...