Jump to content

File Uploads


RobertP

Recommended Posts

The 'name' and 'type' attributes from $_FILES are provided from the client, so you'll need to treat those as user input and filter/validate them.Ā  I would say that common/safe practice would be to ignore them both and use your own naming and do some detection on the type.Ā  The 'name' attribute can be a bit nefarious, the client could provide '../../etc/passwd' as the name for instance and that's definitely not a file you want to write to.Ā  And of course using some kind of antivirus on the server to scan incoming files is common sense.Ā  Microsoft in particular has had some buffer overflow issues with their image libraries and an AV scanner should detect those, not something you want to be redistributing from your site.

Link to comment
Share on other sites

Invoke external command line AV scanner, clamav for instance or one of the many out there, commercial or not they usually have a command line interface.Ā  There are a couple of bindings I know for PHP but those are maintained poorly/not updated, so its best just to hand it off to the CLI.

Link to comment
Share on other sites

Keep in mind that if this is a CMS to be distributed publicly, an AV scanner is probably not going to work out. Number 1 that's probably going to consume a lot of resources and shared hosts get grumpy about that, and Number 2 unless you build an AV to include with your project, you can't guarantee every hosting setup has an AV that works in the same way.

Link to comment
Share on other sites

If you knowingly do not put any protections in place to verify the threat of the files, it would make your site a distributor of viruses and depending on your location and the location of your users can be a criminal offence, be sure to consult your lawyer to come up with a licence agreement to mitigate your liability and warn your users of the risk.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.