Answer the question
In order to leave comments, you need to log in
Can an attacker, for example, upload malware through a photo upload form on a website?
Hello. I'm not good at security. I am interested in such a question. Can an attacker, for example, upload malware through a photo upload form on a website? And if so, how does it happen? He uploaded a file, and then what? This file lies there and does not interfere with anyone. If I open it, then through special programs, for example, ImageMagick. Which not every file can open, but only images.
If this is possible, will type validation help me? The type that comes after the dot in the file name. Or is it just a name change? And does not really give anything in terms of protection? If so, how can you defend yourself?
Answer the question
In order to leave comments, you need to log in
Maybe. It is necessary to check the "body" of the file for the correctness of the fact that this is exactly the image file. Trite - try to get the size of the image using functions for the programming language used.
For example, for PHP: GD library function getimagesize() .
Also, you need to prevent the launch of everything in a row from storage folders!
For understanding, do a Google search (with quotes!):
"Надежная защита веб-сайта от большинства видов атак"
and read the 1st link. Not only can, but will certainly do so, if he is given such an opportunity;)
Above xmoonlight and CityCat4 have already said everything.
I just want to add that in the directory where "for example pictures" are loaded, it should be forbidden to start anything, both at the php level and the system itself.
Maybe. It is necessary to check everything in the file - extension, type. It works in such a way that it first loads the photo file, then looks from where this picture began to open, loads the php file, for example, with the command to delete everything in this folder, a folder above or something else and types its address in the browser, like this launching it.
Also, for protection, it would be nice to prohibit the execution of any files in the photo directory, for example, using htaccess
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question