Skip to content

Commit

Permalink
Fixed issue #19094: [security] Input Validation Vulnerability Leading…
Browse files Browse the repository at this point in the history
… to 500 on responses page (#3520)
  • Loading branch information
Shnoulle committed Oct 13, 2023
1 parent 69efa21 commit b1146f3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion application/helpers/common_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1104,8 +1104,13 @@ function getExtendedAnswer($iSurveyID, $sFieldCode, $sValue, $sLanguage)
if (!isset($file['comment'])) {
$file['comment'] = '';
}
$size = "";
if($file['size'] && strval(floatval($file['size'])) == strval($file['size'])) {
// avoid to throw PHP error if size is invalid
$size = sprintf('%s KB', round($file['size']));
}
$sValue .= rawurldecode((string) $file['name']) .
' (' . round($file['size']) . 'KB) ' .
' (' . $size .' ) ' .
strip_tags((string) $file['title']);
if (trim(strip_tags((string) $file['comment'])) != "") {
$sValue .= ' - ' . strip_tags((string) $file['comment']);
Expand Down
2 changes: 2 additions & 0 deletions application/helpers/expressions/em_manager_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8512,6 +8512,8 @@ public static function ProcessCurrentResponses()
}
$aFiles[$i]->filename = $sDestinationFileName;
}
/* Sanitize size */
$aFiles[$i]->size = floatval($aFiles[$i]->size);
}
$value = ls_json_encode($aFiles); // so that EM doesn't try to parse it.
}
Expand Down
12 changes: 9 additions & 3 deletions application/models/SurveyDynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,15 @@ public function getExtendedData($colName, $sLanguage, $base64jsonFieldMap)
for ($iFileIndex = 0; $iFileIndex < $aQuestionAttributes['max_num_of_files']; $iFileIndex++) {
$sSurveyEntry .= '<tr>';
if (isset($aFilesInfo[$iFileIndex])) {
$sSurveyEntry .= '<td>' . CHtml::link(CHtml::encode(rawurldecode((string) $aFilesInfo[$iFileIndex]['name'])), App()->createUrl("responses/downloadfile", ["surveyId" => self::$sid, "responseId" => $this->id, "qid" => $oFieldMap->qid, "index" => $iFileIndex])) . '</td>';
$sSurveyEntry .= '<td>' . sprintf('%s Mb', round($aFilesInfo[$iFileIndex]['size'] / 1000, 2)) . '</td>';

$url = App()->createUrl("responses/downloadfile", ["surveyId" => self::$sid, "responseId" => $this->id, "qid" => $oFieldMap->qid, "index" => $iFileIndex]);
$filename = CHtml::encode(rawurldecode($aFilesInfo[$iFileIndex]['name']));
$size = "";
if ($aFilesInfo[$iFileIndex]['size'] && strval(floatval($aFilesInfo[$iFileIndex]['size'])) == strval($aFilesInfo[$iFileIndex]['size'])) {
// avoid to throw PHP error if size is invalid
$size = sprintf('%s Mb', round($aFilesInfo[$iFileIndex]['size'] / 1000, 2));
}
$sSurveyEntry .= '<td>' . CHtml::link($filename, $url) . '</td>';
$sSurveyEntry .= '<td>' . $size . '</td>';
if ($aQuestionAttributes['show_title']) {
if (!isset($aFilesInfo[$iFileIndex]['title'])) {
$aFilesInfo[$iFileIndex]['title'] = '';
Expand Down

0 comments on commit b1146f3

Please sign in to comment.