<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	>
<channel>
	<title>Comments on: Off-topic: Has anyone solved the new MS SQL injection hack?</title>
	<atom:link href="http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/</link>
	<description>Gadgets, gear and computer hardware.</description>
	<pubDate>Fri, 09 Jan 2009 11:11:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: emenuasia</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-960119</link>
		<dc:creator>emenuasia</dc:creator>
		<pubDate>Wed, 17 Dec 2008 15:41:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-960119</guid>
		<description>Hello folks, I just went akross this awesome forum through google and I like the especialy this form. I really like the design and the team does its job verry good.
I´m Andrew and I´m pleased to be here :)

Greetings</description>
		<content:encoded><![CDATA[<p>Hello folks, I just went akross this awesome forum through google and I like the especialy this form. I really like the design and the team does its job verry good.<br />
I´m Andrew and I´m pleased to be here :)</p>
<p>Greetings</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: williambit</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-958642</link>
		<dc:creator>williambit</dc:creator>
		<pubDate>Sat, 13 Dec 2008 03:14:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-958642</guid>
		<description>Hi, just registered today, can someone give me some suggestions on which ebooks or guides are good for newbies like me?</description>
		<content:encoded><![CDATA[<p>Hi, just registered today, can someone give me some suggestions on which ebooks or guides are good for newbies like me?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jimbomel</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-944830</link>
		<dc:creator>jimbomel</dc:creator>
		<pubDate>Mon, 03 Nov 2008 01:45:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-944830</guid>
		<description>Hi people,

I recently registered to this forum www.crunchgear.com and hope that somebody can
give me an advice on the forex market - I am looking for an introduction
for noobs. I have already some knowledge about shares. (Hope this is the adequate category.)

Any help is so much appreciated. Most important question: can a noob make money on the forex market?

Thanks,
Jim</description>
		<content:encoded><![CDATA[<p>Hi people,</p>
<p>I recently registered to this forum <a href="http://www.crunchgear.com" rel="nofollow">http://www.crunchgear.com</a> and hope that somebody can<br />
give me an advice on the forex market - I am looking for an introduction<br />
for noobs. I have already some knowledge about shares. (Hope this is the adequate category.)</p>
<p>Any help is so much appreciated. Most important question: can a noob make money on the forex market?</p>
<p>Thanks,<br />
Jim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fred</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-934601</link>
		<dc:creator>Fred</dc:creator>
		<pubDate>Wed, 01 Oct 2008 02:19:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-934601</guid>
		<description>If you are using mySQL, try this site:
http://www.artfulsoftware.com/infotree/queries.php?bw=1276
Also
http://www.artfulsoftware.com/infotree/mysqlquerytree.php</description>
		<content:encoded><![CDATA[<p>If you are using mySQL, try this site:<br />
<a href="http://www.artfulsoftware.com/infotree/queries.php?bw=1276" rel="nofollow">http://www.artfulsoftware.com/infotree/queries.php?bw=1276</a><br />
Also<br />
<a href="http://www.artfulsoftware.com/infotree/mysqlquerytree.php" rel="nofollow">http://www.artfulsoftware.com/infotree/mysqlquerytree.php</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: werutzb</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-934596</link>
		<dc:creator>werutzb</dc:creator>
		<pubDate>Wed, 01 Oct 2008 01:52:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-934596</guid>
		<description>Hi!

I would like make better my SQL capabilities.
 I red that many SQL resources and still feel, that I am not a whise man
in SQL. What can you recommend?

Thanks,
Werutz</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>I would like make better my SQL capabilities.<br />
 I red that many SQL resources and still feel, that I am not a whise man<br />
in SQL. What can you recommend?</p>
<p>Thanks,<br />
Werutz</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dschibut</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-934345</link>
		<dc:creator>dschibut</dc:creator>
		<pubDate>Tue, 30 Sep 2008 02:57:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-934345</guid>
		<description>I began this discussion to discuss public available web proxies:

Which are really anonymous?

Which can unblock facebook, myspace etc, in other words: are fresh ?

Which can you recommend?

Thanks for your help,
Dschibut

P.S.: In my land, the freedom of speech is somehow limited, please give me a hint, if you have doubts about your recommendation.</description>
		<content:encoded><![CDATA[<p>I began this discussion to discuss public available web proxies:</p>
<p>Which are really anonymous?</p>
<p>Which can unblock facebook, myspace etc, in other words: are fresh ?</p>
<p>Which can you recommend?</p>
<p>Thanks for your help,<br />
Dschibut</p>
<p>P.S.: In my land, the freedom of speech is somehow limited, please give me a hint, if you have doubts about your recommendation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Rothfield</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-747613</link>
		<dc:creator>Jacob Rothfield</dc:creator>
		<pubDate>Wed, 25 Jun 2008 18:10:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-747613</guid>
		<description>I rewrote the malicious code to go through and restore the corrupted database.

http://8ways.net/sql-injection-attack-defence/</description>
		<content:encoded><![CDATA[<p>I rewrote the malicious code to go through and restore the corrupted database.</p>
<p><a href="http://8ways.net/sql-injection-attack-defence/" rel="nofollow">http://8ways.net/sql-injection-attack-defence/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-731891</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 11 Jun 2008 20:45:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-731891</guid>
		<description>Watching my logs I see a lot of cast + hex values coming in and are handled correctly.  Today, however, I am noticing a lot of forward slash+singlequote+forward slash then a valid url.  Many of these are combinged with the cast function from some IP.  Does anyone know the significance of the slash, quote, slash in the url they are requesting?   Thanks</description>
		<content:encoded><![CDATA[<p>Watching my logs I see a lot of cast + hex values coming in and are handled correctly.  Today, however, I am noticing a lot of forward slash+singlequote+forward slash then a valid url.  Many of these are combinged with the cast function from some IP.  Does anyone know the significance of the slash, quote, slash in the url they are requesting?   Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fred</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-723934</link>
		<dc:creator>Fred</dc:creator>
		<pubDate>Thu, 05 Jun 2008 14:38:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-723934</guid>
		<description>It turns out I was silly and put those "%20"'s in my code without fully testing if that type of attack was possible.  After further tests, the encoded strings do not get executed by mySQL using ASP ODBC drivers so in my case my code will work just fine.  I welcome you to attempt and prove me otherwise, my site is live and waiting for you.</description>
		<content:encoded><![CDATA[<p>It turns out I was silly and put those &#8220;%20&#8243;&#8217;s in my code without fully testing if that type of attack was possible.  After further tests, the encoded strings do not get executed by mySQL using ASP ODBC drivers so in my case my code will work just fine.  I welcome you to attempt and prove me otherwise, my site is live and waiting for you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fred</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-723841</link>
		<dc:creator>Fred</dc:creator>
		<pubDate>Thu, 05 Jun 2008 13:03:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-723841</guid>
		<description>Tomas,
The problem is these latest SQL injection attacks are not using any single quotes, it used an encoded string with Cast.  So then the best method might be to attempt to decode, check for single quotes and also check for cast.
The actual attack looked like this:

DECLARE%20@S%20NVARCHAR(4000);SET%20@S=CAST(0x440045004300...7200%20AS%20NVARCHAR(4000));

I have snipped the actual attack, however there are no single quotes.</description>
		<content:encoded><![CDATA[<p>Tomas,<br />
The problem is these latest SQL injection attacks are not using any single quotes, it used an encoded string with Cast.  So then the best method might be to attempt to decode, check for single quotes and also check for cast.<br />
The actual attack looked like this:</p>
<p>DECLARE%20@S%20NVARCHAR(4000);SET%20@S=CAST(0&#215;440045004300&#8230;7200%20AS%20NVARCHAR(4000));</p>
<p>I have snipped the actual attack, however there are no single quotes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tomas</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-723494</link>
		<dc:creator>Tomas</dc:creator>
		<pubDate>Thu, 05 Jun 2008 07:56:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-723494</guid>
		<description>Doing instr and stuff is *not* suffient. "exec(" may be encoded as "Exec%28", or "%45xec(" (or some 100 other combinations).

Checking user input for the single qoute (if your SQL statement is using single qoute) is the most efficient if you don't want to do it by Parameters.AddWithValue(..). This code should look something like (replace ' with '')

SQL = "select * from table where name='" + replace(i_UserInput, "'", "''") + "'"

Preferrably, use URLDecode on i_UserInput before passing it to the SQL.

Or, do a reversed check - remove all characters not matching (eg, allow only "a-z, 0-9")

/Tomas</description>
		<content:encoded><![CDATA[<p>Doing instr and stuff is *not* suffient. &#8220;exec(&#8221; may be encoded as &#8220;Exec%28&#8243;, or &#8220;%45xec(&#8221; (or some 100 other combinations).</p>
<p>Checking user input for the single qoute (if your SQL statement is using single qoute) is the most efficient if you don&#8217;t want to do it by Parameters.AddWithValue(..). This code should look something like (replace &#8216; with &#8221;)</p>
<p>SQL = &#8220;select * from table where name=&#8217;&#8221; + replace(i_UserInput, &#8220;&#8216;&#8221;, &#8220;&#8221;&#8221;) + &#8220;&#8216;&#8221;</p>
<p>Preferrably, use URLDecode on i_UserInput before passing it to the SQL.</p>
<p>Or, do a reversed check - remove all characters not matching (eg, allow only &#8220;a-z, 0-9&#8243;)</p>
<p>/Tomas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Biggs</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-723465</link>
		<dc:creator>John Biggs</dc:creator>
		<pubDate>Thu, 05 Jun 2008 07:34:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-723465</guid>
		<description>Sorry, yes MSSQL 2K. Why? Because the folks I'm helping are using it. I'm moving them to LAMP soon.</description>
		<content:encoded><![CDATA[<p>Sorry, yes MSSQL 2K. Why? Because the folks I&#8217;m helping are using it. I&#8217;m moving them to LAMP soon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fred</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-723306</link>
		<dc:creator>Fred</dc:creator>
		<pubDate>Thu, 05 Jun 2008 04:35:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-723306</guid>
		<description>Make sure you are escaping your database input.
Also do not allow "CAST(" to be used.

Here's a snipplet of what I use with ASP.
Make some type of function from it and check all user submitted inputs.

  'SQL Injection specific
  tmpStr = lcase(INPUT_FROM_USER)
  If instr(1, tmpStr, "nvarchar") &#62; 0 Then bEject = True
  If instr(1, tmpStr, "varchar") &#62; 0 Then bEject = True
  If instr(1, tmpStr, "cast(") &#62; 0 Then bEject = True
  If instr(1, tmpStr, "cast (") &#62; 0 Then bEject = True
  If instr(1, tmpStr, "cast%20(") &#62; 0 Then bEject = True
  If instr(1, tmpStr, "(0x") &#62; 0 Then bEject = True
  If instr(1, tmpStr, "drop table") &#62; 0 Then bEject = True
  If instr(1, tmpStr, "exec(") &#62; 0 Then bEject = True
  If instr(1, tmpStr, "exec (") &#62; 0 Then bEject = True
  If instr(1, tmpStr, "exec%20(") &#62; 0 Then bEject = True
  If instr(1, tmpStr, ";--") &#62; 0 Then bEject = True
  If bEject = True Then ShowErrorMessage "SQL Server refused to accept your input."</description>
		<content:encoded><![CDATA[<p>Make sure you are escaping your database input.<br />
Also do not allow &#8220;CAST(&#8221; to be used.</p>
<p>Here&#8217;s a snipplet of what I use with ASP.<br />
Make some type of function from it and check all user submitted inputs.</p>
<p>  &#8216;SQL Injection specific<br />
  tmpStr = lcase(INPUT_FROM_USER)<br />
  If instr(1, tmpStr, &#8220;nvarchar&#8221;) &gt; 0 Then bEject = True<br />
  If instr(1, tmpStr, &#8220;varchar&#8221;) &gt; 0 Then bEject = True<br />
  If instr(1, tmpStr, &#8220;cast(&#8221;) &gt; 0 Then bEject = True<br />
  If instr(1, tmpStr, &#8220;cast (&#8221;) &gt; 0 Then bEject = True<br />
  If instr(1, tmpStr, &#8220;cast%20(&#8221;) &gt; 0 Then bEject = True<br />
  If instr(1, tmpStr, &#8220;(0x&#8221;) &gt; 0 Then bEject = True<br />
  If instr(1, tmpStr, &#8220;drop table&#8221;) &gt; 0 Then bEject = True<br />
  If instr(1, tmpStr, &#8220;exec(&#8221;) &gt; 0 Then bEject = True<br />
  If instr(1, tmpStr, &#8220;exec (&#8221;) &gt; 0 Then bEject = True<br />
  If instr(1, tmpStr, &#8220;exec%20(&#8221;) &gt; 0 Then bEject = True<br />
  If instr(1, tmpStr, &#8220;;&#8211;&#8221;) &gt; 0 Then bEject = True<br />
  If bEject = True Then ShowErrorMessage &#8220;SQL Server refused to accept your input.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yonah</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-723170</link>
		<dc:creator>Yonah</dc:creator>
		<pubDate>Thu, 05 Jun 2008 01:57:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-723170</guid>
		<description>A few more steps beyond the "Best" solution -

1. Type your parameters - i.e most SQL injection attacks happen because the code written on the server side isn't validating input. In other words, if you have a number, but are passing it into SQL as a string, someone could put injection code in there; However, if you type your parameter as an int, if someone tries sticking text in there it will not get passed to SQL.

2. All of these solutions are well and good - so long as you are the programmer- if you use open source, however, you are at the mercy of the people that coded it. If this is the case two suggestions:

1. Many Open Source programs let you specify prefixes for your tables - go ahead and specify something unique as a prefix. while this might not prevent injection attacks, it will serve to lessen the impact (i.e. if the attack is looking for a table called users and your table is cg_users, the SQL won't work)

2. Another option, if you know which tables potentially can be  injected with malicious code, you can run a nightly process to scan their data and flag suspect records.

HTH</description>
		<content:encoded><![CDATA[<p>A few more steps beyond the &#8220;Best&#8221; solution -</p>
<p>1. Type your parameters - i.e most SQL injection attacks happen because the code written on the server side isn&#8217;t validating input. In other words, if you have a number, but are passing it into SQL as a string, someone could put injection code in there; However, if you type your parameter as an int, if someone tries sticking text in there it will not get passed to SQL.</p>
<p>2. All of these solutions are well and good - so long as you are the programmer- if you use open source, however, you are at the mercy of the people that coded it. If this is the case two suggestions:</p>
<p>1. Many Open Source programs let you specify prefixes for your tables - go ahead and specify something unique as a prefix. while this might not prevent injection attacks, it will serve to lessen the impact (i.e. if the attack is looking for a table called users and your table is cg_users, the SQL won&#8217;t work)</p>
<p>2. Another option, if you know which tables potentially can be  injected with malicious code, you can run a nightly process to scan their data and flag suspect records.</p>
<p>HTH</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-723063</link>
		<dc:creator>Bryan</dc:creator>
		<pubDate>Wed, 04 Jun 2008 23:31:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-723063</guid>
		<description>John,

Just saying "use stored procedures" isn't the answer.  The problem occurs when you concatenate _any_ user-entered data into a string that you send off to the database server.  This can happen when you use stored procedures just as easily as when you use direct queries.  You can do something like 

// BAD
cmd.CommandText = "exec MyProcedure '" + UserName.Value + "'";

and still have a problem.  The solution is to never concatenate together a string and send it along.  So, if you are not sending along arguments, using a text command type is safe from SQL injection.  

// GOOD
cmd.CommandText = "SELECT * FROM MyTable";

If you are sending along arguments, though, it is recommended to use the stored procedure command type and pass arguments along using the parameters options.  So, instead of the first example above, do something like this:

// BEST
cmd.CommandText = "MyProcedure";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", UserName.Value);

The examples are in C#, but the general idea is the same in all .NET languages. ;-)  The parameters are automatically scrubbed and cannot be used to inject unwanted SQL into the command.

Hope this helps.  Good luck!</description>
		<content:encoded><![CDATA[<p>John,</p>
<p>Just saying &#8220;use stored procedures&#8221; isn&#8217;t the answer.  The problem occurs when you concatenate _any_ user-entered data into a string that you send off to the database server.  This can happen when you use stored procedures just as easily as when you use direct queries.  You can do something like </p>
<p>// BAD<br />
cmd.CommandText = &#8220;exec MyProcedure &#8216;&#8221; + UserName.Value + &#8220;&#8216;&#8221;;</p>
<p>and still have a problem.  The solution is to never concatenate together a string and send it along.  So, if you are not sending along arguments, using a text command type is safe from SQL injection.  </p>
<p>// GOOD<br />
cmd.CommandText = &#8220;SELECT * FROM MyTable&#8221;;</p>
<p>If you are sending along arguments, though, it is recommended to use the stored procedure command type and pass arguments along using the parameters options.  So, instead of the first example above, do something like this:</p>
<p>// BEST<br />
cmd.CommandText = &#8220;MyProcedure&#8221;;<br />
cmd.CommandType = CommandType.StoredProcedure;<br />
cmd.Parameters.AddWithValue(&#8221;@UserName&#8221;, UserName.Value);</p>
<p>The examples are in C#, but the general idea is the same in all .NET languages. ;-)  The parameters are automatically scrubbed and cannot be used to inject unwanted SQL into the command.</p>
<p>Hope this helps.  Good luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Lynch</title>
		<link>http://www.crunchgear.com/2008/06/04/off-topic-has-anyone-solved-the-new-ms-sql-injection-hack/#comment-722939</link>
		<dc:creator>Jeff Lynch</dc:creator>
		<pubDate>Wed, 04 Jun 2008 20:40:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.crunchgear.com/?p=27532#comment-722939</guid>
		<description>First off there is no SQL Server 2003. Its either SQL 2000 or SQL 2005.

Second - change your web app to call a SQL stored procedure rather than dynamically creating a query. Simple, effective and clean. 

Third - why are you still running Windows 2000? If you must run your web app on Windows at least upgrade to Windows Server 2003 SP2 and make sure its patched.</description>
		<content:encoded><![CDATA[<p>First off there is no SQL Server 2003. Its either SQL 2000 or SQL 2005.</p>
<p>Second - change your web app to call a SQL stored procedure rather than dynamically creating a query. Simple, effective and clean. </p>
<p>Third - why are you still running Windows 2000? If you must run your web app on Windows at least upgrade to Windows Server 2003 SP2 and make sure its patched.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.123 seconds -->
