Security Fix: Check Allowed Extension Types, Disallow Extension Types, and Disallow Mime Types #393
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces comprehensive restrictions on disallowed file types and MIME types for uploads and archive extraction, significantly improving the security of the file manager. The changes ensure that potentially dangerous files (such as PHP scripts or executables) cannot be uploaded, created, renamed, or extracted from ZIP archives. Additionally, the configuration and service layers have been updated to support these new restrictions.
Security enhancements for file uploads and archive extraction:
disallowFileTypes
anddisallowFileMimeTypes
configuration options infile-manager.php
to specify restricted file extensions and MIME types.ConfigRepository
interface and its default implementation to provide access to the new disallow lists, with sensible defaults for common executable/script types. [1] [2]FileManager.php
to block files with disallowed extensions or MIME types from being uploaded.ZIP archive extraction hardening:
Zip
service to check extracted files' extensions and MIME types against the disallow lists, skipping extraction of any that match. The service now requiresConfigRepository
as a dependency. [1] [2] [3]Other improvements:
FilesUploading
andFilesUploaded
event classes to clarify that the$files
property is an array of uploaded files. [1] [2]