Hi,
I want to implement a Universal Security Hotfix for previous versions of Joomla that can provide immediate protection against publicised attacks.
Below is code I am proposing to apply to the top of the index (index.php,index2.php etc) files in both the root and administrator
folders of joomla.
I am developing a universal security hotfix that can hopefully protect sites against attacks. That is, give them a breathing space so that an unrushed upgrade of your site can be performed.
I am currently testing it and need the help of sites that are undergoing an attack to see how effective it is.
THIS IS ALPHA STAGE OF THIS CODE AND SHOULD NOT BE USED BY INEXPERIENCED USERS
TO INSTALL - Copy the code below and paste the code in your globals.php file just below the copyright messages at the top of the file.
The hotfix currently DOES NOT prevent attacks on both Simpleboard and ExtCalandar2 modules - but I am investigating further, but should prevent known attacks on Joomla itself, unless anyone has any further info I am not aware of.
I make no guarentees at this stage as its in its very early stages of development, but the more people who can test the code, the more bullet proof and more helpful this code will be to other users who sites are vunerable.
PLEASE BE AWARE THAT IS HOTFIX IS ONLY DESIGNED AS A SHORT TERM MEASURE UNTIL YOU UPGRADE TO THE LATEST VERSION OF JOOMLA AND UPGRADE AND SECURE ANY OFFENDING 3rd PARTY MODULES
Code:
// ***** Security Hotfix Code version 1.4.8 (13-JUL-06) ********
// NOTE: THIS IS ONLLY A SHORT TERM MEASURE UNTIL YOU UPGRADE TO THE LATEST VERSION OF JOOMLA
// Joomla 1.0.3 and earlier vunerabilities 2005-11-22
$hotfix_protects = array('_REQUEST', '_GET', '_POST', '_COOKIE', '_FILES', '_SERVER', '_ENV', 'GLOBALS', '_SESSION');
foreach ($hotfix_protects as $hotfix_protect) {
if ( in_array($hotfix_protect , array_keys($_REQUEST)) ||
in_array($hotfix_protect , array_keys($_GET)) ||
in_array($hotfix_protect , array_keys($_POST)) ||
in_array($hotfix_protect , array_keys($_COOKIE)) ||
in_array($hotfix_protect , array_keys($_FILES))) {
die("Invalid Request.");
}
}
hotfix_sanitize_input ('Itemid');
// Mambo 4.5.3h and earlier vunerabilities 2006-02-22
// I dont think these are needed in Joomla, can anyone verify ???
hotfix_sanitize_input ('username'); // $_POST
hotfix_sanitize_input ('filter'); // $_POST
hotfix_sanitize_input ('task'); // $_GET, $_POST
hotfix_sanitize_input ('mos_user_template'); // $_COOKIE
hotfix_sanitize_input ('mos_change_template'); // $_REQUEST
// Joomla 1.0.9 and earlier vunerabilities 2006-06-19
hotfix_sanitize_input ('title');
hotfix_sanitize_input ('catid');
hotfix_sanitize_input ('id','integer','|com_jd-wiki|'); // convert "id" to integer except when using module com_jd-wiki
// main hotfix security functions
function hotfix_URLcheck( $filename ) {
$urlfile = '/'.strtolower(basename($_SERVER['PHP_SELF']));
if (strpos($urlfile,$filename) === false) {
return false;
} else {
return true;
}
}
function hotfix_sanitize_input( $vname, $dtype='', $exlist='' ) {
if (isset($_REQUEST[$vname])) {
$safe_data = strip_tags(mysql_escape_string($_REQUEST[$vname]));
if ($dtype != '') {
$m = '|'.$_REQUEST['option'].'|';
if(strpos($exlist,$m)=== false) {
settype($safe_data, $dtype);
}
}
$_REQUEST[$vname] = $safe_data;
if (isset($_GET[$vname])) { $_GET[$vname] = $safe_data; }
if (isset($_POST[$vname])) { $_POST[$vname] = $safe_data; }
if (isset($_COOKIE[$vname])) { $_COOKIE[$vname] = $safe_data; }
}
}
// ***** Security Hotfix Code end ********
Can anyone see any problems with this code or how it would be applied

??
This patch is meant to be an immediate short term defence to allow breathing space to do a proper upgrade and test of joomla to its latest version in a production environment.
Any issues please leave a message in this forum or PM me.