Skip to content

Commit

Permalink
Fixed issue #19599: [security] Stored XSS through csv file upload (th…
Browse files Browse the repository at this point in the history
…anks to paoloelia ) (#3882)
  • Loading branch information
Shnoulle committed Jun 21, 2024
1 parent 43c4960 commit 5ecaa39
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions application/models/UserParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function getDataFromCSV($FILES)
} elseif (strtolower($sExtension) == 'csv') {
$bMoveFileResult = @move_uploaded_file($_FILES['the_file']['tmp_name'], $sFilePath);
} else {
Yii::app()->setFlashMessage(gT("This is not a .csv file.") . 'It is a ' . $sExtension, 'error');
Yii::app()->setFlashMessage(gT("This is not a .csv file."), 'error');
Yii::app()->getController()->redirect(array('/userManagement/index'));
Yii::app()->end();
}
Expand All @@ -45,11 +45,16 @@ public static function getDataFromCSV($FILES)
$delimiter = self::detectCsvDelimiter($sFilePath);
$oCSVFile = fopen($sFilePath, 'r');
if ($oCSVFile === false) {
safeDie('File not found.');
// Throw a 500 error here : file was moved by LimeSurvey at set $bMoveFileResult : there are an install issue
throw new \CException('File can not be read.');
}

$aFirstLine = fgetcsv($oCSVFile, 0, $delimiter, '"');

if (empty($aFirstLine)) {
Yii::app()->setFlashMessage(gT("This CSV file seems to be empty"), 'error');
Yii::app()->getController()->redirect(array('/userManagement/index'));
Yii::app()->end();
}
$iHeaderCount = count($aFirstLine);
$aToBeAddedUsers = [];
while (($row = fgetcsv($oCSVFile, 0, $delimiter, '"')) !== false) {
Expand Down

0 comments on commit 5ecaa39

Please sign in to comment.