I have an Ubuntu system hosting several websites. The DocumentRoot
folder of each website is separate and has a different user. The paths are like this:
/<path_from_root>/websites/websiteA
/<path_from_root>/websites/websiteB
Let's assume that the respective users are userA and userB. Though, the userB doesn't have read access to the folder websiteA, the apache user does have the access. userB can simply write a php file like this in his directory:
<?php
$x=file_get_contents('../websiteA/config.php');
echo $x;
?>
This file will expose the config.php file to the userB. The key issue is that apache needs to have read access to both the folders for running the web services but the userB can exploit this to access userA's files. How to prevent this from happening?