N°1935: Security hardening

This commit is contained in:
Stephen Abello
2019-01-09 14:23:15 +01:00
parent 48c920f848
commit 0bce9c78ea

View File

@@ -184,7 +184,15 @@ EOF
$sFile = utils::ReadParam('file', '', false, 'raw_data');
$oBackup = new DBBackupScheduled();
$sBackupDir = APPROOT.'data/backups/';
$oBackup->DownloadBackup($sBackupDir.$sFile);
$sPathNoDotDotPattern = '/^((?!\/\.\.\/).)*$/';
if(preg_match($sPathNoDotDotPattern, $sBackupDir.$sFile) == 1)
{
$oBackup->DownloadBackup($sBackupDir.$sFile);
}
else
{
throw new InvalidParameterException('Invalid file path');
}
break;
}
}