Skip to content

Commit b66a68f

Browse files
styprunknwon
authored andcommitted
repo: disallow urlencoded new lines in git protocol paths (#6420)
Co-authored-by: ᴜɴᴋɴᴡᴏɴ <[email protected]>
1 parent 16f5c71 commit b66a68f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ All notable changes to Gogs are documented in this file.
1818
### Fixed
1919

2020
- Add `X-Frame-Options` header to prevent Clickjacking. [#6409](https://github.com/gogs/gogs/issues/6409)
21+
- [Security] Potential SSRF attack by CRLF injection via repository migration. [#6413](https://github.com/gogs/gogs/issues/6413)
22+
2123

2224
### Removed
2325

internal/form/repo.go

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ func (f MigrateRepo) ParseRemoteAddr(user *db.User) (string, error) {
7070
if len(f.AuthUsername)+len(f.AuthPassword) > 0 {
7171
u.User = url.UserPassword(f.AuthUsername, f.AuthPassword)
7272
}
73+
// To prevent CRLF injection in git protocol, see https://github.com/gogs/gogs/issues/6413
74+
if u.Scheme == "git" && (strings.Contains(remoteAddr, "%0d") || strings.Contains(remoteAddr, "%0a")) {
75+
return "", db.ErrInvalidCloneAddr{IsURLError: true}
76+
}
7377
remoteAddr = u.String()
7478
} else if !user.CanImportLocal() {
7579
return "", db.ErrInvalidCloneAddr{IsPermissionDenied: true}

0 commit comments

Comments
 (0)