[SECURITY] fileDenyPattern ignored in file-list module 12/22712/2
authorJigal van Hemert <jigal@xs4all.nl>
Tue, 30 Jul 2013 12:39:57 +0000 (14:39 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Tue, 30 Jul 2013 12:40:02 +0000 (14:40 +0200)
Change-Id: Icf4b3452c3b039f12335e184161083cbcbd3acec
Fixes: #47452
Releases: 6.0, 6.1, 6.2
Security-Commit: 15cd3daec85c16cf0e810c41f5005810876fc99b
Security-Bulletin: TYPO3-CORE-SA-2013-002
Reviewed-on: https://review.typo3.org/22712
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/core/Classes/Resource/ResourceStorage.php
typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php

index 165b64a..64865c8 100644 (file)
@@ -947,6 +947,9 @@ class ResourceStorage {
                if (!$this->checkFileActionPermission('write', $file)) {
                        throw new Exception\InsufficientFileWritePermissionsException('Writing to file "' . $file->getIdentifier() . '" is not allowed.', 1330121088);
                }
+               if ($this->checkFileExtensionPermission($file->getName()) === FALSE) {
+                       throw new Exception\IllegalFileExtensionException('You are not allowed to edit a file with extension "' . $file->getExtension() . '"', 1366711933);
+               }
                        // Call driver method to update the file and update file properties afterwards
                $result = $this->driver->setFileContents($file, $contents);
                $fileInfo = $this->driver->getFileInfo($file);
@@ -968,6 +971,9 @@ class ResourceStorage {
         * @return FileInterface The file object
         */
        public function createFile($fileName, Folder $targetFolderObject) {
+               if ($this->checkFileExtensionPermission($fileName) === FALSE) {
+                       throw new Exception\IllegalFileExtensionException('You are not allowed to create a file with this extension on storage "' . $targetFolderObject->getCombinedIdentifier() . '"', 1366711745);
+               }
                if (!$this->checkFolderActionPermission('add', $targetFolderObject)) {
                        throw new Exception\InsufficientFolderWritePermissionsException('You are not allowed to create directories on this storage "' . $targetFolderObject->getIdentifier() . '"', 1323059807);
                }
@@ -1251,6 +1257,10 @@ class ResourceStorage {
                if ($file->getIdentifier() == $targetFileName) {
                        return $file;
                }
+               // Check if file extension is allowed
+               if ($this->checkFileExtensionPermission($targetFileName) === FALSE) {
+                       throw new Exception\IllegalFileExtensionException('You are not allowed to rename a file with to this extension', 1371466663);
+               }
                // Check if user is allowed to rename
                if (!$this->checkUserActionPermission('rename', 'File')) {
                        throw new Exception\InsufficientUserPermissionsException('You are not allowed to rename files."', 1319219349);
index 11aff12..aaa4e13 100644 (file)
@@ -804,6 +804,8 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                        $fileName = $cmds['data'];
                        $resultObject = $targetFolderObject->createFile($fileName);
                        $this->writelog(8, 0, 1, 'File created: "%s"', array($fileName));
+               } catch (\TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException $e) {
+                       $this->writeLog(8, 1, 106, 'Extension of file "%s" was not allowed!', array($fileName));
                } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException $e) {
                        $this->writelog(8, 1, 103, 'You are not allowed to create files!', '');
                } catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
@@ -855,6 +857,9 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileWritePermissionsException $e) {
                        $this->writelog(9, 1, 100, 'File "%s" was not saved! Write-permission problem?', array($fileObject->getIdentifier()));
                        return FALSE;
+               } catch (\TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException $e) {
+                       $this->writelog(9, 1, 100, 'File "%s" was not saved! File extension rejected!', array($fileObject->getIdentifier()));
+                       return FALSE;
                }
        }