Issue Bug Closed

#95581FileNameValidator wrongly allows empty strings

S P 10/12/21, 09:16 updated 10/07/26, 18:05

Description

\TYPO3\CMS\Core\Resource\Security\FileNameValidator->isValid() returns true for an empty string. This is wrong. Filenames may not be empty.

(Category Security because the class is in the Security namespace, re-categorize if this is wrong)

The according Test should also check for empty strings.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 7

  1. Oliver Hader commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2021-10-12T09:22:25+00:00" > 10/12/21, 09:22 </span>

    Can you please describe your use-case? What is the origin of an empty filename? Thx in advance!

  2. S P commented <span data-processor="relativetime" data-value="2021-10-13T05:20:48+00:00" > 10/13/21, 05:20 </span>

    User input, of course. I expect a FileNameValdiator to correctly validate file names. If everyone has to provide additional checks on the file name string anyways, then I wonder why to privide a Validator class at all?

  3. S P commented and changed TYPO3 Version 13 14 <span data-processor="relativetime" data-value="2026-06-11T07:49:30+00:00" > 06/11/26, 07:49 </span>

    v14 still considers the empty string as a valid filename.

  4. Georg Ringer commented and changed status Needs Feedback Closed <span data-processor="relativetime" data-value="2026-10-07T18:05:38+00:00" > 10/07/26, 18:05 </span>

    • Core\Resource\Security\FileNameValidator is a deny-list check (control characters + fileDenyPattern). It answers “is this name forbidden?”, not “is this a well-formed file name?”. The empty string is explicitly special-cased in isValid().
    • For user input there is the Extbase FileNameValidator, which extends AbstractValidator and – like all validators except NotEmpty – accepts empty values by design. To require a non-empty, allowed file name, combine both: #[Validate(['validator' => 'NotEmpty'])] and #[Validate(['validator' => 'FileName'])].
    • Returning false for '' would turn a missing value into a security violation in ~15 core callers (FAL, FileDumpController, TypoScript imports, mbox transport, …), which mixes two different concerns and would be breaking.