Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Potential File Upload/Malicious File Execution

 
Baseet Ahmed
Ranch Hand
Posts: 225
Java Notepad Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Salaam,


We are having one application based on java/servlet/jsp technology, which allows users to upload files to the server through html file upload option.
But the weak point is that, it allows any file to be uploaded.
This could cause problem which may reach to malicious file execution.


Please help us in resolving this, so that we can save our application with Malicious file execution attack.

Any help and tips highly appreciated.

Thank you...

-------------------
Regards
Baseet Ahmed

[ UD: Removed non-English part ]
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to detect the file type on the server side and accept/reject based on whatever criteria you decide (file extension etc). It also helps to not allow executable rights on any file that is in that upload folder (chmod -x in *IX operating systems)
 
Baseet Ahmed
Ranch Hand
Posts: 225
Java Notepad Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Salaam,

We have added the code for restricting the file types based on file extension(by checking filename's ends with .exe etc.).

Are there any further steps we need to follow for making it smart enough to block Malicious file execution attack ?

Like, client side validation through javascript etc.


Thank you...

-------------------
Regards
Baseet Ahmed
[ B: Modified non-English part ]

"Pay wages of a labourer before his perspiration dries." - ISLAM
-------------------
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the other step I mentioned "making sure that the execute permissions on files that are uploaded are changed to non executable" should be sufficient.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic