Review main Merged

46072[BUGFIX] Denied file extensions still shown in upload forms

Marco Huber CR +2 V +2 Easy +4 −4 updated 03/05/16, 14:51

Commit message

The list of denied file extensions does not contain a dot, but our
fileDenyPattern by default starts with a dot. Therefore, although a
check is performed, the file extensions will still be displayed even
though uploading files with the extension is forbidden by
fileDenyPattern.

This commit adds the dot before the extension when performing the 
check, effectively hiding forbidden extensions.

Review

  • Code review CR +2
    • Andreas Wolf +2
  • Verified V +2
    • Andreas Wolf +2

Issues 1

Files 2

Review log 23

  1. Marco Huber uploaded patch set 1 01/19/16, 09:59

  2. Marco Huber commented on patch set 1 01/19/16, 10:35

    Ah, damn. There is a typo in the commit message (agains => against). I will fix it, when there is some more feedback :-)
  3. Andreas Kienast commented on patch set 1 01/19/16, 11:17

    Are there more occurrences where we may need to check this? In this case I opt to change verifyFilenameAgainstDenyPattern instead, including unit tests.
  4. Marco Huber commented on patch set 1 01/19/16, 11:57

    grep -rnw "." -e "verifyFilenameAgainstDenyPattern" ./typo3/sysext/reports/Classes/Report/Status/SecurityStatus.php:177: && GeneralUtility::verifyFilenameAgainstDenyPattern('.htaccess')) { ./typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php:4234: * Tests whether verifyFilenameAgainstDenyPattern detects denied files. ./typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php:4242: $this->assertFalse(GeneralUtility::verifyFilenameAgainstDenyPattern($deniedFile)); ./typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php:932: if (!GeneralUtility::verifyFilenameAgainstDenyPattern($absfilename)) { ./typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php:1114: if (!GeneralUtility::verifyFilenameAgainstDenyPattern($realFileName)) { ./typo3/sysext/core/Classes/Resource/ResourceStorage.php:709: $isAllowed = GeneralUtility::verifyFilenameAgainstDenyPattern($fileName); ./typo3/sysext/core/Classes/Utility/GeneralUtility.php:3576: public static function verifyFilenameAgainstDenyPattern($filename) ./typo3/sysext/core/Classes/Utility/File/BasicFileUtility.php:234: return GeneralUtility::verifyFilenameAgainstDenyPattern($filename) && $this->is_allowed($ext, ($this->is_webpath($theDest) ? 'webspace' : 'ftpspace')); ./typo3/sysext/recordlist/Classes/View/FolderUtilityRenderer.php:125: if (GeneralUtility::verifyFilenameAgainstDenyPattern($fileExt)) { ./typo3/sysext/recordlist/Classes/View/FolderUtilityRenderer.php:185: if (GeneralUtility::verifyFilenameAgainstDenyPattern($fileExt) ./typo3/sysext/backend/Classes/Controller/File/CreateFolderController.php:211: if (GeneralUtility::verifyFilenameAgainstDenyPattern($fileExt)) { ./typo3/sysext/backend/Classes/Controller/File/CreateFolderController.php:250: if (GeneralUtility::verifyFilenameAgainstDenyPattern($fileExt)) { But only in the two patched files a file extension is handed over. Everwhere else it's a full filename.
  5. Stefan Neufeind commented on patch set 1 CR -1 01/19/16, 15:24

    I agree to better adjust verifyFilenameAgainstDenyPattern() or cleanup the filepattern somewhere before. It's no use to add a trick in each and every place we come across.
  6. Marco Huber commented on patch set 1 01/19/16, 17:10

    What do you think about this idea: Accept this patch as hotfix for the master and 7.6 branch and implement a more general solution for master? Because if you look at the patched classes, they definitly should be refactored completly. But a complete refactoring would never make it to 7.6 because of to many breaking changes, I think.
  7. Marco Huber uploaded patch set 2 01/22/16, 15:07

  8. Stefan Neufeind commented on patch set 2 CR +1 01/22/16, 15:21

    imho looks like a viable solution to me for a hotfix. Adding a dot there (it doesn't matter if there might be two dots or so) will make it a "filename" to compare aginst, not just the extension.
  9. Sascha Egerer commented on patch set 2 CR -1 01/24/16, 16:29

    What about a file that starts with a dot? '.htaccess' wil become '..htaccess' which may not match to the pattern. The file deny pattern is a pattern for the whole filename so we should not modify the filename here.
  10. Stefan Neufeind commented on patch set 2 01/24/16, 21:26

    @Sascha: imho not a problem since we check for the file-extension, well here the "end of the filename". The default-pattern for file-extensions contains one dot before the extension (and a dollar to mark the end of the string-match). So adding another dot in front of .htaccess won't do harm here for comparison.
  11. Sascha Egerer commented on patch set 2 01/24/16, 21:32

    @stefan it may work in our default case but could be a problem if a custom pattern is defined
  12. Stefan Neufeind commented on patch set 2 01/24/16, 21:33

    So what do you propose? What fix for 7.6 and what (maybe slightly breaking but documented) behaviour for master?
  13. Sascha Egerer commented on patch set 2 CR 0 01/25/16, 12:08

    No suggestion so far. Just rechecked the code where the points have been added and looks like it's safe there. So I've removed my -1
  14. Helmut Hummel commented on patch set 2 01/26/16, 21:10

    CreateFolderController.php:211

    I would even write 'dummy.' . $fileExt (in all cases)
  15. Marco Huber commented on patch set 2 02/08/16, 07:14

    If we write 'dummy.' . $fileExt then files like .htaccess, .gitconfig, ... won't match.
  16. Mathias Schreiber voted on patch set 2 CR +1 V +1 03/05/16, 14:06

  17. Andreas Wolf commented on patch set 2 CR -1 03/05/16, 14:40

    Writing a unit test currently.
  18. Andreas Wolf uploaded patch set 3 03/05/16, 14:48

  19. Andreas Wolf wrote 03/05/16, 14:50

    Patch set 4: Commit message was updated.
  20. Andreas Wolf wrote 03/05/16, 14:51

    Patch set 5: Commit message was updated.
  21. Andreas Wolf voted on patch set 5 CR +2 V +2 03/05/16, 14:51

  22. Gerrit merged patch set 5 03/05/16, 14:51

  23. Andreas Wolf commented on patch set 6 03/05/16, 14:51

    Cherry Picked This patchset was cherry picked to branch TYPO3_7-6 as commit 9b6287de291daad6713d5041ac32bc869478df66