Restrict the upload of certain Document and Media files by checking their metadata
Written By
Solyom Nagy-Györkös
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Issue
- We would like to restrict uploading any files to the Document and Media portlet by their extension, however, there should be an extra check in their content (mime) type to make sure the extension wasn't just changed, so it should restrict the upload by the files' content instead of their extension
- For example: only JPEG/PNG extension is allowed to upload. The user may change the extension of a PDF file to JPEG. The Document and Media portlet should not allow the user to upload the file by checking the exact type of the file, to avoid forging.
Resolution
- It is a current product limitation, the dl.file.extensions property only filters the uploaded files based on their extensions, but the system does not check if the content of the file corresponds to the extension in the file name. It only looks at the extension, not at the content.
- A Feature Request has already been opened to address the need, however it's private in the meantime, for us to analyze the security concerns too.
[LPD-45728] Restrict uploadable files by their content (mime) type, instead of file extension
Did this article resolve your issue ?