Review 13.4 Merged

89462[SECURITY] Enforce file extension and MIME-type consistency

Oliver Hader CR +2 V +2 Hard +806 −6 updated 05/20/25, 09:41

Commit message

The File Abstraction Layer (FAL) methods `addFile`, `renameFile`,
`replaceFile`, and `addUploadedFile` in `ResourceStorage` have
been enhanced to enforce consistency and security of file data.

Two validations are now applied:

* Only explicitly allowed file extensions are accepted.
  These must be configured in the TYPO3 global config under
  `$GLOBALS['TYPO3_CONF_VARS']['SYS']`:
  - `textfile_ext`
  - `mediafile_ext`
  - `miscfile_ext`
* A file's MIME-type must match the expected type for its
  extension. For example, uploading a PNG image as `image.exe`
  is disallowed.

The new configuration property `miscfile_ext` enables defining
extensions that don't logically fit into text or media groups
(e.g. `zip`, `xz`). Any extensions not configured are disallowed
by default.

New feature flags:

* `security.system.enforceAllowedFileExtensions`
  - Enforces the file extension allowlist.
  - Disabled by default in existing installations.
  - Enabled by default in new installations.
* `security.system.enforceFileExtensionMimeTypeConsistency`
  - Enforces consistency between file extension and MIME type.

For internal use cases, such as file imports via trusted
low-level system components, one-time exemptions can be declared
using a dedicated trait method.

Review

  • Code review CR +2 Done
    • Oliver Hader +2
  • Verified V +2 Done
    • Oliver Hader +2

Issues 1

Files 20

Review log 34

  1. Oliver Hader uploaded patch set 1 05/20/25, 09:11

  2. Oliver Hader commented on patch set 1 CR +2 V +2 05/20/25, 09:11

    Auto-approved
  3. Oliver Hader merged patch set 2 05/20/25, 09:11

  4. core-ci voted on patch set 1 V +1 05/20/25, 09:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/79212