Page 1 of 1

User Folders - best approach?

Posted: Fri Sep 01, 2006 3:26 pm
by bread_man
I started to touch base on this in the security forum, but want to expand a little more and thought this forum was a little more appropriate.

I have a little blogging service. Each user has a folder directly off the webroot, such as

http://www.mysite.com/user1/ (public_html/user1)

In that folder is about 10 php pages and 2 sub-folders, movies and photos.

The movies and photos folder permissions are set to 0777 so my php scripts can move uploaded items there from the temp folder.

So I'm already doing something bad - having folders with write permissions below the web root.

But now I am writing a user creation php script for signing up a new user and the only way to be able to create a new folder for that user is to make the web root itself writable. Seems very bad to do this.

I know other people have had other user systems similar to this and I was hoping someone could shed some light on the best approach? Anyway to get these items above the webroot without modifying the apache httpd.conf? It has to be expandable - more users will be added on the fly.

Thanks for any help!

bread

*edit: got above and below mixed up in my first post :P

Posted: Fri Sep 01, 2006 5:01 pm
by Christopher
I think it depends on who has write access to those folders. If it is only your PHP code and you are controlling what users can do within the code then is should be fine.

Posted: Fri Sep 01, 2006 8:58 pm
by bread_man
The apache user has write access in order for the php scripts to write to those folders. In the upload scripts, I am doing everything I know to ensure nobody is uploading malicious files - checking mime types and using gd and php-ffmpeg to validate uploaded images and movies. I just keep hearing over and over that you're not supposed to have writeable folders below the web root but I can't honestly say I know why.

Posted: Fri Sep 01, 2006 11:00 pm
by Christopher
As long a you are in control of system access to those folders and take appropriate precautions to control what gets written, then having writable folders should not be a problem. I would suggest using Defense in Depth strategy by making sure that you are taking precautions at every level and step you can think of.