Skip to content

Commit 99b0749

Browse files
committed
Security fix - please update ASAP
1 parent dde49db commit 99b0749

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

Classes/Controller/ManagerController.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@
3434
use RENOLIT\ReintDownloadmanager\Domain\Repository\DownloadRepository;
3535
use TYPO3\CMS\Core\Context\Context;
3636
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
37+
use TYPO3\CMS\Core\Http\HtmlResponse;
3738
use TYPO3\CMS\Core\Http\PropagateResponseException;
3839
use TYPO3\CMS\Core\Messaging\FlashMessage;
3940
use TYPO3\CMS\Core\Messaging\FlashMessageService;
4041
use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
4142
use TYPO3\CMS\Core\Resource\File;
4243
use TYPO3\CMS\Core\Resource\FileCollectionRepository;
44+
use TYPO3\CMS\Core\Resource\FileReference;
4345
use TYPO3\CMS\Core\Resource\FileRepository;
4446
use TYPO3\CMS\Core\Resource\ResourceFactory;
4547
use TYPO3\CMS\Core\Session\UserSessionManager;
@@ -493,7 +495,7 @@ protected function loadCollectionsFromFlexform(): bool
493495
* @param array $pageIds
494496
* @throws
495497
*/
496-
protected function getCollectionsFromPages($pageIds): void
498+
protected function getCollectionsFromPages(array $pageIds): void
497499
{
498500
$table = 'sys_file_collection';
499501
$languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
@@ -534,7 +536,7 @@ protected function getCollectionsFromPages($pageIds): void
534536
* @return string
535537
* @throws Exception
536538
*/
537-
protected function getSysFileCollectionData($uid, $fieldname = 'description_frontend'): string
539+
protected function getSysFileCollectionData(int $uid, string $fieldname = 'description_frontend'): string
538540
{
539541
$table = 'sys_file_collection';
540542
/** @var $queryBuilder QueryBuilder */
@@ -569,7 +571,7 @@ protected function setFileNotFound(): void
569571
}
570572

571573
/**
572-
* sets the flashmessage for not found file
574+
* sets the FlashMessage for not found file
573575
*/
574576
protected function setFileNoAccess(): void
575577
{
@@ -596,7 +598,7 @@ protected function writeFlashMessage(string $errorFlashMessage): void
596598
}
597599

598600
/**
599-
* @param integer $uid
601+
* @param int $uid
600602
* @return bool
601603
* @throws Exception
602604
*/
@@ -704,6 +706,22 @@ protected function downloadAction(): ResponseInterface
704706
if ($this->request->hasArgument('downloaduid') && $this->request->hasArgument('actionfrom')) {
705707
$returnToAction = $this->request->getArgument('actionfrom');
706708
$recordUid = (int)$this->request->getArgument('downloaduid');
709+
710+
$this->loadCollectionsFromFlexform();
711+
$this->loadCollectionsFromDb();
712+
$files = [];
713+
foreach ($this->collections as $collection) {
714+
/** @var FileReference $fileReference */
715+
foreach ($collection as $fileReference) {
716+
$fUid = $fileReference->getOriginalFile()->getUid();
717+
$files[$fUid] = $fUid;
718+
}
719+
}
720+
if (!in_array($recordUid, $files)) {
721+
$this->setFileNotFound();
722+
return $this->redirect('list');
723+
}
724+
707725
$publicUri = '';
708726
$fileName = '';
709727
$fileModDate = '';
@@ -726,7 +744,7 @@ protected function downloadAction(): ResponseInterface
726744
$privateUri = $this->getPrivateUrlForNonPublic($file);
727745
} else {
728746
$this->setFileNotFound();
729-
$this->redirect($returnToAction);
747+
return $this->redirect($returnToAction);
730748
}
731749
if (!$file->isMissing() && is_file($privateUri) && $this->feUserFileAccess) {
732750
/* update counter or set new */
@@ -735,15 +753,15 @@ protected function downloadAction(): ResponseInterface
735753
} else {
736754
if (!$this->feUserFileAccess) {
737755
$this->setFileNoAccess();
738-
$this->redirect($returnToAction);
756+
return $this->redirect($returnToAction);
739757
} else {
740758
$this->setFileNotFound();
741-
$this->redirect($returnToAction);
759+
return $this->redirect($returnToAction);
742760
}
743761
}
744762
} else {
745763
$this->setFileNotFound();
746-
$this->redirect('list');
764+
return $this->redirect('list');
747765
}
748766
}
749767
return $this->responseFactory->createResponse();
@@ -761,7 +779,7 @@ protected function downloadAction(): ResponseInterface
761779
* @return ResponseInterface
762780
* @throws PropagateResponseException
763781
*/
764-
protected function downloadFile($privateUri, $fileName, $publicUri, $fileModDate = true): ResponseInterface
782+
protected function downloadFile(string $privateUri, string $fileName, string $publicUri, bool $fileModDate = true): ResponseInterface
765783
{
766784
/* check if there is a setting to redirect only to the file */
767785
if (isset($this->settings['redirecttofile']) && (int)$this->settings['redirecttofile'] === 1) {

Documentation/ChangeLog/Index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
ChangeLog
1212
=========
1313

14+
- **19.05.2025** -> 5.0.1
15+
16+
- Security fix - please update
17+
18+
-----------------------
19+
1420
- **16.01.2025** -> 5.0.0
1521

1622
- initial release for TYPO3 13.4

Documentation/Settings.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[general]
22
project = Download manager
3-
release = 5.0.0
3+
release = 5.0.1
44
version = 5.0
55
copyright = 2025
66

ext_emconf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$EM_CONF[$_EXTKEY] = [
1111
'title' => 'Download manager',
1212
'description' => 'A simple download manager with different views of file collections as downloadable lists.',
13-
'version' => '5.0.0',
13+
'version' => '5.0.1',
1414
'category' => 'plugin',
1515
'constraints' => [
1616
'depends' => [

0 commit comments

Comments
 (0)