<?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>UNIXy &#187; Security</title>
	<atom:link href="http://blog.unixy.net/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.unixy.net</link>
	<description>Fully Managed Dedicated Servers</description>
	<lastBuildDate>Sun, 22 Jan 2012 07:33:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Stable FastCGI configuration on a cPanel Apache shared or dedicated server</title>
		<link>http://blog.unixy.net/2011/12/stable-fastcgi-configuration-on-a-cpanel-apache-shared-or-dedicated-server/</link>
		<comments>http://blog.unixy.net/2011/12/stable-fastcgi-configuration-on-a-cpanel-apache-shared-or-dedicated-server/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 20:35:32 +0000</pubDate>
		<dc:creator>UNIXy</dc:creator>
				<category><![CDATA[Crash Course]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[cPanel]]></category>
		<category><![CDATA[DSO]]></category>
		<category><![CDATA[FastCGI]]></category>
		<category><![CDATA[mod_php]]></category>
		<category><![CDATA[suPHP]]></category>
		<category><![CDATA[UNIXy]]></category>
		<category><![CDATA[varnish]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=1483</guid>
		<description><![CDATA[A default installation of FastCGI on cPanel server is dangerously simple. In this post, I'll go over what it takes to configure FastCGI on a cPanel node properly.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2011%2F12%2Fstable-fastcgi-configuration-on-a-cpanel-apache-shared-or-dedicated-server%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2011%2F12%2Fstable-fastcgi-configuration-on-a-cpanel-apache-shared-or-dedicated-server%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>A default installation of FastCGI on <a title="cPanel Varnish" href="http://www.unixy.net/varnish" target="_blank">cPanel</a> <a title="server" href="http://www.unixy.net/dedicated-servers" target="_blank">server</a> is dangerously simple. It&#8217;s dangerous because one cPanel account (or one vhost) is capable of crashing down a whole <a title="server" href="http://www.unixy.net">server</a> if, say, traffic were to spike up. It&#8217;s also simple because it won&#8217;t allow complex scripts to run cleanly. In brief, it&#8217;s absolutely not ready for production as-is. In this post, I&#8217;ll go over what it takes to configure FastCGI on a cPanel node properly.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><em>Did you know?</em></p>
<blockquote>
<p style="text-align: left;"><strong>UNIXy is a <a title="fully managed server" href="http://www.unixy.net/fully-managed-hosting-promise">fully managed server</a> and cluster provider. What this means is we don&#8217;t expect you to know anything about servers or server management. The good news is it doesn&#8217;t cost you extra to have us manage your UNIXy server! Get in touch with us <a title="UNIXy Contact" href="https://www.unixy.net/secure/contact.php">here</a> to get the ball rolling!</strong></p>
<p style="text-align: left;">
</blockquote>
<p>Before you continue reading, be sure to have FastCGI up and running as the PHP handler on your cPanel server. The installation of FastCGI is covered in the online cPanel documentation. From here on now, I&#8217;ll assume you&#8217;re ready to add the settings for FastCGI.</p>
<p>The following is a list of settings that you need to add to /etc/httpd/conf/php.conf upon switching to FastCGI:</p>
<blockquote>
<pre>MaxRequestsPerProcess 1000
FcgidMaxProcesses 200
FcgidProcessLifeTime 7200
MaxProcessCount 500
FcgidIOTimeout 400
FcgidIdleTimeout 600
FcgidIdleScanInterval 90
FcgidBusyTimeout 300
FcgidBusyScanInterval 80
ErrorScanInterval 3
ZombieScanInterval 3
<strong>DefaultMinClassProcessCount 0</strong>
<strong>DefaultMaxClassProcessCount 3</strong>
<strong>MaxRequestLen 20468982</strong></pre>
</blockquote>
<p>You&#8217;re more likely to adjust the settings in <strong>bold </strong>above. <em>Default<strong>Min</strong>ClassProcessCount 0 </em>instructs FastCGI to keep zero PHP processes running for user when traffic is idle (cPanel account user) . On the other hand, <em>Default<strong>Max</strong>ClassProcessCount 3 </em>tells FastCGI to never allow more than 3 PHP processes running at a time. This settings prevents one users from crashing the server were they to receive a lot of traffic.</p>
<p>So go ahead and copy/paste the above into your httpd.conf and restart Apache (service httpd restart). You&#8217;re good to go now! For greater performance, be sure to check out our <a title="Varnish" href="http://www.unixy.net/varnish">Varnish plugin</a>. Whether you&#8217;re running suPHP, FastCGI, or even DSO (mod_php), <a title="varnish" href="http://www.unixy.net/varnish">Varnish</a> will make your website load much faster.</p>
<p>That&#8217;s all folks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2011/12/stable-fastcgi-configuration-on-a-cpanel-apache-shared-or-dedicated-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable or detect Minute cron / crontab job runs</title>
		<link>http://blog.unixy.net/2011/10/disable-or-detect-minute-cron-crontab-job-runs/</link>
		<comments>http://blog.unixy.net/2011/10/disable-or-detect-minute-cron-crontab-job-runs/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 10:14:32 +0000</pubDate>
		<dc:creator>UNIXy</dc:creator>
				<category><![CDATA[Interesting]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[abuse]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[detect]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[disable cron]]></category>
		<category><![CDATA[disable crontab]]></category>
		<category><![CDATA[disable minute]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[minute]]></category>
		<category><![CDATA[minute crontab]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=1396</guid>
		<description><![CDATA[So how does one detect (and eventually prevent) crontab jobs on a server from running every minute? First of all, why would one ever want to control crontab? Long story short, an aggressive cron job can cripple a shared server and affect all users on such paltform. Here&#8217;s a script that crawls cron jobs and [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2011%2F10%2Fdisable-or-detect-minute-cron-crontab-job-runs%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2011%2F10%2Fdisable-or-detect-minute-cron-crontab-job-runs%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>So how does one detect (and eventually prevent) crontab jobs on a <a title="server" href="http://www.unixy.net/dedicated-servers">server</a> from running every minute? First of all, why would one ever want to control crontab? Long story short, an aggressive cron job can cripple a <a title="server" href="http://www.unixy.net/dedicated-servers">shared server</a> and affect all users on such paltform.</p>
<p>Here&#8217;s a <a title="script" href="http://www.unixy.net/advanced-hosting" target="_blank">script</a> that crawls cron jobs and reports non-root scripts that run at 5 minute frequency or less. Let&#8217;s beautify the code &amp; pack it into a runnable file script:</p>
<blockquote>
<pre>
#!/bin/bash
admin="admin@example.com";
ls -1 /var/spool/cron/| grep -v '^root'|while read u;
do
        cat /var/spool/cron/${u}|\
        awk '{print $1":"$2":"$3":"$4":"$5":"$NF}'|\
        while read entry;
        do
                mn=$(echo ${entry}|awk -F':' '{print $1}');
                if [[ ${mn} == "*" || ${mn} =~ "\*\/[0-5]$" ]];
                then
                        echo "Minutely script found -> ${u}";
                fi;
        done;
done | mail -s "Minutely script search - report" ${admin};
</pre>
</blockquote>
<p>Be sure to change the email address. You&#8217;ll need to set this to run as root as a crontab job every 10 minutes or so.<br />
That&#8217;s all folks. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2011/10/disable-or-detect-minute-cron-crontab-job-runs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Death Match Benchmark &#8211; Web Servers Battle One Another</title>
		<link>http://blog.unixy.net/2011/06/death-match-benchmark-web-servers-battle-one-another/</link>
		<comments>http://blog.unixy.net/2011/06/death-match-benchmark-web-servers-battle-one-another/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 03:46:00 +0000</pubDate>
		<dc:creator>UNIXy</dc:creator>
				<category><![CDATA[Interesting]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[death match]]></category>
		<category><![CDATA[fastlayer]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[varnish]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=1301</guid>
		<description><![CDATA[Here is a post detailing an interesting setup of Web servers made to go against one another in real time. This could prove to be entertaining for benchmarkers or perhaps decisive for those who need an ultimate killer proof that their favorite Web server can kick some behind.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2011%2F06%2Fdeath-match-benchmark-web-servers-battle-one-another%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2011%2F06%2Fdeath-match-benchmark-web-servers-battle-one-another%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: left;">Here is a post detailing an interesting setup of <a title="Web server" href="http://www.unixy.net/advanced-hosting" target="_blank">Web servers</a> made to go against one another in real time. This could prove to be entertaining for benchmarkers or perhaps decisive for those who need an ultimate <em>killer</em> proof that their favorite Web server can kick some behind.</p>
<p>Definition of <a title="Server" href="http://www.unixy.net">server</a> Web benchmarking (according to Wikipedia):</p>
<blockquote><p>It is the process of estimating a web server performance in order to find if the server can serve sufficiently high workload [sic].</p></blockquote>
<p>In this article, I&#8217;m going to butcher this definition and depart from the tradition &#8211; a tad bit. Here are a some interesting questions that come to mind: What if the end goal is not to obtain measurements but to take a knock-out approach? What if we were to put three Web servers all against one another is a threesome match? Is the outcome of this death match meaningful? How do we select the winner? Switching gears forward a bit, could this death match approach be maliciously leveraged in a <a title="Botnet" href="http://en.wikipedia.org/wiki/Botnet" target="_blank">botnet</a> situation?</p>
<p><img class="aligncenter size-full wp-image-1331" title="Death Match Diagram" src="http://blog.unixy.net/wp-content/uploads/2011/06/dmdiag.png" alt="" width="404" height="306" /></p>
<p>Let&#8217;s dive right into the code! But first, let&#8217;s discuss the logic necessary to trigger, enable, and maintain a match until death occurs or an apparent draw ensues. The death match in this post is triggered via a single GET action from a regular browser and can be sent to any Web server (or all) that is participating in the fight. The trigger calls a server-side python script called <a title="Bench.py" href="http://www.unixy.net/files/bench.py" target="_blank">bench.py</a>, which in turns forks a threaded python program, called <em><a title="Benchlet.py" href="http://www.unixy.net/files/benchlet.py" target="_blank">benchlet.py</a></em>, that perpetuates the  match. Each Web server participating in the death match receives a GET request and then resonates another similar multi-threaded request against the other Web server. This back and forth exchange escalates the match further and further&#8230;until death occurs.</p>
<p>&nbsp;</p>
<p><a href="http://blog.unixy.net/wp-content/uploads/2011/06/bench.py_.png"><img class="aligncenter size-full wp-image-1314" title="Bench.py" src="http://blog.unixy.net/wp-content/uploads/2011/06/bench.py_.png" alt="" width="547" height="120" /></a></p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://blog.unixy.net/wp-content/uploads/2011/06/benchlet.py_2.png"><img class="aligncenter size-full wp-image-1317" title="Benchlet.py" src="http://blog.unixy.net/wp-content/uploads/2011/06/benchlet.py_2.png" alt="" width="350" height="304" /></a></p>
<p>&nbsp;</p>
<p>The following video illustrates the trigger action and an excerpt from the match.</p>
<p>&nbsp;</p>
<p><object width="640" height="390"><param name="movie" value="http://www.youtube.com/v/iZl2NSZomHA&amp;hl=en_US&amp;feature=player_embedded&amp;version=3" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><embed type="application/x-shockwave-flash" width="640" height="390" src="http://www.youtube.com/v/iZl2NSZomHA&amp;hl=en_US&amp;feature=player_embedded&amp;version=3&amp;rel=0" rel="0" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
<p>The mechanism used to trigger and maintain the match is written in python but it could be just about any server-side processing language like PHP or Ruby.</p>
<p><strong>About UNIXy</strong></p>
<p>UNIXy is a fully managed server and cluster services providers with a focus on high traffic Web sites. Server and cluster management is offered courtesy at not extra costs to their clients. They have been offering <a title="Varnish" href="http://www.unixy.net/varnish">Varnish</a> acceleration to their clients for more than three years. They have released the first c<a title="cPanel Varnish" href="http://www.unixy.net/varnish">Panel Varnish plugin</a> as well as spun a new startup, <a title="Fastlayer" href="http://fastlayer.com/">Fastlayer</a>, the on-demand HTTP accelerator for the <a title="Fastlayer for the cloud" href="http://fastlayer.com/">cloud</a>.</p>
<p>That&#8217;s all folks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2011/06/death-match-benchmark-web-servers-battle-one-another/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Possible flaw in LOIC &#8211; Tool used to DDoS Amazon</title>
		<link>http://blog.unixy.net/2010/12/possible-flaw-in-loic-tool-used-to-ddos-amazon/</link>
		<comments>http://blog.unixy.net/2010/12/possible-flaw-in-loic-tool-used-to-ddos-amazon/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 16:42:47 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[DDoS]]></category>
		<category><![CDATA[flaw]]></category>
		<category><![CDATA[LOIC]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=1075</guid>
		<description><![CDATA[The attackers are so determined they are asking everybody on the planet to download this program called Low Orbit Ion Canon (LOIC) and launch it against Amazon. In this post, we (UNIXY) will share a flaw in the program that we think can be used to mitigate the attack.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F12%2Fpossible-flaw-in-loic-tool-used-to-ddos-amazon%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F12%2Fpossible-flaw-in-loic-tool-used-to-ddos-amazon%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hitting the news today is a concerted <a title="How to stop DDoS attack" href="blog.unixy.net/2010/08/the-penultimate-guide-to-stopping-a-ddos-attack-a-new-approach/">DDoS</a> attack effort directed at Amazon as vendetta for its role in ousting Wikileaks.org off its hosting cloud. The attackers are so determined they are asking everybody on the planet to download this program called Low Orbit Ion Canon (<a title="LOIC" href="http://encyclopediadramatica.com/LOIC" target="_blank">LOIC</a>) and launch it against Amazon. In this post, we&#8217;rel sharing a flaw in the program that we think can be used to mitigate the attack, to an extent.</p>
<p>The program is written in C# with its source code available for anyone to inspect it and modify it. In fact one has to compile the code in order to use the tool. The flaw in this program is apparent in the source code of the program. In file HTTPFlooder.cs at line 63, the payload of the request is constructed like this:</p>
<blockquote><p>byte[] buf = System.Text.Encoding.ASCII.GetBytes(String.Format(&#8220;GET {0} HTTP/1.0{1}{1}{1}&#8221;, Subsite, Environment.NewLine));</p></blockquote>
<p>This is at the heart of the attack. It consists of a flood of HTTP GET request using protocol 1.0. These kind of attacks are difficult to defend against because the request looks very similar to a legitimate request coming from a typical Web user. The request flows through several layers in the OSI stack and exhausts a lot of computing resources &#8211; all the way to the 7th logical layer of the OSI model.</p>
<p>But notice that this request is missing the host header (Example: Host: www.amazon.com). This fact alone can help with filtering the attack. One could ensure that all requests contain this important header either in the Web server configuration (imperfect solution). The optimal solution, however, is to introduce specialized ASIC deep packet inspection devices with proper signatures to filter out the attack.</p>
<p>That&#8217;s all folks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2010/12/possible-flaw-in-loic-tool-used-to-ddos-amazon/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>The perfect cPanel shared host Web server configuration</title>
		<link>http://blog.unixy.net/2010/11/the-perfect-cpanel-shared-host-web-server-configuration/</link>
		<comments>http://blog.unixy.net/2010/11/the-perfect-cpanel-shared-host-web-server-configuration/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 01:30:20 +0000</pubDate>
		<dc:creator>UNIXy</dc:creator>
				<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[cPanel]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[shared]]></category>
		<category><![CDATA[shared provider]]></category>
		<category><![CDATA[shared server]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=971</guid>
		<description><![CDATA[In this post, we are going to share a list of software and configurations ideal for a cPanel shared hosting server.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F11%2Fthe-perfect-cpanel-shared-host-web-server-configuration%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F11%2Fthe-perfect-cpanel-shared-host-web-server-configuration%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In this post, we are going to share a list of software and configurations ideal for a cPanel shared hosting server. Should you be interested in having a fully managed server with us, we&#8217;ll be very happy to set all these measures up for you and maintain them. This configuration is ideal to:</p>
<ul>
<li>Prevent server abuse</li>
<li>Maximize profitability</li>
<li>Provide memory, CPU, disk IO, and bandwidth fair share</li>
<li>Guarantee resources (SLA)</li>
<li>Maintain stability for all tenants</li>
<li>Provide all-aroud best performance</li>
<li>Improve security</li>
</ul>
<p>Without further delay, here is our growing master list:</p>
<ul>
<li><del>Nginx</del> <a title="Varnish" href="http://www.unixy.net/varnish">Varnish</a> accelerator
<ul>
<li>Increase max_connections</li>
<li>Increase thread_pools</li>
<li>Increase thread_pool_min</li>
<li>Cookie based caching</li>
</ul>
</li>
<li>cgroups and io-throttle
<ul>
<li>Put a memory limit per FCGI process per user</li>
<li>Put a CPU limit per FCGI process per user</li>
<li>Put disk IO limit per FCGI process per user</li>
<li>Limit disk IO for all Exim processes</li>
<li>Limit bandwidth IO for all Exim processes</li>
<li>Put each of Exim, MySQL, PHP, and HTTPD processes in their own group</li>
</ul>
</li>
<li>Fast-CGI
<ul>
<li>Limit number of PHP process per user</li>
<li>Enable and configure SuEXEC</li>
<li>Limit number of PHP processes</li>
<li>Set number of minimum PHP processes per user to zero</li>
<li>Configure FCGI safe mode</li>
</ul>
</li>
<li>Suhosin
<ul>
<li>Set maximum stack depth to prevent runaway processes</li>
<li>Disable eval execution to find out where eval is maliciously used</li>
<li>Run in simulation mode to see what Suhosin could break</li>
<li>Inject DB user prefix to DB queries</li>
<li>Add memory_limit measure</li>
</ul>
</li>
<li>Eaccelerator
<ul>
<li>Enable opcode caching (complements Nginx caching above)</li>
<li>Set the cache directory to /dev/shm/eacclerator</li>
</ul>
</li>
<li>MySQL
<ul>
<li>Limit SQL queries per user</li>
<li>Optional: put the MySQL data directory on SSD drives</li>
<li>Put MySQL tmpdir on /dev/shm (be cautious with this setting)</li>
</ul>
</li>
<li>PRM
<ul>
<li>Put a ceiling on max memory usage per process (Exception: MySQL)</li>
<li>Put maximum amount of processes for httpd and exim only</li>
</ul>
</li>
<li>CSF
<ul>
<li>Per-IP connection limit</li>
<li>Increase .htaccess failure detection and blocking</li>
<li>Enable port flooding protection</li>
<li>Enable RBL and other DNSBL filters</li>
</ul>
</li>
<li>DCC
<ul>
<li>Become a participating agent node</li>
</ul>
</li>
<li>ulimit
<ul>
<li>Put a hard limit on all resources</li>
</ul>
</li>
</ul>
<p>Stay tuned as we fine tune the list!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2010/11/the-perfect-cpanel-shared-host-web-server-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The penultimate guide to stopping a DDoS attack &#8211; A new approach</title>
		<link>http://blog.unixy.net/2010/08/the-penultimate-guide-to-stopping-a-ddos-attack-a-new-approach/</link>
		<comments>http://blog.unixy.net/2010/08/the-penultimate-guide-to-stopping-a-ddos-attack-a-new-approach/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 13:47:15 +0000</pubDate>
		<dc:creator>UNIXy</dc:creator>
				<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[DDoS]]></category>
		<category><![CDATA[DoS]]></category>
		<category><![CDATA[large attack]]></category>
		<category><![CDATA[large DDoS attack]]></category>
		<category><![CDATA[mitigate DDoS]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[reverse proxy]]></category>
		<category><![CDATA[stop DDoS attack]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=479</guid>
		<description><![CDATA[Update (2011-03-24): In this article. we&#8217;re discussing how we leveraged the smart Russian-built Web server Nginx to stop a DDoS attack. We&#8217;ve also experimented quite a bit with Varnish, another fine half-Danish half-Norwegian open source software, as a DDoS mitigation tool. It can be made to form the same constellation that we used for Nginx [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F08%2Fthe-penultimate-guide-to-stopping-a-ddos-attack-a-new-approach%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F08%2Fthe-penultimate-guide-to-stopping-a-ddos-attack-a-new-approach%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>Update (2011-03-24)</strong>: In this article. we&#8217;re discussing how we leveraged the smart Russian-built Web server Nginx to stop a DDoS attack. We&#8217;ve also experimented quite a bit with Varnish, another fine half-Danish half-Norwegian open source software, as a DDoS mitigation tool. It can be made to form the same constellation that we used for Nginx but can perform much better in the face of a large DDoS. So it&#8217;s worth pursuing should you be interested (read: desperate). Shameful plug: check out our cPanel Varnish plugin: <a title="Varnish cPanel" href="http://www.unixy.net/varnish">http://www.unixy.net/varnish</a></p>
<p>In this post we (<a title="Fully Managed Dedicated Servers and Clusters" href="http://www.unixy.net" target="_blank">UNIXY</a>) are going to share our experience fending off a large <a title="Wikipedia Distributed Denial of Service Attack" href="http://en.wikipedia.org/wiki/Denial-of-service_attack" target="_blank">Distributed Denial of Service</a> (DDoS) attack for a client. Generally, Website owners deal with DDoS attacks on their own. There are equipment and solutions vendors cater to these owners and guarantee protection against these kind of attacks up to a certain threshold. The cost of hiring these vendors can range from thousands to hundreds of thousand or millions of dollars depending on the severity of the attack.</p>
<p>Our goal was to build a solution with the least amount of funds possible. This solution is scalable and can handle the worst attacks. The client&#8217;s dedicated server is not a special server but a simple quad core Xeon <strong><a title="UNIXY Managed Dedicated Server" href="http://www.unixy.net/dedicated-servers" target="_blank">managed server</a><span style="font-weight: normal;"> running the LAMP stack</span></strong>. The DDoS riposte described in this article can scale to stop a 10Gbps attack or more. The good news is this solution does not require changing anything on the <a title="UNIXY Dedicated Servers" href="http://www.unixy.net/dedicated-servers" target="_blank"><strong>dedicated server</strong></a> itself. The server could be running just about any software stack. This configuration will work just fine with almost all cases effortlessly.</p>
<ul>
<li><strong>Distributed Denial of Service &#8211; The Social</strong></li>
</ul>
<p>Before we delve into the glorious technical details, there is an important aspect of DDoS attacks that one should know about; that is the social dynamics that lead to the attack. The more one understands about the the social aspect of a DDoS attack the easier it becomes to prevent or stop it. Because once a DDoS has started, priorities shift quite dramatically and rational for making wise decisions becomes flawed.</p>
<div id="attachment_533" class="wp-caption aligncenter" style="width: 330px"><a href="http://blog.unixy.net/wp-content/uploads/2010/08/JimmyDDoS.png"><img class="size-full wp-image-533" title="DDoS comic" src="http://blog.unixy.net/wp-content/uploads/2010/08/JimmyDDoS.png" alt="DDoS comic" width="320" height="274" /></a><p class="wp-caption-text">DDoS comic</p></div>
<p>DDoS attacks do not occur randomly. They are targeted and come with a motive. The motive could be revenge but most of the time the motive is financial. The individual or groups that conduct the DDoS attacks are most of the time hired to complete the job. They have the resources and know-how to orchestrate the attack while hoping to avoid getting caught by the authorities. They have no emotional attachment to the DDoS attack itself; they have no hard feelings towards the victim. They just get paid for what they do and nonchalantly, but meticulously, execute.</p>
<p>As explained, DDoS attacks are preceded by an email, post, or phone call, from the individual or group with interest, to the victim. It is always recommended to treat strangers you meet online or offline professionally and politely. The smallest altercation can lead to a negative reaction, which can escalate actions. In the face of anonymous threats against your business or organization, remain calm and composed.</p>
<div id="attachment_517" class="wp-caption aligncenter" style="width: 410px"><a href="http://blog.unixy.net/wp-content/uploads/2010/08/DDoS_Offer_forum.png"><img class="size-medium wp-image-517 " title="DDoS Offer in Forum" src="http://blog.unixy.net/wp-content/uploads/2010/08/DDoS_Offer_forum-300x78.png" alt="DDoS Offer in Forum" width="400" height="100" /></a><p class="wp-caption-text">DDoS Offer in Forum</p></div>
<p>There are public markets online (please don&#8217;t ask for links) where wannabe DDoS perpetrators get to hire the attackers. Pricing varies from $5/hr to $10 for a simple non-distributed DoS attack. A DDoS, however, tends to be more expensive depending on the sheer amount of data or packets that needs to be delivered at the target. It can range from $20/hr to $100/hr. The word used to in the circles in lieu of DDoS is to &#8220;drop;&#8221; meaning to drop a certain Web site or network off the Internet. It really means to either overwhelm the target with enough traffic that the equipment fails or to force upstream providers to &#8220;null route&#8221; the destination IP at the network level. The end result is that the IP gets dropped from the routing tables and the server to stop responding to all requests.</p>
<p>The fact that DDoS is not cheap has got to be comforting to an extent. It means that it is only a matter of time before the DDoS &#8220;client&#8221; runs out of cash. This in itself is encouraging. Keep that in mind should you begin to lose patience. Perseverance is omnipotent. Denial of service attacks are considered a crime and are punishable by Federal law in the US and by the police in the UK. As we will explain in the technical part of this article, DDoS attacks are almost impossible to trace to back to the individual or group that are orchestrating the attack. Because of the distributed nature, it requires cooperation from several network engineers that work for upstream providers.</p>
<p><strong>Distributed Denial of Service &#8211; The Technicals</strong></p>
<p>First things first, What is a DoS? what is the difference between a DoS and DDoS? A Denial of Service (DoS) is an attack originating from one source or one system that results in the service in question being unavailable to its legitimate users. It denies its very users access either because the service runs out of available resources or has been tricked to deny access to legitimate users. For example, a DoS attack on a Web server can cause it to run out of resources and stop responding to requests. A DDoS, on the other hand, is a more sophisticated attack since the attack originates from hundreds or thousands or nodes.</p>
<p>A DDoS attack is almost impossible to trace back to the source due to its distributed nature. DDoS orchestrators call the nodes and controller system a &#8220;bot.&#8221; With a few commands, the bot owner can instruct infected nodes from around the world to attack a target. The bot systems are hosted and controlled via <a title="Wikipedia: Internet Relay Chat" href="http://en.wikipedia.org/wiki/Internet_Relay_Chat" target="_blank">the Internet Relay Chat</a> (IRC) system or via a direct connection port connection. The nodes used to attack the target are made of compromised Windows and Linux nodes from around the world.</p>
<p>Before we present our solution, we need to discuss the two types of DDoS attacks that exist. On one hand you have attacks are bandwidth-based and seek to saturate the connectivity link. On the other hand, you have attacks that are packet-based and seek to saturate the processing capability of the equipment. In other words, they seek to overwhelm the processing power of the CPU and memory  or <em>fabric</em> of the routers or switches. All equipment has hard limits when it comes to their ability to handle a certain number of packets per second. Routers and switches are no exception.</p>
<div id="attachment_529" class="wp-caption aligncenter" style="width: 440px"><a href="http://blog.unixy.net/wp-content/uploads/2010/08/MbpsVspps2.png"><img class="size-full wp-image-529 " title="Capacity of networking equipment - Mbps vs pps" src="http://blog.unixy.net/wp-content/uploads/2010/08/MbpsVspps2.png" alt="Capacity of networking equipment - Mbps vs pps" width="430" height="184" /></a><p class="wp-caption-text">Capacity of networking equipment - Mbps vs pps</p></div>
<p>For example, take the above specification for a Cisco 6500 firewall. Each module is able to handle 5Gbps <em>or </em>2.8 million pps. This firewall sure looks like it can handle a 5Gbps attack. Great! However, should there be a packet-based DDoS attack, one would only need a 1.5Gbps payload to saturate it. That&#8217;s 2.8 million pps * 64 Bytes = 1.5Gbps. So bandwidth capacity means nothing by itself and small packets can cause havoc.</p>
<p>Our client was facing a 2Gbps DDoS attack that is packet based. It sought to force routing equipment along the way to start dropping legitimate packets. This caused the upstream to null route the IP to alleviate the burden on other customers that are behind the link. This is the typical reaction from all upstreams as they seek to protect their many other customers from feeling the pinch of the attack. We were given one last chance to &#8220;fix&#8221; things before the IP could be routed back in. Here is how we were able to fend off the attack and keep the server running.</p>
<p>We have deployed what we call a &#8220;constellation&#8221; of reverse proxy VM or <a title="UNIXY Fully Managed VPS" href="http://www.unixy.net/vps-hosting" target="_blank">VPS</a> nodes running the high performance Web server Nginx. The VM nodes were purchased from several providers given they are located at separate facilities. Essentially, we are off-loading and &#8220;splitting&#8221; both packet processing and bandwidth consumption across several data center facilities (physical routers &amp; carriers).</p>
<div id="attachment_540" class="wp-caption aligncenter" style="width: 314px"><a href="http://blog.unixy.net/wp-content/uploads/2010/08/nginx_constellation.png"><img class="size-full wp-image-540" title="Nginx constellation" src="http://blog.unixy.net/wp-content/uploads/2010/08/nginx_constellation.png" alt="Nginx constellation" width="304" height="463" /></a><p class="wp-caption-text">Nginx constellation</p></div>
<p>The configuration of the Nginx nodes is a typical reverse proxy configuration with the usual extra kernel security configuration. So for a 2Gbps attack and with 20 VM nodes, the bandwidth consumption per node is a maximum of 2GBps / 20 = 100Mbps. That&#8217;s a 100Mbps load per <a title="Managed VPS" href="http://www.unixy.net/vps-hosting" target="_blank">VM</a> node, which is reasonable enough and is below the threshold for getting one&#8217;s IP null routed by the provider. One could add more and more Nginx nodes to the constellation without issues.</p>
<p>So how is 20 VM nodes going to be affordable? VM prices have dropped dramatically over the last year. For the above configuration, a VM can cost between $5/mo and $10/mo. That&#8217;s an average of $8*20 = $160/Mo. Knowing that most DDoS attackers have the attention span of a gold fish, the $160 is all you need to send your attacker and his accomplice packing.</p>
<p style="text-align: center;"><a href="http://blog.unixy.net/wp-content/uploads/2010/08/ddos_cost.png"><img class="size-full wp-image-545 aligncenter" title="Total cost for averting a 2Gbps attack" src="http://blog.unixy.net/wp-content/uploads/2010/08/ddos_cost.png" alt="Total cost for averting a 2Gbps attack" width="240" height="196" /></a></p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: left;">Let&#8217;s talk more about the Nginx constellation configuration. The Nginx front-end nodes will run in proxy mode caching static files and requests. The more aggressive the DDoS the higher the time-to-live for cache objects should be. This prevents the Nginx nodes from proxy-passing requests to the quad core node. Although, if the main node has idle CPU and plenty of memory it wouldn&#8217;t hurt to put it to good use to alleviate the burden on the Nginx front nodes. Your domain&#8217;s A records is going to be the IP of the Nginx front nodes configured in round robin fashion. DNS round robin has its shortcomings in terms of not having control over how long (bad) records get cached by resolvers around the world. But in this case, it does not matter much. Just be sure to set high TTL for the records so your DNS server does not collapse under the enormous volume.</p>
<p style="text-align: left;">&nbsp;</p>
<div id="attachment_559" class="wp-caption aligncenter" style="width: 625px"><a href="http://blog.unixy.net/wp-content/uploads/2010/08/nginx_constellation3.png"><img class="size-full wp-image-559" title="Nginx DDoS Constellation" src="http://blog.unixy.net/wp-content/uploads/2010/08/nginx_constellation3.png" alt="Nginx DDoS Constellation" width="615" height="613" /></a><p class="wp-caption-text">Nginx DDoS Constellation</p></div>
<p>There are tons of online tutorials that go over the installation of Nginx as a reverse proxy so be sure to read up on it. But we will list some of the peculiar settings that are needed to handle a large scale DDoS. Of importance is the number of Nginx worker processes and worker connections. Those values will need to adjusted gradually and higher to handle different kind of attacks depending the VM resource allocation. But you should set them at least as high as the following:</p>
<blockquote><p>worker_processes 8;<br />
events {<br />
.<br />
.<br />
worker_connections 4096; # Be sure to set ulimit -n 4096 or more<br />
.<br />
.<br />
}</p></blockquote>
<p>Keep in mind that one still needs to gear up for the event by setting kernel and system variables on the Nginx nodes. Simple things like per-IP rate limiting, flooding rate limits, and syn cookies should be enabled without a question. Here are some measures you can implement:</p>
<blockquote><p>net.ipv4.tcp_syncookies = 1<br />
# source validation / reversed path<br />
net.ipv4.conf.all.rp_filter = 1<br />
net.ipv4.conf.default.rp_filter = 1<br />
kernel.pid_max = 65536<br />
net.ipv4.ip_local_port_range = 9000 65000</p></blockquote>
<p><strong>Recap</strong></p>
<p>In brief, here are the elements that constitute our solution:</p>
<ul>
<li><strong>Nginx reverse proxy constellation</strong></li>
<li><strong>DNS round robin records</strong></li>
<li><strong>Security at the Nginx front end level</strong></li>
<li><strong>Know the social and technical dynamics behind DDoS attacks</strong></li>
</ul>
<p>That&#8217;s all folks. We hope you enjoyed this article. Should you have any question or comment, don&#8217;t hesitate to get in touch! No question is minor and we are always looking for feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2010/08/the-penultimate-guide-to-stopping-a-ddos-attack-a-new-approach/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.106 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-01-25 14:43:41 -->

