-1

This question already has an answer here:

I have set the permission on my uploads directory(in which end user can upload their documents) to 777.

I understand this is not a good idea, but the files wont get uploaded with any other permission.

I want to understand the security risks attached to it and what i can do to prevent them.

Additionally, i will be setting the permission on uploaded files in upload dir to 644.

Appreciate your response.

marked as duplicate by voretaq7 Aug 21 '13 at 14:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Shouldn't the mode be 1777 (sticky bit set)? – ott-- Aug 21 '13 at 12:00
0

If you have a shared hosting, then each user might be able to read the content of this folder (if a path through that directory exists with the appropriate x flag).

If you have a dedicated server, then each system user (ie each server) would also be able to access this folder. Be it your webserver, or FTP server. If one of these have a security breach, it could be use to spawn a shell (interractive or not) and thus, obtaining the server's privileges. In that case, you fall through the previous case, where each user may access the folder.

This was for reading. Now consider the same case for writting. A user could just put some files there and access it through your website. What if one of the file uploaded in that directory rewrites your homepage?

0

The threat models and vulnerabilities of doing this are dependant on a lot of context you've not provided (is this a shared server? Is it a dedicated webserver? Is the directory inside the document root? Does PHP run as the same uid as the webserver? Do you have admin access to the system? Who else does?....) it's a complicated question to answer with the suporting data, impossible to answer specifically without out.

Making the files readable by all and the directory writeable by all should be an absolute last resort after you have exhausted all other methods of configuring restricted access.

Not the answer you're looking for? Browse other questions tagged or ask your own question.