aspose file tools*
The moose likes Java in General and the fly likes Potential File Upload/Malicious File Execution Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Potential File Upload/Malicious File Execution" Watch "Potential File Upload/Malicious File Execution" New topic
Author

Potential File Upload/Malicious File Execution

Baseet Ahmed
Ranch Hand

Joined: Dec 18, 2006
Posts: 224
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

Joined: Jun 24, 2003
Posts: 3274
    
    5

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)


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Baseet Ahmed
Ranch Hand

Joined: Dec 18, 2006
Posts: 224
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

Joined: Jun 24, 2003
Posts: 3274
    
    5

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.
 
jQuery in Action, 2nd edition
 
subject: Potential File Upload/Malicious File Execution