Repository navigation
caddyhttp: fix url_pattern authorization bypass via encoded-slash traversal - #7941
Merged
mholt merged 2 commits intoAug 15, 2026
Merged
Conversation
The url_pattern matcher evaluated the raw, percent-encoded request URI while path-consuming handlers resolve the decoded, cleaned r.URL.Path. An encoded-slash payload such as "..%2f" stayed a single opaque segment for the WHATWG URLPattern parser, so "/public/..%2fadmin/secret" matched "/public/*" while handlers decoded it to "/admin/secret", bypassing any route-level access control built with url_pattern. Match the same path model handlers resolve: decode the path, normalize and clean it (mirroring the path matcher and caddyserver#4407), then re-encode through url.URL to a canonical escaped form before running the pattern. The go-urlpattern library is spec-correct; the fix is in the integration.
Moves off the pseudo-version to the first tagged release.
Member
|
Hm, I know you have signed our CLA, but it's not showing up at all here. I will go ahead and merge since we know your contribution history already covers that. |
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Advisory: GHSA-m8m5-v4jf-3wcm
Reported by @z3k0sec.
Affected versions
No released version is affected.
url_patternsupport was added in #7787 and has not been part of a tagged release; the bug only exists onmaster.Problem
The
http.matchers.url_patternmatcher evaluated the raw, percent-encoded request URI (r.URL.RequestURI()), while every path-consuming handler resolves the decoded, cleanedr.URL.Path. An encoded-slash payload like..%2fstays a single opaque segment for the WHATWGURLPatternparser, so:/public/..%2fadmin/secretmatches an allow-list pattern of/public/*%2fto/and resolve/admin/secretMatcher and handler ran two different path models on the same request, so any route ACL built with
url_patterncould be bypassed by an unauthenticated request (file_server,reverse_proxy,php_fastcgi, internal routes).The classic
pathmatcher is unaffected; it already compares the cleaned, decoded path (#4407).Fix
Match against the same path model the handlers resolve:
r.URL.PathnormalizeWindowsPath+CleanPath(collapses..and, per the pattern, doubled slashes, mirroringMatchPath)url.URLto a canonical escaped form beforeExecmergeSlashesis derived once inProvisionfrom the pattern's path part, matching the path matcher's//rule.The
github.com/dunglas/go-urlpatternlibrary is spec-correct: keeping%2Fencoded is required by RFC 3986 and matches browserURLPatternbehavior. The defect is in the integration, so the fix stays in Caddy. This PR also bumps go-urlpattern from its pseudo-version to the first tagged release,v1.0.0.Tests
Added regression cases: encoded-slash (
..%2f,..%2F), encoded dots (%2e%2e), raw dots (../), positive re-match on the real decoded target, slash collapsing, empty-segment preservation, and encoded-character decode. Verified against the advisory's live reproduction: all three payloads now return403, control paths still serve.Assistance Disclosure
Patched by Claude, reviewed by me.