Properly remove bad profile dir #435

Merged
dan merged 2 commits from import_export into master 2022-03-09 23:58:37 +00:00
2 changed files with 3 additions and 2 deletions
Showing only changes of commit bf4cca631c - Show all commits

View File

@ -129,7 +129,7 @@ func (app *application) AddPeerPlugin(onion string, pluginID plugins.PluginID) {
func (app *application) ImportProfile(exportedCwtchFile string, password string) (peer.CwtchPeer, error) {
profileDirectory := path.Join(app.directory, "profiles")
profile, err := peer.ImportProfile(exportedCwtchFile, profileDirectory, password)
if err == nil {
if profile != nil || err == nil {
app.installProfile(profile)
}
return profile, err

View File

@ -191,7 +191,8 @@ func ImportProfile(exportedCwtchFile string, profilesDir string, password string
return profile, err
}
// Otherwise purge
os.RemoveAll(filepath.Join(profilesDir, profileDir))
log.Errorf("error importing profile: %v. removing %s", err, profileDir)
os.RemoveAll(profileDir)
dan marked this conversation as resolved
Review

is it possible a malicious profile tarball could be constructed with a "id" / directory named '..' or something that on import and failure it trigers a deletion of the profiles directory or worse?

is it possible a malicious profile tarball could be constructed with a "id" / directory named '..' or something that on import and failure it trigers a deletion of the profiles directory or worse?
return nil, err
}
return nil, err