<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Neil Carpenter's Blog</title><link>http://blogs.technet.com/neilcar/default.aspx</link><description>Forefront products, WSUS, Security Incident Response, and whatever else comes up.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>SQL Injection Hijinks</title><link>http://blogs.technet.com/neilcar/archive/2008/10/31/sql-injection-hijinks.aspx</link><pubDate>Fri, 31 Oct 2008 23:07:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3145432</guid><dc:creator>neilcar</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3145432.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3145432</wfw:commentRss><description>&lt;P&gt;&lt;I&gt;or Why I Keep Harping On Blacklisting&lt;/I&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Summary:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;An incident reveals attempts to get around blacklisting by manipulating behavior in ASP, illustrating the weakness of blacklist approaches.&lt;/P&gt;
&lt;P&gt;A new version of &lt;A href="http://blogs.iis.net/wadeh/archive/2008/10/31/urlscan-3-1.aspx" mce_href="http://blogs.iis.net/wadeh/archive/2008/10/31/urlscan-3-1.aspx"&gt;UrlScan is shipping today&lt;/A&gt; with a change specifically to address this.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Discussion:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;I was working with a colleague on an incident last week that looked like a garden-variety SQL injection drive-by except for something interesting.&lt;/P&gt;
&lt;P&gt;While looking through the IIS logs from the affected server, I saw this:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;abc=120364DEC%LARE%20@S%20VAR%CHAR(4000)%3BS%ET%20@S%...&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As I looked at this, "DEC%LARE", "VAR%CHAR", and "BS%ET" immediately stood out to me.&amp;nbsp; Obviously, the percent sign is usually used to escape something in a URL (like the %20's in there, which are spaces); however, this naked percent sign thrown in there didn't seem to have any purpose and should have caused SQL to not execute the code in question.&lt;/P&gt;
&lt;P&gt;When I see somebody do something like this, it's usually for a purpose so I took another look at it.&amp;nbsp; I realized that, if ASP silently stripped that percent sign out of there, then this would be an efficient way to bypass a lot of blacklist-based filters.&lt;/P&gt;
&lt;P&gt;I wrote a quick test ASP page(1) and found that my guess was right on -- ASP drops a percent sign from the query string if it isn't followed by two valid hex characters(0-9, A-F) when it actually interprets it via Request.QueryString.&amp;nbsp; This means that any filter that inspects raw headers using Request.ServerVariables is going to miss "DEC%LARE" if it is looking for "DECLARE" but, on the other hand, the ASP app that actually consumes that string using Request.QueryString("abc") is going to get it without the percent sign.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Conclusion:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;As this incident illustrates, a blacklist approach to SQL injection only works for as long as nobody finds a way around your blacklist.&amp;nbsp; As soon as somebody finds a way around it (and experience suggests that attackers are motivated to do so), the value of your blacklist is zero.&lt;/P&gt;
&lt;P&gt;The right approach is to fix the actual vulnerability in the code using parameterized queries.&amp;nbsp; See the articles below for more information and examples.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A title=http://msdn.microsoft.com/en-us/library/cc676512.aspx href="http://msdn.microsoft.com/en-us/library/cc676512.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc676512.aspx"&gt;http://msdn.microsoft.com/en-us/library/cc676512.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A title="SQL Injection Mitigation- Using Parameterized Queries" href="http://blogs.technet.com/neilcar/archive/2008/05/21/sql-injection-mitigation-using-parameterized-queries.aspx" mce_href="http://blogs.technet.com/neilcar/archive/2008/05/21/sql-injection-mitigation-using-parameterized-queries.aspx"&gt;SQL Injection Mitigation- Using Parameterized Queries&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A title="SQL Injection Mitigation- Using Parameterized Queries part 2 (types and recordsets)" href="http://blogs.technet.com/neilcar/archive/2008/05/23/sql-injection-mitigation-using-parameterized-queries-part-2-types-and-recordsets.aspx" mce_href="http://blogs.technet.com/neilcar/archive/2008/05/23/sql-injection-mitigation-using-parameterized-queries-part-2-types-and-recordsets.aspx"&gt;SQL Injection Mitigation- Using Parameterized Queries part 2 (types and recordsets)&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The IIS team is releasing an update to UrlScan today that includes changes to address this in their filtering product.&amp;nbsp; Of course, as I've said over and and over, no filter-based approach is going to be perfect, but UrlScan is still an excellent defense-in-depth tool and a way to mitigate SQL injection vulns in the short term while your developers fix them.&lt;/P&gt;
&lt;P&gt;For more information on the UrlScan update, Wade Hilmo has all the details:&amp;nbsp; &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://blogs.iis.net/wadeh/archive/2008/10/31/urlscan-3-1.aspx" mce_href="http://blogs.iis.net/wadeh/archive/2008/10/31/urlscan-3-1.aspx"&gt;http://blogs.iis.net/wadeh/archive/2008/10/31/urlscan-3-1.aspx&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(1)&lt;/P&gt;
&lt;P&gt;&amp;lt;HTML&amp;gt; &lt;BR&gt;QUERY_STRING = &amp;lt;%= Request.ServerVariables("QUERY_STRING") %&amp;gt; &amp;lt;BR&amp;gt;&amp;nbsp; &lt;BR&gt;test =&amp;lt;%= Request.QueryString("test") %&amp;gt; &amp;lt;BR&amp;gt; &lt;BR&gt;&amp;lt;/HTML&amp;gt;&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3145432" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.technet.com/neilcar/archive/tags/Incident+Response/default.aspx">Incident Response</category><category domain="http://blogs.technet.com/neilcar/archive/tags/SQL/default.aspx">SQL</category><category domain="http://blogs.technet.com/neilcar/archive/tags/ASP/default.aspx">ASP</category><category domain="http://blogs.technet.com/neilcar/archive/tags/Tool/default.aspx">Tool</category></item><item><title>PASSGEN</title><link>http://blogs.technet.com/neilcar/archive/2008/10/22/passgen.aspx</link><pubDate>Wed, 22 Oct 2008 21:52:02 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3140463</guid><dc:creator>neilcar</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3140463.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3140463</wfw:commentRss><description>&lt;p&gt;Occasionally, I see a security incident where one of the things that went wrong was that all of the customer's machines have the same password for the built-in administrator's account.&amp;#160; Whenever this happens, I suggest the PASSGEN tool that was included with the book &lt;a href="http://www.amazon.com/dp/0321336437"&gt;&amp;quot;Protect Your Windows Network&amp;quot;&lt;/a&gt; by &lt;a href="http://blogs.technet.com/steriley"&gt;Steve Riley&lt;/a&gt; and &lt;a href="http://msinfluentials.com/blogs/jesper/"&gt;Jesper Johansson&lt;/a&gt;.&amp;#160; Obviously, most people don't want to run to the bookstore in the middle of a security incident but, fortunately, it was available on their website.&lt;/p&gt;  &lt;p&gt;Unfortunately, the website disappeared recently and I had to scramble around to find it.&amp;#160; If you're looking for PASSGEN (and you should be if you have the same password for local admin across a number of machines), you can find it in two places:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;a href="http://blogs.technet.com/steriley/archive/2008/09/29/passgen-tool-from-my-book.aspx"&gt;The Windows Server 2008 Resource Kit&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.technet.com/steriley/archive/2008/09/29/passgen-tool-from-my-book.aspx"&gt;Steve's blog&lt;/a&gt;&lt;/li&gt; &lt;/ol&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3140463" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.technet.com/neilcar/archive/tags/Tool/default.aspx">Tool</category></item><item><title>Err</title><link>http://blogs.technet.com/neilcar/archive/2008/08/12/err.aspx</link><pubDate>Wed, 13 Aug 2008 05:10:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3104496</guid><dc:creator>neilcar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3104496.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3104496</wfw:commentRss><description>&lt;p&gt;I might be the last person to know this but one of my favorite internal Microsoft tools is now external.&amp;nbsp; Err.exe is a command-line tool that looks up error codes and spits out possible matches from various header files.&amp;nbsp; This is invaluable when you're reading through a log and run across something like "Failed, err 0x80070003" -- just run err and you'll find out what this possibly means:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;C:\Users\Neilcar\Downloads\Err&amp;gt;err 0x80070003&lt;br&gt;# for hex 0x80070003 / decimal -2147024893 :&lt;br&gt;&amp;nbsp; COR_E_DIRECTORYNOTFOUND&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; corerror.h&lt;br&gt;# MessageText:&lt;br&gt;# The specified path couldn't be found.&lt;br&gt;# 1 matches found for "0x80070003" &lt;br&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;The download for err is available at &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=be596899-7bb8-4208-b7fc-09e02a13696c&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=be596899-7bb8-4208-b7fc-09e02a13696c&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=be596899-7bb8-4208-b7fc-09e02a13696c&amp;amp;displaylang=en&lt;/a&gt;.&amp;nbsp; Download it and extract it to somewhere in %PATH% so that it's only a command prompt away. &lt;br&gt;&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3104496" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Tool/default.aspx">Tool</category></item><item><title>Input Validation Is Not The Answer</title><link>http://blogs.technet.com/neilcar/archive/2008/08/07/input-validation-is-not-the-answer.aspx</link><pubDate>Thu, 07 Aug 2008 21:11:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3102263</guid><dc:creator>neilcar</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3102263.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3102263</wfw:commentRss><description>&lt;p&gt;I just sent a piece of e-mail to my team about input validation and SQL injection and it occurred to me that I've been meaning to get into this here, too:&lt;/p&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;&lt;b&gt;If you're trying to solve a SQL injection problem, input validation is NOT the answer!&lt;/b&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;p&gt;There, I've said it. &amp;nbsp; I keep seeing blog posts, forum posts, e-mail, etc, that say "Oh, you got hax0red by SQL injection, you should have been doing input validation".&amp;nbsp; I'm sorry, but y'all are wrong, wrong, wrong, wrong.&amp;nbsp; Let me copy-and-paste my e-mail to explain why:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Your customer is failing to stop SQL injection because they don’t understand the problem (or, by extension, the solution).&lt;br&gt;&lt;br&gt;It sounds like the customer is trying to do input validation.&amp;nbsp; What input validation does is to check input coming from an untrusted user to make sure that it doesn’t contain any blacklisted characters/phrases.&amp;nbsp; Depending on the implementation, it either replaces items on the blacklist with something innocuous or it blocks the input entirely.&lt;br&gt;&lt;br&gt;This is the wrong way to stop SQL injection, period.&amp;nbsp; Input validation is sometimes useful as part of a defense-in-depth strategy but that’s it.&amp;nbsp; There are several major problems with input validation:&lt;br&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;It only works for as long as you’re smarter than your attackers because you have to anticipate every potential attack. &lt;/li&gt;&lt;li&gt;It doesn’t solve your real problem, which is that SQL can potentially execute something in input you get from your untrusted user. &lt;/li&gt;&lt;li&gt;You can end up with a lot of false positives if you’re not careful — if you’re blocking “exec”, what happens when one of your users has the title “Executive Assistant”?&lt;br&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;To use an analogy, using input validation to stop SQL injection is like using anti-virus software to stop malware.&amp;nbsp; It might work, it might not, but you’d be far better off if you actually resolved the vulnerability instead of just trying to mitigate it.&lt;br&gt;&lt;br&gt;How, then, should the customer fix their vulnerabilities?&amp;nbsp; Parameterizing queries is the single best step.&amp;nbsp; Instead of simply mitigating the vulnerability, this actually resolves it.&amp;nbsp; At a high level, I think of parameterized queries as DEP for SQL — it separates the executable code from the data and prevents anything in the data from executing.&lt;br&gt;&lt;br&gt;Bala Neeumalla wrote a great MSDN article on how to code in ASP to prevent SQL injection (&lt;a href="http://msdn.microsoft.com/en-us/library/cc676512.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc676512.aspx"&gt;http://msdn.microsoft.com/en-us/library/cc676512.aspx&lt;/a&gt;) that covers this in detail.&amp;nbsp; His article should be considered definitive.&amp;nbsp; I wrote a few blog entries (&lt;a href="http://blogs.technet.com/neilcar/archive/2008/05/21/sql-injection-mitigation-using-parameterized-queries.aspx" mce_href="http://blogs.technet.com/neilcar/archive/2008/05/21/sql-injection-mitigation-using-parameterized-queries.aspx"&gt;http://blogs.technet.com/neilcar/archive/2008/05/21/sql-injection-mitigation-using-parameterized-queries.aspx&lt;/a&gt;, &lt;a href="http://blogs.technet.com/neilcar/archive/2008/05/23/sql-injection-mitigation-using-parameterized-queries-part-2-types-and-recordsets.aspx" mce_href="http://blogs.technet.com/neilcar/archive/2008/05/23/sql-injection-mitigation-using-parameterized-queries-part-2-types-and-recordsets.aspx"&gt;http://blogs.technet.com/neilcar/archive/2008/05/23/sql-injection-mitigation-using-parameterized-queries-part-2-types-and-recordsets.aspx&lt;/a&gt;) that have additional examples that might be helpful to the customer.&lt;br&gt;&lt;br&gt;Michael Howard also wrote a great blog entry regarding SQL injection and the SDL (&lt;a href="http://blogs.msdn.com/sdl/archive/2008/05/15/giving-sql-injection-the-respect-it-deserves.aspx" mce_href="http://blogs.msdn.com/sdl/archive/2008/05/15/giving-sql-injection-the-respect-it-deserves.aspx"&gt;http://blogs.msdn.com/sdl/archive/2008/05/15/giving-sql-injection-the-respect-it-deserves.aspx&lt;/a&gt;).&amp;nbsp; Besides using parameterized queries, there are two additional steps that can be taken to further protect an application:&lt;br&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Use properly designed stored procedures &lt;/li&gt;&lt;li&gt;Use SQL Execute-only permission so that the application can only execute the stored procedures and cannot execute other statements.&lt;/li&gt;&lt;/ul&gt;&lt;/blockquote&gt;&lt;p&gt;This doesn't mean that input validation isn't useful and it doesn't mean it isn't appropriate mitigation in some cases.&amp;nbsp; It's still not the way to prevent SQL injection.&lt;/p&gt;&lt;p&gt;And I'm not just talking about&amp;nbsp; ASP, either.&amp;nbsp; The same thing holds true for ASP.Net, the same thing holds true for Cold Fusion (look up &lt;a href="http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-b20.htm" mce_href="http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-b20.htm"&gt;CFQueryParam&lt;/a&gt;), &lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/sql/PreparedStatement.html" mce_href="http://java.sun.com/j2se/1.4.2/docs/api/java/sql/PreparedStatement.html"&gt;Java&lt;/a&gt;, etc, etc.&amp;nbsp; Wherever you query, there shall ye parameterize.&lt;br&gt;&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3102263" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.technet.com/neilcar/archive/tags/SQL/default.aspx">SQL</category></item><item><title>Forefront Server Security Management Console, Templates, and Revisions</title><link>http://blogs.technet.com/neilcar/archive/2008/07/11/forefront-server-security-management-console-templates-and-revisions.aspx</link><pubDate>Fri, 11 Jul 2008 23:57:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3087531</guid><dc:creator>neilcar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3087531.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3087531</wfw:commentRss><description>&lt;P&gt;Sometimes, working in support, you come across a best practice or a bit of knowledge that is well-known to some people...but that bit of knowledge has never actually been documented.&amp;nbsp; Today was one of those days.&lt;/P&gt;
&lt;P&gt;While working in an environment with multiple Exchange Server 2003 servers running Antigen 9.1 Hotfix Rollup 3, we had to reinstall Antigen on one of the servers.&amp;nbsp; We installed Antigen 9.1 and tested to make sure that mail was flowing after the install (it was).&amp;nbsp; We then configured Antigen, including re-installing the FSSMC agent, redeploying the template for this server, and disabling Antigen performance counters.&lt;/P&gt;
&lt;P&gt;At that point, things went off the rails.&amp;nbsp; When we opened the Antigen admin console, it told us "You have 4 days left on your evaluation".&amp;nbsp; Confused, we tried various things, including rebooting the box; however, every time, the console mocked us with it's eval message.&lt;/P&gt;
&lt;P&gt;Since we were working in a maintenance window and we had run out of time, we made a decision to disable Antigen temporarily and investigate further.&amp;nbsp; We took the template to a non-production Antigen 9.1 server and applied it.&amp;nbsp; After applying it, we opened the admin console and we were greeted with "You have 4 days left on your evaluation".&lt;/P&gt;
&lt;P&gt;At this point, we knew we were onto something.&amp;nbsp; After working with our sustained engineering team to investigate further, we found out the root cause was something that is an FSSMC best practice even though I don't know that it's been written down before:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;You should never apply a template created with a later version of Antigen or Forefront Server to an earlier version.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In this case, the template had been created in Antigen 9.1 Hotfix Rollup 3.&amp;nbsp; As long as we applied it to servers running rollup 3 (or later), everything was A-OK; however, when we applied it to an Antigen 9.1 with no hotfix rollup on it, we ran into trouble.&lt;/P&gt;
&lt;P&gt;The trouble, in this case, is that the schema for scanjobs was changed to add some additional options into the scanjobs.&amp;nbsp; The template includes this new information but, once it's applied, the older code doesn't know how to handle it.&amp;nbsp; This resulted in memory corruption which caused the false eval notice.&lt;/P&gt;
&lt;P&gt;The takeaway here is that, if you're running a mixture of patch levels for your Antigen or Forefront Server servers, you have to be sure that the templates you are deploying with FSSMC were created in the earliest patch level you have in production.&amp;nbsp; This will mean that you can't take advantage of any settings that are added in later patch levels but it also means that you won't run into issues like the one we wrestled with today.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Alternately, you could create templates for each patch level but I think that would end up being more difficult to manage.&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3087531" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Forefront/default.aspx">Forefront</category><category domain="http://blogs.technet.com/neilcar/archive/tags/Antigen/default.aspx">Antigen</category><category domain="http://blogs.technet.com/neilcar/archive/tags/FSSMC/default.aspx">FSSMC</category></item><item><title>Does This Make Me A Fanboy?</title><link>http://blogs.technet.com/neilcar/archive/2008/07/10/does-this-make-me-a-fanboy.aspx</link><pubDate>Fri, 11 Jul 2008 06:21:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3087133</guid><dc:creator>neilcar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3087133.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3087133</wfw:commentRss><description>&lt;p&gt;I upgraded my iPhone to the 2.0 firmware today and I've been playing with the app store all day.&amp;nbsp; It's pretty neat stuff.&lt;/p&gt;&lt;p&gt;Since I'm on a conference call tonight but I'm only here in an advisory/observational way, I put my phone on mute and kept playing with the app store.&amp;nbsp; I downloaded the &lt;a href="http://blogs.technet.com/neilcar/archive/2008/07/10/does-this-make-me-a-fanboy.aspx" mce_href="http://blogs.technet.com/neilcar/archive/2008/07/10/does-this-make-me-a-fanboy.aspx"&gt;PhoneSaber&lt;/a&gt; application, which lets you pretend your phone is a light saber from Star Wars.&amp;nbsp; As you move the phone around, it makes light saber sounds.&lt;/p&gt;&lt;p&gt;So, I amused myself with my virtual light saber for a few moments before somebody said "What is all that noise?&amp;nbsp; I think we have a bad connection!"&lt;/p&gt;&lt;p&gt;I stopped what I was doing and thought for a long, hard moment before sending her an instant message:&amp;nbsp; "Ummm, did it sound like a light saber?"&lt;/p&gt;&lt;p&gt;"Yes." &lt;br&gt;&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3087133" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/humor/default.aspx">humor</category><category domain="http://blogs.technet.com/neilcar/archive/tags/iphone/default.aspx">iphone</category></item><item><title>Antigen 9.1 Hotfix Rollup 3 and Performance Monitor</title><link>http://blogs.technet.com/neilcar/archive/2008/07/09/antigen-9-1-hotfix-rollup-3-and-performance-monitor.aspx</link><pubDate>Wed, 09 Jul 2008 22:56:30 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3086321</guid><dc:creator>neilcar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3086321.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3086321</wfw:commentRss><description>&lt;p&gt;While investigating an issue where mail was queuing in the Exchange Information Store, we discovered an issue that affects customers running Antigen 9.1 Hotfix Rollup 3 when there are performance monitoring tools such as Perfmon, Perfwiz, and the MOM client running.&amp;#160; This issue will manifest itself as mail queuing (and never un-queueing), particularly immediately after the store is restarted.&amp;#160; In this particular instance, we were seeing this happen when we failed from one cluster node to another.&amp;#160; This could also occur in non-cluster environments and it could occur if scanjobs are restarted for other reasons (such as scan timeouts).&lt;/p&gt;  &lt;p&gt;Additionally, you may see entries in ProgamLog.txt similar to the following:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;quot;ERROR: scanjobs.cpp::ConfigScanJobFile(): AddNewScanJob() Failed 0x80030021&amp;quot;      &lt;br /&gt;&amp;quot;ERROR: scanjobs.cpp::CheckScanJobs(): ConfigScanJobFile() failed. hr[0x80030021]&amp;quot;&lt;/p&gt;    &lt;p&gt;&amp;quot;ERROR: Unexpected, RetrieveScanJobIdentifier could not find the index&amp;quot;      &lt;br /&gt;&amp;quot;ERROR: Problems retrieving ScanJob identifier from RegisterMonitor&amp;quot;       &lt;br /&gt;&amp;quot;ERROR: antigenvsapi.cpp::VSAPINavigatorThread(): RegisterMonitor() returned 8000ffff&amp;quot;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;You may also see instances where you open the Antigen Administrator console and scanjobs are not visible.&lt;/p&gt;  &lt;p&gt;The root cause of this is a regression in the Antigen performance counters DLL that results in Antigen services being unable to access the configuration information for scanjobs; thus, when the server is in this state, scanning processes cannot be started and the admin console cannot access scanjob configuration information. &lt;/p&gt;  &lt;p&gt;These symptoms will not occur in all instances.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Recommendations:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If a server is having this issue, you should be able to resolve the immediate issue by stopping all applications that are performing performance monitoring and restarting Exchange services.&lt;/p&gt;  &lt;p&gt;If you are running services/applications that gather performance data on your Exchange Server with Antigen 9.1 Hotfix Rollup 3, you can mitigate this in the short-term by disabling Antigen performance counters.&amp;#160; The following steps will disable those counters:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;At c:\program files\microsoft antigen for exchange\ &lt;/li&gt;    &lt;li&gt;Enter command: antigenpmsetup -uninstall &lt;/li&gt;    &lt;li&gt;You will also have to restart any application that loads performance counters.&amp;#160; Rebooting the server will accomplish this; however, short of that, you can run 'tlist -m antigenpmdll.dll' to get a list.&amp;#160; (Tlist is part of the debuggers package.) &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;This will be resolved in Rollup 4 when it is released.&amp;#160; After Rollup 4 is available, we recommend re-enabling Antigen performance counters by running 'antigenpmsetup -install'.&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3086321" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Forefront/default.aspx">Forefront</category><category domain="http://blogs.technet.com/neilcar/archive/tags/Antigen/default.aspx">Antigen</category></item><item><title>SQL Storm:  Possible ASP.Net</title><link>http://blogs.technet.com/neilcar/archive/2008/06/04/sql-storm-possible-asp-net.aspx</link><pubDate>Thu, 05 Jun 2008 00:13:59 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3066167</guid><dc:creator>neilcar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3066167.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3066167</wfw:commentRss><description>&lt;p&gt;I&amp;#8217;ve had an unconfirmed report that the SQL Storm attacks are now also affecting ASP.Net pages, specifically with a&amp;#160; URL of http://www.chliyi.com/m.js (this appears to be offline currently but I wouldn't suggest browsing there...) being injected into those pages.&amp;#160; My team hasn&amp;#8217;t worked on any incidents yet so I can&amp;#8217;t confirm that it is the same issue; however, it certainly looks very similar.&lt;/p&gt;  &lt;p&gt;This is a good time for me to remind everybody that Microsoft does provide no-cost support in the case of a security incident.&amp;#160; If you&amp;#8217;ve been affected, you can call 1-866-PCSAFETY in the United States &amp;amp; Canada.&amp;#160; Outside of that area, refer to &lt;a href="http://support.microsoft.com/common/international.aspx?rdpath=4"&gt;http://support.microsoft.com/common/international.aspx?rdpath=4&lt;/a&gt; to find the right contact information.&amp;#160; &lt;/p&gt;  &lt;p&gt;(Thanks to Erwin Geirnaert for the heads-up.)&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3066167" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.technet.com/neilcar/archive/tags/SQL/default.aspx">SQL</category><category domain="http://blogs.technet.com/neilcar/archive/tags/asp.net/default.aspx">asp.net</category></item><item><title>SQL Injection:  Trends &amp; Guidance</title><link>http://blogs.technet.com/neilcar/archive/2008/05/30/sql-injection-trends-guidance.aspx</link><pubDate>Fri, 30 May 2008 19:17:11 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3063668</guid><dc:creator>neilcar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3063668.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3063668</wfw:commentRss><description>&lt;p&gt;I've been working with the SWI team to write a comprehensive overview of the SQL Storm attacks with guidance for IT administrators, developers, and end users.&amp;#160; That article is posted at &lt;a title="sql-injection-attack.aspx" href="http://blogs.technet.com/swi/archive/2008/05/29/sql-injection-attack.aspx"&gt;sql-injection-attack.aspx&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;For developers, specifically, Bala Neerumalla has written an excellent overview of SQL injection and classic ASP code for MSDN at &lt;a title="cc676512.aspx" href="http://msdn.microsoft.com/en-us/library/cc676512.aspx"&gt;cc676512.aspx&lt;/a&gt;.&amp;#160; This is well worth a read for any developer who has legacy ASP code running -- it covers a variety of scenarios and how to resolve them.&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3063668" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.technet.com/neilcar/archive/tags/SQL/default.aspx">SQL</category><category domain="http://blogs.technet.com/neilcar/archive/tags/ASP/default.aspx">ASP</category></item><item><title>SQLInjectionFinder</title><link>http://blogs.technet.com/neilcar/archive/2008/05/27/sqlinjectionfinder.aspx</link><pubDate>Tue, 27 May 2008 20:51:23 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3061755</guid><dc:creator>neilcar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3061755.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3061755</wfw:commentRss><description>&lt;p&gt;My colleague &lt;a href="http://www.codeplex.com/site/users/view/GCTech"&gt;Greg&lt;/a&gt;, who has forgotten more about command line scripting than I will ever know, put together a sample on CodePlex that automates finding SQL injection attacks from the ongoing &lt;a href="http://blogs.technet.com/neilcar/archive/2008/03/14/anatomy-of-a-sql-injection-incident.aspx"&gt;mass SQL injection attack&lt;/a&gt; (&amp;quot;SQL Storm&amp;quot;, as I saw it dubbed today).&amp;#160; This is a fairly convenient approach to searching logfiles on an IIS server.&amp;#160; &lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=WSUS&amp;amp;ReleaseId=13436"&gt;SQLInjectionFinder&lt;/a&gt; -- &lt;a title="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=WSUS&amp;amp;ReleaseId=13436" href="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=WSUS&amp;amp;ReleaseId=13436"&gt;http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=WSUS&amp;amp;ReleaseId=13436&lt;/a&gt;&lt;/h3&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3061755" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.technet.com/neilcar/archive/tags/Incident+Response/default.aspx">Incident Response</category><category domain="http://blogs.technet.com/neilcar/archive/tags/SQL/default.aspx">SQL</category><category domain="http://blogs.technet.com/neilcar/archive/tags/Tool/default.aspx">Tool</category></item><item><title>SQL Injection Mitigation: Using Parameterized Queries part 2 (types and recordsets)</title><link>http://blogs.technet.com/neilcar/archive/2008/05/23/sql-injection-mitigation-using-parameterized-queries-part-2-types-and-recordsets.aspx</link><pubDate>Fri, 23 May 2008 19:18:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3060009</guid><dc:creator>neilcar</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3060009.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3060009</wfw:commentRss><description>&lt;P&gt;(Part 1 is &lt;A href="http://blogs.technet.com/neilcar/archive/2008/05/21/sql-injection-mitigation-using-parameterized-queries.aspx" mce_href="http://blogs.technet.com/neilcar/archive/2008/05/21/sql-injection-mitigation-using-parameterized-queries.aspx"&gt;here&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;Previously, I provided a simple example of using parameterized queries in classic ASP; however, that sample lacked a few things such as explicit typing for the parameters.&amp;nbsp; It also created a read-only ADODB.RecordSet which, obviously, isn't one-size-fits-all.&lt;/P&gt;
&lt;H2&gt;Typing&lt;/H2&gt;
&lt;P&gt;In the last installment, we had worked up this code to do our query:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Set objConnection = Server.CreateObject("ADODB.Connection") &lt;BR&gt;objConnection.Open "Provider=SQLOLEDB;Data Source=SQLSERVER;" _ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "Initial Catalog=website;User Id=user;Password=password;" _ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "Connect Timeout=15;Network Library=dbmssocn;" &lt;BR&gt;strSql = "SELECT name, info FROM [companies] WHERE name = ?;" &lt;BR&gt;set objCommand = Server.CreateObject("ADODB.Command") &lt;BR&gt;objCommand.ActiveConnection = objConnection &lt;BR&gt;objCommand.CommandText = strSql &lt;BR&gt;objCommand.Parameters(0).value = strSearch &lt;BR&gt;Set objSearchResults = objCommand.Execute()&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As I noted then, this code has a minor performance issue because ADODB is going to have to made a round-trip to SQL to figure out the parameter type before it can execute the query.&amp;nbsp; We can fix this and do input validation by explicitly typing our parameters like this:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Set objConnection = Server.CreateObject("ADODB.Connection") &lt;BR&gt;objConnection.Open "Provider=SQLOLEDB;Data Source=SQLSERVER;" _ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "Initial Catalog=website;User Id=user;Password=password;" _ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "Connect Timeout=15;Network Library=dbmssocn;" &lt;BR&gt;strSql = "SELECT name, info FROM [companies] WHERE name = ?;" &lt;BR&gt;set objCommand = Server.CreateObject("ADODB.Command") &lt;BR&gt;objCommand.ActiveConnection = objConnection &lt;BR&gt;objCommand.CommandText = strSql &lt;BR&gt;&lt;STRONG&gt;set objParameter = objCommand.CreateParameter("search", adVarChar, adParamInput, 20) &lt;BR&gt;objCommand.Parameters.Append objParameter &lt;BR&gt;obParameter.value = strSearch&lt;/STRONG&gt; &lt;BR&gt;Set objSearchResults = objCommand.Execute()&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here, we are creating an explicit parameter with a type of adVarChar (ie, it's a string) that is an input parameter with a maximum length of 20.&amp;nbsp; We append the parameter to our ADODB.Command object and set the parameter's value to the search string we want in our command.&amp;nbsp; More info about ADODB.Parameter objects is &lt;A href="http://msdn.microsoft.com/en-us/library/ms681010(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms681010(VS.85).aspx"&gt;here&lt;/A&gt;, more info about the possible types is &lt;A href="http://msdn.microsoft.com/en-us/library/ms675318(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms675318(VS.85).aspx"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;H2&gt;RecordSets&lt;/H2&gt;
&lt;P&gt;We may want to be able to write to the ADODB.RecordSet that we create; however, the code above won't work for that because it creates a recordset with the default parameters (Set objSearchResults = objCommand.Execute()).&amp;nbsp; If we want to be able to update the recordset, we have to create it with explicit parameters:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Set objConnection = Server.CreateObject("ADODB.Connection") &lt;BR&gt;objConnection.Open "Provider=SQLOLEDB;Data Source=SQLSERVER;" _ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "Initial Catalog=website;User Id=user;Password=password;" _ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "Connect Timeout=15;Network Library=dbmssocn;" &lt;BR&gt;strSql = "SELECT name, info FROM [companies] WHERE name = ?;" &lt;BR&gt;set objCommand = Server.CreateObject("ADODB.Command") &lt;BR&gt;objCommand.ActiveConnection = objConnection &lt;BR&gt;objCommand.CommandText = strSql &lt;BR&gt;set objParameter = objCommand.CreateParameter("search", adVarChar, adParamInput, 20) &lt;BR&gt;objCommand.Parameters.Append objParameter &lt;BR&gt;obParameter.value = strSearch &lt;BR&gt;&lt;STRONG&gt;Set objSearchResults = Server.CreateObject("ADODB.RecordSet") &lt;BR&gt;objSearchResults.Open objCommand,null,adOpenDynamic,adLockOptimistic&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now, we are explicitly providing parameters to indicate that we want a dynamic cursor (adOpenDynamic) and that we want optimistic locking (adLockOptimistic).&amp;nbsp; This creates a recordset that can be updated via the RecordSet.Update method (&lt;A title=http://msdn.microsoft.com/en-us/library/ms676529(VS.85).aspx href="http://msdn.microsoft.com/en-us/library/ms676529(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms676529(VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms676529(VS.85).aspx&lt;/A&gt;).&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3060009" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.technet.com/neilcar/archive/tags/SQL/default.aspx">SQL</category><category domain="http://blogs.technet.com/neilcar/archive/tags/ASP/default.aspx">ASP</category></item><item><title>SQL Injection Mitigation: Using Parameterized Queries</title><link>http://blogs.technet.com/neilcar/archive/2008/05/21/sql-injection-mitigation-using-parameterized-queries.aspx</link><pubDate>Wed, 21 May 2008 16:05:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3058592</guid><dc:creator>neilcar</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3058592.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3058592</wfw:commentRss><description>&lt;P&gt;Michael Howard wrote an excellent article yesterday on &lt;A href="http://blogs.msdn.com/sdl/archive/2008/05/15/giving-sql-injection-the-respect-it-deserves.aspx" mce_href="http://blogs.msdn.com/sdl/archive/2008/05/15/giving-sql-injection-the-respect-it-deserves.aspx"&gt;how the SDL addresses SQL injection&lt;/A&gt;.&amp;nbsp; He walks through three coding requirements/defenses:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Use SQL Parameterized Queries &lt;/LI&gt;
&lt;LI&gt;Use Stored Procedures &lt;/LI&gt;
&lt;LI&gt;Use SQL Execute-only Permissions &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;As Michael points out, only the first, parameterized queries, remedies the problem.&amp;nbsp; The other two provide additional defense.&lt;/P&gt;
&lt;P&gt;The good news is that changing your ASP pages to use parameterized queries instead of just dynamically building the query is dead simple.&amp;nbsp; The bad news is that MSDN doesn't have a lot of samples of how to do parameterized queries in ASP so I thought providing one would be helpful.&lt;/P&gt;
&lt;P&gt;As an example, I'm sure that a lot of the websites that have been compromised recently via SQL injection have something like this:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Set objConnection = Server.CreateObject("ADODB.Connection") &lt;BR&gt;objConnection.Open "Provider=SQLOLEDB;Data Source=SQLSERVER;" _ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "Initial Catalog=website;User Id=user;Password=password;" _ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "Connect Timeout=15;Network Library=dbmssocn;" &lt;BR&gt;strSQL = "SELECT name, info FROM [companies] WHERE name =" &amp;amp; strSearch &amp;amp; "';" &lt;BR&gt;Set objSearchResults = objConnection.Execute(strSQL)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This code is going to be extremely vulnerable to SQL injection since it's just taking the user input (which was passed in via a query string from a web form) and pasting it into the SQL statement.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The good thing about parameterization is that it separates the 'executable' code ("SELECT name, info...") from the 'data' (strSearch) we're using.&amp;nbsp; With a few changes, we can make this code use parameters for the query and, with this small change, defend against being exploited in this way.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Set objConnection = Server.CreateObject("ADODB.Connection") &lt;BR&gt;objConnection.Open "Provider=SQLOLEDB;Data Source=SQLSERVER;" _ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "Initial Catalog=website;User Id=user;Password=password;" _ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "Connect Timeout=15;Network Library=dbmssocn;" &lt;BR&gt;strSql = "SELECT name, info FROM [companies] WHERE name = ?;" &lt;BR&gt;set objCommand = Server.CreateObject("ADODB.Command") &lt;BR&gt;objCommand.ActiveConnection = objConnection&lt;BR&gt;objCommand.CommandText = strSql &lt;BR&gt;objCommand.Parameters(0).value = strSearch &lt;BR&gt;Set objSearchResults = objCommand.Execute()&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;All that we needed to do was:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Replace the query string in our SQL squery statement with a ? (which is the placeholder for a parameter). &lt;/LI&gt;
&lt;LI&gt;Create a new Command object for our command. &lt;/LI&gt;
&lt;LI&gt;Assign our active connection and command text to the Command object. &lt;/LI&gt;
&lt;LI&gt;Set the first parameter in the parameters collection to our dynamic string. &lt;/LI&gt;
&lt;LI&gt;Execute the command. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If we needed to use multiple parameters in our query, we'd add additional question marks to strSQL and additional parameters to the Parameters collection.&amp;nbsp; For example:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;strSql = "SELECT name, info FROM [companies] WHERE name = ?" _ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp; "AND info = ?;" &lt;BR&gt;... &lt;BR&gt;objCommand.Parameters(0).value = strName &lt;BR&gt;objCommand.Parameters(1).value = strInfo &lt;BR&gt;...&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There is a BIG caveat on this -- the method I show above has a performance hit because I haven't specified the types of the parameters.&amp;nbsp; This means that ADO has to make a roundtrip to the SQL server to figure out the type before actually using it.&amp;nbsp; You can fix this by creating parameters objects with the appropriate type which would have the added bonus of doing simple input validation as well.&amp;nbsp; If there's interest, I'll write a followup in the next few weeks with some samples of typed, parameterized queries.&amp;nbsp; (EDIT:&amp;nbsp; Written, it's &lt;A class="" href="http://blogs.technet.com/neilcar/archive/2008/05/23/sql-injection-mitigation-using-parameterized-queries-part-2-types-and-recordsets.aspx" mce_href="http://blogs.technet.com/neilcar/archive/2008/05/23/sql-injection-mitigation-using-parameterized-queries-part-2-types-and-recordsets.aspx"&gt;here&lt;/A&gt;.)&lt;/P&gt;
&lt;P&gt;Additional info is available on MSDN &lt;A href="http://msdn.microsoft.com/en-us/library/ms808739.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms808739.aspx"&gt;here&lt;/A&gt;.&amp;nbsp; NomadPete has a fuller walkthrough &lt;A href="http://www.nomadpete.com/2007/03/23/classic-asp-which-is-still-alive-and-parametised-queries/" mce_href="http://www.nomadpete.com/2007/03/23/classic-asp-which-is-still-alive-and-parametised-queries/"&gt;here&lt;/A&gt; that covers parameterized queries and stored procedures.&lt;/P&gt;
&lt;P&gt;As always, this is only part of the job in securing against SQL injection; however, it is probably the single most useful change you could make.&lt;/P&gt;
&lt;P&gt;(Big thanks to &lt;A class="" href="http://msdn.microsoft.com/en-us/magazine/cc301140.aspx" mce_href="http://msdn.microsoft.com/en-us/magazine/cc301140.aspx"&gt;Bala Neerumalla&lt;/A&gt; for tech reviewing this for me.)&lt;BR&gt;(Edit:&amp;nbsp; Fixed two minor issues with the code examples.&amp;nbsp; Thanks, Steve!)&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://blogs.technet.com/neilcar/archive/2008/05/23/sql-injection-mitigation-using-parameterized-queries-part-2-types-and-recordsets.aspx" mce_href="http://blogs.technet.com/neilcar/archive/2008/05/23/sql-injection-mitigation-using-parameterized-queries-part-2-types-and-recordsets.aspx"&gt;Continue on to Part 2&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3058592" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.technet.com/neilcar/archive/tags/SQL/default.aspx">SQL</category><category domain="http://blogs.technet.com/neilcar/archive/tags/ASP/default.aspx">ASP</category></item><item><title>SQL Injection -- A Comment</title><link>http://blogs.technet.com/neilcar/archive/2008/04/07/sql-injection-a-comment.aspx</link><pubDate>Mon, 07 Apr 2008 17:51:19 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3031695</guid><dc:creator>neilcar</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3031695.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3031695</wfw:commentRss><description>&lt;p&gt;Kumar comments &lt;a href="http://blogs.technet.com/neilcar/archive/2008/03/15/anatomy-of-a-sql-injection-incident-part-2-meat.aspx"&gt;here&lt;/a&gt; and I think he has some questions/concerns that are worth addressing.&amp;#160; I'm going to add my own comments (and, please note, the comments I make here are my own and do not necessarily reflect Microsoft's corporate opinions).&lt;/p&gt;  &lt;p&gt;---------------------------------------------------------------------------------------&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#0000ff"&gt;My site extensively uses asp and sql server. My site ranking is good with google for certain keywords searches.&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#0000ff"&gt;Friday morning I found that the bad people (nmidahena) had updated text fields in almost all of the tables with a &amp;lt;script&amp;gt; some thing.js &amp;lt;/script&amp;gt;. This has created a nightmare for me.&lt;/font&gt;&amp;#160; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;[nbc] This is consistent with what we've seen elsewhere.&amp;#160; You had one or more SQL injection vulnerabilities on an ASP page that used a query string as the SQL query.&amp;#160; The attackers found you on Google and ran their scripted attack against you, resulting in all your text getting the &amp;lt;script&amp;gt; tag appended to it.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#0000ff"&gt;Fortunately, I had a backup that came to my rescue. I also downloaded all asp and html files to my local machines and searched for &amp;quot;nmidahena&amp;quot; - nothing came up.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;[nbc] You won't find anything in the code files, at least not in this attack.&amp;#160; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#0000ff"&gt;This is what I have done:&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#0000ff"&gt;a) Restore sql server tables from the backup.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;[nbc] This is a very good step as long as you also fix the holes that were used to compromise it in the first place.&amp;#160; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#0000ff"&gt;b) Rewrite my asp forms to not to accept any character or words that could be used for sql injection.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;[nbc] This one is more problematic.&amp;#160; Just blacklisting a set of characters/words is probably going to break this attack but it's not likely to prevent future attacks from working.&amp;#160; I am not really qualified to answer this as I'm not a developer by trade.&amp;#160; Thankfully, Michael Howard and David LeBlanc spent a lot of time answering it in &lt;a href="http://www.google.com/url?sa=t&amp;amp;ct=res&amp;amp;cd=1&amp;amp;url=http%3A%2F%2Fwww.microsoft.com%2Fmspress%2Fbooks%2F5957.aspx&amp;amp;ei=MC_6R_CiE4ryiQG3ieztDg&amp;amp;usg=AFQjCNEfjlFqaCyHIguH2jfDABfm7x2WpQ&amp;amp;sig2=mbV15Vx-7v-CJDfqqhZSOw"&gt;Writing Secure Code&lt;/a&gt;.&amp;#160; I have the 2nd edition on my desk and pages 399-411 cover this at great length.&lt;/p&gt;  &lt;p&gt;[nbc] There are almost certainly other issues to be considered here.&amp;#160; The first one is that, in most of these attacks, it looks like the web app is using a user with sysadmin privileges in SQL.&amp;#160; This is as bad an idea as putting IUSR_MYSERVER in the administrators group.&amp;#160; Your web app should have the least possible privilege in SQL.&amp;#160; Running as sysadmin in SQL enables things such as xp_cmdshell, which is a great way for attackers to run sniffers, password-stealing utilities, and other malware on your SQL Server.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;[nbc] Another thing to consider is the possibility that this isn't the first SQL injection attack against you.&amp;#160; Another attacker might not have defaced your website; instead, they might have silently stolen every bit of data in your database.&amp;#160; If your web app was running as sysadmin, they might have silently stolen every bit of data in EVERY database on your SQL Server.&amp;#160; It is entirely possible that every name, e-mail address, password, credit-card number, etc that is in your database server's possession is now in somebody else's possession as well.&amp;#160; If so, your IIS logs should tell the story.&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#0000ff"&gt;Do you think this would be sufficient to prevent future attack?&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;[nbc] There are two answers to this question:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;I think this is sufficient to prevent future iterations of this same attack...until the attackers change the script they're using.     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;I don't think this is sufficient to prevent all future SQL injection attacks.&amp;#160; The only approach that is going to help with that is to make sure that you are using least privilege in SQL and build secure SQL statements/stored procedures.&amp;#160; Even then, of course, there may be other vulnerabilities in your site that can lead to compromise.&lt;/li&gt; &lt;/ol&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#0000ff"&gt;I dont know where to look for help. The hosting agency has no good answers.&lt;/font&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;[nbc] I don't envy your hosting company or, for that matter, any hosting company.&amp;#160; In general, I don't think it's going to be their responsibility to ensure that your code is secure, so I'm not surprised that they don't have good answers.&amp;#160; On the other hand, if the security bugs in your code are severe enough, you might be opening their facility up to further compromise.&amp;#160; &lt;/p&gt;  &lt;p&gt;---------------------------------------------------------------------------------------&lt;/p&gt;  &lt;p&gt;Other people may have better advice than I, and I'd love to hear it.&amp;#160; Since I'm seeing another 11K (and rising) servers compromised this month via this attack, I think you're not the only person asking these questions.&amp;#160; I've spent a lot of time thinking about this lately from a support/incident response perspective and I have some very large questions that I can't seem to answer.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Since my team operates from a reactive position (customer gets compromised, customer calls us, we investigate and offer suggestions), how can we help customers remediate this problem when we work with them?&amp;#160; Realistically, the customer needs to do a security code review; however, this is beyond the scope of my team.&amp;#160; There are offerings that cover this but, given the amount of work and expertise involved, they are costly.     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Even if I had the opportunity to be proactive, how could I contact the large number of people who appear to be vulnerable due to their own code defects (67K+ from last month's attack, 11K+ so far this month)?&amp;#160; &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3031695" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.technet.com/neilcar/archive/tags/Incident+Response/default.aspx">Incident Response</category><category domain="http://blogs.technet.com/neilcar/archive/tags/SQL/default.aspx">SQL</category></item><item><title>Mass SQL Injection -- Get Used To It</title><link>http://blogs.technet.com/neilcar/archive/2008/04/04/mass-sql-injection-get-used-to-it.aspx</link><pubDate>Fri, 04 Apr 2008 21:00:34 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3028907</guid><dc:creator>neilcar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3028907.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3028907</wfw:commentRss><description>&lt;p&gt;It looks like &lt;a href="http://malwaredomains.com/?p=148"&gt;another wave&lt;/a&gt; of the mass SQL injection &lt;a href="http://blogs.technet.com/neilcar/archive/2008/03/14/anatomy-of-a-sql-injection-incident.aspx"&gt;I talked about last month&lt;/a&gt; is going on.&amp;#160; The inserted link is different and, in the one specific incident I've seen, the source IP address is different; however, other than that, the attack looks to be identical.&lt;/p&gt;  &lt;p&gt;2.1K websites so far, this month. &lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3028907" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.technet.com/neilcar/archive/tags/Incident+Response/default.aspx">Incident Response</category><category domain="http://blogs.technet.com/neilcar/archive/tags/SQL/default.aspx">SQL</category></item><item><title>Good News</title><link>http://blogs.technet.com/neilcar/archive/2008/03/20/good-news.aspx</link><pubDate>Fri, 21 Mar 2008 00:50:45 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3016789</guid><dc:creator>neilcar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/neilcar/comments/3016789.aspx</comments><wfw:commentRss>http://blogs.technet.com/neilcar/commentrss.aspx?PostID=3016789</wfw:commentRss><description>&lt;p&gt;The good news is that, whatever else might happen, &lt;a href="http://thedailywtf.com/Articles/So-You-Hacked-Our-Site!.aspx"&gt;these guys&lt;/a&gt; won't get pwned by SQL injection.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;(Via &lt;a href="http://www.grumpysecurityguy.com/worst-security-i-have-seen-in-a-long-time/"&gt;GrumpySecurityGuy&lt;/a&gt;.)&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3016789" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/neilcar/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.technet.com/neilcar/archive/tags/humor/default.aspx">humor</category></item></channel></rss>