Headline
CVE-2016-15017: [SECURITY] Prevent directory traversal · fabarea/media_upload@b25d42a
A vulnerability has been found in fabarea media_upload and classified as critical. This vulnerability affects the function getUploadedFileList of the file Classes/Service/UploadFileService.php. The manipulation leads to pathname traversal. Upgrading to version 0.9.0 is able to address this issue. The name of the patch is b25d42a4981072321c1a363311d8ea2a4ac8763a. It is recommended to upgrade the affected component. VDB-217786 is the identifier assigned to this vulnerability.
@@ -34,33 +34,35 @@ public function getUploadedFileList($property = ‘’)
* Return an array of uploaded files, done in a previous step.
*
* @param string $property
* @throws \Exception
* @return UploadedFile[]
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function getUploadedFiles($property = ‘’)
{
$files = array();
$uploadedFiles = GeneralUtility::trimExplode(',’, $this->getUploadedFileList($property), TRUE);
// Convert uploaded files into array
foreach ($uploadedFiles as $uploadedFileName) {
$temporaryFileNameAndPath = UploadManager::UPLOAD_FOLDER . ‘/’ . $uploadedFileName;
// Protection against directory traversal
$uploadedFileName = str_replace(‘…’ . DIRECTORY_SEPARATOR, '’, $uploadedFileName);
$temporaryFileNameAndPath = UploadManager::UPLOAD_FOLDER . DIRECTORY_SEPARATOR . $uploadedFileName;
if (!file_exists($temporaryFileNameAndPath)) {
$message = sprintf(
'I could not find file "%s". Something went wrong during the upload? Or is it some cache effect?’,
$temporaryFileNameAndPath
);
throw new \Exception($message, 1389550006);
throw new \RuntimeException($message, 1389550006);
}
$fileSize = round(filesize($temporaryFileNameAndPath) / 1000);
/** @var UploadedFile $uploadedFile */
$uploadedFile = GeneralUtility::makeInstance(UploadedFile::class);
$uploadedFile->setTemporaryFileNameAndPath($temporaryFileNameAndPath)
->setFileName($uploadedFileName)
->setFileName(basename($uploadedFileName))
->setSize($fileSize);
$files[] = $uploadedFile;