Skip to content

Commit 9dddb96

Browse files
committed
Add check against external->local
Signed-off-by: Andrew Thornton <[email protected]>
1 parent cf5a1d2 commit 9dddb96

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

services/migrations/migrate.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,18 @@ func migrateRepository(doer *user_model.User, downloader base.Downloader, upload
205205
return err
206206
}
207207

208-
// And so can the original URL too so again we must recheck
209-
if repo.OriginalURL != "" {
210-
if err := IsMigrateURLAllowed(repo.OriginalURL, doer); err != nil {
211-
return err
208+
// SECURITY: Ensure that we haven't been redirected from an external to a local filesystem
209+
// Now we know all of these must parse
210+
cloneAddrURL, _ := url.Parse(opts.CloneAddr)
211+
cloneURL, _ := url.Parse(repo.CloneURL)
212+
213+
if cloneURL.Scheme == "file" || cloneURL.Scheme == "" {
214+
if cloneAddrURL.Scheme != "file" && cloneAddrURL.Scheme != "" {
215+
return fmt.Errorf("repo info has changed from external to local filesystem")
212216
}
213217
}
218+
219+
// We don't actually need to check the OriginalURL as it isn't used anywhere
214220
}
215221

216222
log.Trace("migrating git data from %s", repo.CloneURL)

0 commit comments

Comments
 (0)