ensuring uploaded files are safe

后端 未结 6 2057
予麋鹿
予麋鹿 2021-01-04 23:23

My boss has come to me and asked how to enure a file uploaded through web page is safe. He wants people to be able to upload pdfs and tiff images (and the like) and his real

相关标签:
6条回答
  • 2021-01-05 00:07

    It depends on your company's budget but there are hardware devices and software applications that can sit between your web server and the outside world to perform these functions. Some of these are hardware firewalls with anti-virus software built in. Sometimes they are called application gateways or application proxies.

    Here are links to an open source gateway that uses Clam-AV: http://en.wikipedia.org/wiki/Gateway_Anti-Virus http://gatewayav.sourceforge.net/faq.html

    0 讨论(0)
  • 2021-01-05 00:11

    Viruses embedded in image files are unlikely to be a major problem for your application. What will be a problem is JAR files. Image files with JAR trailers can be loaded from any page on the Internet as a Java applet, with same-origin bindings (cookies) pointing into your application and your server.

    The best way to handle image uploads is to crop, scale, and transform them into a different image format. Images should have different sizes, hashes, and checksums before and after transformation. For instance, Gravatar, which provides the "buddy icons" for Stack Overflow, forces you to crop your image, and then translates it to a PNG.

    Is it possible to construct a malicious PDF or DOC file that will exploit vulnerabilities in Word or Acrobat? Probably. But ClamAV is not going to do a very good job at stopping those attacks; those aren't "viruses", but rather vulnerabilities in viewer software.

    0 讨论(0)
  • 2021-01-05 00:11

    You'd probably need to chain an actual virus scanner to the upload process (the same way many virus scanners ensure that a file you download in your browser is safe).

    In order to do this yourself, you'd have to keep it up to date, which means keeping libraries of virus definitions around, which is likely beyond the scope of your application (and may not even be feasible depending on the size of your organization).

    0 讨论(0)
  • 2021-01-05 00:13

    Use a reverse proxy setup such as

    www <-> HAVP <-> webserver

    HAVP (http://www.server-side.de/) is a way to scan http traffic though ClamAV or any other commercial antivirus software. It will prevent users to download infected files. If you need https or anything else, then you can put another reverse proxy or web server in reverse proxy mode that can handle the SSL before HAVP

    Nevertheless, it does not work at upload, so it will not prevent the files to be stored on servers, but prevent the files from being downloaded and thus propagated. So use it with a regular file scanning (eg clamscan).

    0 讨论(0)
  • 2021-01-05 00:23

    I'd recommend running your uploaded files through antivirus software such as ClamAV. I don't know about scrubbing files to remove viruses, but this will at least allow you to detect and delete infected files before you view them.

    0 讨论(0)
  • 2021-01-05 00:29

    Yes, ClamAV should scan the file regardless of the extension.

    0 讨论(0)
提交回复
热议问题