THE SITUATION
I have multiple folders in my /var/www/
directory.
Users are created that have control over a specific directory... /var/www/app1
belongs to app1:app1
(www-data
is a member of the app1
group).
This works fine for what I want.
THE PROBLEM
If the app1
user uploads a PHP script that changes the file/folder permissions for something in app2
s directory structure, the Apache process (as there's only one installed on the server) will be more than happy to run it, as it has the necessary permissions to access both /var/www/app1
and /var/www/app2
folders and files.
EDIT:
To the best of my knowledge, something like, /var/www/app1/includes/hack.php
:
<?php
chmod("/var/www/app2", 777);
?>
The Apache process (owned by www-data
) will run this, as it has permissions to change both /var/www/app1
and /var/www/app2
directories. The user app1
will then be able to cd /var/www/app2
, rm -rf /var/www/app2
, etc., which is obviously not good.
THE QUESTION
How can I avoid this cross-contamination of the Apache process? Can I instruct Apache to only run PHP scripts that affect the files/folders that reside within the relevant vHost root directory and below?