From 122f8f86d5f6712a3b9be162aa01cb525ba4055a Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 11 Nov 2020 22:47:42 +0100 Subject: [PATCH] Disallow urlencoded new lines in git protocol paths if there is a port (#13521) (#13524) Signed-off-by: Andrew Thornton Co-authored-by: zeripath --- 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 039b0cb58..f27812bb1 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) {