#95581FileNameValidator wrongly allows empty strings
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
-
Oliver Hader changed removed the assignee <span data-processor="relativetime" data-value="2021-10-12T09:17:29+00:00" > 10/12/21, 09:17 </span>
-
Oliver Hader commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2021-10-12T09:22:25+00:00" > 10/12/21, 09:22 </span> -
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?
-
S P changed TYPO3 Version
1012 <span data-processor="relativetime" data-value="2024-12-18T11:03:44+00:00" > 12/18/24, 11:03 </span> -
S P changed TYPO3 Version
1213 <span data-processor="relativetime" data-value="2024-12-19T08:37:42+00:00" > 12/19/24, 08:37 </span> -
S P commented and changed TYPO3 Version
1314 <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.
-
Georg Ringer commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2026-10-07T18:05:38+00:00" > 10/07/26, 18:05 </span>Core\Resource\Security\FileNameValidatoris 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 inisValid().- For user input there is the Extbase
FileNameValidator, which extendsAbstractValidatorand – like all validators exceptNotEmpty– accepts empty values by design. To require a non-empty, allowed file name, combine both:#[Validate(['validator' => 'NotEmpty'])]and#[Validate(['validator' => 'FileName'])]. - Returning
falsefor''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.
Can you please describe your use-case? What is the origin of an empty filename? Thx in advance!