List of files directly accessed by Apache:
Web pages, graphics, MAIN scripts, .htaccess, password file.
If a directory contain one of these or a sub directory with these somewhere below,
you should set it to 710.
Otherwise, set 700.
Exception to this rule of thumb:
If you use Apaches default directory index, you have to set 750
to the particular directory.
Many people recommend 755 for directories.
Well, it may give lots of advantage to someone who cracked other user's account.
Why would you loosen the security when you can keep it tight without penalty ?
So, use 710 or 700 according to what the directory contains.
Now, about the files.
List of files directly accessed by Apache:
Web pages, graphics, .htaccess, password file.
These files must have the permission of 640
or something readable by anyone.
Normally, people use 644, which is fine.
Normal html pages and graphics are publicly available data,
and you shouldn't worry about its security, anyway.
I mean, everybody can get it through web access !
If you want to secure html page for some reason,
there is no way to do that unless you serve the page via CGI/SSI/PHP.
To make it accessible to the Apache web server,
you have to set 640 minimum (on
PowWeb server).
And that will permit anyone on the same server or clucter to see it.
By setting the permission of directory to 710,
attacker cannot browse the directoy.
It mean he has to know the exact location of the files to read it.
But it's usually very easy to know the exact path from the URL,
and it's still relatively easy to know it even if you use mod_rewrite
to change actual file paths.
So, you can protect the access to files by password protection
and/or IP based 'deny from', mechanism, but unfortunately,
there is no way to secure them from back entry attacks,
as long as the permission of 640 (or 644) is used.
For Perl/shellscript, set 700, or 500.
For PHP scripts, set 600 or 400 if you want more security.
And for all other data, you can use 600 (if it needs to be read/write)
or 400 (if it's normally read only, and updated normally only by FTP).
710 on Directory with Web pages, graphics, MAIN scripts, .htaccess, password file,
and any sub directory with these somewherer below.
700 on all other directory
Applicable to PowWeb:
/www/U/USER/htdocs/subdomain/subdir-with-html/subdir-for-includ-files/
710 710 710 710 700
/subdir-with-html/subdir-for-includ-files/
710 700
/datadir-no-access-by apache/subdir-for-data/
700 700
/subdir-using-default-directory-index/
750
/subdomain/htdocs/subdir-with-html/subdir-for-includ-files/
710 710 710 700
/cgi-bin/subdir-with-cgi/subdir-for-includ-files/
710 710 700
/etc/subdir-for-data/
700 700
/logs/subdir-for-data/
700 700
Permission setting of sites hosted by Servage.net
As Servage.net runs mod_php and mod_perl, and the FTP user gorupe
is diffferent from nobody group, we have to make directories and files
available to "nobody", I mean, to anyone.
For all directories that contain readonly data, set them to 711.
If there is a directory that contain files with read/write access, set it to 733.
If certain application need to brows and get list of files in the directory,
you have no other choice than setting 777, which is very vulnerable.
For files, normal readonly files should be 644.
Files that need read/write access have to be 666.
Note that directories with 777 permit ANYONE to do ANYTHING to that directory,
including deleting things in it, renaming, moving, whatever !
Files with 666 can be written, appended, or overwritten by ANYONE.
As Servage.net refused to explain the security level, and more over,
refuse to discuss about it, I think their security level is indeed very low.
DO NOT USE 777/733 on directories, or 666 on files
unless you are ready to loose control of your site in the event of
intrusion or attack coming from back side.
In other words, it's safe as long as you place readonly static pages,
or CGI/PHP without any writing actions.
Also, your files should not contain ANY sensitive data because
they can't be protected from back side peeping.
NO PASSWORD of any kind, no personal info, no account information, NOTHING !
I will edit and modify this contents if Servage.net changes the opinion,
and provide me convincing technical explanation to support their claim of SAFE SANDBOX.
Similiar security concerns are shared by many hosts
who don't use SuEXECed/cgiwraped cgi/php and doing "Nobody" access on everything.
So, Servage.net isn't worse than other hosts.
But
PowWeb, LunarPages
? and many other hosts are much safer, in my opinion.
The site design
As I coverd in the section for PHP, the resource usage has
direct and indirect impact on the security of your site.
Construct your site as light as possible with the features you really need.
Calculate number of access required for the given page.
exmaple: mypage.php is a top frame and it loads two side frames,
left.php and right.php.
In each php page, you may have a couple of includes.
And if these includes (or fopen) contains "http:// ...." in it,
that counts for another http access.
And you may have a counter that access php driven graphic,
as well as thumbnails that are shrunk on every request by php ....
Now, you may get the idea.
THIS PAGE IS HEAVY on the server !
It requires not only lots and lots of requests to serve the page,
but also many of them invoke heavy and slow php processes !
And sadly, this type of site cu\onstruction is very common among naive PHP users,
CMS lovers, and design oriented people who doesn't care about resource usage.
Well, when you see the slow server load, don't just blame hosting companies,
but people who use these heavy page for very busy site,
and also those who promoted these stupidity for naive people.
CPU power and memory resources are just like OIL !
You waste it, and it will run out, sooner.
And maybe sooner than you hoped ...
But human beings are so superior and created to be the governor of the earth that
they don't learn anything even when they are shown hard facts.
They love more sweat illusion than the simple cruel fact.
Link(s)