Apache, PHP, SuEXEC: added security and control

suhosin
As we know from original article using Apache, PHP in CGI mode along with suExec gives us 2 important security advantages:
– suExec allows to run PHP process with (only) the file owner user privileges, enforcing proper permissions on PHP scripts and thus allowing to avoid cross-site exploits on the server that is running multiple dynamic web sites;
– per site php.ini.
That gives some unique opportunities for securing separate web sites on the server.

Easier way is to use the pricinple of the least privilege. For the impatient, who can not go the read the article the idea is simple – give the site the least possible privileges that required to function properly and disable everything else. I am talking about disable_functions.
What to disable exactly? Unfortunately most of the modern PHP scripts are written without security in mind so YMMV.

  • Light and essential (taken from here)

    . Affects only most dangerous functions but still might break some Wordpress plugins (and will definitely break vbulletin, that uses eval).

  • more deep, enablig PHP functions on the “least privilege” basis. (You will need to adjust this list to exclude functions that are used in your PHP sccitps, unfortunately if it is third party script the only way to find out would be “trial and error”)

  • using Suhosin, PHP security extension, and reducing PHP scripts privileges using suhosin configuration. (taken from here). Obviously you will need to have shared suhosin extension binary installed on the system.

    This setup works in most usage scenarios, however this article concentrates on some details to pay attention to when you are planning to deploy Suhosin on your server.
    Quick Tip: you can turn suhosin.simulation flag to “on” and disable all suhosin functionality at once, while you still have it’s logging running.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">