The application allows file uploads where both the filename and content are not properly filtered, creating a risk of client-side JavaScript execution.
The checkValidFileName() function (from Security.php) only performs superficial checks on characters and extensions, but does not prevent uploading .html files containing JavaScript code:
Codepublic static function checkValidFileName($fileName,$activeTraceHack=true, $forAttach
ment=true) {
// Checks for invalid characters and accents
if (! preg_match('#^[^/?*:;{}\\<>|"]*\.?[^/?*:;{}\\<>|"]+$#',
pq_nvl($fileName))) {
if($activeTraceHack) traceHack("filename $fileName containts invalid
characters");
}
// Minimal extension filtering
if ($forAttachment) {
$ext = pq_strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
if (pq_substr($ext,0,3)=='php' or $ext=='htaccess') {
$fileName .= '.projeqtor.txt';
}
}
return $fileName;
}
The code does not block .html files and does not validate content, allowing malicious script injection through uploaded files.
Code<script>alert('XSS via file upload');</script>
Upload the file via the form:
Client-side execution:
Successful exploitation of this vulnerability may lead to significant impacts, including:
Codeif (in_array($ext, ['html','htm','js'])) {
$fileName .= '.txt';
}