10 Simple Security Tasks for Locking Down Your LAMP Website
6. Upgrade Early and Often
Despite being actively developed for almost 15 years, PHP is still subject to the occasional serious security issue. Over the years the alarm bells, which used to ring with security-related announcements, seem to have waned (not due to any fault on the PHP developer's part but rather I suspect due to the fact that the Web is a much busier place than in years past). For instance, although PHP 5.3 has been out for several months now, chances are quite a few developers are still running a PHP 5.2.X release, which up until 5.2.13 happens to contain several significant security issues.
Given the deluge of other information you're regularly perusing online, hoping a relevant feed reader headline catches your eye probably isn't the best way to keep abreast of required security updates. Instead, you should proactively monitor for any security-related news pertinent to your software stack; the easiest way to do so is by subscribing to the various project's announcement mailing lists. These low-volume lists will announce significant releases, often with links to the change logs (PHP announce list , Apache announce list , MySQL announce list).
7. Restrict the MySQL User Privileges
DROP TABLEcommand. Even if your site wasn't properly filtering user input, the attack would fail if you configured the database user responsible for running the website so that it was unable to execute the
Given the goal of hampering attackers by introducing several levels of security into your website's operation, consider configuring your website's database user privileges to only those that are necessary to power the site. You can learn more about MySQL's access privilege system here.
8. Disable your phpinfo Script
phpinfo() function within a PHP script will produce a long list of PHP- and server-specific configuration data, including information about the PHP version, extensions configured, and configuration directive settings. This information can be useful during the development process, providing an easy way to diagnose issues involving settings such as the
include_path directive and sessions.
This information could be equally beneficial to an attacker searching for ways to exploit your system, so be sure to remove this script when deploying the site. If you prefer to continue referencing it from the production server, configure Apache to restrict the file's access to your IP address.
9. Disable Potentially Dangerous PHP Functions
Continuing with the theme of layered security, consider adding potentially dangerous functions such as
phpinfo() to the
disable_functions directive within your
10. Mind the Document Root
Remember that unless your server is specifically configured to restrict access to certain files or directories, anything placed within your website's document root is subject to access via the browser! Therefore, be sure to remove image templates, development notes, documentation, and anything else that could provide an attacker with useful fodder for further exploitation.
The 10 tasks discussed in this article are all easily completed, and can greatly reduce the possibility of downtime due to an attack. What else are you doing to protect your site? Tell us about it in the comments!
About the Author
Jason Gilmore is the founder of EasyPHPWebsites.com. He also is the author of several popular books, including "Easy PHP Websites with the Zend Framework," "Easy PayPal with PHP," and "Beginning PHP and MySQL, Third Edition."
Page 2 of 2