You are here: Templates Club arrow Blog arrow Tutorials arrow Protect your Joomla! installation!
Protect your Joomla! installation!
Friday, 04 December 2009

Last few days , Youjoomla Team  was testing security or better said, testing the best protection you can use in your Joomla! website. We have focused mainly on XSS  ( cross site scripting ) since it is one of the most common ways for intruder to get in or abuse your website.  If you did not know, one of the best ways to protect yourself from XSS is to turn your Joomla! SEF on.

But the problem is that not everyone is using it like they should. So it is up to us developers, to try to protect you before you even think about downloading our products. Bumping heads together has helped and we also joined forces with brilliant Mr. andresg888 who was to our surprise,  very polite and helped us test some common exploits.

Most of them use your in code $_POST and $_GET that are not sanitized to attack you. We have brushed up on our strip_tags() , htmlentities() , htmlspecialchars() and so on , but most of them either strip everything or are not 100% reliable for protection. So we came up with few lines of code that would strip everything from $_POST or $_GET and just return letters, numbers , spaces and  ' . Mr. andress888 was kind enough to test it for us and confirmed protection.

So here it is , 2 lines that can save you from trouble

 

$_GET = preg_replace("|([^\w\s\'])|i",'',$_GET);
$_POST = preg_replace("|([^\w\s\'])|i",'',$_POST);

Simply add them to your template index.php after the first <?php deceleration and you should be safe. Please remember that every code has weakness and if you find  one in this code snippet, we would like to hear your thoughts or advices.

 

Best regards

Youjoomla Team

 

    

Comments

 
#7 Robbin Smith 2010-04-24 07:30
Hello Everybody ! Thanks for developing it for us you don't that how much we are afraid of spam in our sites Joomla is saviour of us .
Uniqur Cars
Quote
 
 
#6 aDesign 2010-04-21 23:29
Nice infos. Thanks for the detailed article this is what most of us miss regarding the security of Joomla.
Quote
 
 
#5 Tom 2010-04-11 15:18
Thanks ... so simple yet so powerful.
Quote
 
 
#4 USH 2010-01-18 21:20
Wow, that's great, thanks for this!!
Quote
 
 
#3 neo 2010-01-18 21:18
Quoting USH:
Would these work in any Joomla! template or only the ones from youjoomla.com?

we tested in wordpress , joomla and other php driven sites and worked in all of them. no matter what template used
Quote
 
 
#2 USH 2010-01-18 21:17
Would these work in any Joomla! template or only the ones from youjoomla.com?
Quote
 
 
#1 web design sydney 2010-01-17 07:58
Thank you for sharing with us how to add protection to joomla,i will try adding these codes you suggested to us.
Quote
 

Add comment


Security code
Refresh