File Upload Vulnerability - Unrestricted File Upload
Issue 1:
The file upload is done incorrectly. An adversary can forge the virtual file path, thereby it could be saved to another folder with replacing.
Uploaded files have to be saved with a virtual file name to avoid collisions, and users should not be able to choose where the file will be saved. For this, the file path does not contain any user-sent parameter and the virtual name is generated randomly, so existing files couldn't be replaced.
Allowing to upload profile picture files without applying proper checks would let an adversary to upload files containing malicious content that could harm the application or the host system.
The application protects itself against unrestricted file upload in several ways. There is an allow list of extensions, the file size is limited, and the application sets the filename. Also, the file upload functionality has been removed from the controller to the UploadService, which guarantees a cleaner, more structured application.
Comments
Post a Comment