Skip to content

Commit

Permalink
Add check against external->local
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed Sep 2, 2022
1 parent cf5a1d2 commit 9dddb96
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions services/migrations/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,18 @@ func migrateRepository(doer *user_model.User, downloader base.Downloader, upload
return err
}

// And so can the original URL too so again we must recheck
if repo.OriginalURL != "" {
if err := IsMigrateURLAllowed(repo.OriginalURL, doer); err != nil {
return err
// SECURITY: Ensure that we haven't been redirected from an external to a local filesystem
// Now we know all of these must parse
cloneAddrURL, _ := url.Parse(opts.CloneAddr)
cloneURL, _ := url.Parse(repo.CloneURL)

if cloneURL.Scheme == "file" || cloneURL.Scheme == "" {
if cloneAddrURL.Scheme != "file" && cloneAddrURL.Scheme != "" {
return fmt.Errorf("repo info has changed from external to local filesystem")
}
}

// We don't actually need to check the OriginalURL as it isn't used anywhere
}

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

0 comments on commit 9dddb96

Please sign in to comment.