Bug #93805
closedDeleteUploadsFinisher deletes top level upload folder
100%
Description
The initial security fix for Mitigate directly accessible file upload in form framework was designed that way that uploaded files are stored within 2 levels of random named sub folders within the configured "saveToFileMount" path.
While developing the patch there was several refactorings and now only one random named subfolder is created.
While developing the patch the DeleteUploadsFinisher was adjusted to delete 2 levels of parent folders (if these are empty) while UploadedFileReferenceConverter was implemented to generate 2 levels of random named sub folders. The UploadedFileReferenceConverter changes was never adjusted within the DeleteUploadsFinisher.
This finisher now tries to delete 2 levels of parent folders if these are empty instead of one.
If a form upload is configured to save files within "1:/user_upload/test/" (saveToFileMount: '1:/user_upload/test/'), an upload will be saved within "1:/user_upload/test/form_<random>/file.png". Lateron, the DeleteUploadsFinisher delete "1:/user_upload/test/form_<random>/file.png" (ok). If "1:/user_upload/test/form_<random>/" is emty, this folder will be deleted too (ok). If "1:/user_upload/test/" is emty, this folder will be deleted too (not ok).