From ad8ba07b21fecb28730717ba6ede4a8149e09520 Mon Sep 17 00:00:00 2001 From: Leandro Lafin Date: Thu, 11 Jul 2024 14:16:08 -0300 Subject: [PATCH] fix: use X-Forwarded-Uri if it exists for pathRegex match --- CHANGELOG.md | 1 + oauthproxy.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04e606a9..694f0d92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - [#2013](https://github.com/oauth2-proxy/oauth2-proxy/pull/2013) Upgrade alpine to version 3.17.2 and library dependencies (@miguelborges99) - [#2028](https://github.com/oauth2-proxy/oauth2-proxy/pull/2028) Update golang.org/x/net to v0.7.0 ato address GHSA-vvpx-j8f3-3w6h - [#2047](https://github.com/oauth2-proxy/oauth2-proxy/pull/2047) CVE-2022-41717: DoS in Go net/http may lead to DoS (@miguelborges99 +- [#2133](https://github.com/oauth2-proxy/oauth2-proxy/pull/2133) Use X-Forwarded-Uri if it exists for pathRegex match # V7.4.0 diff --git a/oauthproxy.go b/oauthproxy.go index 39b66418..bdb911fc 100644 --- a/oauthproxy.go +++ b/oauthproxy.go @@ -578,7 +578,7 @@ func isAllowedMethod(req *http.Request, route allowedRoute) bool { } func isAllowedPath(req *http.Request, route allowedRoute) bool { - matches := route.pathRegex.MatchString(req.URL.Path) + matches := route.pathRegex.MatchString(requestutil.GetRequestURI(req)) if route.negate { return !matches @@ -599,7 +599,7 @@ func (p *OAuthProxy) isAllowedRoute(req *http.Request) bool { func (p *OAuthProxy) isAPIPath(req *http.Request) bool { for _, route := range p.apiRoutes { - if route.pathRegex.MatchString(req.URL.Path) { + if route.pathRegex.MatchString(requestutil.GetRequestURI(req)) { return true } }