store | blogs | forums | twitter | facebook | wiki | mailing lists | downloads | support portal
Atomic Secure Linux
It is currently Thu May 23, 2013 8:44 am

» Feed - Atomicorp

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic Share/Bookmark  [ 9 posts ] 
Author Message
 Post subject: To many 777s
Unread postPosted: Sun Feb 26, 2012 7:05 pm 
Offline
Long Time Forum Regular
Long Time Forum Regular

Joined: Thu Dec 09, 2004 11:19 am
Posts: 1846
Long story short:

It is not uncommon for lazy customers to 777 EVERYTHING in a site to get a CMS like Joomla working with the minimum of effort.

It would be nice for ASL to scan for such sites, possibly by checking to see if more than X% of files/dirs in site are 777.

As an extra twist, I wonder if it would also be useful to scan for anything with a filename containing the word "config" (possibly only if it has an extension of "php" ?) that's 777 (or apache.apache and writable by apache??? That's probably not a good situation, though there may be some scripts that need it?)

_________________
--------------------------------
<advert>
If you want to rent a UK-based VPS that comes with friendly advice and support from a fellow ART fan, please get in touch.
</advert>


Top
 Profile  
 
 Post subject: Re: To many 777s
Unread postPosted: Tue Mar 06, 2012 5:35 pm 
Offline
Forum User
Forum User

Joined: Tue Mar 06, 2012 5:23 pm
Posts: 7
Location: Melbourne
Depending on your server setup (the way Apache is running - suPHP, Ruid2 or DSO) all you need is to create a crontab for daily run like this:
e.g for cPanel running Apache with suPHP or Ruid2:

1 1 * * * cd /home && find . -type f -perm 0777 -exec chmod 0644 "{}" \;
2 1 * * * cd /home && find . -type d -perm 0777 -exec chmod 0755 "{}" \;
3 1 * * * cd /home && find . -type f -perm 0666 -exec chmod 0644 "{}" \;


Top
 Profile  
 
 Post subject: Re: To many 777s
Unread postPosted: Wed Mar 07, 2012 9:58 am 
Offline
Atomicorp Staff - Site Admin
Atomicorp Staff - Site Admin

Joined: Wed Dec 31, 1969 8:00 pm
Posts: 7425
Location: earth
Its possible to do this with the HIDS and do both administrator and per user notifications by monitoring the /var/www/vhosts directory and then setting up Notify options for different domains to their respective owners.

Additionally you can use the regex field to narrow the search to specific files and send diffs of the changes to files (note, this can use a lot of space! side effect, you now have backups and rollbacks). It can also do this in real-time if your kernel supports inotify().


Top
 Profile  
 
 Post subject: Re: To many 777s
Unread postPosted: Sat Jun 30, 2012 3:58 pm 
Offline
Forum Regular
Forum Regular

Joined: Mon Oct 29, 2007 6:51 pm
Posts: 606
That could be bad though - if they run as dso some directories would need to be 777 so their sites can upload and work with files that the ftp user uploaded and vice versa. Joomla and wordpress are the two main examples that comes to mind


Top
 Profile  
 
 Post subject: Re: To many 777s
Unread postPosted: Sun Jul 01, 2012 4:28 pm 
Offline
Atomicorp Staff - Site Admin
Atomicorp Staff - Site Admin
User avatar

Joined: Thu Feb 07, 2008 7:49 pm
Posts: 3245
Location: Chantilly, VA
I understand what you're saying. Would group write work with some control panels, or are the users just so unrelated that it needs to be world writable?

The idea of alerting on 777 is an interesting idea (if its feasible, but if web apps need this to work, ZOMG is that vulnerable!), I could see maybe this being a domain user only alert? For example, they get an email warning them that their websites may have insecure permissions?

_________________
Michael Shinn
Atomicorp - Security For Everyone

Co-Author of Troubleshooting Linux Firewalls.


Top
 Profile  
 
 Post subject: Re: To many 777s
Unread postPosted: Sun Jul 01, 2012 4:59 pm 
Offline
Long Time Forum Regular
Long Time Forum Regular

Joined: Thu Dec 09, 2004 11:19 am
Posts: 1846
The domain user would probably not understand what the warning was about. It might work if we could define the text of the warning and maybe add a link to a website page explaining what this was all about.

_________________
--------------------------------
<advert>
If you want to rent a UK-based VPS that comes with friendly advice and support from a fellow ART fan, please get in touch.
</advert>


Top
 Profile  
 
 Post subject: Re: To many 777s
Unread postPosted: Mon Jul 02, 2012 4:10 am 
Offline
Long Time Forum Regular
Long Time Forum Regular

Joined: Sat Aug 20, 2005 9:30 am
Posts: 2812
Location: The Netherlands
mikeshinn wrote:
Would group write work with some control panels, or are the users just so unrelated that it needs to be world writable?


A very common case Plesk end users run into is using mod_php (PHP running as user 'apache') with a web application which needs to be able to upload files (file uploads for a WordPress installation for instance). This won't work out of the box since the upload directory will be 755 and owned by the domain user and 'psacln' group by default, which does not allow user 'apache' to write files to this directory. User 'apache' isn't a member of the 'psacln' group, so setting 775 permissions won't help either.

Since end users can't change the user or group owner they have no choice but to change permissions and setting the upload directory to be world writable is the only way user 'apache' will be allowed to write files to the upload directory. AFAIK using 777 permissions is actually the only way PHP file uploads with mod_php will work in Plesk's setup without an administrator stepping in to change user or group ownership, use sticky bits or some other voodoo end users are not allowed to perform.

When a domain is running PHP via FastCGI it will work out of the box, since in that case the PHP code will be executed by the user owning the PHP file.

The WordPress file permissions documentation at http://codex.wordpress.org/Changing_File_Permissions tries its best to explain how file permissions work and why 777 is bad, but my experience is that end users feel the documentation is way too complex for them to understand, so they'll find some forum post which tells them using 777 permissions (recursively!) will solve all their problems. They try it and ta-da, it works! Some even go as far as recursively setting 777 on all files and directories in their httpdocs directory for good measure.

_________________
Lemonbit Internet Dedicated Server Management


Last edited by breun on Mon Jul 02, 2012 1:08 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: To many 777s
Unread postPosted: Mon Jul 02, 2012 12:56 pm 
Offline
Atomicorp Staff - Site Admin
Atomicorp Staff - Site Admin
User avatar

Joined: Thu Feb 07, 2008 7:49 pm
Posts: 3245
Location: Chantilly, VA
Agreed, any useful message will need to explain this in easily understood terms and why its important to the domain owner.

_________________
Michael Shinn
Atomicorp - Security For Everyone

Co-Author of Troubleshooting Linux Firewalls.


Top
 Profile  
 
 Post subject: Re: To many 777s
Unread postPosted: Mon Jul 02, 2012 1:00 pm 
Offline
Forum Regular
Forum Regular

Joined: Mon Oct 29, 2007 6:51 pm
Posts: 606
maybe it would be good to have a button inside plesk for each domain that may be entitled something like "Security Scan" in which you can offer suggestions - like set php to run as cgi/fcgi, change permissions on these folders to xxxx, set this file to be outside the web root (like config.php, etc), etc - combine this with your app scan and you can give tailored security messages to the end user for best practices based on teh app, as well as just stupid things to avoid in general. Possibly even letting them know about insecure passwords, email accounts, etc.

Let them know if they installed their own version of phpmyadmin that they are being retarded, that kind of stuff :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic Share/Bookmark  [ 9 posts ] 

» Feed - Atomicorp

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group