mirror of
https://github.com/gogs/gogs.git
synced 2026-03-06 12:11:00 +01:00
repo: disallow urlencoded new lines in git protocol paths (#6420)
Co-authored-by: ᴜɴᴋɴᴡᴏɴ <u@gogs.io>
This commit is contained in:
@@ -72,6 +72,10 @@ func (f MigrateRepo) ParseRemoteAddr(user *db.User) (string, error) {
|
||||
if len(f.AuthUsername)+len(f.AuthPassword) > 0 {
|
||||
u.User = url.UserPassword(f.AuthUsername, f.AuthPassword)
|
||||
}
|
||||
// To prevent CRLF injection in git protocol, see https://github.com/gogs/gogs/issues/6413
|
||||
if u.Scheme == "git" && (strings.Contains(remoteAddr, "%0d") || strings.Contains(remoteAddr, "%0a")) {
|
||||
return "", db.ErrInvalidCloneAddr{IsURLError: true}
|
||||
}
|
||||
remoteAddr = u.String()
|
||||
} else if !user.CanImportLocal() {
|
||||
return "", db.ErrInvalidCloneAddr{IsPermissionDenied: true}
|
||||
|
||||
Reference in New Issue
Block a user