2004-01-26 13:22:25 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2007-06-20 22:25:43 +00:00
|
|
|
<!-- $Revision: 1.4 $ -->
|
2004-01-26 13:22:25 +00:00
|
|
|
<!-- splitted from ./index.xml, last change in rev 1.66 -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<chapter xml:id="security.apache" xmlns="http://docbook.org/ns/docbook">
|
2004-01-26 13:22:25 +00:00
|
|
|
<title>Installed as an Apache module</title>
|
|
|
|
<simpara>
|
|
|
|
When PHP is used as an Apache module it inherits Apache's user
|
|
|
|
permissions (typically those of the "nobody" user). This has several
|
|
|
|
impacts on security and authorization. For example, if you are using
|
|
|
|
PHP to access a database, unless that database has built-in access
|
|
|
|
control, you will have to make the database accessible to the
|
|
|
|
"nobody" user. This means a malicious script could access and modify
|
|
|
|
the database, even without a username and password. It's entirely
|
|
|
|
possible that a web spider could stumble across a database
|
|
|
|
administrator's web page, and drop all of your databases. You can
|
|
|
|
protect against this with Apache authorization, or you can design
|
|
|
|
your own access model using LDAP, &htaccess; files, etc. and include
|
|
|
|
that code as part of your PHP scripts.
|
|
|
|
</simpara>
|
|
|
|
<simpara>
|
|
|
|
Often, once security is established to the point where the PHP user
|
|
|
|
(in this case, the apache user) has very little risk attached to it,
|
|
|
|
it is discovered that PHP is now prevented from writing any files
|
|
|
|
to user directories. Or perhaps it has been prevented from accessing
|
|
|
|
or changing databases. It has equally been secured from writing
|
|
|
|
good and bad files, or entering good and bad database transactions.
|
|
|
|
</simpara>
|
|
|
|
<simpara>
|
|
|
|
A frequent security mistake made at this point is to allow apache
|
2004-08-13 01:00:48 +00:00
|
|
|
root permissions, or to escalate apache's abilities in some other
|
2004-01-26 13:22:25 +00:00
|
|
|
way.
|
|
|
|
</simpara>
|
|
|
|
<simpara>
|
|
|
|
Escalating the Apache user's permissions to root is extremely
|
|
|
|
dangerous and may compromise the entire system, so sudo'ing,
|
|
|
|
chroot'ing, or otherwise running as root should not be considered by
|
|
|
|
those who are not security professionals.
|
|
|
|
</simpara>
|
|
|
|
<simpara>
|
|
|
|
There are some simpler solutions. By using
|
|
|
|
<link linkend="ini.open-basedir">open_basedir</link> you can control and restrict what
|
|
|
|
directories are allowed to be used for PHP. You can also set up
|
|
|
|
apache-only areas, to restrict all web based activity to non-user,
|
|
|
|
or non-system, files.
|
|
|
|
</simpara>
|
2004-08-08 16:11:36 +00:00
|
|
|
</chapter>
|
2004-01-26 13:22:25 +00:00
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|