Replies: 1 comment 1 reply
-
Hi @alexbudin, This library does not work with files, not even filenames. It is impossible for this library to cause any security problems because it is simply a collection that translates a mime type into its extension and vice versa. I've used this library on an educational website that lists and then asks for Mime Types, there's no reason to prevent it from being used on a public project like this or similar. That people could Anyway, I will try to specify better what it does to avoid confusion. Thank you! |
Beta Was this translation helpful? Give feedback.
-
With this library you are getting the mime type based on the file extension and not the actual mime type of the file, based on the file content (the actual binary data), which is s HUGE security problem. If someone uses this with form submitted files, they are introducing a massive security hole in their code as the extension of the file can be easily changed by anyone so that they can easily upload a file.
You must place a warning in your readme so that this is not used for form upload purposes or for public facing projects.
Have a look at how PHP does this with the function mime_content_type and look for actual code and you will see that it actually opens the file to read the first bytes.
I realize that you specify that this library determines the mime type from an extension, but you need to warn people about the dangers of that in case someone less experienced uses this for production ready projects where security is very important.
Hope this helps and does not get deleted.
Beta Was this translation helpful? Give feedback.
All reactions