Reputation: 23
We are working on a website to allow animated GIF upload. To ensure the image is indeed an image and without malware/virus/backdoor/trojan or anything other than image data itself, we try to recreate the original image.
However, the process itself will take sometime when there are lots of frames inside. Is there any other way to ensure an uploaded animated GIF file is free from the issues mentioned above?
Upvotes: 2
Views: 720
Reputation: 33578
You can never 100% guarantee that a file does not contain malware - even with your approach there is the chance that the gif contains some code that could be malicious simply by opening the image in a vulnerable viewer.
That said, the chances are low and you can expect these sort of bugs to be patched fairly quickly in most modern operating systems.
There are various checks you can do on uploaded files though that take less processing time:
content-type
at upload stage though as this can be spoofed.www.example.com/uploads/image.aspx
).When serving the files, ensure the correct content-type
, and if possible, filename extension is set correctly. Use Content-Disposition
to set the name the browser will use:
Content-Disposition: attachment; filename="fname.ext"
Upvotes: 1