Review 14.3 Merged

94773[SECURITY] Register MimeTypeValidator for file uploads at runtime

Oliver Hader CR +2 V +2 Hard +381 −52 updated 07/14/26, 12:08

Commit message

The "allowedMimeTypes" restriction of the FileUpload and ImageUpload
form elements was never enforced on the server side. Uploading a file
whose MIME type is not part of the configured list (e.g. a PNG while
only "application/pdf" is allowed) passed validation and the form was
processed as valid, including running finishers.

Root cause is a timing issue during form building:
FileUpload::initializeFormElement() registered the MimeTypeValidator
based on the "allowedMimeTypes" property. However, the method
initializeFormElement() is called from AbstractSection::createElement()
*before* the concrete form definition properties are applied via the
second setOptions() call in ArrayFormFactory::addNestedRenderable().
As the prototype type definition does not contain "allowedMimeTypes",
the property was always empty at that point and the validator was never
added to the ProcessingRule. The client-side "accept" attribute was
therefore the only remaining barrier, which can be trivially bypassed
in the browser file picker.

The MimeTypeValidator registration is now performed at runtime in
PropertyMappingConfiguration::adjustPropertyMappingForFileUploadsAtRuntime(),
where the form definition properties are fully available and which runs
before the submitted values are validated. The same class already sets
the upload seed and removal configuration there for the exact same
reason. Registration is guarded against duplicates.

Review

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

Issues 1

Files 7

Review log 5

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

  2. Oliver Hader commented on patch set 1 07/14/26, 12:04

  3. Oliver Hader wrote 07/14/26, 12:05

    Unset private
  4. Oliver Hader voted on patch set 1 CR +2 V +2 07/14/26, 12:08

  5. Oliver Hader merged patch set 2 07/14/26, 12:08