Web Hosting Talk


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Control panel written in php - security question
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.

 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-30-2009, 12:10 AM
steve45 steve45 is offline
View Beta Profile
Newbie
 
Join Date: Jun 2009
Posts: 10
Exclamation Control panel written in php - security question

Hi,

I am kind of new to PHP

I am developing a site, similar to control panel, where people could register for an account, and upload their web pages.

When people register an account, a folder will be created for the user, and will be named with his/her username. However this folder will be owned by the linuxuser “http” since pages will be uploaded by people via a control panel written in PHP. So folders allocated to users, and any file that gets uploaded via the control panel will all be owned by the linuxuser “http” with permission 755.

Customer authentication is performed using a table stored in MySql. No linuxuser account will be created when a person registers for a webspace/account.

Now this is my question:-
If a CUSTOMER uploads a script, lets say written in php to read any file accessible by the linuxuser “http”, wont he be able to see the contents of those files, including /etc/passwd ?

How do we prevent it? Or is there a better design?

Reply With Quote
Sponsored Links
  #2  
Old 06-30-2009, 09:44 AM
HivelocityDD HivelocityDD is offline
View Beta Profile
WHT Addict
 
Join Date: Apr 2009
Location: localhost
Posts: 174
Yes .. he might be able to see those details. One way to prevent this is enable the openbasedir option in php. So the scripts can only run inside the specific folders.

Another option I think is you create your own encryption algorithm by which you rename the files inside before storing and decrypt it when it needs to be downloaded.

__________________
Dedicated Servers - sales@hivelocity.net - 1-888-869-HOST(4678)
Award winning Managed Hosting - Dedicated Server Hosting
Managed Dedicated Servers. Reseller Discounts. 24/7 Impressive Tech Support.

Reply With Quote
  #3  
Old 06-30-2009, 07:24 PM
foobic foobic is offline
View Beta Profile
Community Liaison
 
Join Date: Feb 2005
Location: Australia
Posts: 3,420
Viewing /etc/passwd isn't that big a deal, but you'll have no good way to separate customers from each other. The "better design" is the conventional shared-hosting model where each customer is set up as a different linux user and every user is isolated by file ownership and permissions. If you go ahead with a system like you describe then you should aim to prevent your clients running their own scripts (ie. block execution of both cgi and php (edit: and ssi) in client-accessible areas).

Slightly OT: You might want to look at WordpressMU because it sounds like you may be reinventing it.

__________________
Chris <ClonePanel>
"Not everything that can be counted counts, and not everything that counts can be counted" - Albert Einstein

Reply With Quote
Sponsored Links
  #4  
Old 07-01-2009, 02:58 AM
steve45 steve45 is offline
View Beta Profile
Newbie
 
Join Date: Jun 2009
Posts: 10
Yes I guess a "better design" is what I should be looking for. Should use linux users.
I found an article on net that seems to address my concern.
jimkeller.blogspot.com/2008/01/php-security-in-shared-hosting.html

Thanks a lot folks for your advises.
Regards.

Reply With Quote
  #5  
Old 07-07-2009, 07:47 PM
kieransimkin kieransimkin is offline
View Beta Profile
Junior Guru Wannabe
 
Join Date: Aug 2007
Location: Brighton, UK
Posts: 63
We found that the conventional shared hosting model was still weak from a security standpoint because many scripts tell you to chmod some of their files to world readable during the install process. This resulted in many of our users having mysql passwords stored and visible to anyone who was looking. Eventually someone did look and we were in trouble. PHP's openbasedir doesn't cover you completely because of SSI and CGI.

The solution that we came up with was to configure apache to run all PHP as CGI and then hack Apache's suexec.c to call chroot() before changing to the user. This gave us PHP that ran as the user chrooted to their home directory, which contained a copy of the FreeBSD base system hardlinked in. This effectively isolates each user and also discourages them from applying insecure file permissions because they're simply not needed. To this day we've had no further security problems.

I believe you can essentially do the things I describe now with suPHP and the like but I haven't tried as we're still using the CGI method with our custom apache patch.

Of course if you don't want your users to be able to run scripts at all then you needn't worry about any of this. But if you do, then I would strongly advise creating separate proper UNIX accounts for each of your users and having their scripts run as them. foobic's right it's not /etc/passwd you wanna be worried about, that file contains no plaintext passwords, but unfortunately eventually there will be other fils on your server that do.

Reply With Quote
  #6  
Old 07-08-2009, 08:07 AM
XCart XCart is offline
View Beta Profile
Premium Member
 
Join Date: May 2009
Posts: 197
You need to either forbid these kind of scripts or use jails for such scripts.

By the way, you could find browse sourforge.net , they may have this kind of management panel created already.

__________________
X-Cart - tens thousands live web shops worldwide
Join us on Facebook

Reply With Quote
  #7  
Old 07-10-2009, 06:01 AM
alons alons is offline
View Beta Profile
Web Hosting Master
 
Join Date: May 2009
Posts: 550
Creating UNIX accounts is the only way to get out of the situation.
Otherwise users who have SSH access will be able to browse through all the files.

__________________
Softaculous - Auto Installer for cPanel, Direct Admin, InterWorx, Plesk, ISP System
Rate for the softwares you love the best. Install in just ONE STEP!
The only Auto Installer that installs 140(HUNDRED +) softwares.
Aefer - Remote Auto Installer (We are beta testing it)

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:

Similar Threads
Thread Thread Starter Forum Replies Last Post
VPS...Control Panel + Security Nikolasr Hosting Security and Technology 5 03-30-2009 04:03 PM
do any control panel packages automate security updates? disgust Web Hosting 3 02-06-2009 07:58 PM
Plesk control panel security warning com1usa Hosting Software and Control Panels 2 03-11-2007 07:56 PM
Control Panel Security Everyday Hosting Software and Control Panels 3 03-24-2003 10:53 AM
OLM control panel/web mail security houghton Web Hosting 8 07-12-2002 05:50 PM