Thursday, March 5, 2015

linux - Stopping PHP ability to read/write other PHP files



I host a very small hosting site that hosts a type of chat software. I give each user a /home/ jailed ftp but they have their own www folder they can upload things to.




One of my users uploaded this php file: http://pastebin.com/YAJW8weh - which seems to be able to save php files and allow him to download them.



Using this I think he was able to access some of my files and one of my php files had my MySQL password in the php, which he then gained access to a database with all my clients passwords.



How can I stop this from happening again? What precautions should I take when giving users their own /home/ directory.


Answer



You want to disable php for the home folder.



When using PHP as an Apache module (default on Ubuntu 10.04), add the following to your Apache configuration





php_admin_value engine Off



You should probably also use Options -ExecCGI and AllowOverride None there for safety. See the official Apache security tips. If your webserver have other kinds of scripts enabled (like mod_perl), be sure to disable them for the home folder too.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...