<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Secure Code</title><link>http://cyberforge.com/weblog/aniltj/category/1.aspx</link><description>Secure Code</description><managingEditor>Anil John</managingEditor><dc:language>en-US</dc:language><generator>.Text Version 0.95.2004.102</generator><item><dc:creator>Anil John</dc:creator><title>This blog is moving! - New location http://www.aniltj.com/blog</title><link>http://cyberforge.com/weblog/aniltj/archive/2005/05/09/995.aspx</link><pubDate>Mon, 09 May 2005 18:03:00 GMT</pubDate><guid>http://cyberforge.com/weblog/aniltj/archive/2005/05/09/995.aspx</guid><description>&lt;P&gt;This blog is moving!&lt;/P&gt;
&lt;P&gt;New location &lt;A href="http://www.aniltj.com/blog"&gt;http://www.aniltj.com/blog&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;RSS Feed @ &lt;A href="http://www.aniltj.com/blog/SyndicationService.asmx/GetRss"&gt;http://www.aniltj.com/blog/SyndicationService.asmx/GetRss&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src ="http://cyberforge.com/weblog/aniltj/aggbug/995.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anil John</dc:creator><title>Upcoming Secure Coding Book by authors of Writing Secure Code!</title><link>http://cyberforge.com/weblog/aniltj/archive/2004/12/10/788.aspx</link><pubDate>Fri, 10 Dec 2004 22:42:00 GMT</pubDate><guid>http://cyberforge.com/weblog/aniltj/archive/2004/12/10/788.aspx</guid><description>&lt;p&gt;Came across an interesting comment on one of the lists that I am on.&amp;nbsp;&lt;/p&gt; &lt;p&gt;It would appear that Michael Howard and David LeBlanc, the authors of Writing Secure Code, are working on a new book with John Viega (Building Secure Software)&amp;nbsp;and David Wheeler which is scheduled to hit the shelves in about 6 months.&amp;nbsp; According to LeBlanc, they specifically chose this set of authors to provide really good cross-platform coverage.&lt;/p&gt; &lt;p&gt;Looks like&amp;nbsp;a must have book!&lt;/p&gt;&lt;img src ="http://cyberforge.com/weblog/aniltj/aggbug/788.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anil John</dc:creator><title>IEEE Security &amp; Privacy: Building Security In </title><link>http://cyberforge.com/weblog/aniltj/archive/2004/12/10/787.aspx</link><pubDate>Fri, 10 Dec 2004 22:30:00 GMT</pubDate><guid>http://cyberforge.com/weblog/aniltj/archive/2004/12/10/787.aspx</guid><description>&lt;p&gt;Gary McGraw has a series of articles in IEEE Security &amp;amp; Privacy that address secure coding issues. As a service to the community, he has made the articles available to the community. The current article in the series ".... is on Penetration Testing.&amp;nbsp; This article was co-authored by Brad Arkin (Symantec) and Scott Stender."&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Previous articles in the series:&lt;br /&gt; &lt;a href="http://www.cigital.com/papers/download/bsi5-static.pdf"&gt;http://www.cigital.com/papers/download/bsi5-static.pdf&lt;/a&gt;&lt;br /&gt; &lt;a href="http://www.cigital.com/papers/download/misuse-bp.pdf"&gt;http://www.cigital.com/papers/download/misuse-bp.pdf&lt;/a&gt;&lt;br /&gt; &lt;a href="http://www.cigital.com/papers/download/risk-analysis.pdf"&gt;http://www.cigital.com/papers/download/risk-analysis.pdf&lt;/a&gt;&lt;br /&gt; &lt;a href="http://www.cigital.com/papers/download/j2oth-qxd.pdf"&gt;http://www.cigital.com/papers/download/j2oth-qxd.pdf&lt;/a&gt;&lt;br /&gt; &lt;a href="http://www.cigital.com/papers/download/software-security-gem.pdf"&gt;http://www.cigital.com/papers/download/software-security-gem.pdf&lt;/a&gt;&lt;br /&gt; &lt;a href="http://www.cigital.com/papers/download/bsi6-pentest.pdf"&gt;http://www.cigital.com/papers/download/bsi6-pentest.pdf&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Check them out!&lt;/p&gt;&lt;img src ="http://cyberforge.com/weblog/aniltj/aggbug/787.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anil John</dc:creator><title>Presentation on Instrumenting .NET Code &amp; Defense-in-Depth </title><link>http://cyberforge.com/weblog/aniltj/archive/2004/12/07/781.aspx</link><pubDate>Tue, 07 Dec 2004 22:08:00 GMT</pubDate><guid>http://cyberforge.com/weblog/aniltj/archive/2004/12/07/781.aspx</guid><description>&lt;P&gt;I just got back from&amp;nbsp;the &lt;A href="http://www.cmap-online.org/"&gt;CMAP .NET User Group&lt;/A&gt; meeting during which I did 2 short presentations. At CMAP's December meetings we have a "10 Tips &amp;amp; Tricks for the Holidays" presentation format in which members do short 10-15 minute presentations on various topics. This year's topics ranged from my stuff to a demo of how to use client side script in ASP.NET.&amp;nbsp;&amp;nbsp;My topics were "Instrumenting .NET Code with &lt;A href="http://logging.apache.org/log4net/"&gt;Log4Net&lt;/A&gt;" and&amp;nbsp;"Applying Defense-in-Depth to protecting admin sections of web sites".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;During the instrumenting &amp;amp; logging presentation I mentioned that &lt;A href="http://odetocode.com/Blogs/scott/"&gt;K. Scott Allen&lt;/A&gt; has a &lt;A href="http://www.odetocode.com/Articles/294.aspx"&gt;great write-up on Diagnostics and Logging in ASP.NET&lt;/A&gt; and that people should check it out to get a background on the "Why?" regarding instrumenting applications. Then I went into a short description of what &lt;A href="http://logging.apache.org/log4net/"&gt;Log4Net&lt;/A&gt; brought to the table and compared it to the &lt;A title="" href="http://www.microsoft.com/resources/practices/" target=_blank&gt;PAG&lt;/A&gt;'s Exception Management Block and the Logging Block.&amp;nbsp; In addition, &lt;A href="http://cyberforge.com/weblog/aniltj/archive/2004/09/14/653.aspx"&gt;I also had an earlier blog entry about incorporating logging into a web application.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;My Defense-in-Depth short presentation was an expansion of an &lt;A href="http://cyberforge.com/weblog/aniltj/archive/2004/10/09/685.aspx"&gt;earlier blog entry that I had made on this topic&lt;/A&gt;.&lt;/P&gt;&lt;img src ="http://cyberforge.com/weblog/aniltj/aggbug/781.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anil John</dc:creator><title>Browsing the Web and Reading E-mail Safely as an Administrator</title><link>http://cyberforge.com/weblog/aniltj/archive/2004/11/19/758.aspx</link><pubDate>Fri, 19 Nov 2004 21:41:00 GMT</pubDate><guid>http://cyberforge.com/weblog/aniltj/archive/2004/11/19/758.aspx</guid><description>&lt;p&gt;&lt;!--StartFragment --&gt;Michael Howard discusses how you can run as an administrator and access Internet data safely by dropping unnecessary administrative privileges when using any tool to access the Internet.&lt;/p&gt; &lt;p&gt;He has created an application called &lt;em&gt;DropMyRights&lt;/em&gt; to help users who must run as an administrator run applications in a much-safer context&amp;mdash;that of a non-administrator. It does this by taking the current user's token, removing various privileges and SIDs from the token, and then using that token to start another process, such as Internet Explorer or Outlook. This tool works just as well with Mozilla's Firefox, Eudora, or Lotus Notes e-mail.&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn.microsoft.com/security/securecode/columns/default.aspx?pull=/library/en-us/dncode/html/secure11152004.asp"&gt;Check out the article...&lt;/a&gt;&lt;/p&gt;&lt;img src ="http://cyberforge.com/weblog/aniltj/aggbug/758.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anil John</dc:creator><title>Security focused Issues - TechNet Magazine &amp; MSDN Magazine</title><link>http://cyberforge.com/weblog/aniltj/archive/2004/10/30/741.aspx</link><pubDate>Sat, 30 Oct 2004 22:26:00 GMT</pubDate><guid>http://cyberforge.com/weblog/aniltj/archive/2004/10/30/741.aspx</guid><description>&lt;p&gt;The premier issue of TechNet Magazine is out and it is focused on Security. Sections include&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Hacking: Fight Back&lt;/li&gt; &lt;li&gt;Cross-Platform Security&lt;/li&gt; &lt;li&gt;Security: Beyond the Basics&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/technet/technetmag/"&gt;Check it out the full issue which is availabe for free online&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Of course, the current issue of MSDN Magazine is also focused on security. Topics include Attack Surface minimization, App Lockdown, Crypto and more. &lt;a href="http://msdn.microsoft.com/msdnmag/"&gt;Check it out online as well.&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src ="http://cyberforge.com/weblog/aniltj/aggbug/741.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anil John</dc:creator><title>Using Secret Questions &amp; Blocking Brute Force Attacks</title><link>http://cyberforge.com/weblog/aniltj/archive/2004/10/24/703.aspx</link><pubDate>Sun, 24 Oct 2004 20:33:00 GMT</pubDate><guid>http://cyberforge.com/weblog/aniltj/archive/2004/10/24/703.aspx</guid><description>&lt;p&gt;Mark Burnett, who is the author of "Hacking the Code",&amp;nbsp;has a couple of great articles posted to the &lt;a href="http://www.owasp.org/"&gt;OWASP&lt;/a&gt; site.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.owasp.org/columns/mburnett/questions.html"&gt;Using Secret Question to recover passwords&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.owasp.org/columns/mburnett/brutegeneral.html"&gt;Blocking Brute Force Attacks&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;div&gt;Both are must read articles!&lt;/div&gt; &lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;img src ="http://cyberforge.com/weblog/aniltj/aggbug/703.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anil John</dc:creator><title>Password Memorability and Security</title><link>http://cyberforge.com/weblog/aniltj/archive/2004/10/14/689.aspx</link><pubDate>Thu, 14 Oct 2004 19:24:00 GMT</pubDate><guid>http://cyberforge.com/weblog/aniltj/archive/2004/10/14/689.aspx</guid><description>&lt;P&gt;There has been much talk about what is considered a secure password. So it was a true pleasure for me to recently read a fascinating study on this topic that provided some hard numbers to back up the claims.&lt;FONT color=#0000ff&gt;&amp;nbsp;&lt;/FONT&gt; The study was published in the current issue of IEEE Security and Privacy and is titled "Password Memorability and Security: Empirical Results" by Jeff Yan, Alan Blackwell, Ross Anderson and Alasdair Grant.&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;First some background. Per the article "Human memory for sequences is temporally limited, with a short term capacity of around seven, plus or minus two items. In addition, when humans do remember a sequence of items, those items be familiar chunks such as words or familiar symbols. Finally, human memory thrives on redundancy-we're much better at remembering information we can encode in multiple ways"&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;So what these folks did was have three separate test&amp;nbsp;groups:&lt;/P&gt;
&lt;DIV dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;UL&gt;
&lt;LI&gt;The control group were asked to choose a seven-character password with at least one nonletter 
&lt;LI&gt;Second group chose passwords by closing their eyes and pointing randomly to a grid of numbers and letters 
&lt;LI&gt;The third group was instructed to chose passwords based on mnemonic phrases and given examples of how to go about doing so&lt;BR&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;
&lt;P&gt;Then the testers ran the following types of attacks against the passwords:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Dictionary attacks: Simply use different dictionary files to crack the passwords 
&lt;LI&gt;Permutation of words and numbers: For each word from a dictionary file, permute with 0, 1, 2 and 3 digits and also use common number substitutions such as 1 for an I and 5 for S etc. 
&lt;LI&gt;User information attacks: Exploit user data that is collected from password files such as userid, full name etc 
&lt;LI&gt;They also tried brute force attacks (Try all possible combination of keys) against passwords 6 characters long.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Pick up and read the article itself for the details and the numbers, but the conclusions are interesting. The permuted dictionary attack was the most successful and the brute force attack successfully cracked all six-character passwords.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;They also confirmed the two folk beliefs that "... user have difficulty remembering random passwords and that passwords based on mnemonic phrases are harder to guess than naively selected passwords." They have also debunked the folk beliefs that "... random passwords are better than passwords based on mnemonic phrases. Each appeared to be as strong as the other" and that "... passwords based on mnemonic phrases are harder to remember than naively selected passwords. In fact, each type is as easy to remember as the other".&lt;/P&gt;
&lt;P&gt;Some of the key take-aways were:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&amp;nbsp;"... security can be significantly improved by educating users to select mnemonic passwords 
&lt;LI&gt;Size of the password matters 
&lt;LI&gt;Entropy per character matters, so instruct users to choose passwords containing numbers and special characters as well as letters."&lt;BR&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;So what does this mean for me?&amp;nbsp; Well from now on, my password selection page is going to have the following (Some of the content is adapted from the directions that were given to the mnemonic group in the test):&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="LIST-STYLE-TYPE: none"&gt;
&lt;P&gt;Choosing a good password is critical to maintaining the security of this system. To construct a good password, create a simple sentence of 8 to 9 words and choose letters from the words to make up a password. You might take the initial or final letters; you should put some letters in upper case to make the password harder to guess; and at least one number and special character should be inserted as well.&amp;nbsp; An example is the phrase "It's 12 noon and I am hungry" which can be used to create the password "I's12n&amp;amp;Iah".&amp;nbsp; All passwords will be checked to make sure that the following complexity requirements are met:&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Must be&amp;nbsp;at least 9 characters 
&lt;LI&gt;Must contain at least one&amp;nbsp;lower case letter, one upper case letter, one digit and one special character 
&lt;LI&gt;Valid special characters are -&amp;nbsp;&amp;nbsp; @#'$%^&amp;amp;+=&lt;BR&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;DIV&gt;The key point here is not to just to show them the 3 above bullet items but to provide explicit guidance on how a password should be chosen to meet the outlined complexity criteria.&lt;/DIV&gt;
&lt;P&gt;Oh yes, as a bonus here is a regex that will enforce the above complexity requirement:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;^.*(?=.{9,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#'$%^&amp;amp;+=]).*$&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr&gt;&amp;nbsp;&lt;/P&gt;&lt;img src ="http://cyberforge.com/weblog/aniltj/aggbug/689.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anil John</dc:creator><title>Authentication/Authorization and Defense in Depth</title><link>http://cyberforge.com/weblog/aniltj/archive/2004/10/09/685.aspx</link><pubDate>Sat, 09 Oct 2004 17:39:00 GMT</pubDate><guid>http://cyberforge.com/weblog/aniltj/archive/2004/10/09/685.aspx</guid><description>&lt;P&gt;It has been interesting to me to see the recent ASP.NET vulnerability play out.&amp;nbsp;&amp;nbsp;One of the main factors that came into focus for me was that most developers do not seem to consider the principal of Defense in Depth when it comes to writing privileged code.&lt;/P&gt;
&lt;P&gt;Since an example speaks much louder than lectures, lets take the following case..&lt;/P&gt;
&lt;P&gt;My web site is as follows:&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;\webroot&lt;BR&gt;&amp;nbsp;- web.config&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;\Camelot&lt;BR&gt;&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; - ProtectedPage.aspx&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;My web.config has the following:&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;location&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;path&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Camelot"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;system.web&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;authorization&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;allow&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;roles&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="KnightsRoundTable"&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;/&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;deny&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;users&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="*"&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;/&amp;gt;&lt;/FONT&gt;&amp;nbsp;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/&lt; font&gt;&lt;FONT color=#800000&gt;authorization&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/&lt; font&gt;&lt;FONT color=#800000&gt;system.web&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&lt;/&lt; font&gt;&lt;FONT color=#800000&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;location&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;As you can see above, the web application is configured such that the only users who have access to the protected directory "Camelot" are members of the group "KnightsRoundTable".&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;The problem is that most people leave it at that.. &lt;STRONG&gt;That is NOT Enough!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;At this point you are basically&amp;nbsp;exposed when your authorization module is somehow bypassed. So let us take a look at some things you can do to apply the principle of Defense in Depth to ProtectedPage.aspx.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;&lt;STRONG&gt;1) Restrict which users can call your code&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;One of the easiest ways to do this is to annotate your classes and methods with declarative principal permission demands to control which users can call your classes and class members. In the above example, I would do the following:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;[System.Security.Permissions.PrincipalPermission&lt;BR&gt;(System.Security.Permissions.SecurityAction.Demand,Role=@"KnightsRoundTable")]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;public class&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;ProtectedPage: System.Web.UI.Page&lt;BR&gt;{&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;If anyone who is not in the KnightsRoundTable group tries to call this page, they will get the following error:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;Security Exception&lt;BR&gt;Exception Details: System.Security.SecurityException: Request for principal permission failed.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;And if you've done right thing and set up a &lt;CUSTOMERRORS&gt;Default Redirect page for errors, they will not get a stack trace and will be redirected to a generic error page.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;&lt;STRONG&gt;2) Protect against spoofed post backs.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;void Page_Init (Object sender, EventArgs e)&lt;BR&gt;{&lt;BR&gt;&lt;SPAN class=484020021-09102004&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; if (User.Identity.IsAuthenticated)&lt;BR&gt;&lt;SPAN class=484020021-09102004&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; ViewStateUserKey = User.Identity.Name;&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;What this does is&amp;nbsp;key the view state to an individual using a unique value of your choice.&amp;nbsp; This option, which is&amp;nbsp;only available in ASP.NET 1.1, is the Page.ViewStateUserKey. This needs to be applied in Page_Init because the key has to be provided to ASP.NET before view state is loaded.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;&lt;STRONG&gt;3) Redirect if user is not authenticated&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;The third thing that I do in a protected page simply make sure that a user is authenticated before they are allowed to view any content.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;private void Page_Load(object sender, System.EventArgs e)&lt;BR&gt;{&lt;BR&gt;&lt;SPAN class=484020021-09102004&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; if (!User.Identity.IsAuthenticated)&lt;BR&gt;&lt;SPAN class=484020021-09102004&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; Response.Redirect("~/&lt;SPAN class=484020021-09102004&gt;GoodBye&lt;/SPAN&gt;.aspx",true);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=484020021-09102004&gt;&lt;FONT color=#000000&gt;The key point here is that I am not simply depending on just one thing here to protect this page but a layered defense. Hopefully if one thing fails, the others will protect the page.&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=484020021-09102004&gt;&lt;FONT color=#000000&gt;Oh, did I mention that I also extensively instrument my applications such that when someone does try to access a protected page, I log that activity and if the content of that page is sensitive enough, I may also send real time notification of attempted break-ins to an admin?&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=484020021-09102004&gt;&lt;FONT color=#000000&gt;Paranoid? Perhaps.&amp;nbsp;&amp;nbsp;But I also sleep a whole lot more soundly :-)&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;img src ="http://cyberforge.com/weblog/aniltj/aggbug/685.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Anil John</dc:creator><title>Enforcing Password Complexity</title><link>http://cyberforge.com/weblog/aniltj/archive/2004/09/23/670.aspx</link><pubDate>Thu, 23 Sep 2004 22:18:00 GMT</pubDate><guid>http://cyberforge.com/weblog/aniltj/archive/2004/09/23/670.aspx</guid><description>&lt;p&gt;There has been some discussion of late about passwords vs. pass phrases and how long a password should be. I won't add to the mix except to say that I am a believer when it comes to complex passwords. Heck, my 4 year old is required to use a userid and password to log into his session on his computer :-)&lt;/p&gt; &lt;p&gt;I've recently been working on some things that require me to make sure that the passwords that&amp;nbsp;are used&amp;nbsp;are sufficiently complex.&amp;nbsp; Here is what I am using right now:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Must be&amp;nbsp;at least 10 characters&lt;/li&gt; &lt;li&gt;Must contain at least one&amp;nbsp;one lower case letter, one upper case letter, one digit and one special character&lt;/li&gt; &lt;li&gt;Valid special characters are -&amp;nbsp;&amp;nbsp;&lt;!--StartFragment --&gt; @#$%^&amp;amp;+=&lt;/li&gt;&lt;/ul&gt; &lt;div&gt;The regex that I am using to enforce this is:&lt;/div&gt; &lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt; &lt;div&gt;^.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&amp;amp;+=]).*$&lt;/div&gt; &lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;/blockquote&gt; &lt;div dir="ltr"&gt;As you can see in the regex, the list of special characters is configurable...&lt;/div&gt; &lt;div dir="ltr"&gt;&amp;nbsp;&lt;/div&gt;&lt;img src ="http://cyberforge.com/weblog/aniltj/aggbug/670.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>