For example, when I had a specific file writing problem
uploaded to the public/uploads folder of a particular system, I gave the
777 permission in this folder.
I love who lives in a dangerous way rsrs(joke), it is more than explained the reasons, the previous answers spoke everything, I just came here to add with practical examples what can happen, how your Operating System can be invaded...
Imagine that I am walking on your page and I find myself in an upload area, let’s say that the upload algorithm does not check metadata or file extensions, you will simply be lost, the attacker will not have root access, but still can do a lot of damage, surely he will be able to read many things inside his SO
, besides being able to look at the source codes of your page (php, Asp, etc.), you can even get the passwords of your database for access (looking at the codes of your page you can find the connection passwords of your bank), in this case the attacker does not need to be very smart, it would upload a file into the upload folder ex. hack.php
(a code that opens files and shows on the screen), then just run and see the return...
http://meusite/upload/hack.php?var=/etc/passwd
If he’s a little smarter, he’d make a. php file that sends and returns commands (dir, ls, rm)
http://meusite/upload/comandos.php?var=ls&local=/etc/
Of course I’m only saying basic things not to give ideas to the malicious, this is critical, is the worst possible scenario, the hacker could upload any file and use php, Asp, java, python, etc to run, could try to scale root using exploits and have full control of OS, ie it would be a "party" inside your upload folder :-(
Now imagine that your upload algorithm checks extensions but doesn’t look at metadata (headers), let’s imagine that your algorithm in theory just lets upload files .jpg
, imagine that I create the following file:
<?php echo "<p>Ola Mundo</p>"; ?>
And save as teste.jpg
(of course it’s a silly example, but it could be something really dangerous), your upload folder would become a minefield, malicious code within allowed extensions :-( I say that it is a minefield because the hacker will only need to fire the trigger, usually this trigger can not be executed from outside, via http
, I said "generally", the hacker will need to use artifices to perform for example a php teste.jpg
.
These are just superficial examples of how to upload a folder with chmod 777
can become the heel of your heel SO
.
Reply on the subject: http://answall.com/a/2281/67
– Kenny Rafael
Possible duplicate of Permission denied when moving file with move_upload_file on Linux server
– Mineiro