<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.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>Alik Levin's : Code Inspection</title><link>http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx</link><description>Tags: Code Inspection</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Security Code Review – Use Visual Studio Bookmarks To Capture Security Findings</title><link>http://blogs.msdn.com/alikl/archive/2008/01/24/security-code-review-use-visual-studio-bookmarks-to-capture-security-findings.aspx</link><pubDate>Thu, 24 Jan 2008 16:38:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7222033</guid><dc:creator>alikl</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/alikl/comments/7222033.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=7222033</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=7222033</wfw:comment><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;How to streamline the process of capturing security flaws during security code review? How to save time and avoid switching between the tools? How to stay focused?&lt;/p&gt;  &lt;p&gt;In this post I will show my simple technique to capture security flaws using Bookmarks in Visual Studio.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Create bookmark folders. &lt;/b&gt;Hit Ctrl + K and then Ctrl + W to bring Bookmarks window up. Create 10 folders according to &lt;a href="http://blogs.msdn.com/jmeier/pages/security-frame.aspx" target="_blank"&gt;security frame&lt;/a&gt; categories:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewUseVisualStudioBookmar_10D47/clip_image002_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="263" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewUseVisualStudioBookmar_10D47/clip_image002_thumb.jpg" width="230" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Focus on one category. &lt;/b&gt;Grab security &lt;a href="http://blogs.msdn.com/ace_team/archive/2008/01/15/generate-your-own-security-code-review-checklist-document-using-outlook-2007.aspx" target="_blank"&gt;checklist document&lt;/a&gt; you created using Guidance Explorer. Choose one category from the security frame, Authentication for example, and inspect the code manually. Do not pay attention to anything else on your way but Authentication issues. One category a time.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Bookmark security bugs. &lt;/b&gt;Once you find security bug hit Ctrl + K and then Ctrl +K again. You just created the bookmark. Drag it into the appropriate folder in Bookmarks window. Move on. When you finish the inspection using your checklist you should have something like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewUseVisualStudioBookmar_10D47/clip_image001_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="308" alt="clip_image001" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewUseVisualStudioBookmar_10D47/clip_image001_thumb.png" width="392" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Copy to the report in one run.&lt;/b&gt; Just run through the bookmarks and paste the findings to your final report. One run. Mechanical work. Done. Peace of mind.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;My related posts&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/06/05/visual-studio-2005-as-general-code-search-tool.aspx"&gt;Visual Studio 2005 As General Code Search Tool&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/31/security-code-inspection-eternal-search-for-sql-injection.aspx"&gt;Security Code Inspection - Eternal Search For SQL Injection&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/26/security-net-code-inspection-using-outlook-2007.aspx"&gt;Security .Net Code Inspection Using Outlook 2007&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/20/code-inspection-first-look-for-what-to-look-for.aspx"&gt;Code Inspection - First Look For What To Look For&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/11/21/asp-net-2-0-internet-security-reference-implementation-have-it-handy.aspx"&gt;ASP.NET 2.0 Internet Security Reference Implementation - Have It Handy&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7222033" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Tools/default.aspx">Tools</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx">Code Inspection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Practices/default.aspx">Practices</category></item><item><title>Use DIR Command To Generate List Of Files And Store It In File</title><link>http://blogs.msdn.com/alikl/archive/2007/12/01/use-dir-command-to-generate-list-of-files-and-store-it-in-file.aspx</link><pubDate>Sat, 01 Dec 2007 17:16:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6631017</guid><dc:creator>alikl</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/alikl/comments/6631017.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=6631017</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=6631017</wfw:comment><description>&lt;div class="pullquote_right"&gt;DIR /S /B /A:-D&lt;/div&gt;I use simple DIR command to generate file lists. It serves me in many scenarios. For example, I use it to generate .Net assemblies list when I conduct preliminary scan as part of &lt;a href="http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx"&gt;code inspection&lt;/a&gt; process. Here are the explanations to the switches:  &lt;ul&gt; &lt;li&gt;/S - search sub folders  &lt;li&gt;/B - bare format, no summaries and headings  &lt;li&gt;/A:-D - no directories, files only&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;To save generated list of files into text file simply add &amp;gt;C:\myfileslist.txt. The resulting command would look as follows:&lt;/p&gt; &lt;p&gt;DIR /S /B /A:-D *.DLL &amp;gt;C:\myfileslist.txt&lt;/p&gt; &lt;p&gt;&lt;strong&gt;My related posts:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/26/security-net-code-inspection-using-outlook-2007.aspx"&gt;Security .Net Code Inspection Using Outlook 2007&lt;/a&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/31/security-code-inspection-eternal-search-for-sql-injection.aspx"&gt;Security Code Inspection - Eternal Search For SQL Injection&lt;/a&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/20/code-inspection-first-look-for-what-to-look-for.aspx"&gt;Code Inspection - First Look For What To Look For&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6631017" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx">Code Inspection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Practices/default.aspx">Practices</category></item><item><title>XSSDetect Public Beta now Available!</title><link>http://blogs.msdn.com/alikl/archive/2007/10/24/xssdetect-public-beta-now-available.aspx</link><pubDate>Wed, 24 Oct 2007 23:21:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5656467</guid><dc:creator>alikl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/alikl/comments/5656467.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=5656467</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=5656467</wfw:comment><description>&lt;p&gt;XSSDetect public beta is now available for &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=19a9e348-bdb9-45b3-a1b7-44ccdcb7cfbe&amp;amp;displaylang=en" target="_blank"&gt;download&lt;/a&gt; on MSDN.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;&lt;/p&gt; &lt;blockquote&gt; &lt;h6&gt;XSSDetect is a static code analysis tool that helps identify Cross-Site Scripting security flaws found within Web applications. It is able to scan compiled managed assemblies (C#, Visual Basic .NET, J#) and analyze dataflow paths from sources of user-controlled input to vulnerable outputs. It also detects whether proper encoding or filtering has been applied to the data and will ignore such "sanitized" paths.&lt;/h6&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;strong&gt;Related resources:&lt;/strong&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;&lt;a href="http://msdn2.microsoft.com/en-us/security/aa973814.aspx" target="_blank"&gt;Anti-Cross Site Scripting Library&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;&lt;a href="http://msdn2.microsoft.com/ms998274.aspx" target="_blank"&gt;How To: Prevent Cross-Site Scripting in ASP.NET&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;My related posts:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/25/xss-do-not-make-me-laugh-we-use-winforms.aspx"&gt;&lt;strong&gt;XSS? - Do not Make Me Laugh, We Use WinForms&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Enjoy&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5656467" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Tools/default.aspx">Tools</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx">Code Inspection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category></item><item><title>Visual Studio 2005 As General Code Search Tool</title><link>http://blogs.msdn.com/alikl/archive/2007/06/05/visual-studio-2005-as-general-code-search-tool.aspx</link><pubDate>Wed, 06 Jun 2007 00:50:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3104886</guid><dc:creator>alikl</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/alikl/comments/3104886.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=3104886</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=3104886</wfw:comment><description>&lt;p&gt;Visual Studio 2005 has&amp;nbsp;powerful search capabilities. One of my favorites is "Find in Files". &lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/HowIUseVisualStudioAsGeneralCodeSearchTo_8D08/image_6.png" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; margin: 0px 20px 0px 0px; border-left: 0px; border-bottom: 0px" height="447" alt="image" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/HowIUseVisualStudioAsGeneralCodeSearchTo_8D08/image_thumb_6.png" width="375" align="left" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Just hit Ctrl+Shift+F (more shortcuts - &lt;a href="http://blogs.msdn.com/alikl/archive/2007/04/29/my-favorite-shortcuts.aspx" target="_blank"&gt;My Favorite Shortcuts&lt;/a&gt;).&lt;/p&gt; &lt;p&gt;Essentially it uses FindStr utility that sits in System32 folder and comes for free with Windows OS. FindStr is a command line utility and those who like typing would prefer it, but those who like UI would go for Visual Studio. There is no need to open project - just fire up Visual Studio and hit Ctrl+Shift+F.&lt;/p&gt; &lt;p&gt;I discussed different searching options I practice here - &lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/31/security-code-inspection-eternal-search-for-sql-injection.aspx" target="_blank"&gt;Security Code Inspection - Eternal Search For SQL Injection&lt;/a&gt;&amp;nbsp;, but&amp;nbsp;I thought FindStr and its utilization in Visual Studio deserves special attention. &lt;/p&gt; &lt;p&gt;The best part I like is that after hitting "Find All" button I am presented with list of all files that matched the search criteria and the match itself, so I can quickly evaluate what I got in my net. Once I smell something fishy I hit the file and it opens in the very same Visual Studio for detailed inspection. I think it is very handy.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;Enjoy.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3104886" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Tools/default.aspx">Tools</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx">Code Inspection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/VSTS/default.aspx">VSTS</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Practices/default.aspx">Practices</category></item><item><title>Security Code Inspection - Eternal Search For SQL Injection</title><link>http://blogs.msdn.com/alikl/archive/2007/03/31/security-code-inspection-eternal-search-for-sql-injection.aspx</link><pubDate>Sat, 31 Mar 2007 23:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2001473</guid><dc:creator>alikl</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/alikl/comments/2001473.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=2001473</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=2001473</wfw:comment><description>&lt;P&gt;Here are couple of techniques I used for searching hints&amp;nbsp;of SQL Injections in .Net apps.&lt;/P&gt;
&lt;P&gt;The basic approach is described here &lt;A title=http://msdn2.microsoft.com/en-us/library/ms998399.aspx href="http://msdn2.microsoft.com/en-us/library/ms998399.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms998399.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms998399.aspx&lt;/A&gt;. It is basically split into two major parts - preliminary scan and the detailed scan. The keyword is hotspot - find hotspot and&amp;nbsp; investigate it accordingly. Hotspot can be something around &lt;A href="http://msdn2.microsoft.com/en-us/library/ms998271.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms998271.aspx"&gt;SQL injection&lt;/A&gt; or &lt;A href="http://msdn2.microsoft.com/en-us/library/ms998274.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms998274.aspx"&gt;XSS&lt;/A&gt;. I personally like calling it hints rather hotspot.&lt;/P&gt;
&lt;P&gt;Here are some techniques I used during &lt;A href="http://msdn2.microsoft.com/en-us/library/ms998364.aspx#paght000027_step2" mce_href="http://msdn2.microsoft.com/en-us/library/ms998364.aspx#paght000027_step2"&gt;preliminary scan&lt;/A&gt; to&amp;nbsp;find hints for SQL Injection:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/alikl/archive/2007/03/20/code-inspection-first-look-for-what-to-look-for.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2007/03/20/code-inspection-first-look-for-what-to-look-for.aspx"&gt;&lt;STRONG&gt;Code Inspection - First Look For What To Look For&lt;/STRONG&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;This technique allows to dump all the strings from compiled assemblies. It is very useful when looking for sensitive data in it but along the way one can recognize funny things: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/CodeInspectionFirstLookForWhatToLookFor_C01E/image022.png" atomicselection="true" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/CodeInspectionFirstLookForWhatToLookFor_C01E/image022.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=101 src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/CodeInspectionFirstLookForWhatToLookFor_C01E/image0_thumb12.png" width=576 border=0 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/CodeInspectionFirstLookForWhatToLookFor_C01E/image0_thumb12.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;that can provide some hints for further investigation. &lt;/P&gt;
&lt;P&gt;ILDASM and FindStr are our friends with this technique. Resulting dump can be investigated using ... Outlook 2007 - &lt;A href="http://blogs.msdn.com/alikl/archive/2007/03/26/security-net-code-inspection-using-outlook-2007.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2007/03/26/security-net-code-inspection-using-outlook-2007.aspx"&gt;Security .Net Code Inspection Using Outlook 2007&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeInspectionUsingOutlook2007_878A/image011.png" atomicselection="true" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeInspectionUsingOutlook2007_878A/image011.png"&gt;&lt;IMG height=347 src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeInspectionUsingOutlook2007_878A/image0_thumb5.png" width=729 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeInspectionUsingOutlook2007_878A/image0_thumb5.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Look inside source code&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;This techniques assumes you one knows what to look for - it can be&amp;nbsp;&lt;STRONG&gt;hints&lt;/STRONG&gt; gathered from previous step or just finding all instances of&amp;nbsp;&lt;B&gt;OdbcCommand, &lt;/B&gt;&lt;B&gt;OleDbCommand, &lt;/B&gt;&lt;B&gt;OracleCommand, &lt;/B&gt;&lt;B&gt;SqlCommand, &lt;/B&gt;&lt;B&gt;SqlCeCommand&lt;/B&gt; usage.&lt;/P&gt;
&lt;P&gt;FindStr is of great help here and the syntax would look like : FindStr /S /M /I /d:c:\projects\yourweb "SqlCommand" *.cs&lt;/P&gt;
&lt;P&gt;from &lt;A title=http://msdn2.microsoft.com/en-us/library/aa302437.aspx href="http://msdn2.microsoft.com/en-us/library/aa302437.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa302437.aspx"&gt;http://msdn2.microsoft.com/en-us/library/aa302437.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;FindStr&lt;/B&gt; uses the following command-line parameters: 
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;/S&lt;/B&gt; — include subdirectories. 
&lt;LI&gt;&lt;B&gt;/M&lt;/B&gt; — list only the file names. No actual matches displayed. 
&lt;LI&gt;&lt;B&gt;/I&lt;/B&gt; — use a case insensitive search. 
&lt;LI&gt;/&lt;B&gt;D:&lt;/B&gt;&lt;I&gt;dir&lt;/I&gt; — search a semicolon-delimited list of directories. If the file path you want to search includes spaces, surround the path in double quotes. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Incase where Visual Studio is at hand same result (I presume FindStr is used under the cover) can be achieved by pressing ctrl+shift+f. This command brings up "Find In Files" dialog box:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D%5B5%5D.png" atomicselection="true" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D%5B5%5D.png"&gt;&lt;IMG height=304 src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D_thumb%5B1%5D.png" width=354 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D_thumb%5B1%5D.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;and the result is:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D%5B9%5D.png" atomicselection="true" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D%5B9%5D.png"&gt;&lt;IMG height=155 src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D_thumb%5B3%5D.png" width=737 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D_thumb%5B3%5D.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;(file and the string match == FindStr /S /I /d:c:\projects\yourweb "SqlCommand" *.*)&lt;/P&gt;
&lt;P&gt;Looking at the match one can decide to look further into it or not.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms182310(VS.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms182310(VS.80).aspx"&gt;&lt;STRONG&gt;Use FxCop's ReviewSqlQueriesForSecurityVulnerabilities&lt;/STRONG&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Run FxCop with ReviewSqlQueriesForSecurityVulnerabilities rule checked:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D%5B13%5D.png" atomicselection="true" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D%5B13%5D.png"&gt;&lt;IMG height=209 src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D_thumb%5B5%5D.png" width=678 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeReviewEternalSearchForSQLinj_C715/image%7B0%7D_thumb%5B5%5D.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Do not include any other checks - FxCop consumes tones of memory, and it may be a problem with large projects that include many DLL's.&lt;/P&gt;
&lt;P&gt;Seems like FxCop approach is most efficient since it knows how&amp;nbsp;to get hold on those hints where XXXComand object is used and CommandText property includes string that was built dynamically.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do not fall in trap of false&amp;nbsp;positives and false negatives - tools are great but &lt;A href="http://blogs.microsoft.co.il/blogs/alikl/archive/2007/02/14/Most-Powerful-Security-Tool.aspx" mce_href="http://blogs.microsoft.co.il/blogs/alikl/archive/2007/02/14/Most-Powerful-Security-Tool.aspx"&gt;the best tool is between your ears&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;False positives&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp; - it is situation&amp;nbsp;when the tool finds the issue but from detailed inspection it is not. For example, FxCop spots the code like this:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt; sql &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"SELECT NAME, DESCN FROM PRODUCT WHERE NAME ='"&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/SPAN&gt; searchCriteria &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"'"&lt;/SPAN&gt; &lt;BR&gt;&lt;BR&gt;SqlCommand cmd &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; SqlCommand(sql, con); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Is it a problem? Depends where &lt;EM&gt;searchCriteria &lt;/EM&gt;value&amp;nbsp;comes from - if it is &lt;FONT color=#ff0000&gt;user controlled&lt;/FONT&gt; then &lt;FONT color=#ff0000&gt;YES&lt;/FONT&gt;, otherwise not [sure]. 
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;False negatives&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp; - it is situation where the tool does not find anything but the problem actually exists and only manual detailed scan can reveal it. 
&lt;P&gt;While false positives just consume more energy while manually inspecting&amp;nbsp;the findings, false negatives leave bad stuff undiscovered, which is I think worse. 
&lt;P&gt;&lt;STRONG&gt;Conclusion&lt;/STRONG&gt; 
&lt;P&gt;While tools are vital and usually boost the productivity when inspecting the code for security vulnerabilities, it is important to have right set of expectations from those tools - what it can and what it cannot do. Remember the best tool is between your ears (&lt;A href="http://blogs.msdn.com/jmeier/archive/2007/02/07/it-s-between-your-ears.aspx" mce_href="http://blogs.msdn.com/jmeier/archive/2007/02/07/it-s-between-your-ears.aspx"&gt;original version by JD&lt;/A&gt;)&amp;nbsp; 
&lt;P&gt;:) 
&lt;P&gt;Enjoy&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2001473" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Input+Validation/default.aspx">Input Validation</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx">Code Inspection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category></item><item><title>Performance Gain - Security Risk</title><link>http://blogs.msdn.com/alikl/archive/2007/03/27/performance-gain-security-risk.aspx</link><pubDate>Tue, 27 Mar 2007 17:26:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1964079</guid><dc:creator>alikl</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/alikl/comments/1964079.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=1964079</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=1964079</wfw:comment><description>&lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;Reposted from &lt;a href="http://blogs.microsoft.co.il/blogs/alikl/archive/2007/02/23/Performance-Gain-_2D00_-Security-Risk.aspx"&gt;Performance Gain - Security Risk&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Good intention for better performance may lead to flawed design and&amp;nbsp;bring in more security&amp;nbsp;risks.&lt;/p&gt; &lt;p&gt;Consider the following ASPX page:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceGainSecurityHole_D7E1/image02.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="248" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceGainSecurityHole_D7E1/image0_thumb.png" width="656" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Here is why it cannot be accessed:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceGainSecurityHole_D7E1/image05.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="328" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceGainSecurityHole_D7E1/image0_thumb1.png" width="474" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;When trying to navigate there you get:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceGainSecurityHole_D7E1/image08.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="333" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceGainSecurityHole_D7E1/image0_thumb2.png" width="648" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Great, love URL authorization!!&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Now let's examine another ASPX page:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceGainSecurityHole_D7E1/image011.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="310" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceGainSecurityHole_D7E1/image0_thumb3.png" width="595" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;When navigating to this page you surprisingly get this:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceGainSecurityHole_D7E1/image014.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="186" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/PerformanceGainSecurityHole_D7E1/image0_thumb4.png" width="465" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The reason for that is when using Server.Transfer the request to the second page does not go through the &lt;a href="http://msdn2.microsoft.com/en-us/library/aa302376.aspx"&gt;whole ASP.NET pipeline&lt;/a&gt; which includes URL Authorization module&lt;/p&gt; &lt;p&gt;Security part is here &lt;a href="http://msdn2.microsoft.com/en-us/library/ms998375.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms998375.aspx&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Performance part is here &lt;a title="http://msdn2.microsoft.com/en-us/library/ms998549.aspx" href="http://msdn2.microsoft.com/en-us/library/ms998549.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms998549.aspx&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Performance and Security has never been good friends -&amp;nbsp;fortunately we have &lt;a href="http://blogs.msdn.com/jmeier/default.aspx"&gt;J.D.&lt;/a&gt; who is bridging the two letting us enjoy both.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Enjoy&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1964079" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx">Code Inspection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Performance/default.aspx">Performance</category></item><item><title>Security .Net Code Inspection Using Outlook 2007</title><link>http://blogs.msdn.com/alikl/archive/2007/03/26/security-net-code-inspection-using-outlook-2007.aspx</link><pubDate>Mon, 26 Mar 2007 17:04:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1952406</guid><dc:creator>alikl</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/alikl/comments/1952406.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=1952406</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=1952406</wfw:comment><description>&lt;p&gt;In my previous post, &lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/20/code-inspection-first-look-for-what-to-look-for.aspx"&gt;Code Inspection - First Look For What To Look For&lt;/a&gt;, I've described how to look for sensitive data and hints in the compiled assemblies. The other challenge I was looking to solve is boosting my productivity. So with little magic of scripting (more magic here &lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/23/scriptomania-scripting-tools-and-utilities.aspx"&gt;Scriptomania - Scripting Tools and Utilities&lt;/a&gt;) and generous help from my friend DIR (more here &lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/22/security-code-deployment-review-using-office.aspx"&gt;Security Deployment Inspection Using Office.&lt;/a&gt;) I've accomplished task of scanning all directories, and dumping all the strings into text files, like this:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeInspectionUsingOutlook2007_878A/image03.png" atomicselection="true"&gt;&lt;img height="193" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeInspectionUsingOutlook2007_878A/image0_thumb1.png" width="501"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;All I had to do is go over each and every text file and look for funny things (depicted in &lt;a href="http://blogs.msdn.com/alikl/archive/2007/03/20/code-inspection-first-look-for-what-to-look-for.aspx"&gt;Code Inspection - First Look For What To Look For&lt;/a&gt;). Pretty annoying: double click, scroll down, move to "Seen" folder - no marking and categorization or follow up capabilities - WAIT A MINUTE!!!&amp;nbsp;Does not it sound like Outlook? So I dragged all the text files into my new shiny Outlook 2007 getting all the goodies it provides:&lt;/p&gt; &lt;p&gt;1. Move through items using up and down arrow using left hand.&lt;/p&gt; &lt;p&gt;2. Scroll the text in preview pane using mouse wheel by right hand.&lt;/p&gt; &lt;p&gt;3. Tag and categorize.&lt;/p&gt; &lt;p&gt;4. Everything else Outlook provides.&lt;/p&gt; &lt;p&gt;5. AND OF COURSE USING INSTANT SEARCH IS A REAL PLEASURE:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeInspectionUsingOutlook2007_878A/image011.png" atomicselection="true"&gt;&lt;img height="408" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/SecurityCodeInspectionUsingOutlook2007_878A/image0_thumb5.png" width="853"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Enjoy&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1952406" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Tools/default.aspx">Tools</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx">Code Inspection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category></item><item><title>Code Inspection - First Look For What To Look For</title><link>http://blogs.msdn.com/alikl/archive/2007/03/20/code-inspection-first-look-for-what-to-look-for.aspx</link><pubDate>Wed, 21 Mar 2007 00:13:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1921458</guid><dc:creator>alikl</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/alikl/comments/1921458.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=1921458</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=1921458</wfw:comment><description>&lt;p&gt;Reposted from &lt;a href="http://blogs.microsoft.co.il/blogs/alikl/archive/2007/01/03/Code-Inspection-_2D00_-First-Look-For-What-To-Look-For.aspx"&gt;Security Code Inspection - First Look For What To Look For&lt;/a&gt;&amp;nbsp;for further reuse on this blog.&lt;/p&gt; &lt;p&gt;I found it extremely productive to first look for strings in the code. But what strings to look for? And how to look for the strings? Looking into the source files?&lt;/p&gt; &lt;p&gt;My good friend &lt;a href="http://blogs.microsoft.co.il/blogs/alikl/archive/2006/12/29/How-They-Will-Discover-Secrets-You-Hide.aspx" target="_blank"&gt;FindStr&lt;/a&gt; is of great help here:&lt;/p&gt; &lt;p&gt;So first let's find what to look for:&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/THCMCh21.asp"&gt;Ildasm.exe secureapp.dll /text | findstr ldstr&lt;/a&gt;&lt;/p&gt; &lt;p&gt;This is what I've got using it:&lt;/p&gt; &lt;p&gt;Wouldn't it trigger you think of authorization data doing roundtrip thus vulnerable to tampering and elevation of privileges?&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/CodeInspectionFirstLookForWhatToLookFor_C01E/image020.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="55" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/CodeInspectionFirstLookForWhatToLookFor_C01E/image0_thumb10.png" width="568" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Wouldn't it trigger you think there is some custom authentication mechanism that potentially could be vulnerable thus enabling identity spoofing?&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/CodeInspectionFirstLookForWhatToLookFor_C01E/image021.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="128" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/CodeInspectionFirstLookForWhatToLookFor_C01E/image0_thumb11.png" width="325" border="0"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Wouldn't it trigger you think.....&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/CodeInspectionFirstLookForWhatToLookFor_C01E/image022.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="101" src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/CodeInspectionFirstLookForWhatToLookFor_C01E/image0_thumb12.png" width="576" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;So once you have these strings you use same FindStr to find actual files to inspect:&lt;/p&gt; &lt;p&gt;findstr /S /M /I /d:c:\projects\yourweb "StringOfInterestGoesHere" *.cs &lt;/p&gt; &lt;p&gt;Cheers&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1921458" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Information+Gathering/default.aspx">Information Gathering</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Sensitive+Data/default.aspx">Sensitive Data</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Tools/default.aspx">Tools</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx">Code Inspection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category></item><item><title>Good Chance For Canonicalization Attack When Using Path.Combine()</title><link>http://blogs.msdn.com/alikl/archive/2007/03/15/beware-of-path-combine-s1-s2-good-chance-for-canonicalization-attack.aspx</link><pubDate>Fri, 16 Mar 2007 01:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1890210</guid><dc:creator>alikl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/alikl/comments/1890210.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=1890210</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=1890210</wfw:comment><description>&lt;P&gt;In my previous post, &lt;A href="http://blogs.msdn.com/alikl/archive/2007/03/12/net-assembly-spoof-attack.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2007/03/12/net-assembly-spoof-attack.aspx"&gt;.Net Assembly Spoof Attack&lt;/A&gt;, I've described potential DLL hijacking/spoof attack when using reflection for dynamically loaded assemblies. &lt;/P&gt;
&lt;P&gt;Today I was reviewing some project where I stumbled on exactly such case. One thing that caught my eyes was that path to reflected DLL, the one to be loaded dynamically was built like this:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; Main(&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt;[] args)&lt;BR&gt;{ &lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt; dllName &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; Console.ReadLine();&amp;nbsp;&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;while&lt;/SPAN&gt; (!dllName.Equals(&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"exit"&lt;/SPAN&gt;))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&lt;/SPAN&gt; path &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;@"C:\DLLS\"&lt;/SPAN&gt;&amp;nbsp;&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//BUILD FULL PATH TO ASSEMBLY TO LOAD DYNAMICALLY USING Assembly.LoadFrom&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&lt;/SPAN&gt; fullDllPath &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; Path.Combine(path, dllName);&amp;nbsp;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine(&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"FULL PATH IS: "&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/SPAN&gt; fullDllPath);&amp;nbsp;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dllName &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; Console.ReadLine();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;}&lt;/SPAN&gt; &lt;/P&gt;
&lt;P&gt;Let me run it and see what happens if I provide expected DLL name say, alikl.dll: 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Bew.Combines1s2GoodChanceForCanonicaliza_3B3/image%7B0%7D%5B2%5D.png" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Bew.Combines1s2GoodChanceForCanonicaliza_3B3/image%7B0%7D%5B2%5D.png" atomicselection="true"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=117 src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Bew.Combines1s2GoodChanceForCanonicaliza_3B3/image%7B0%7D_thumb.png" width=437 border=0 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Bew.Combines1s2GoodChanceForCanonicaliza_3B3/image%7B0%7D_thumb.png"&gt;&lt;/A&gt; 
&lt;P&gt;And now let's provide something less expected like Z:\XACKER\ATTACK.DLL: 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Bew.Combines1s2GoodChanceForCanonicaliza_3B3/image%7B0%7D%5B5%5D.png" mce_href="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Bew.Combines1s2GoodChanceForCanonicaliza_3B3/image%7B0%7D%5B5%5D.png" atomicselection="true"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=117 src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Bew.Combines1s2GoodChanceForCanonicaliza_3B3/image%7B0%7D_thumb%5B1%5D.png" width=437 border=0 mce_src="http://blogs.msdn.com/blogfiles/alikl/WindowsLiveWriter/Bew.Combines1s2GoodChanceForCanonicaliza_3B3/image%7B0%7D_thumb%5B1%5D.png"&gt;&lt;/A&gt; 
&lt;P&gt;It&amp;nbsp;means that if we supply full path as second parameter to Combine method it will ignore the first parameter. 
&lt;P&gt;How to validate? 
&lt;P&gt;1. Check the path for goodness using Path.GetFullPath() comparing result to "C:\DLLS" in our case 
&lt;P&gt;2. Sign your assembly and explicitly check it's evidence&amp;nbsp; - example is here &lt;A href="http://blogs.msdn.com/alikl/archive/2007/03/12/net-assembly-spoof-attack.aspx" mce_href="http://blogs.msdn.com/alikl/archive/2007/03/12/net-assembly-spoof-attack.aspx"&gt;.Net Assembly Spoof Attack&lt;/A&gt; 
&lt;P&gt;More resources: 
&lt;P&gt;&lt;A onmouseover='TopicTipOn(this, "id1167");' onmouseout=TopicTipOff(); href="http://channel9.msdn.com/wiki/default.aspx/SecurityWiki.CanonicalizationLab"&gt;Canonicalization Lab&lt;/A&gt; (includes code and video by &lt;A class="" href="http://pluralsight.com/blogs/keith/" mce_href="http://pluralsight.com/blogs/keith/"&gt;Keith Brown&lt;/A&gt;) 
&lt;P&gt;&lt;A class="" href="http://msdn2.microsoft.com/en-us/library/bb355989.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/bb355989.aspx"&gt;How To: Protect From Injection Attacks in ASP.NET&lt;/A&gt; 
&lt;P&gt;Enjoy &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1890210" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Input+Validation/default.aspx">Input Validation</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx">Code Inspection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category></item><item><title>.Net Assembly Spoof Attack</title><link>http://blogs.msdn.com/alikl/archive/2007/03/12/net-assembly-spoof-attack.aspx</link><pubDate>Mon, 12 Mar 2007 22:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1867215</guid><dc:creator>alikl</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/alikl/comments/1867215.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alikl/commentrss.aspx?PostID=1867215</wfw:commentRss><wfw:comment>http://blogs.msdn.com/alikl/rsscomments.aspx?PostID=1867215</wfw:comment><description>&lt;P&gt;To be honest I am not sure about the name of such attack, but in the nutshell it is attack where the original good code is replaced by bad one with the same interface but very bad implementation - may be Trojan DLL? Anyway...&lt;/P&gt;
&lt;P&gt;My Australia based teammate &lt;A href="http://blogs.msdn.com/rockyh/" mce_href="http://blogs.msdn.com/rockyh/"&gt;Rocky&lt;/A&gt; posted sometime ago coolest screencast - &lt;A href="http://www.rockyh.net/AssembHijacking/AssembHijacking.html" mce_href="http://www.rockyh.net/AssembHijacking/AssembHijacking.html"&gt;Assembly Hijacking&lt;/A&gt;. He calls it hijacking. Go see it, very cool.&lt;/P&gt;
&lt;P&gt;The final verdict was to sign the assemblies with SNK which is almost always a good idea to do. This should definitely prevent such attack he demonstrated. To "&lt;B&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/aa480477.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa480477.aspx"&gt;Evaluate Whether You Need Strong Names&lt;/A&gt;&lt;/B&gt;" check on the following in referenced article:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;You need to add your assembly to the global assembly cache&lt;/B&gt;. &lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;You want to prevent partial trust callers&lt;/B&gt;. &lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;You want cryptographically strong evidence for security policy evaluation&lt;/B&gt;. &lt;EM&gt;&lt;STRONG&gt;&lt;FONT color=#008040&gt;&amp;lt;-- this one is for our case&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Lately I&amp;nbsp;stumbled on another post &lt;A href="http://blogs.microsoft.co.il/blogs/sasha/archive/2007/03/06/Assembly-Load-Contexts-Subtleties.aspx" mce_href="http://blogs.microsoft.co.il/blogs/sasha/archive/2007/03/06/Assembly-Load-Contexts-Subtleties.aspx"&gt;Assembly Load Contexts Subtleties&lt;/A&gt;&amp;nbsp;that "focus on &lt;A href="https://msdn2.microsoft.com/en-us/library/system.reflection.assembly.load.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/system.reflection.assembly.load.aspx"&gt;Assembly.Load&lt;/A&gt; and &lt;A href="http://msdn2.microsoft.com/en-us/library/system.reflection.assembly.loadfrom.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.reflection.assembly.loadfrom.aspx"&gt;Assembly.LoadFrom&lt;/A&gt;" which discusses dynamic assembly and types invocation.&lt;/P&gt;
&lt;P&gt;I thought to myself "What role SNK plays in this case?" &lt;/P&gt;
&lt;P&gt;None&lt;/P&gt;
&lt;P&gt;Dynamically loaded assembly is not checked for its evidence. That means that &lt;STRONG&gt;&lt;STRONG&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Arial','sans-serif'"&gt;all applications that use reflection to load assemblies dynamically are vulnerable to such attack&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;- regardless if there is SNK in place or not.&lt;/P&gt;
&lt;P&gt;What to do to prevent such attack when using reflection?&lt;/P&gt;
&lt;P&gt;1. Do sign with SNK your assemblies.&lt;/P&gt;
&lt;P&gt;2. &lt;STRONG&gt;&lt;A class="" href="http://msdn2.microsoft.com/en-us/library/aa480477.aspx#pagguidelines0003_reflect1" mce_href="http://msdn2.microsoft.com/en-us/library/aa480477.aspx#pagguidelines0003_reflect1"&gt;Use Full Assembly Names When You Dynamically Load Assemblies&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The code you should find there will look like this:&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/SPAN&gt; StrongName GetStrongName(Assembly assembly)&lt;BR&gt;{&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/SPAN&gt;(assembly == &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/SPAN&gt;)&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; ArgumentNullException(&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"assembly"&lt;/SPAN&gt;);&amp;nbsp;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;AssemblyName assemblyName &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; assembly.GetName();&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// get the public key blob&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;byte&lt;/SPAN&gt;[] publicKey &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; assemblyName.GetPublicKey();&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/SPAN&gt;(publicKey == &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/SPAN&gt; || publicKey.Length == 0)&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; InvalidOperationException(String.Format(&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"{0} is not strongly named"&lt;/SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;assembly));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;StrongNamePublicKeyBlob keyBlob &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; StrongNamePublicKeyBlob(publicKey);&amp;nbsp;&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// create the StrongName&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; StrongName(keyBlob, assemblyName.Name, assemblyName.Version);&lt;BR&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;And here is the check itself:&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//LOAD ASSEMBLY DYNAMICALLY&lt;/SPAN&gt;&lt;BR&gt;Assembly assembly &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; Assembly.LoadFrom(&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"ReflectedDll.dll"&lt;/SPAN&gt;);&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//GET STRONG NAME FOR THE LOADED ASSEMBLY&lt;/SPAN&gt;&lt;BR&gt;StrongName sn &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; GetStrongName(assembly);&lt;BR&gt;&lt;BR&gt;StrongName myStrongName &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/SPAN&gt;;&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//GET CURRENT APPDOMAIN STRONG NAME&lt;/SPAN&gt;&lt;BR&gt;IEnumerator enumerator &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; (IEnumerator)AppDomain.CurrentDomain.Evidence.GetEnumerator();&lt;BR&gt;enumerator.Reset();&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;while&lt;/SPAN&gt; (enumerator.MoveNext())&lt;BR&gt;{&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/SPAN&gt; (enumerator.Current.GetType().Equals(&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;typeof&lt;/SPAN&gt;(StrongName)))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myStrongName &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; (StrongName)enumerator.Current;&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/SPAN&gt; (!sn.PublicKey.Equals(myStrongName.PublicKey))&lt;BR&gt;{&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; ApplicationException(&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"SPOOFED!!"&lt;/SPAN&gt;);&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//OK, STRONG NAME IS COOL, LETS RUN IT FURTHER&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #00b050; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin"&gt;In the world of&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin"&gt; &lt;A href="http://msdn2.microsoft.com/en-us/library/ms972370.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms972370.aspx"&gt;provider&amp;nbsp; design pattern&lt;/A&gt;&amp;nbsp;&lt;A href="http://www.dofactory.com/Patterns/PatternAbstract.aspx" mce_href="http://www.dofactory.com/Patterns/PatternAbstract.aspx"&gt;(abstract factory – GoF definition)&lt;/A&gt; &lt;STRONG&gt;&lt;SPAN style="COLOR: #00b050; FONT-FAMILY: 'Calibri','sans-serif'"&gt;where assemblies get loaded dynamically one should pay closer attention to this.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Enjoy&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1867215" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alikl/archive/tags/Test+Phase/default.aspx">Test Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Code+Inspection/default.aspx">Code Inspection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Reflection/default.aspx">Reflection</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Development+Phase/default.aspx">Development Phase</category><category domain="http://blogs.msdn.com/alikl/archive/tags/CAS/default.aspx">CAS</category><category domain="http://blogs.msdn.com/alikl/archive/tags/Implementation/default.aspx">Implementation</category></item></channel></rss>