I've been asked to create a PHP environment on a web-server I administer that is currently only running Python applications. The authors of these applications don't necessarily have a programming background, so I'd like to limit what they can possibly do wrong.

I'm using Ubuntu 9.04, and know that I should have register_globals disabled, but what else can/should I restrict?


Here is a list of things that I was about to type up. There are other things you can do, like Suhosin, but the first link is a good start to this.

| improve this answer | |
  • 1
    In Ubuntu, apt-get install php-suhosin will get you that. – staticsan Aug 31 '09 at 23:13
  • It is still working for me.. – Josh Brower Aug 30 '11 at 13:37

As you can't really trust your app developers to write secure code, you'll have to limit the attack vectors non-secure php code could provide. Using user input without proper sanitizing as SQL or as an argument to open() are classic examples of things that go wrong.

My brief list:

  • put the php environment inside a chroot jail, to limit the risks to the host.
  • make sure the php apps don't access the same databases which are used otherwise.
  • rate-limit (and monitor) outgoing mail. If there's a way to send email with user-specified content and address, some spammer will sooner or later find and exploit it.

I'm sure there are plenty of other things I either don't know about or I can't remember any more.

There are also plenty of stuff you as an administrator can't prepare for. For example, it's very hard to control cross-site scripting risks and to make sure mechanics inside the apps don't encourage any malicious use cases, such as using the app as a drop box for bad stuff like rootkits.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.