Please keep in mind that every .htaccess directive adds to server loads. Not only can they impact on your site performance, but several sites on a shared server running large .htaccess files are likely to get into strife with web hosts.
For nearly all the reported attacks so far, only two simple changes are necessary.
1. Turn register_globals OFF.
You can ask your host to do this (it is a server-wide setting in php.ini) and if they will not, then people who have sites that run PHP as an Apache module can add the following to their .htaccess:
Code:
php_flag register_globals off
If you have components that require register_globals, you can use the Joomla globals.php emulation. This emulates register_globals on while protecting from vulnerabilities if it is enabled through your server space.
If you are running your site under CGI then the .htaccess directive given above may not work for you. You will need to ask your host for assistance with turning register_globals OFF.
Please Note: register_globals is not, in itself, a security issue. However, some scripts have not been written to correctly sanitise input and use an "easy" globals option that leaves security holes. For those scripts, turning register_globals off will either protect them or break them.
If they break, please contact the script developer for a fix, or change scripts.
2. All Joomla extensions should be checked to ensure that all files contain the default:
Code:
// Don't allow direct linking
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
Many of the intrusions have been because the 3rd party extensions allow direct access to the php code.
Additionally: To stop external access directly to components or modules you could also add this to your htaccess - it makes every access condtional on someone actually being on your site.
Note: I use this to stop content in wrappers being directly accessed from outside of the site itself, and have not tried it on components, but it should work just the same.
Code:
# Blocking direct access
RewriteCond %{HTTP_REFERER} !^http://www.domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$ [NC]
RewriteCond %{REQUEST_URI} ^.*index\\.php$
RewriteRule .* - [F]
Replacing domain.com with your domain, of course!