Описание
Caddy: MatchPath %xx (escaped-path) branch skips case normalization, enabling path-based route/auth bypass
Summary
Caddy's HTTP path request matcher is intended to be case-insensitive, but when the match pattern contains percent-escape sequences (%xx) it compares against the request's escaped path without lowercasing. An attacker can bypass path-based routing and any access controls attached to that route by changing the casing of the request path.
Details
In Caddy v2.10.2, MatchPath is explicitly designed to be case-insensitive and lowercases match patterns during provisioning:
modules/caddyhttp/matchers.go: rationale captured in theMatchPathcomment.MatchPath.Provisionlowercases configured patterns viastrings.ToLower.MatchPath.MatchWithErrorlowercases the request path for the normal matching path:reqPath := strings.ToLower(r.URL.Path).
But when a match pattern contains a percent sign (%), MatchPath.MatchWithError switches to "escaped space" matching and builds the comparison string from r.URL.EscapedPath():
reqPathForPattern := CleanPath(r.URL.EscapedPath(), mergeSlashes)- If it doesn't match, it
continues (skipping the remaining matching logic for that pattern).
Because r.URL.EscapedPath() is not lowercased, case differences in the request path can cause the escaped-space match to fail even though MatchPath is meant to be case-insensitive. For example, with a pattern of /admin%2Fpanel:
- Requesting
/admin%2Fpanelmatches and can be denied as intended. - Requesting
/ADMIN%2Fpaneldoes not match and falls through to other routes/handlers.
Suggested fix
- In the
%-pattern matching path, ensure the effective string passed topath.Matchis lowercased (same as the normal branch).- Simplest seems to lowercase the constructed string in
matchPatternWithEscapeSequenceright beforepath.Match.
- Simplest seems to lowercase the constructed string in
Reproduced on:
- Stable release:
v2.10.2-- this is the release referenced in the reproduction below. - Dev build:
v2.11.0-beta.2. - Master tip: commit
58968b3fd38cacbf4b5e07cc8c8be27696dce60f.
PoC
Prereqs:
- bash, curl
- A pre-built Caddy binary available at
/opt/caddy-2.10.2/caddy(editCADDY_BINin the script if needed)
Script (Click to expand)
Expected output (Click to expand)
Impact
This is a route/auth bypass in Caddy's path-matching logic for patterns that include escape sequences. Deployments that use path matchers with %xx patterns to block or protect sensitive endpoints (including encoded-path variants such as encoded slashes) can be bypassed by changing the casing of the request path, allowing unauthorized access to sensitive endpoints behind Caddy depending on upstream configuration.
The reproduction is minimal per the reporting guidance. In a realistic "full" scenario, a deployment may block %xx variants like path /admin%2Fpanel, otherwise proxying. If the backend is case-insensitive/normalizing, /ADMIN%2Fpanel maps to the same handler; Caddy’s %-pattern match misses due to case, so the block is skipped and the request falls through.
AI Use Disclosure
A custom AI agent pipeline was used to discover the vulnerability, after which was manually reproduced and validated each step. The entire report was ran through an LLM to make sure nothing obvious was missed.
Disclosure/crediting
Asim Viladi Oglu Manizada
Ссылки
- https://github.com/caddyserver/caddy/security/advisories/GHSA-g7pc-pc7g-h8jh
- https://nvd.nist.gov/vuln/detail/CVE-2026-27587
- https://github.com/caddyserver/caddy/commit/a1081194bfae4e0d8c227ec44aecb95eded55d1e
- https://github.com/caddyserver/caddy/releases/tag/v2.11.1
- https://pkg.go.dev/vuln/GO-2026-4538
Пакеты
github.com/caddyserver/caddy/v2
< 2.11.1
2.11.1
Связанные уязвимости
Caddy is an extensible server platform that uses TLS by default. Prior to version 2.11.1, Caddy's HTTP `path` request matcher is intended to be case-insensitive, but when the match pattern contains percent-escape sequences (`%xx`) it compares against the request's escaped path without lowercasing. An attacker can bypass path-based routing and any access controls attached to that route by changing the casing of the request path. Version 2.11.1 contains a fix for the issue.
Caddy is an extensible server platform that uses TLS by default. Prior to version 2.11.1, Caddy's HTTP `path` request matcher is intended to be case-insensitive, but when the match pattern contains percent-escape sequences (`%xx`) it compares against the request's escaped path without lowercasing. An attacker can bypass path-based routing and any access controls attached to that route by changing the casing of the request path. Version 2.11.1 contains a fix for the issue.
Caddy is an extensible server platform that uses TLS by default. Prior ...