From 8116f7be7da8c92965138e5334ac2e5d8a7b9707 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Wed, 11 Nov 2020 17:12:01 +0000 Subject: [PATCH] Disallow urlencoded new lines in git protocol paths if there is a port Signed-off-by: Andrew Thornton --- modules/auth/repo_form.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index 039b0cb583a0..f27812bb1b96 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -102,6 +102,9 @@ func ParseRemoteAddr(remoteAddr, authUsername, authPassword string, user *models u.User = url.UserPassword(authUsername, authPassword) } remoteAddr = u.String() + if u.Scheme == "git" && u.Port() != "" && (strings.Contains(remoteAddr, "%0d") || strings.Contains(remoteAddr, "%0a")) { + return "", models.ErrInvalidCloneAddr{IsURLError: true} + } } else if !user.CanImportLocal() { return "", models.ErrInvalidCloneAddr{IsPermissionDenied: true} } else if !com.IsDir(remoteAddr) {