86092[FEATURE] Restrict backend file uploads by file extensions
Commit message
Review
-
Code review CR 0
-
Verified V 0
- core-ci +1 CI
Issues 1
Files 8
- typo3/sysext/core/Classes/Resource/Security/FileNameValidator.php+98 −1
- typo3/sysext/core/Classes/Resource/AbstractFile.php2+1 −2
- typo3/sysext/core/Classes/Resource/ResourceStorage.php+2 −1
- typo3/sysext/core/Classes/Utility/PathUtility.php+15 −0
- typo3/sysext/core/Configuration/DefaultConfiguration.php+2 −0
- typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml+6 −0
- typo3/sysext/core/Documentation/Changelog/14.0/Feature-102644-AddConfigurationForRestrictingAllowedFileExtensions.rstnew+98 −0
- typo3/sysext/core/Tests/Unit/Resource/Security/FileNameValidatorTest.php+105 −0
Review log 2944
Show 1119 earlier messages
-
Sybille Peters uploaded patch set 1 09/14/24, 10:43
-
Sybille Peters updated the commit message in patch set 2 09/14/24, 10:44
-
Sybille Peters updated the commit message in patch set 3 09/14/24, 10:45
-
core-ci voted on patch set 2 V -1 09/14/24, 10:52 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65752
-
core-ci voted on patch set 3 V -1 09/14/24, 10:54 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65753
-
core-ci voted on patch set 1 V -1 09/14/24, 10:54 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65751
-
Sybille Peters uploaded patch set 4
V -109/14/24, 11:01 -
core-ci voted on patch set 4 V -1 09/14/24, 11:07 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65754
-
Sybille Peters uploaded patch set 5
V -109/14/24, 11:23 -
core-ci voted on patch set 5 V +1 09/14/24, 11:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65755
-
Sybille Peters uploaded patch set 6
V +109/14/24, 11:58 -
core-ci voted on patch set 6 V +1 09/14/24, 12:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65756
-
Garvin Hicking commented on patch set 7
V +109/14/24, 18:58Published edit on patch set 6. -
Garvin Hicking commented on patch set 7 09/14/24, 19:01
Unresolved
I think this is a feature helpful to have! I could not test the functionality yet and not perform a proper code review. I adjusted the ReST file for some commentary, hope that was fine by you. Things that need testing: - How does this play with TCA configurations for uploads (allow/deny patterns) - How does it play with Extbase file uploads, with also use the FilenameValidator by default. Especially because for extbase file uploads different allowed/denied filename patterns will be applied - Neesd involvement of the Security team for approvalAbstractFile.php:258IMO this does not belong into the Abstract File class, but a method in `TYPO3\CMS\Core\UtilityPathUtility` instead, especially because what's checked is not part of an AbstractFile object, but a another file...? We could then utilize that method also in AbstractFile::getExtension() then. A dependency to PathUtility already exists. -
core-ci voted on patch set 7 V +1 09/14/24, 19:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65767
-
Garvin Hicking updated the commit message in patch set 8
V +109/14/24, 19:06 -
core-ci voted on patch set 8 V +1 09/14/24, 19:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65768
-
Benni Mack commented on patch set 8 09/14/24, 19:26
I think that's quite interesting, even though I think if we want to do this on editor-level (at least this is my understanding when reading the commit message), a userTSconfig option would be better suited? I also would like to know what is the definition of which option trumps which? we have this often in other places, such as "allowTags" vs. "denyTags". Setting values to "" or "*" etc, where this needs to be well thought-out. What was your idea here? Also if people would need both options at the same time? -
Garvin Hicking commented on patch set 8 09/14/24, 19:47
Reply
Maybe I wrongly changed terminology when I referred to "editorial" and mislead you, Benni. I think this is still meant to apply installation-wide. But it's an interesting thought to maybe apply this to backend user groups, too (IMO not on per-user level though). So that certain editors can only upload images, and others can upload zips. Most pressing would be system-wide though, maybe the other enhancement per-groups would be a different patch. I think it's mainly to generally prevent files that are not supported in an implemented site. The ReST file explains the stacking idea: denyPatter filters out dangerous files. AllowTypes positively filter (if used) and in the end deny takes place, and IMO deny needs to be able to deny patterns that were allowed in allowpattern. But I leave the concept to this up to Sybille :)
-
Sybille Peters commented on patch set 8 09/14/24, 20:58
Reply Unresolved
Fron my end, I did not intend to do this on editor-level. In fact I (primarily) want to restrict editors from uploading files which are not suitable for the web. Which option trumps which - yes, that is the question. Right now it is very restrictive, so if you have something in the "deny", it is denied in any case, regardless if it is in "allow". If "allow" is set, only these will be allowed, even if not set in deny. I think this is a safe way to do this. (It does not make sense to set both). Also, the already existing fileDenyPattern is always applied additionally. Also, there is no pattern matching or "*". You only use a list of extensions. (If pattern is required, you can override the fileDenyPattern). I hope my intention is more or less clear. I explained a little in the changelog. -
Sybille Peters uploaded patch set 9
V +112/01/24, 14:06 -
core-ci voted on patch set 9 V +1 12/01/24, 14:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70422
-
Sybille Peters commented on patch set 9 12/07/24, 07:07
Feature-102644-AddConfigurationForRestrictingAllowedFileExtensions.rst:21I think this should be "Comma-separated" or "comma separated" -
Sybille Peters uploaded patch set 10
V +112/07/24, 07:07 -
Sybille Peters uploaded patch set 11 12/07/24, 07:11
-
Sybille Peters commented on patch set 9 12/07/24, 07:11
AbstractFile.php:258ReplyI moved the method -
Sybille Peters updated the commit message in patch set 12 12/07/24, 07:12
-
Sybille Peters commented on patch set 12 12/07/24, 07:13
Feature-102644-AddConfigurationForRestrictingAllowedFileExtensions.rst:21ReplyDone -
core-ci voted on patch set 10 V +1 12/07/24, 07:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70738
-
core-ci voted on patch set 12 V -1 12/07/24, 07:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70740
-
core-ci voted on patch set 11 V -1 12/07/24, 07:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70739
-
Sybille Peters uploaded patch set 13
V -112/08/24, 17:26 -
core-ci voted on patch set 13 V +1 12/08/24, 17:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70777
-
Benni Mack wrote 01/24/25, 10:05
Removed cc Benni Mack. -
Garvin Hicking uploaded patch set 14
V +104/03/25, 19:44rebase and fix merge conflict -
core-ci voted on patch set 14 V +1 04/03/25, 19:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76969
-
Sybille Peters updated the commit message in patch set 15
V +105/09/25, 06:29 -
core-ci voted on patch set 15 V +1 05/09/25, 06:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78718
-
Oliver Hader commented on patch set 15 05/17/25, 08:46
In general we should aim for an allow-list-only approach. I'll come back to this topic the next few days... -
Sybille Peters commented on patch set 15 05/20/25, 10:30
Reply
Oliver Hader, it looks like this issue is obsolete with https://typo3.org/security/advisory/typo3-core-sa-2025-014. Can you confirm? -
Oliver Hader commented on patch set 15 05/20/25, 12:20
Reply
I think, it is. The deny-list approach has been dropped, but it has an opt-in functionality via feature flags (which might be enforced in v14). -
Oliver Hader commented on patch set 15 05/20/25, 12:21
Reply
However, there are some good changed in this very patch that would help to streamline the existing code (e.g. using appropriate `PathUtility` functions). -
Sybille Peters commented on patch set 15 05/20/25, 14:11
Reply Unresolved
Ok, waiting for instructions how to proceed. There is no rush from my end. -
Oli Bartsch abandoned the change 11/10/26, 20:26
Abandoning, as the use case of #102644 is covered without touching fileDenyPattern: * System-wide allowlist: feature toggle security.system.enforceAllowedFileExtensions together with SYS.textfile_ext / mediafile_ext / miscfile_ext (see Important-106240, 12.4.x). Remove e.g. "zip" from miscfile_ext to reject it. * Per storage and per file mount: allowedFileExtensions in file-storages.yaml and the new file mount field, merged with #103594 (https://review.typo3.org/c/Packages/TYPO3.CMS/+/96681). A separate deny list on top would add a third place to configure the same thing; an allowlist is the safer model anyway.