Hacker News new | ask | show | jobs
by static_cast 5352 days ago
That's pretty sound advice. However a lot of scripts won't work if you disable exec and co.

some other random ideas for php-security:

If you have to enable some form of option to exec binaries be aware that open_basedir is useless now, because the attacker can just start a python instance and operate under apache user if you are using mod_php

using fastcgi (mod_fcgid or nginx+php-fpm) and restrictive permissions on your directories should at least protect your other users home directories.

another idea is prevent malicous scripts is to firewall apache and php from iptables. there is an iptables module for restricting uid and gid ranges to have access to the outside world. this could at least prevent a trojan dropped in /tmp to connect to their irc-server. but you can also disallow outgoing traffic to port 80, this breaks however all the auto-update features of e.g. wordpress.

A lot of script-kiddie toolkits can also be stopped by not having gcc,wget,python etc.pp available to the user running php.

if you have to host sensitive data on the same host as the php application it's wise to use a jail or at least chroot for php, there are some guides to put a mod_fcgid php into a chroot

and: never ever use the mysql root user for database connectivity!