Review main Merged

90152[BUGFIX] Skip consistency checks in ResourceStorage::addUploadedFile

Oliver Hader CR +2 V +2 Easy +1 −1 updated 09/12/25, 13:04

Commit message

`ResourceStorage::addUploadedFilе` currently invokes the resource
consistency checks - which is invoked again in subsequent calls
of `addUploadedFile` to either `replaceFile` or `addFile`.
As a result, skipping consistency checks did not work in this
case, since skip instructions are revoked immediately.

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Torben Hansen +1
    • Stefan Froemken +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Torben Hansen +1
    • Stefan Froemken +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 2124

  1. Oliver Hader uploaded patch set 1 07/25/25, 08:48

  2. core-ci voted on patch set 1 V +1 07/25/25, 08:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82308

  3. Markus Klein voted on patch set 1 CR +1 07/25/25, 09:11

  4. Garvin Hicking commented on patch set 1 07/25/25, 15:36

    Not getting an exception anymore (yay), however upload of an `exe` file would now be possible with feature flags enabled and not having 'exe' listed in either mediafile_ext, miscfile_ext, textfile_ext...?
  5. Garvin Hicking commented on patch set 1 07/25/25, 16:27

    I've uploaded my small extension: https://github.com/garvinhicking/extbase_upload/tree/v14-mime (use only that branch). It ships a very reduced Extbase CRUD Plugin that allows to upload files, and ships an example EXT:form file. Both ways have no MIME-Type restrictions. When used, I would expect "exe" files to not be allowed, given that: * feature flags `security.system.enforceFileExtensionMimeTypeConsistency` && `security.system.enforceAllowedFileExtensions` are enabled * `exe` not listed in either mediafile_ext, miscfile_ext, textfile_ext config * https://review.typo3.org/c/Packages/TYPO3.CMS/+/90134 is applied (otherwise EXT:form will crash on file uploads)
  6. Oliver Hader commented on patch set 1 CR -2 08/01/25, 11:15

    On hold for the time being
  7. Oliver Hader commented on patch set 1 08/01/25, 11:45

    Reply

    https://review.typo3.org/c/Packages/TYPO3.CMS/+/90219 (or ensuring that Extbase file upload at least performs a mime-type consistency check) should be handled first.
  8. Garvin Hicking rebased onto patch set 2 CR +1 V +1 08/02/25, 18:52

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  9. core-ci voted on patch set 2 V +1 08/02/25, 19:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82670

  10. Garvin Hicking rebased onto patch set 3 V +1 08/28/25, 19:06

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  11. core-ci voted on patch set 3 V +1 08/28/25, 19:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83943

  12. Oliver Hader voted on patch set 3 CR 0 08/28/25, 19:16

  13. Oliver Hader commented on patch set 3 08/28/25, 19:18

    Reply

    Done
  14. Garvin Hicking voted on patch set 3 CR +1 V +1 08/28/25, 19:47

  15. Garvin Hicking commented on patch set 3 08/28/25, 19:49

    Reply

    Done

    Reply

    Done
  16. Torben Hansen voted on patch set 3 CR +1 V +1 08/29/25, 10:33

  17. Stefan Froemken commented on patch set 3 V -1 08/29/25, 11:23

    I don't get the point about this patch. I have activated "Security: system enforce file extension mime type consistency" (default). Now I create a text-file locally and rename that file to stefan.pdf. Without this patch I can not upload that file via EXT:form. Perfect! After applying this patch I CAN upload my stefan.pdf. This is not what I expect from the activated feature flag.
  18. Oliver Hader commented on patch set 3 08/29/25, 18:29

    Reply

    How did you configure your `ext:form` YAML definition? Did you configure a corresponding mime-type validation there? This patch is about delegating the checks to the more specific application (which is e.g. Extbase file-upload, import-export, or `ext:form`).
  19. Stefan Froemken commented on patch set 3 08/29/25, 20:51

    Reply

    I have following configured: - properties: saveToFileMount: '1:/user_upload/' allowedMimeTypes: - application/pdf - text/vcard type: FileUpload identifier: fileupload-1 label: 'File upload' I created stefan.vcard in PhpStorm, filled it with vcard stuff and renamed it to stefan.pdf.
  20. Garvin Hicking commented on patch set 3 09/05/25, 11:08

    Reply

    @froemken@gmail.com - You actually allowed "text/vcard" as a mimetype. So a file "stefan.pdf" with vcard contents would be fine!
  21. Oliver Hader commented on patch set 3 09/08/25, 19:16

    Reply

    The more specific application in `ext:form` correctly validated the mime-type of the submitted file content. Thus, there is no need to further block persistence in the low-level file abstraction layer. Enforcing resource consistence (or an additional file-name validator) would have to happen in `\TYPO3\CMS\Form\Mvc\Property\TypeConverter\UploadedFileReferenceConverter` instead.
  22. Stefan Froemken commented on patch set 3 CR +1 V +1 09/12/25, 12:48

    I looked into the upload validation flow in detail. The reason why the unit test (https://review.typo3.org/c/Packages/TYPO3.CMS/+/90226) fails only on the Core side is that Extbase and FAL apply similar checks but with different defaults: 1. Extbase enforces FileNameValidator and FileExtensionMimeTypeConsistencyValidator. The FileExtensionValidator by default does not use Core defaults unless `useStorageDefaults = true`. That means a developer **can** allow e.g. `exe` files explicitly and Extbase will accept them. 2. When the file reaches the Core API, `ResourceConsistencyService` still applies the global checks (`textfile_ext`, `mediafile_ext`, `miscfile_ext`) and rejects the same file, even though Extbase already validated it. 3. The skip flag mechanism does not survive until `replaceFile()` / `addFile()`, so the Core ends up repeating validations. The patch removes duplicate checks in `addUploadedFile()`, so validations happen only once in `replaceFile()` / `addFile()`.

    Reply

    Done
  23. Garvin Hicking voted on patch set 3 CR +2 V +2 09/12/25, 13:01

  24. Garvin Hicking merged patch set 4 09/12/25, 13:04