-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential Issue regarding file upload #3044
Comments
Sorry I'm to stupid to understand the example: I tried "filetxt", "filetxt.", "file.pdf.txt", all of them lead to aborting the upload of the file. |
@OzzieIsaacs , thanks for the reply. Sorry for my unclear explanation. Here is a better example? The consequence of this vunlerability could be that an attacker can drop malicious files for the benefits of future attack (like this step is one piece of the whole attack chain). Or he could fool other users to download his malicious script while other users just think it is a txt file e-book. |
I think the best way to resolve this would be to allow for an integration with an antimalware toolkit like ClamAV. Accept the upload, scan the files and if nothing gets flagged, add to the db. An alternative would be to have such a toolkit running separately and scan the files on the local system. |
I thought some time on this. If you upload an executable on Linux, the executable flag isn't set, so the file can't be executed (I currently can't check it in windows). I'm using ClamAV on my computer to scan files and there it's slow like hell (feels like over 30sec before a file scan is complete), if you have to do this on every upload, users will complain about it. So I think this would be nice to have, yes, but it's not practicable. |
@OzzieIsaacs yes, single uploading wont execute an executable file. But it could be used to future exploitable or malicious user could use the platform to distribute malware. The solution to this topic is using the file's magic code instead of using the remote-user provided extension to decide the file type . One intro document is available here. Magic code is often the first a few bytes of the file. For different file types, the magic code would be different. For example, unix executable is |
Describe the bug/problem
In the code here, it uses the user provided file extension to determine the file type. However, it is possible to bypass it with a crafted a file name. This could be a potential security issue as described in CWE-646
To Reproduce
upload any file with a extension name like txt.
Expected behavior
A magic number based file type detection could be applied here.
I would be happy to make a PR for this. Please let me know your opinion.
The text was updated successfully, but these errors were encountered: