LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 02-24-2011, 07:32 AM   #1
pooja2003
LQ Newbie
 
Registered: Feb 2011
Posts: 2

Rep: Reputation: 0
Folder permissions to avoid file upload by http user


Hello

Not a Linux expert. However, configured a website on a dedicated server using WHM/cPanel. The site was uploaded using the master account for the website.

The security issue is public users are able to upload files on to my server via the website. They could even access the root and execute whatever they want on the server.

I have consulted with 2-3 Linux experts. According to them, the PHP user has rights to execute anything on the server or upload & store files in whichever folder they want.

Can I protect my folders to avoid file uploads via the website. The application has security vulnerabilites. However, I want to prevent hackers to enter my site until the vulnerabilities are fixed.

Can somebody guide me through.

It is Joomla CMS on a Debian Linux server.

Regards
Pooja
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-25-2011, 04:36 AM   #2
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
For starters, since you are running Joomla, take a look at their Security Checklist: here.

I assume here that you are running these tools on top of an Apache server with PHP and MySQL (as discussed in Wikipedia: here). If so, I would also recommend that you start by reading about basic apache and PHP security. Each of these applications, by themselves, is relatively secure. Each application, module, bit of code, and so forth that you add to them, including cPanel, Joomla, and WHM add additional complexities and vulnerabilities. This will make your task exponentially more difficult with each addition.

To address some of the basics and your other questions:

Apache file permissions are the most basic thing that you have to address. By default, Apache is limited to the specified document roots and can pull information from outside of the directory structure by using Alias directives. Apache starts up as root and then drops the root permissions for the daemon processes. These processes run as a non privileged user with a locked account, typically something like apache, www-data, nobody, etc. The files in your folder structure should be owned by root and readable by others. This is how pages are read and served. The directories need to be executable to work, but files should not. Files and folders should not be writable. There is NO PHP user. PHP files are read by Apache and interpreted in-line to generate HTML. As long as you are configured so that files are interpreted and don't open up holes beyond your document root, web users can't get at the PHP code itself.

By adding a content management system with additional command and control tools you may need to add more users and groups and assign appropriate permissions to certain files and folders for this purpose. However, your web directories should not be writable and your files executable by the public. If they are, it is an indication that you have made a sever permissions mistake.

Also, one of the most important things you can do is keep your web based applications (Apache, PHP, and all the other stuff like Joomla) up to date. Failure to keep these programs patched is one of the most commonly exploited vectors!

As far as your 2-3 "experts" go, I questioned their expertise the moment you said "php user"

After you feel you have things appropriately secured, you might consider running a security vulnerability scan against your system. This will help identify if there are vulnerabilities you have missed. !!Do not replace a real understanding of the security basics with a scanner tool!! Use the tool in addition only. An example of such a tool is OpenVAS, which is a free version fork of the popular Nessus scanner.
 
3 members found this post helpful.
Old 03-06-2011, 10:05 AM   #3
pooja2003
LQ Newbie
 
Registered: Feb 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for the reply. What I could figure out is any PHP file uploaded on the server has write permissions on all folders. is_writable [http://php.net/manual/en/function.is-writable.php] returns true for all folders. Even if, folder permissions are set to 0755. File owner/group owner is the same account owner configured by cpanel.

How can I remove write permissions so that is_writable PHP function returns false. I have seen similar rules set with shared hosting servers. They will configure one folder for http uploads and I can write [upload files] to that folder only even if via PHP.

What I could understand is http user/apache user is set differently from the account owner.

Can somebody who has experience with websites configuration help me.

Regards
Pooja
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying FTP user' rights/permissions/upload criteria Brent45 Linux - Newbie 2 07-15-2010 02:12 PM
I can remove a file with the permissions 444.Any way to lock it to avoid removing it? tirengarfio Linux - Newbie 3 06-03-2010 06:24 AM
IglooFTP-PRO refuses to upload files in folder when I upload folder eBopBob Linux - Software 0 08-27-2004 05:52 AM
Changing file permissions on upload guix Linux - General 2 07-05-2004 08:58 AM
File upload in binary mode via HTTP saravanan1979 Programming 0 04-05-2002 01:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration