I strongly recommend that you do not accept any xlsx file from an untrusted 
source.

I wrote a blog about it a while ago.

https://medium.com/system-weakness/caveats-with-accepting-microsoft-office-file-formats-in-uploads-26be3673c330

The format is defined by Microsoft. Deal with them. If you read the history of 
POI, we all think that the Microsoft data formats are poorly designed.

https://en.wikipedia.org/wiki/Apache_POI

xlsx files do support file signatures. Read 
https://poi.apache.org/apidocs/dev/org/apache/poi/poifs/crypt/dsig/SignatureInfo.html

You could generate a SHA checksum and send it independently of the xlsx file 
and you could verify that the checksum matches the xlsx file when you receive 
them.





On Wednesday 27 September 2023 at 15:04:08 IST, Alireza Fattahi 
<[email protected]> wrote: 





I am using workBook = WorkbookFactory.create(fis); to read excel files.

I found something strange, I opened the file with notepad++ and added some text 
at the end of the file and tampered it. The WorkbookFactory.create(fis) still 
works and opens the file!!! I have attached a sample file.

Is this some built-in feature which fixes this file.

I am adding screenshot of the file which I change in notepad++
---------------------

The source of the problem is that I get the  excel file from the users via 
upload and pass this file to WorkbookFactory. I thought that the 
WorkbookFactory checks the file validity and I was not worried about a hacker 
who tries to add some code or script and send it to me via excel.




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to