From dc756b9de33e7e87f6e134f7cfd10455d2a9fbb8 Mon Sep 17 00:00:00 2001 From: Joel Speed <joel.speed@hotmail.co.uk> Date: Sun, 31 May 2020 15:32:07 +0100 Subject: [PATCH] Don't log invalid redirect if redirect is empty --- CHANGELOG.md | 1 + oauthproxy.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22e489a1..5ea4fc00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ ## Changes since v5.1.1 - [#620](https://github.com/oauth2-proxy/oauth2-proxy/pull/620) Add HealthCheck middleware (@JoelSpeed) +- [#597](https://github.com/oauth2-proxy/oauth2-proxy/pull/597) Don't log invalid redirect if redirect is empty (@JoelSpeed) - [#604](https://github.com/oauth2-proxy/oauth2-proxy/pull/604) Add Keycloak local testing environment (@EvgeniGordeev) - [#539](https://github.com/oauth2-proxy/oauth2-proxy/pull/539) Refactor encryption ciphers and add AES-GCM support (@NickMeves) - [#601](https://github.com/oauth2-proxy/oauth2-proxy/pull/601) Ensure decrypted user/email are valid UTF8 (@JoelSpeed) diff --git a/oauthproxy.go b/oauthproxy.go index b4119918..4c2b23c0 100644 --- a/oauthproxy.go +++ b/oauthproxy.go @@ -598,6 +598,9 @@ func validOptionalPort(port string) bool { // IsValidRedirect checks whether the redirect URL is whitelisted func (p *OAuthProxy) IsValidRedirect(redirect string) bool { switch { + case redirect == "": + // The user didn't specify a redirect, should fallback to `/` + return false case strings.HasPrefix(redirect, "/") && !strings.HasPrefix(redirect, "//") && !invalidRedirectRegex.MatchString(redirect): return true case strings.HasPrefix(redirect, "http://") || strings.HasPrefix(redirect, "https://"):