11-30-2019, 09:19 PM
I could recreate the AV. A patch will be released soon
IW15 FileUplader and GetUploadedFileMimeType
|
11-30-2019, 09:19 PM
I could recreate the AV. A patch will be released soon
01-02-2020, 02:24 PM
01-15-2020, 02:31 PM
Hi again. I just downloaded 15.1.11 and tested TIWFileUploader.CheckMimeType() and now it works without errors, thanks!
The only thing I noticed in my tests is that the method in some cases seems to take the file extension into account rather than just the file contents (which is not ideal since the function typically can be used as an extra layer of protection against attempts to upload malicious files). For example, a genuine xlsx file is recognized as application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. If I rename a .pdf file to .xlsx it is correctly identified as application/pdf anyway. But if I rename a .docx file to .xlsx the function reports it as a spreadsheet even though it isn't. And if I allow .docx files in my file filter and rename a .xlsx file to .docx it will similarly return application/vnd.openxmlformats-officedocument.wordprocessingml.document even though it isn't.
01-16-2020, 01:29 AM
You know that it is virtually impossible to accurately differentiate docx and xlsx files, right?
All "new" Office file formats are simply zip files. They all have the same zip signature. Without extracting the content from the zip file and deeply analyzing the content it is not possible to be sure what file is that
Hi Alexandre and thanks for the clarification on how the office file format works. I am now implementing a validity check for an uploaded file in an import function. If I detect a file that has an unexpected mime type, is there a way to tell the TIWFileUploader component to consider it as failed (which I assume would color it red and generate the OnAsyncUploadError event rather than OnAsyncUploadSuccess)? This is my current test code (which works functionally, but it would be nicer if the file was not shown in green):
Code: procedure TBaseClientImportWebDialog.FileUploaderWebFrameFileUploaderAsyncUploadCompleted(
01-17-2020, 08:56 PM
Let me test it and see what I get. I'll get back to you soon.
05-12-2020, 06:50 AM
Hi,
just wanted to update you on the usage of TIWFileUploader.CheckMimeType(), we have had it running in production for a while now. We have noticed one issue: if a user uploads a password protected xlsx file the function returns an empty string, which causes our security check to tell the user that it does not appear to be a valid xlsx file. Normally, the function will return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' or 'application/zip' (we get the latter for Excel files we have created ourselves using TMS FlexCel). It would be great if it could return one of these also in the case of password protection. Best regards Magnus Oskarsson
05-12-2020, 03:42 PM
Can you please attach a sample of a file that fails?
05-13-2020, 05:43 AM
Attached is a password protected sample file. The password is 'Atozed' if you want to look at the contents.
Best regards Magnus Oskarsson
05-13-2020, 03:38 PM
Thank you. Alexandre will take it from here.
|
« Next Oldest | Next Newest »
|