<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://keepitlocked.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">KeepItLocked.net</title><subtitle type="html" /><id>http://keepitlocked.net/atom.aspx</id><link rel="alternate" type="text/html" href="http://keepitlocked.net/default.aspx" /><link rel="self" type="application/atom+xml" href="http://keepitlocked.net/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20611.960">Community Server</generator><updated>2007-10-08T13:41:31Z</updated><entry><title>Giving the OWASP .NET ESAPI a Second Look</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx" /><id>http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx</id><published>2008-09-10T01:20:00Z</published><updated>2008-09-10T01:20:00Z</updated><content type="html">&lt;p&gt;I've started up work again on the &lt;a href="https://www.owasp.org/index.php/.NET_ESAPI" mce_href="https://www.owasp.org/index.php/.NET_ESAPI"&gt;OWASP .NET ESAPI&lt;/a&gt;. Since a few months ago, when I translated the &lt;a href="http://www.owasp.org/index.php/ESAPI" mce_href="http://www.owasp.org/index.php/ESAPI"&gt;OWASP ESAPI&lt;/a&gt; from Java to C#, I've decided to change course a bit.
&lt;/p&gt;&lt;p&gt;Java and .NET are architecturally and semantically similar - a lot of the direct code translation I did could be automated. But they are drastically different platforms. ASP.NET has a lot more security functionality built-in around authentication, authorization, and user management (&lt;a href="http://msdn.microsoft.com/en-us/library/aa480476.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa480476.aspx"&gt;Forms Authentication&lt;/a&gt;, the &lt;a href="http://msdn.microsoft.com/en-us/library/ms998314.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms998314.aspx"&gt;RoleManager&lt;/a&gt;, and the &lt;a href="http://msdn.microsoft.com/en-us/library/ms998347.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms998347.aspx"&gt;Membership API&lt;/a&gt;, respectively). Including a whole new user model makes sense in the Java ESAPI because JEE doesn't give you APIs for the typical web site security architecture. ASP.NET does, and so re-inventing the wheel has become low priority.
&lt;/p&gt;&lt;p&gt;Instead, I am going to focus on what I think will be helpful to ASP.NET developers. The .NET ESAPI will continue to mirror the Java ESAPI. But I'd like to spend my time extending rather than aligning, because there are some big opportunities to improve ASP.NET security. 
&lt;/p&gt;&lt;p&gt;Here's a list of things I'd like to build:
&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Web Controls that can validate and encode data. Web controls are central to ASP.NET (at least pre-MVC). &lt;a href="http://msdn.microsoft.com/en-us/library/aa310913.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa310913.aspx"&gt;ValidatorControls&lt;/a&gt; can be attached to most regular controls – why combine them into a "SecureControl"? While we're at it, let's make it easy by solving some common validation problems through regular expressions. Also, it's a shame that we still haven't addressed data encoding issues more cleanly than &lt;a href="http://blogs.msdn.com/sfaust/attachment/8918996.ashx" mce_href="http://blogs.msdn.com/sfaust/attachment/8918996.ashx"&gt;this&lt;/a&gt;. Integrate &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EFB9C819-53FF-4F82-BFAF-E11625130C25&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EFB9C819-53FF-4F82-BFAF-E11625130C25&amp;amp;displaylang=en"&gt;AntiXss&lt;/a&gt; and &lt;a href="http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project_.NET" mce_href="http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project_.NET"&gt;AntiSamy.NET&lt;/a&gt; into the control output!
&lt;/li&gt;&lt;li&gt;A &lt;a href="http://en.wikipedia.org/wiki/Web.config" mce_href="http://en.wikipedia.org/wiki/Web.config"&gt;web.config&lt;/a&gt; file that contains default secure settings, with directions and discussion of risk. This could replace the default web.config file.
&lt;/li&gt;&lt;li&gt;Cross-site request forgery prevention. &lt;a href="http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx" mce_href="http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx"&gt;ViewStateUserKey&lt;/a&gt; isn't enough – perhaps use &lt;a href="https://www.owasp.org/index.php/.Net_CSRF_Guard" mce_href="https://www.owasp.org/index.php/.Net_CSRF_Guard"&gt;.NET CSRF Guard&lt;/a&gt;.
&lt;/li&gt;&lt;li&gt;Fix the default ASPNETSESSIONID session cookie to support &lt;a href="http://keepitlocked.net/archive/2007/12/26/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx" mce_href="http://keepitlocked.net/archive/2007/12/26/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx"&gt;regeneration&lt;/a&gt; and the secure property. Find out how to uproot the plumbing and make it seamless for everyone else.
&lt;/li&gt;&lt;li&gt;Several other small fixes and gotchas that I'm sure I'll think of after I hit publish.
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I'd also like to polish some things that already exist:
&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Make horizontal and vertical authorization rules easy to integrate into any application. How about instrumenting reads and writes in data-bound controls with authorization checks?
&lt;/li&gt;&lt;li&gt;Make a simple cryptography library for .NET. It must be possible, but I still haven't seen it. Let the user worry about a password, and securing that – the library does everything else.
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Some things I won't be looking into anytime soon:
&lt;/p&gt;&lt;ul&gt;&lt;li&gt;A new user model for ASP.NET for performing authentication and authorization. See above.
&lt;/li&gt;&lt;li&gt;Error handling, logging, exception management. See the &lt;a href="http://www.codeplex.com/entlib" mce_href="http://www.codeplex.com/entlib"&gt;Enterprise Library&lt;/a&gt;.
&lt;/li&gt;&lt;li&gt;The implementation of encoding for different contexts. See &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EFB9C819-53FF-4F82-BFAF-E11625130C25&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EFB9C819-53FF-4F82-BFAF-E11625130C25&amp;amp;displaylang=en"&gt;AntiXss&lt;/a&gt; and &lt;a href="http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project_.NET" mce_href="http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project_.NET"&gt;AntiSamy.NET&lt;/a&gt; &lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Overall, I'm hoping to solve problems rather than follow a spec. The OWASP ESAPI is great and growing, and I think it's time that the OWASP .NET ESAPI do the same. &lt;br&gt;&lt;/p&gt;&lt;p&gt;I'll be travelling to various OWASP Chapters in the next two months (&lt;a href="http://www.owasp.org/index.php/Columbus" mce_href="http://www.owasp.org/index.php/Columbus"&gt;Columbus&lt;/a&gt;, &lt;a href="http://www.owasp.org/index.php/Buffalo" mce_href="http://www.owasp.org/index.php/Buffalo"&gt;Buffalo&lt;/a&gt;, &lt;a href="http://www.owasp.org/index.php/Denver" mce_href="http://www.owasp.org/index.php/Denver"&gt;Denver&lt;/a&gt;, &lt;a href="http://www.owasp.org/index.php/Boulder" mce_href="http://www.owasp.org/index.php/Boulder"&gt;Boulder&lt;/a&gt;) to talk about the OWASP .NET ESAPI project. Hopefully I can drum up some support so that we can get some great ideas and the great minds to build them. If you reading and are interested in helping or have some feedback, please leave a comment and let me know.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx&amp;amp;;subject=Giving+the+OWASP+.NET+ESAPI+a+Second+Look" target="_blank" title = "Post http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx&amp;amp;;title=Giving+the+OWASP+.NET+ESAPI+a+Second+Look" target="_blank" title = "Post http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx&amp;amp;title=Giving+the+OWASP+.NET+ESAPI+a+Second+Look" target="_blank" title = "Post http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx&amp;amp;;title=Giving+the+OWASP+.NET+ESAPI+a+Second+Look" target="_blank" title = "Post http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx&amp;amp;;title=Giving+the+OWASP+.NET+ESAPI+a+Second+Look&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=34" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>Input Validation Isn’t For Wimps</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx" /><id>http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx</id><published>2008-08-26T20:02:00Z</published><updated>2008-08-26T20:02:00Z</updated><content type="html">&lt;p class="MsoNormal"&gt;There’s an axiom in the appsec community - “all input is
evil”. Every piece of data sent by the user may be teeming with virulent host
compromising attacks, and that you better validate ANY and ALL user-modifiable parameters
or your computer will explode in a mushroom cloud of buffer overflows.&lt;/p&gt;

&lt;p class="MsoNormal"&gt;There's a common misstep that people make when figuring
out how to fix these issues.&lt;/p&gt;

&lt;p class="MsoNormal"&gt;“Is there a method I can use to validate all my data coming
in?”&lt;/p&gt;

&lt;p class="MsoNormal"&gt;Well, it turns out that you can’t. Sorry. Each piece of data
needs to be validated separately. &lt;/p&gt;

&lt;p class="MsoNormal"&gt;Phone numbers need to look like phone numbers, usernames
need to look like usernames, uploaded images need to look like uploaded images,
and there isn’t any method out there that’s “one size fits all”.&lt;/p&gt;



&lt;p&gt;Input validation isn’t for wimps.&lt;b&gt;&lt;a onclick="bypassCheck();" href='BLOCKED SCRIPTWebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl00$OuterTaskRegion$TaskRegion$Editor1$PostButton", "", true, "", "", false, true))' id="ctl00_ctl00_OuterTaskRegion_TaskRegion_Editor1_PostButton" class="CommonTextButtonBig"&gt;&lt;br&gt;&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx&amp;amp;;subject=Input+Validation+Isn%e2%80%99t+For+Wimps" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx&amp;amp;;title=Input+Validation+Isn%e2%80%99t+For+Wimps" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx&amp;amp;title=Input+Validation+Isn%e2%80%99t+For+Wimps" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx&amp;amp;;title=Input+Validation+Isn%e2%80%99t+For+Wimps" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx&amp;amp;;title=Input+Validation+Isn%e2%80%99t+For+Wimps&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/26/input-validation-isn-t-for-wimps.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=33" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author><category term="Input Validation" scheme="http://keepitlocked.net/archive/tags/Input+Validation/default.aspx" /></entry><entry><title>Managing Secure Software: From Concept to Maintenance</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx" /><id>http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx</id><published>2008-08-20T01:45:20Z</published><updated>2008-08-20T01:45:20Z</updated><content type="html">&lt;p&gt;Rudy and I did a Fishbowl Talk at TechEd, where we spoke extemporaneously about whatever was on our mind that week. Check it out &lt;a href="http://mfile.akamai.com/14853/wmv/microsofttec.download.akamai.com/14853/TechEdOnline/Videos/08_NA_ITP_techtalk_121_low.asx"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx&amp;amp;;subject=Managing+Secure+Software%3a+From+Concept+to+Maintenance" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx&amp;amp;;title=Managing+Secure+Software%3a+From+Concept+to+Maintenance" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx&amp;amp;title=Managing+Secure+Software%3a+From+Concept+to+Maintenance" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx&amp;amp;;title=Managing+Secure+Software%3a+From+Concept+to+Maintenance" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx&amp;amp;;title=Managing+Secure+Software%3a+From+Concept+to+Maintenance&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/19/managing-secure-software-from-concept-to-maintenance.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=31" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>Is It That Easy to Get Hacked?</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx" /><id>http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx</id><published>2008-08-14T00:50:54Z</published><updated>2008-08-14T00:50:54Z</updated><content type="html">&lt;p&gt;Self-proclaimed "alpha-geekess" and all around nice person Rachel Appel has given me a virtual shout-out on her blog.
&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.rachelappel.com/2008/07/17/YesItrsquosThatEasyToGetHacked.aspx"&gt;http://www.rachelappel.com/2008/07/17/YesItrsquosThatEasyToGetHacked.aspx&lt;/a&gt;
	&lt;/p&gt;&lt;p&gt;I guess &lt;a href="http://blogs.technet.com/tnspot/archive/2008/07/07/technet-spotlight-on-demand-video-alex-smolen-rudolph-araujo.aspx"&gt;our presentation at TechEd&lt;/a&gt; was good enough to get me labeled as a "security expert" whose screencast needs to be watched by "every single developer &lt;em&gt;and&lt;/em&gt; every sys admin". Thanks Rachel!&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx&amp;amp;;subject=Is+It+That+Easy+to+Get+Hacked%3f" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx&amp;amp;;title=Is+It+That+Easy+to+Get+Hacked%3f" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx&amp;amp;title=Is+It+That+Easy+to+Get+Hacked%3f" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx&amp;amp;;title=Is+It+That+Easy+to+Get+Hacked%3f" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx&amp;amp;;title=Is+It+That+Easy+to+Get+Hacked%3f&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2008/08/13/is-it-that-easy-to-get-hacked.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=30" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>"The Spy Who Hacked Me" - TechEd 2008 Demo</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx" /><id>http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx</id><published>2008-06-17T15:51:00Z</published><updated>2008-06-17T15:51:00Z</updated><content type="html">
&lt;p&gt;Since my demo at TechEd was besmirched with a few technical difficulties, I decided to record a screencast and post it to my blog. Enjoy!&lt;br&gt;&lt;br&gt;&lt;/p&gt;
&lt;div align="center"&gt;
&lt;a href="http://keepitlocked.net/Screencasts/TechEd.swf" style="left: 577px ! important; top: 0px ! important;" title="Click here to block this object with Adblock Plus" class="abp-objtab-08165914794378436 visible ontop"&gt;&lt;/a&gt;&lt;a href="http://keepitlocked.net/Screencasts/TechEd.swf" style="left: 577px ! important; top: 0px ! important;" title="Click here to block this object with Adblock Plus" class="abp-objtab-08165914794378436 visible ontop"&gt;&lt;/a&gt;&lt;object id="csSWF" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://active.macromedia.com/flash7/cabs/ swflash.cab#version=9,0,28,0" height="318" width="400"&gt;
                
&lt;param name="src" value="http://keepitlocked.net/Screencasts/TechEd.swf"&gt;
                
&lt;param name="bgcolor" value="#1a1a1a"&gt;
                
&lt;param name="quality" value="best"&gt;
                
&lt;param name="allowScriptAccess" value="always"&gt;
                
&lt;param name="allowFullScreen" value="false"&gt;
                
&lt;param name="scale" value="noscale"&gt;
                
&lt;param name="flashVars" value="autostart=false"&gt;
                
&lt;embed src="http://keepitlocked.net/Screencasts/TechEd.swf" name="csSWF" mce_src="TechEd.swf" bgcolor="#1a1a1a" quality="best" allowscriptaccess="always" allowfullscreen="false" scale="noscale" flashvars="autostart=false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" height="318" width="400"&gt;
            &lt;/object&gt;
&lt;/div&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx&amp;amp;;subject=%26quot%3bThe+Spy+Who+Hacked+Me%26quot%3b+-+TechEd+2008+Demo" target="_blank" title = "Post http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx&amp;amp;;title=%26quot%3bThe+Spy+Who+Hacked+Me%26quot%3b+-+TechEd+2008+Demo" target="_blank" title = "Post http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx&amp;amp;title=%26quot%3bThe+Spy+Who+Hacked+Me%26quot%3b+-+TechEd+2008+Demo" target="_blank" title = "Post http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx&amp;amp;;title=%26quot%3bThe+Spy+Who+Hacked+Me%26quot%3b+-+TechEd+2008+Demo" target="_blank" title = "Post http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx&amp;amp;;title=%26quot%3bThe+Spy+Who+Hacked+Me%26quot%3b+-+TechEd+2008+Demo&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2008/06/17/quot-the-spy-who-hacked-me-quot-teched-2008-demo.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=29" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>ViewStateUserKey Doesn’t Prevent Cross-Site Request Forgery</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx" /><id>http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx</id><published>2008-05-29T21:30:07Z</published><updated>2008-05-29T21:30:07Z</updated><content type="html">&lt;p&gt;ViewStateUserKey is not a completely effective mitigation against Cross-Site Request Forgery. It doesn't work for non post-backs (I.e. GET requests), and it doesn't work if the ViewState MAC is turned off.
&lt;/p&gt;&lt;p&gt;In &lt;a href="http://msdn.microsoft.com/en-us/library/ms972969.aspx"&gt;several&lt;/a&gt;
		&lt;a href="http://www.guidanceshare.com/wiki/ASP.NET_2.0_Security_Guidelines_-_Parameter_Manipulation"&gt;different&lt;/a&gt;
		&lt;a href="http://channel9.msdn.com/wiki/default.aspx/Channel9.ASPNETSecurityGuidelines"&gt;places&lt;/a&gt;, we see a piece of advice repeated - use the ViewStateUserKey property to prevent One-Click Attacks. Often, this piece of advice is accompanied by the following code:
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;span style="color:blue"&gt;void&lt;/span&gt; Page_Init(&lt;span style="color:blue"&gt;object&lt;/span&gt; sender, &lt;span style="color:teal"&gt;EventArgs&lt;/span&gt; e)
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;    {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;        ViewStateUserKey = Session.SessionID;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;    }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;What exactly does this code do? To understand it, we first need to look at the ViewState mechanism itself. The ViewState is an ASP.NET mechanism used to persist the value of web controls between post-backs. This allows a lot of the drag and drop, UI-driven ASP.NET architecture to function "auto-magically" by serializing and de-serializing data automatically on the fly.
&lt;/p&gt;&lt;p&gt;The ViewState is encoded and stored as a hidden field. This introduces security issues, because the value is under the control of the client. There may be a value stored in a field that you do not want someone to see and modify, like an admin-only control with the visible property set to false.
&lt;/p&gt;&lt;p&gt;ASP.NET helps us out by introducing two mechanisms to help protect the ViewState. ViewState MAC prevents tampering with the ViewState by introducing a separate Message Authentication Code that is verified when the ViewState is submitted. ViewState Encryption protects the ViewState confidentially by encrypting the ViewState value. By default, the ViewState MAC is enabled, and ViewState Encryption is not.
&lt;/p&gt;&lt;p&gt;The ViewStateUserKey property is an optional addition to the data used in ViewState MAC calculation. If that value changes between post-backs, the ViewState MAC calculation will fail and the page will cause an error.
&lt;/p&gt;&lt;p&gt;When we set the value of ViewStateUserKey to something associated with a particular user (like a Session ID or a Username), we are making sure that the ViewState is valid &lt;em&gt;only for that user.&lt;/em&gt;
	&lt;/p&gt;&lt;p&gt;Back to One-Click Attacks. One-Click Attack is sometimes incorrectly referred to as Microsoft's name for Cross-Site Request Forgery. However, this is not entirely correct.
&lt;/p&gt;&lt;p&gt;One-Click Attacks refer to CSRF attacks that use a malicious ViewState to perform the request. Because web forms developed with ASP.NET use ViewState for post-backs, the attacker can perform the post-back they want the user to perform unknowingly, and record the ViewState. Due to the way that ASP.NET ignores HTTP verbs when using &lt;span style="font-family:Courier New"&gt;Request.Params&lt;/span&gt; versus &lt;span style="font-family:Courier New"&gt;Request.Form&lt;/span&gt;, and in web controls, this request can often be made via GET.
&lt;/p&gt;&lt;p&gt;Example:
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New"&gt;http://site/Default.aspx?__VIEWSTATE=%2FwEPDwULLTExOTcyMDExODNkZAShpi32DKvqCd4uvHuQ%2FmmnBcdY&amp;amp;TextBox1=&lt;span style="color:red"&gt;&lt;strong&gt;&amp;lt;MALICIOUS_CONTROL_DATA_GOES_HERE&amp;gt;&lt;/strong&gt;&lt;/span&gt;&amp;amp;Button1=Button&amp;amp;__EVENTVALIDATION=%2FwEWAwKEyYGZBwLs0bLrBgKM54rG3sCHijug9ibUUfHX808cCvcppg1i
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This link can be used in a CSRF attack. It is then known as a one-click attack, because it uses the ViewState. This, however, is not:
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New"&gt;http://site/DeleteUser.aspx?user_id=123456789
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;If the page is not a post-back (as in the case of a direct link), the ViewState MAC is never checked. Several ASP.NET applications allow you to modify data without submitting a form. Consider &lt;a href="http://www.asp.net/mvc/"&gt;ASP.NET MVC&lt;/a&gt; - it doesn't even use post-backs.
&lt;/p&gt;&lt;p&gt;Furthermore, the ViewState MAC can be disabled at the page level:
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;&lt;span style="background-color:yellow"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue"&gt;@&lt;/span&gt;
			&lt;span style="color:maroon"&gt;Page&lt;/span&gt;
			&lt;span style="color:red"&gt;Language&lt;/span&gt;&lt;span style="color:blue"&gt;="C#"&lt;/span&gt;
			&lt;span style="color:red"&gt;EnableViewStateMac&lt;/span&gt;&lt;span style="color:blue"&gt;="false"&lt;/span&gt;&lt;span style="background-color:yellow"&gt;%&amp;gt;&lt;/span&gt;
		&lt;/span&gt;&lt;/p&gt;&lt;p&gt;or in &lt;span style="font-family:Courier New"&gt;web.config&lt;/span&gt;.:
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;&lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:maroon"&gt;pages&lt;/span&gt;&lt;span style="color:blue"&gt;
			&lt;/span&gt;&lt;span style="color:red"&gt;enableViewStateMac&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;"&lt;span style="color:blue"&gt;false&lt;/span&gt;"&lt;span style="color:blue"&gt;&amp;gt;      
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;&lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:maroon"&gt;pages&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;ViewState MAC is often disabled for (perceived) performance reason, or (more likely) if there is some functionality in the application that causes the ViewState MAC to cause error.
&lt;/p&gt;&lt;p&gt;This reminds of &lt;a href="http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx"&gt;problems with Request Validation is ASP.NET&lt;/a&gt; - the mechanism works, sometimes. This can be dangerous, because people rely on it and can get burned. The solution is to write something similar to&lt;a href="http://www.owasp.org/index.php/Category:OWASP_CSRFGuard_Project"&gt; CSRFGuard&lt;/a&gt; from &lt;a href="http://www.owasp.org/index.php/Main_Page"&gt;OWASP&lt;/a&gt; in .NET. I have a feeling that the newly resurgent &lt;a href="http://www.owasp.org/index.php/Category:OWASP_.NET_Project"&gt;OWASP .NET project&lt;/a&gt; will add this to their to-do list.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx&amp;amp;;subject=ViewStateUserKey+Doesn%e2%80%99t+Prevent+Cross-Site+Request+Forgery" target="_blank" title = "Post http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx&amp;amp;;title=ViewStateUserKey+Doesn%e2%80%99t+Prevent+Cross-Site+Request+Forgery" target="_blank" title = "Post http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx&amp;amp;title=ViewStateUserKey+Doesn%e2%80%99t+Prevent+Cross-Site+Request+Forgery" target="_blank" title = "Post http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx&amp;amp;;title=ViewStateUserKey+Doesn%e2%80%99t+Prevent+Cross-Site+Request+Forgery" target="_blank" title = "Post http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx&amp;amp;;title=ViewStateUserKey+Doesn%e2%80%99t+Prevent+Cross-Site+Request+Forgery&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2008/05/29/viewstateuserkey-doesn-t-prevent-cross-site-request-forgery.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=26" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>Developing ASP.NET in Partial Trust</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx" /><id>http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx</id><published>2008-04-11T22:20:00Z</published><updated>2008-04-11T22:20:00Z</updated><content type="html">&lt;p&gt;Recently I developed a lab for our Writing Secure Code – ASP.NET training course where students modify Hacme Bank to run in Partial Trust rather than Full Trust.
&lt;/p&gt;

&lt;p&gt;A lot has been written about Partial Trust. It's not going to solve every security problem, but it's a smart thing to do. I wanted to show students that it was easy to take an existing application and get it to run with only the privileges it needed.
&lt;/p&gt;

&lt;p&gt;Turns out, there is more than one way to skin a cat. And, depending on your architecture, you may be spinning your wheels needlessly, as I learned the hard way.
&lt;/p&gt;

&lt;p&gt;Hacme Bank is based on the older &lt;span style="font-family: Courier New;"&gt;.asmx&lt;/span&gt; web service architecture, with the web front-end calling a service layer, which calls the database.
&lt;/p&gt;

&lt;p&gt;If we configure the site to run in the default Medium Trust level, it does not have access to the Hacme Bank web service (a &lt;span style="font-family: Courier New;"&gt;WebPermission&lt;/span&gt; error is thrown).
&lt;/p&gt;

&lt;p&gt;After a few hours of tinkering, reading, debugging, and throwing my innocent wireless mouse across the room (my preferred method of stress management), I discovered a couple of different methods that I could use to get this working. Thanks to &lt;a href="http://www.leastprivilege.com/" mce_href="http://www.leastprivilege.com/"&gt;Dominick Baier&lt;/a&gt; and &lt;a href="http://www.codesecurely.org" mce_href="http://www.codesecurely.org"&gt;Rudolph Araujo&lt;/a&gt; for seeding the clouds of this brainstorm.
&lt;/p&gt;

&lt;p&gt;The four options are:
&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set the &lt;span style="font-family: Courier New;"&gt;originUrl&lt;/span&gt; attribute in the &lt;span style="font-family: Courier New;"&gt;trust&lt;/span&gt; element of the &lt;span style="font-family: Courier New;"&gt;web.config&lt;/span&gt; file
&lt;/li&gt;

&lt;li&gt;Create a new custom trust level
&lt;/li&gt;

&lt;li&gt;Partition the privileged code into an assembly and install in the Global Assembly Cache
&lt;/li&gt;

&lt;li&gt;Partition the privileged code into an assembly and create a new custom trust level
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And, for those of you who aren't into reading longish blog posts, here's a summary of what I found:
&lt;/p&gt;
&lt;div&gt;
&lt;table style="border-collapse: collapse;" border="0" height="390" width="701"&gt;&lt;colgroup&gt;&lt;col style="width: 234px;"&gt;&lt;col style="width: 234px;"&gt;&lt;col style="width: 234px;"&gt;&lt;/colgroup&gt;&lt;tbody valign="top"&gt;
&lt;tr style="background: rgb(102, 102, 102) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;td style="border: 0.5pt solid rgb(217, 217, 217); padding-left: 5px; padding-right: 5px;"&gt;
&lt;p style="text-align: center;"&gt;&lt;b&gt;Approach&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: solid solid solid none; border-color: rgb(217, 217, 217) rgb(217, 217, 217) rgb(217, 217, 217) -moz-use-text-color; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p style="text-align: center;"&gt;&lt;b&gt;Pros&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: solid solid solid none; border-color: rgb(217, 217, 217) rgb(217, 217, 217) rgb(217, 217, 217) -moz-use-text-color; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p style="text-align: center;"&gt;&lt;b&gt;Cons&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td style="border-style: none solid solid; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217); border-width: medium 0.5pt 0.5pt; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;Set the &lt;span style="font-family: Courier New;"&gt;originUrl&lt;/span&gt; attribute in the &lt;span style="font-family: Courier New;"&gt;trust&lt;/span&gt; element of the &lt;span style="font-family: Courier New;"&gt;web.config&lt;/span&gt; file
&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217) -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;&amp;nbsp;Really easy
&lt;/p&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;/td&gt;

&lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217) -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;
Only works for web permissions (like calling a web service)
&lt;br&gt;&lt;br&gt;&lt;/p&gt;
&lt;ul&gt;

&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td style="border-style: none solid solid; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217); border-width: medium 0.5pt 0.5pt; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;Create a new custom trust level
&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217) -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;Only necessary permissions are granted 
&lt;/p&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;/td&gt;

&lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217) -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;All code runs with the extra permissions
&lt;br&gt;
&lt;/p&gt;
&lt;ul&gt;

&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td style="border-style: none solid solid; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217); border-width: medium 0.5pt 0.5pt; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;Partition the privileged code into an assembly and install in the Global Assembly Cache&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217) -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;Only a small amount of code gets elevated privileges&lt;/p&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;/td&gt;

&lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217) -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;The code that gets elevated privileges runs in Full Trust
&lt;br&gt;&lt;br&gt;&lt;/p&gt;
&lt;ul&gt;

&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td style="border-style: none solid solid; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217); border-width: medium 0.5pt 0.5pt; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;Partition the privileged code into an assembly and create a new custom trust level&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217) -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;Only necessary permissions are granted and only a small amount of code gets elevated privileges&lt;br&gt;&lt;/p&gt;
&lt;ul&gt;

&lt;/ul&gt;

&lt;/td&gt;

&lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color rgb(217, 217, 217) rgb(217, 217, 217) -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding-left: 5px; padding-right: 5px;"&gt;
&lt;p&gt;Difficult&lt;/p&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Now for some background:
&lt;/p&gt;

&lt;p&gt;1. Set the &lt;span style="font-family: Courier New;"&gt;originUrl&lt;/span&gt; attribute in the &lt;span style="font-family: Courier New;"&gt;trust&lt;/span&gt; element of the &lt;span style="font-family: Courier New;"&gt;web.config&lt;/span&gt; file.
&lt;/p&gt;

&lt;ol&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;originUrl &lt;/span&gt;is an optional attribute that punches a hole in medium trust, allowing web connections to hosts defined by a regular expression. This is used to facilitate exactly what we need – connecting to a web service at an arbitrary location.
&lt;/p&gt;

&lt;p&gt;This is implemented by an entry in the &lt;span style="font-family: Courier New;"&gt;web_mediumtrust.config&lt;/span&gt; file:
&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;IPermission class="WebPermission" version="1"&amp;gt;
&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;ConnectAccess&amp;gt;
&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;URI uri="$OriginHost$"/&amp;gt;
&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;/ConnectAccess&amp;gt;
&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;/IPermission&amp;gt;&lt;/span&gt;
	&lt;/p&gt;

&lt;p&gt;Besides making this lab a little too easy, the &lt;span style="font-family: Courier New;"&gt;originUrl&lt;/span&gt; attribute is limited to web permissions and is not useful for different permission elevation scenarios such as accessing the registry or using reflection.
&lt;/p&gt;

&lt;p&gt;2. Create a new custom trust level.
&lt;/p&gt;

&lt;ol&gt;
&lt;/ol&gt;

&lt;p&gt;A more flexible approach is to create a new trust level. Usually this is done by copying over one of the policy files and adding the necessary permission. A good description is available at the Patterns and Practices site &lt;a href="http://msdn2.microsoft.com/en-us/library/ms998341.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms998341.aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;While this approach gives us the tools to add arbitrary permissions to the code base, it doesn't exactly follow the principal of least privilege, because all of the code in the web site is granted the permissions, rather than just the code that requires them.
&lt;/p&gt;

&lt;p&gt;3. Partition the privileged code into an assembly and install in the Global Assembly Cache.
&lt;/p&gt;

&lt;ol&gt;
&lt;/ol&gt;

&lt;p&gt;In order to segregate duties and reduce the overall privileges granted, we can rip out the code that needs permissions and throw it in to a new assembly. This is also known as sandboxing. All code that can run with low privileges is in a very low privilege environment, and is given limited access to higher privilege functionality. This approach has some similarity with the Silverlight security model and the security safe critical attribute – I'll blog about this later.
&lt;/p&gt;

&lt;p&gt;Once we have our privileged code in a separate assembly, we need to configure our environment so that the privileged code can be accessed safely. First, the privileged assembly should be decorated with the &lt;span style="font-family: Courier New;"&gt;AllowPartiallyTrustedCallersAttribtue&lt;/span&gt;, strong nam signed, and (in this case) installed in the GAC. To protect the code from being accessed by other classes, we can add a Code Access Security demand that will prevent access by all but the required classes. We have a few options here:
&lt;/p&gt;

&lt;ol style="margin-left: 54pt;"&gt;
&lt;li&gt;Use a &lt;span style="font-family: Courier New;"&gt;StrongNameIdentityPermission&lt;/span&gt;. If we strong name the ASP.NET application (running with partial trust), we can verify the strong name in the privileged assembly. This, unfortunately, isn't as easy as you might think. It's not supported in Visual Web Developer Express 2008, and so it wouldn't work for my lab. In the full version of Visual Studio, we can strong name the assembly by adding a compiler option &lt;i&gt;however &lt;/i&gt;this means that we need to create a new trust level. This is because modifying compiler options requires unmanaged code permissions. The suggestion is to use this modified trust level while debugging, then to deploy the assembly as a pre-compiled, strongly named assembly, with the unmodified trust level. I feel that this is probably a bad design choice – there should be a simple option for the Visual Studio built-in web server to perform strong naming on the ASP.NET code to support this type of scenario in medium trust. One note - Dominick points out that strong naming doesn't scale particularly well, since more than one strong name cannot be demand (this will result in an AND condition).
&lt;/li&gt;

&lt;li&gt;Use the &lt;span style="font-family: Courier New;"&gt;UrlIdentityPermission&lt;/span&gt;. I wasn't able to get this working, but theoretically you could restrict the caller's file location to the URL &lt;span style="font-family: Courier New;"&gt;file://c:\directorytowebapp\*&lt;/span&gt;. Not sure if anyone has tried this successfully, but if you could, you may get around some of the difficulties around strong naming.
&lt;/li&gt;

&lt;li&gt;Use a custom permission. This may be the most natural way to express the demand and justify the extra effort in creating a new permission, which isn't trivial.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note that these permissions do not prevent Full Trust callers from accessing the assembly. See this &lt;a href="http://blogs.msdn.com/eugene_bobukh/archive/2005/05/06/415217.aspx" mce_href="http://blogs.msdn.com/eugene_bobukh/archive/2005/05/06/415217.aspx"&gt;blog post&lt;/a&gt; for a description of why "Full Trust Means Full Trust"
&lt;/p&gt;

&lt;p&gt;One major problem here is that the assembly will run in the GAC with Full Trust. This is a fairly significant privilege escalation, even for a very small piece of code. However, we can do better.
&lt;/p&gt;

&lt;p&gt;4. Partition the privileged code into an assembly and create a new custom trust level.
&lt;/p&gt;

&lt;ol&gt;
&lt;/ol&gt;

&lt;p&gt;In this approach, we will combine approaches 2 and 3 to get the best of both worlds. We partition the code into a privileged assembly and the low privileged web site, taking into account the precautions discussed in the previous step. Then, rather than installing the code in the GAC, we create a custom policy file (as described in approach 2) and add a new code group which refers to our privileged assembly, and assign that code group a permission set that has only the requisite permissions. This approach is described in the hyperbolically-titled but otherwise helpful article "&lt;a href="http://www.devx.com/codemag/Article/37396/1763/page/5" mce_href="http://www.devx.com/codemag/Article/37396/1763/page/5"&gt;Never Write an Insecure ASP.NET Application Ever Again&lt;/a&gt;" and in Dominick's &lt;a href="http://www.microsoft.com/mspress/books/9989.aspx" mce_href="http://www.microsoft.com/mspress/books/9989.aspx"&gt;book&lt;/a&gt; (pages 330-332). One thing to note here is that you don't use the .NET Framework Configuration tool to set the security policy for the privileged assembly – you want to use the ASP.NET policies in the &lt;span style="font-family: Courier New;"&gt;.config&lt;/span&gt; file. Boy, I wish I had known that a few days ago.
&lt;/p&gt;

&lt;p&gt;This approach gives us the best shot at least privilege, and is extremely flexible. However, it's probably not appropriate for the couple of hours that the students have to complete the lab. Hopefully in the future we'll get an easy way to a) secure a privileged assembly with a simple permission demand and b) create a new trust level based off medium trust and c) create a new code group in the custom trust level based on the strong name of the privileged assembly.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx&amp;amp;;subject=Developing+ASP.NET+in+Partial+Trust" target="_blank" title = "Post http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx&amp;amp;;title=Developing+ASP.NET+in+Partial+Trust" target="_blank" title = "Post http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx&amp;amp;title=Developing+ASP.NET+in+Partial+Trust" target="_blank" title = "Post http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx&amp;amp;;title=Developing+ASP.NET+in+Partial+Trust" target="_blank" title = "Post http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx&amp;amp;;title=Developing+ASP.NET+in+Partial+Trust&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=25" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>OWASP ESAPI.NET</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx" /><id>http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx</id><published>2008-03-12T02:04:00Z</published><updated>2008-03-12T02:04:00Z</updated><content type="html">&lt;p&gt;&lt;i&gt;Sent via OWASP ESAPI &lt;a href="https://lists.owasp.org/mailman/listinfo/owasp-esapi" target="_blank" mce_href="https://lists.owasp.org/mailman/listinfo/owasp-esapi"&gt;mailing list&lt;/a&gt;:&amp;nbsp;&lt;/i&gt;&lt;/p&gt;&lt;p&gt;The ESAPI.NET project is now available on Google code (&lt;a href="http://code.google.com/p/owasp-esapi-dotnet/" target="_blank" mce_href="http://code.google.com/p/owasp-esapi-dotnet/"&gt;http://code.google.com/p/owasp-esapi-dotnet/&lt;/a&gt;).&lt;br&gt;&lt;br&gt;The ESAPI.NET project is an implementation of the original ESAPI code base (&lt;a href="http://code.google.com/p/owasp-esapi-java/" target="_blank" mce_href="http://code.google.com/p/owasp-esapi-java/"&gt;http://code.google.com/p/owasp-esapi-java/&lt;/a&gt;) in C#, using the .NET platform.&lt;br&gt;&lt;br&gt;Some notes on the implementation:&lt;br&gt;&lt;br&gt;1) The code uses nUnit for unit testing. Currently, all unit tests pass and there is &amp;gt;80% code coverage.&lt;br&gt;&lt;br&gt;2) The code uses the built-in .NET documentation format. Sandcastle (&lt;a href="http://blogs.msdn.com/sandcastle/" target="_blank" mce_href="http://blogs.msdn.com/sandcastle/"&gt;http://blogs.msdn.com/sandcastle/&lt;/a&gt;) will be used to compile the documentation.&lt;br&gt;&lt;br&gt;3) The code follows the .NET/C# coding conventions discussed here: &lt;a href="http://www.irritatedvowel.com/Programming/Standards.aspx" target="_blank" mce_href="http://www.irritatedvowel.com/Programming/Standards.aspx"&gt;http://www.irritatedvowel.com/Programming/Standards.aspx&lt;/a&gt;.&lt;br&gt;&lt;br&gt;4) For unit testing purposes, the code uses the HTTP Interfaces and Duck Typing library described here: &lt;a href="http://haacked.com/archive/2007/09/09/ihttpcontext-and-other-interfaces-for-your-duck-typing-benefit.aspx" target="_blank" mce_href="http://haacked.com/archive/2007/09/09/ihttpcontext-and-other-interfaces-for-your-duck-typing-benefit.aspx"&gt;http://haacked.com/archive/2007/09/09/ihttpcontext-and-other-interfaces-for-your-duck-typing-benefit.aspx&lt;/a&gt;. Hopefully we can use Microsoft code in a future release, as I believe that the ASP.NET MVC framework will use similar constructs (the author of the blog above is the project manager for ASP.NET MVC).&lt;br&gt;&lt;br&gt;5) In general, the code is more of a direct translation of the Java implementation than a re-write from scratch for the .NET framework. Future work may include more .NET specific security functionality as well as implementations leveraging existing .NET security mechanisms.&lt;br&gt;&lt;br&gt;6) The code passes its unit tests, but probably has some kinks to work out based on actually applying the library to an ASP.NET application. The next step will be to build a sample ASP.NET application that uses the ESAPI features.&lt;br&gt;&lt;br&gt;Please feel free to provide feedback. Thanks in advance!&lt;br&gt;&lt;br&gt;Alex &lt;br&gt;&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx&amp;amp;;subject=OWASP+ESAPI.NET" target="_blank" title = "Post http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx&amp;amp;;title=OWASP+ESAPI.NET" target="_blank" title = "Post http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx&amp;amp;title=OWASP+ESAPI.NET" target="_blank" title = "Post http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx&amp;amp;;title=OWASP+ESAPI.NET" target="_blank" title = "Post http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx&amp;amp;;title=OWASP+ESAPI.NET&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2008/03/11/owasp-esapi-net.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=24" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>Software Security and Earthquake Engineering</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx" /><id>http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx</id><published>2008-01-02T19:05:00Z</published><updated>2008-01-02T19:05:00Z</updated><content type="html">&lt;p&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/010208_1905_SoftwareSec1.png" mce_src="http://keepitlocked.net/images/keepitlockednet/010208_1905_SoftwareSec1.png" alt=""&gt;
	&lt;/p&gt;&lt;p&gt;Back in my days at &lt;a href="http://www.berkeley.edu/" mce_href="http://www.berkeley.edu/"&gt;Cal&lt;/a&gt;, I worked part-time as a "Data Entry Specialist" (uh, typist) at the &lt;a href="http://nisee.berkeley.edu/library/" mce_href="http://nisee.berkeley.edu/library/"&gt;Earthquake Engineering Center Library&lt;/a&gt; in Richmond for a couple extra bucks. I typed abstracts into a database - nothing too glamorous, although it did pay for more than a few &lt;a href="http://www.yelp.com/biz/ibs-hoagies-berkeley" mce_href="http://www.yelp.com/biz/ibs-hoagies-berkeley"&gt;IB's Hoagies&lt;/a&gt; and &lt;a href="http://www.topdoghotdogs.com/" mce_href="http://www.topdoghotdogs.com/"&gt;Top Dogs&lt;/a&gt; for a hungry &lt;a href="http://www.eecs.berkeley.edu/" mce_href="http://www.eecs.berkeley.edu/"&gt;EECS&lt;/a&gt; student.
&lt;/p&gt;&lt;p&gt;Beyond picking up a few pounds, I also picked up some tidbits from technical journals and abstracts about the process of engineering for disasters, like earthquakes. There were some common themes in these articles - from what I could tell in between the mostly incomprehensible (to me) dialogue on issues like torsion analysis and plasticity versus elasticity.
&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Studying failure is the best way to master compensating factors.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Safety should not preclude efficiency.
&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Disasters occur when poor engineering meets unexpected circumstances.
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;What we as security practitioners do is roughly comparable to earthquake engineering, and these themes are just as true when discussing SQL injection as inelastic oscillations. A crumbling structure may be more dramatic than a hacked system, but security folks' specialized knowledge is highly prized because it removes mystery from tragedy and derives lessons for the next time. Earthquakes are unpredictable - like attacks. We must study what has happened in the past to understand how to protect ourselves in the future.
&lt;/p&gt;&lt;p&gt;Looking back in this New Year is a good opportunity to consider what has worked, and what hasn't (I will post on my experiences with this later). I think overall software security specialists could collaborate more, interact more, and gain from each other's real-world experience. However, because security knowledge can be sensitive, it may not be as simple as submitting every piece of analysis to the local college intern to enter into a world readable database.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx&amp;amp;;subject=Software+Security+and+Earthquake+Engineering" target="_blank" title = "Post http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx&amp;amp;;title=Software+Security+and+Earthquake+Engineering" target="_blank" title = "Post http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx&amp;amp;title=Software+Security+and+Earthquake+Engineering" target="_blank" title = "Post http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx&amp;amp;;title=Software+Security+and+Earthquake+Engineering" target="_blank" title = "Post http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx&amp;amp;;title=Software+Security+and+Earthquake+Engineering&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2008/01/02/software-security-and-earthquake-engineering.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=23" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>Preventing Session Fixation through Session ID Regeneration in Java and ASP.NET</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx" /><id>http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx</id><published>2007-12-27T03:16:00Z</published><updated>2007-12-27T03:16:00Z</updated><content type="html">&lt;P&gt;&lt;IMG alt="" src="http://keepitlocked.net/images/keepitlockednet/122707_0308_PreventingS1.png" mce_src="http://keepitlocked.net/images/keepitlockednet/122707_0308_PreventingS1.png"&gt; &lt;/P&gt;
&lt;P&gt;Let's suppose I wanted to steal a car. One way I could&amp;nbsp;do it is&amp;nbsp;to buy a car, make a copy of the key, sell&amp;nbsp;the car&amp;nbsp;to a victim, tail them and then drive the car&amp;nbsp;away with my copied key while the unsuspecting victim&amp;nbsp;is off&amp;nbsp;purchasing a Frappucino.&lt;/P&gt;
&lt;P&gt;Maybe this wouldn't work in the paper-and-ink real world, but it's actually pretty easy in the virtual one. It is analogous to the web application attack called &lt;A href="http://www.owasp.org/index.php/Session_Fixation" mce_href="http://www.owasp.org/index.php/Session_Fixation"&gt;Session Fixation&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;Session Fixation is a vulnerability caused by an attacker forcing a victim to use a known session ID. Once the victim has authenticated, the attacker can hijack the session using the known session ID. There are multiple ways an attacker could get a victim to use a known session ID. For example, the attacker could entice a user to respond to a phishing email by clicking the following link: &lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.example.com/index.html?sessionid=%5bknownvalue%5de" mce_href="https://www.example.com/index.html?sessionid=%5bknownvalue%5de"&gt;https://www.example.com/index.html?sessionid=[knownvalue]&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Note that this link appears to come from the correct domain, and would not cause an SSL error message. The caveat is that the application must accept the session ID as a get argument. &lt;/P&gt;
&lt;P&gt;Additionally, an attacker could access a shared terminal (in a library, or a café) and visit several vulnerable sites, collecting session IDs, without authenticating. They could then continue to attempt to access these sites and see if the session has been authenticated (while keeping the session from expiring) until a victim logs in to a site using the shared terminal. &lt;/P&gt;
&lt;P&gt;The most efficient way to curtail this vulnerability is to regenerate the session ID when a user logs in. It renders the known session ID useless. Let's take a look at how this applies (or doesn't!) to Java and .NET. &lt;/P&gt;
&lt;H2&gt;Java &lt;/H2&gt;
&lt;P&gt;In Java, there is not well-supported programmatic access to the JSESSIONID cookie. You can't change the name of the cookie or set cookie properties (such as HttpOnly) very easily. However, in Java, it is possible to invalidate and recreate the session (not the session ID, necessarily) using the following code: &lt;/P&gt;
&lt;P style="MARGIN-LEFT: 108pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;session.invalidate();&lt;/SPAN&gt; &lt;/P&gt;
&lt;P style="MARGIN-LEFT: 108pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;session=request.getSession(true);&lt;/SPAN&gt; &lt;/P&gt;
&lt;P&gt;This is also the &lt;A href="http://www.owasp.org/index.php/Session_Fixation_in_Java" mce_href="http://www.owasp.org/index.php/Session_Fixation_in_Java"&gt;OWASP&lt;/A&gt; recommendation, although it isn't explained in much detail on the site. Note I said that this does not regenerate the session ID necessarily. Looking at the comment thread for this &lt;A href="http://afongen.com/blog/2006/08/01/generate-new-session-id-in-java-ee/" mce_href="http://afongen.com/blog/2006/08/01/generate-new-session-id-in-java-ee/"&gt;blog&lt;/A&gt;, it appears JBoss doesn't regenerate the JSESSIONID using this code. I haven't confirmed this myself, but there is no guarantee in the Java specification that the &lt;SPAN style="FONT-FAMILY: Courier New"&gt;session.invalidate&lt;/SPAN&gt; will actually regenerate the session ID if it is recreated using &lt;SPAN style="FONT-FAMILY: Courier New"&gt;request.getSession&lt;/SPAN&gt; during the same request. So be careful and test if you use this method - I tried the code with Tomcat, and it worked, but I can't vouch for the other Java application servers. &lt;/P&gt;
&lt;P&gt;In addition, you have to manually copy over all of the current data in the session. This may be necessary when designing an experience like Amazon.com, where you can add things to your cart before you log in. You would have to make sure that this information is persisted in the new session after authentication. This is an inconvenience, but is certainly doable. &lt;/P&gt;
&lt;H2&gt;ASP.NET &lt;/H2&gt;
&lt;P&gt;ASP.NET may have less of a problem with session fixation if you are using the ASP.NET Forms Authentication mechanism. A separate Forms Authentication token will be used after authentication, and since the attacker cannot set this value before the victim authenticates, it prevents a full-scale session fixation attacker. However, while this makes the ASP_NETSESSIONID less useful, it doesn't entirely negate the threat of session fixation. &lt;/P&gt;
&lt;P&gt;For instance, depending on how the application is designed, an attacker could use his or her own Forms Authentication token along with the hijacked session to access data from the hijacked session. &lt;/P&gt;
&lt;P&gt;ASP.NET does not directly support functionality to regenerate a session ID. See the documentation regarding the issue &lt;A href="https://connect.microsoft.com/feedback/viewfeedback.aspx?FeedbackID=143361&amp;amp;wa=wsignin1.0&amp;amp;siteid=210" mce_href="https://connect.microsoft.com/feedback/viewfeedback.aspx?FeedbackID=143361&amp;amp;wa=wsignin1.0&amp;amp;siteid=210"&gt;here&lt;/A&gt;. There is a &lt;A href="http://support.microsoft.com/kb/899918" mce_href="http://support.microsoft.com/kb/899918"&gt;not-so quick and dirty way&lt;/A&gt; to do it by setting the ASPNET_SessionID value to the empty string and redirecting so that the value is regenerated. &lt;/P&gt;
&lt;P&gt;I think both platforms need to re-examine the fact that session ID regeneration is an important security feature, and implement simple APIs for regenerating the session ID &lt;EM&gt;without&lt;/EM&gt; creating a new session. Perhaps they should even perform session regeneration on login and privilege escalation by default, creating a &lt;A href="http://www.codinghorror.com/blog/archives/000940.html" mce_href="http://www.codinghorror.com/blog/archives/000940.html"&gt;pit of success&lt;/A&gt;. I think this points to the fact that session mechanisms in web applications have a huge, but often underappreciated, security relevance.&lt;/P&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx&amp;amp;;subject=Preventing+Session+Fixation+through+Session+ID+Regeneration+in+Java+and+ASP.NET" target="_blank" title = "Post http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx&amp;amp;;title=Preventing+Session+Fixation+through+Session+ID+Regeneration+in+Java+and+ASP.NET" target="_blank" title = "Post http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx&amp;amp;title=Preventing+Session+Fixation+through+Session+ID+Regeneration+in+Java+and+ASP.NET" target="_blank" title = "Post http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx&amp;amp;;title=Preventing+Session+Fixation+through+Session+ID+Regeneration+in+Java+and+ASP.NET" target="_blank" title = "Post http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx&amp;amp;;title=Preventing+Session+Fixation+through+Session+ID+Regeneration+in+Java+and+ASP.NET&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2007/12/27/preventing-session-fixation-through-session-id-regeneration-in-java-and-asp-net.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=22" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>Java and HttpOnly</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx" /><id>http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx</id><published>2007-11-06T06:10:00Z</published><updated>2007-11-06T06:10:00Z</updated><content type="html">&lt;p&gt;&lt;a href="http://www.owasp.org/index.php/HTTPOnly" mce_href="http://www.owasp.org/index.php/HTTPOnly"&gt;HttpOnly&lt;/a&gt; is an HTTP cookie property originally developed by &lt;a href="http://msdn2.microsoft.com/en-us/library/ms533046.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms533046.aspx"&gt;Microsoft&lt;/a&gt; that makes cookies "non-scriptable" - any attempts to access the cookie value through JavaScript will fail. 
&lt;/p&gt;

&lt;p&gt;HttpOnly mitigates the threat of session hijacking through cross-site scripting, but only partially - more on this later.
&lt;/p&gt;

&lt;p&gt;Until recently, HttpOnly was only supported in Internet Explorer 6, SP1 and up. Now, however, the &lt;a href="http://forums.mozillazine.org/viewtopic.php?p=2965188" mce_href="http://forums.mozillazine.org/viewtopic.php?p=2965188"&gt;latest version of FireFox&lt;/a&gt; supports HttpOnly.
&lt;/p&gt;

&lt;p&gt;It's easy to specify a cookie as HttpOnly, it raises the bar for an attacker, and it doesn't affect most regular functionality. So why not set your session identifier cookies to HttpOnly?
&lt;/p&gt;

&lt;p&gt;Well, if you're developing &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.httpcookie.httponly.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.web.httpcookie.httponly.aspx"&gt;ASP.NET&lt;/a&gt;, &lt;a href="http://ilia.ws/index.php?url=archives/121-httpOnly-cookie-flag-support-in-PHP-5.2.html" mce_href="http://ilia.ws/index.php?url=archives/121-httpOnly-cookie-flag-support-in-PHP-5.2.html"&gt;PHP&lt;/a&gt;, or &lt;a href="http://dev.rubyonrails.org/ticket/8895" mce_href="http://dev.rubyonrails.org/ticket/8895"&gt;Ruby on Rails&lt;/a&gt; web applications, you're in luck. Just set a property, or change a config file, and you're golden.
&lt;/p&gt;

&lt;p&gt;But what about J2EE? Well, there is no HttpOnly property supported in the Cookie interface. You can set your own cookies to be HttpOnly:
&lt;/p&gt;

&lt;p class="codeblock"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;response.setHeader("Set-Cookie", "originalcookiename=originalvalue; HTTPOnly");
&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;But that doesn't work for JSESSIOND, the J2EE session identifier, since it is handled by the container. So, you're out of luck. Or are you?
&lt;/p&gt;

&lt;p&gt;&amp;lt;Pause for commercial break&amp;gt;
&lt;/p&gt;
&lt;a href="http://www.youtube.com/v/WmFBOVZ6BLM&amp;amp;rel=1" style="left: 0px ! important; top: 0px ! important;" title="Click here to block this object with Adblock Plus" class="abp-objtab-07211693743939975 visible ontop"&gt;&lt;/a&gt;&lt;a href="http://www.youtube.com/v/WmFBOVZ6BLM&amp;amp;rel=1" style="left: 0px ! important; top: 0px ! important;" title="Click here to block this object with Adblock Plus" class="abp-objtab-07211693743939975 visible ontop"&gt;&lt;/a&gt;&lt;a href="http://www.youtube.com/v/WmFBOVZ6BLM&amp;amp;rel=1" style="left: 0px ! important; top: 0px ! important;" title="Click here to block this object with Adblock Plus" class="abp-objtab-07211693743939975 visible ontop"&gt;&lt;/a&gt;
&lt;p align="center"&gt;&lt;a href="http://www.youtube.com/v/WmFBOVZ6BLM&amp;amp;rel=1" style="left: 569px ! important; top: 0px ! important;" title="Click here to block this object with Adblock Plus" class="abp-objtab-07211693743939975 visible ontop"&gt;&lt;/a&gt;&lt;a href="http://www.youtube.com/v/WmFBOVZ6BLM&amp;amp;rel=1" style="left: 569px ! important; top: 0px ! important;" title="Click here to block this object with Adblock Plus" class="abp-objtab-07211693743939975 visible ontop"&gt;&lt;/a&gt;&lt;object height="355" width="425"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/WmFBOVZ6BLM&amp;amp;rel=1"&gt;
&lt;param name="wmode" value="transparent"&gt;
&lt;embed src="http://www.youtube.com/v/WmFBOVZ6BLM&amp;amp;rel=1" type="application/x-shockwave-flash" wmode="transparent" height="355" width="425"&gt;&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;&amp;lt;/Pause for commercial break&amp;gt;
&lt;/p&gt;

&lt;p&gt;Welcome back. After fiddling around with &lt;a href="http://www.foundstone.com/us/resources/proddesc/hacmebooks.htm" mce_href="http://www.foundstone.com/us/resources/proddesc/hacmebooks.htm"&gt;HacmeBooks&lt;/a&gt;, the Foundstone Free Tool for demonstrating common web application vulnerabilities in Java, I was able to get the HttpOnly property set on the JSESSIONID cookie.
&lt;/p&gt;

&lt;p&gt;Here's the code below (from a ServletFilter):
&lt;/p&gt;

&lt;p class="codeblock"&gt;&lt;span style="font-family: Courier New;"&gt;// Check if this is where the JSESSIONID is being set (assuming that JSESSIONID is the only cookie used)&lt;br&gt;if (response.containsHeader("SET-COOKIE"))&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String sessionid = request.getSession().getId();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; response.setHeader("SET-COOKIE", "JSESSIONID=" + sessionid + "; Path=/HacmeBooks; HttpOnly");&lt;br&gt;}&lt;br&gt;// Continue down the Filter Chain&lt;br&gt;chain.doFilter(request, response);
&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;This code is far from ideal - it essentially replaces the JSESSIONID cookie set by the server, so any properties (path, expires, secure, etc.) that the server sets have to be specified in the code. It also won't work if other cookies besides JSESSIONID are being used (you could fix this by looking at the request and making sure JSESSIONID isn't already set).
&lt;/p&gt;

&lt;p&gt;However, until Java gets around to supporting HttpOnly cleanly, this is the best way I could figure to set this property on the JSESSIONID.
&lt;/p&gt;

&lt;p&gt;*BONUS*
&lt;/p&gt;

&lt;p&gt;I mentioned that there are some people who have taken HttpOnly to task for being an incomplete mitigation for XSS.
&lt;/p&gt;

&lt;p&gt;&lt;a href="http://jeremiahgrossman.blogspot.com/2007/04/xst-lives-bypassing-httponly.html" mce_href="http://jeremiahgrossman.blogspot.com/2007/04/xst-lives-bypassing-httponly.html"&gt;Jeremiah Grossman&lt;/a&gt; talks about using the HTTP TRACE verb to get access to HttpOnly cookies in the reflected request.
&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.gnucitizen.org/blog/why-httponly-wont-protect-you" mce_href="http://www.gnucitizen.org/blog/why-httponly-wont-protect-you"&gt;pdp&lt;/a&gt; suggests that HttpOnly is meaningless because most attackers don't really care about session hijacking through XSS - there are more damaging attacks that can be leveraged through XSS.
&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/" mce_href="http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/"&gt;RSnake&lt;/a&gt; points out that in FireFox XMLHttpRequest can be used to access the cookie and bypass HttpOnly. Additionally, some older, obscure browsers (IE5 on Mac, WebTV) choke and die on the header instead of safely ignoring it.
&lt;/p&gt;

&lt;p&gt;&lt;a href="http://seclists.org/webappsec/2006/q2/0181.html" mce_href="http://seclists.org/webappsec/2006/q2/0181.html"&gt;Amit Klein&lt;/a&gt; suggest several different methods, including some mentioned above, for bypassing the HttpOnly protection.
&lt;/p&gt;

&lt;p&gt;I think for all of its shortcomings, HttpOnly is still a good idea. The bugs will get worked out, and everyone will be a little safer.&lt;/p&gt;

&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx&amp;amp;;subject=Java+and+HttpOnly" target="_blank" title = "Post http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx&amp;amp;;title=Java+and+HttpOnly" target="_blank" title = "Post http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx&amp;amp;title=Java+and+HttpOnly" target="_blank" title = "Post http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx&amp;amp;;title=Java+and+HttpOnly" target="_blank" title = "Post http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx&amp;amp;;title=Java+and+HttpOnly&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2007/11/05/java-and-httponly.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=17" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>ASP.NET ValidateRequest and the HTML Attribute Based Cross Site Scripting </title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx" /><id>http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx</id><published>2007-10-31T03:45:00Z</published><updated>2007-10-31T03:45:00Z</updated><content type="html">
&lt;p&gt;ASP.NET &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.configuration.pagessection.validaterequest.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.web.configuration.pagessection.validaterequest.aspx"&gt;ValidateRequest&lt;/a&gt; is a security mechanism designed to prevent cross-site scripting attacks in ASP.NET applications. It looks at data in the HTTP request parameters, and issues an error if it finds anything that is "suspicious". And, for the most part, it works fine. But, like many security technologies, there are two big problems - false positives and false negatives. First off, let's take a look at how ValidateRequest works. Using the .NET Reflector tool, we can see the attack detection algorithm in the &lt;span style="font-family: Courier New;"&gt;IsDangerousString&lt;/span&gt; method of the&lt;span style="font-family: Courier New;"&gt; CrossSiteScriptingValidation &lt;/span&gt;class, which is the crux of the ValidateRequest functionality:
&lt;/p&gt;

&lt;p align="center"&gt;
		&lt;img src="http://keepitlocked.net/images/keepitlockednet/103107_0344_ASPNETValid1.png" mce_src="http://keepitlocked.net/images/keepitlockednet/103107_0344_ASPNETValid1.png" alt=""&gt;
	&lt;/p&gt;

&lt;p&gt;This method looks for either a less than or ampersand character in the string. If one exists, it first checks to make sure it is not the last character (I'm not entirely sure why, but it seems this would only allow fairly benign strings). Then, if the offending character is a less than character, the method checks if the next character is a letter, an exclamation point, or a forward slash. If so, it is considered dangerous. Also, if the offending character was an ampersand, and the next character is a hash mark, the string is considered dangerous. This algorithm iterates through the string, stopping at each instance of one of these symbols.
&lt;/p&gt;

&lt;p&gt;Now that we have a good idea how this functionality works, let's examine why it isn't always ideal.
&lt;/p&gt;

&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;False Positives
&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;ValidateRequest looks for anything that resembles HTML that code be used to execute script. Unfortunately, the detection technique can be a bit trigger-happy.  Some strings that appear to be malicious are perfectly normal and expected. Examples:&lt;span style="text-decoration: underline;"&gt;
		&lt;/span&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Rich text controls often use HTML characters for markup.
&lt;/li&gt;

&lt;li&gt;XML in AJAX calls has been known to trip the ValidateRequest error.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Many people advise turning ValidateRequest off at the first sign of problems. The first &lt;a href="http://www.google.com/search?q=validaterequest" mce_href="http://www.google.com/search?q=validaterequest"&gt;Google hit for ValidateRequest&lt;/a&gt; is a link to an article from 2004 titled "&lt;a href="http://www.aspnetpro.com/NewsletterArticle/2004/03/asp200403dk_l/asp200403dk_l.asp" mce_href="http://www.aspnetpro.com/NewsletterArticle/2004/03/asp200403dk_l/asp200403dk_l.asp"&gt;Surviving ValidateRequest&lt;/a&gt;" discussing why it's not always in a developer's best interest to use the mechanism (although it does discuss the threats and countermeasures regarding cross-site scripting in the article as well). Here's a quote:
&lt;/p&gt;

&lt;p style="margin-left: 36pt;"&gt;"Another problem with ValidateRequest set to true is that it is a rather broad and stupid protection, erring on the side of catching too much rather than letting something dangerous slide by."
&lt;/p&gt;

&lt;p&gt;OK, fair enough, simply disable ValidateRequest when it causes problems, and figure out how to prevent XSS by yourself in those cases. But something so strict that it chokes on regular input has got to prevent all bad input, right?
&lt;/p&gt;

&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;False Negatives
&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;No one claims that ValidateRequest is perfectly effective in stopping cross-site scripting attacks. But what does it miss? From &lt;a href="http://blogs.msdn.com/esiu/archive/2007/10/19/asp-net-validaterequest-does-not-mitigate-xss-completely.aspx" mce_href="http://blogs.msdn.com/esiu/archive/2007/10/19/asp-net-validaterequest-does-not-mitigate-xss-completely.aspx"&gt;a recent blog post&lt;/a&gt;:
&lt;/p&gt;

&lt;p style="margin-left: 36pt;"&gt;"ValidateRequest may miss some crafty inputs."
&lt;/p&gt;

&lt;p&gt;Well, what are these "crafty" values? One is mentioned in the article - an exploit which is mentioned in the &lt;a href="http://www.microsoft.com/technet/security/Bulletin/MS07-040.mspx" mce_href="http://www.microsoft.com/technet/security/Bulletin/MS07-040.mspx"&gt;Microsoft Security Bulletin MS07-040&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;There is another, perhaps more common (and still unpatched) form of XSS which isn't stopped by ValidateRequest. It is known as &lt;a href="http://jeremiahgrossman.blogspot.com/2007/07/attribute-based-cross-site-scripting.html" mce_href="http://jeremiahgrossman.blogspot.com/2007/07/attribute-based-cross-site-scripting.html"&gt;HTML Attribute-Based Cross Site Scripting&lt;/a&gt;, according to Jeremiah Grossman. The attacker uses an HTML attribute to insert an event handler that causes a script to run. 
&lt;/p&gt;

&lt;p&gt;ValidateRequest doesn't even attempt to look for this - there are no angle brackets required.
&lt;/p&gt;

&lt;p&gt;For example, take the following ASP.NET code:
&lt;/p&gt;

&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/103107_0344_ASPNETValid2.png" mce_src="http://keepitlocked.net/images/keepitlockednet/103107_0344_ASPNETValid2.png" alt=""&gt;
	&lt;/p&gt;

&lt;p&gt;This code is used to display a page which renders a link to an article on Wikipedia.
&lt;/p&gt;

&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/103107_0344_ASPNETValid3.png" mce_src="http://keepitlocked.net/images/keepitlockednet/103107_0344_ASPNETValid3.png" alt=""&gt;
	&lt;/p&gt;

&lt;p&gt;We can enter this value:
&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;

&lt;img src="http://keepitlocked.net/images/keepitlockednet/xss.png" mce_src="http://keepitlocked.net/images/keepitlockednet/xss.png" alt=""&gt;

&lt;br&gt;
&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;This will cause the following HTML to be rendered:
&lt;/p&gt;

&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/103107_0344_ASPNETValid4.png" mce_src="http://keepitlocked.net/images/keepitlockednet/103107_0344_ASPNETValid4.png" alt=""&gt;
	&lt;/p&gt;

&lt;p&gt;This will cause script to execute when the person moves their mouse over the link:
&lt;/p&gt;

&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/103107_0344_ASPNETValid5.png" mce_src="http://keepitlocked.net/images/keepitlockednet/103107_0344_ASPNETValid5.png" alt=""&gt;
	&lt;/p&gt;

&lt;p&gt;So we have caused cross-site scripting in spite of ValidateRequest being enabled. This is due to the fact that not all cross-site scripting attacks require the use of less than or ampersand characters. For example, consider what would happen if a parameter value was echoed directly in JavaScript (this can happen in AJAX apps). The results can be scary!
&lt;/p&gt;

&lt;p&gt;ValidateRequest is not a panacea. Instead, consider augmenting the functionality with stronger protection afforded by the &lt;a href="http://msdn2.microsoft.com/en-us/security/aa973814.aspx" mce_href="http://msdn2.microsoft.com/en-us/security/aa973814.aspx"&gt;Anti XSS&lt;/a&gt; library, and as always, implement and enforce strict validation.&lt;/p&gt;

&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx&amp;amp;;subject=ASP.NET+ValidateRequest+and+the+HTML+Attribute+Based+Cross+Site+Scripting+" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx&amp;amp;;title=ASP.NET+ValidateRequest+and+the+HTML+Attribute+Based+Cross+Site+Scripting+" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx&amp;amp;title=ASP.NET+ValidateRequest+and+the+HTML+Attribute+Based+Cross+Site+Scripting+" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx&amp;amp;;title=ASP.NET+ValidateRequest+and+the+HTML+Attribute+Based+Cross+Site+Scripting+" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx&amp;amp;;title=ASP.NET+ValidateRequest+and+the+HTML+Attribute+Based+Cross+Site+Scripting+&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/30/asp-net-validaterequest-and-the-html-attribute-based-cross-site-scripting.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=16" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>Encrypting External Configuration Files Using Protected Configuration/DPAPI</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx" /><id>http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx</id><published>2007-10-12T22:13:00Z</published><updated>2007-10-12T22:13:00Z</updated><content type="html">
&lt;p&gt;In ASP.NET 2.0, the &lt;a href="http://msdn2.microsoft.com/en-us/library/53tyfkaw.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/53tyfkaw.aspx"&gt;Protected Configuration&lt;/a&gt; functionality can be used to automatically encrypt and decrypt sections of the Web.config file. This is useful for keeping sensitive data like connection strings and cryptographic keys secret from internal personnel who require access to other areas of the configuration file.
&lt;/p&gt;
&lt;p&gt;Web.config files contain application level configuration, and they are often deployed with the code, from development/testing/staging environments to production environments. Because secrets like connection string should be different in production, the Web.config file has to be modified. However, another piece of functionality, the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.configuration.sectioninformation.configsource.aspxhttp:/msdn2.microsoft.com/en-us/library/system.configuration.sectioninformation.configsource.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.configuration.sectioninformation.configsource.aspxhttp:/msdn2.microsoft.com/en-us/library/system.configuration.sectioninformation.configsource.aspx"&gt;configSource&lt;/a&gt; attribute or the &lt;a href="http://msdn2.microsoft.com/en-us/library/ms228154.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms228154.aspx"&gt;appSettings&lt;/a&gt; element, allows configuration sections in Web.config to be located in external files.
&lt;/p&gt;
&lt;p&gt;These two functionalities work just fine together. This makes deployment easier because secrets can be stored statically and encrypted on each machine, or just the production machine, plus the Web.config file doesn't need to be modified each time.
&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Example
&lt;/b&gt;&lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/101207_2212_EncryptingE1.png" mce_src="http://keepitlocked.net/images/keepitlockednet/101207_2212_EncryptingE1.png" alt=""&gt;
	&lt;/p&gt;
&lt;p&gt;connectionStrings section in Web.config (staging and production) refers to external source
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/101207_2212_EncryptingE2.png" mce_src="http://keepitlocked.net/images/keepitlockednet/101207_2212_EncryptingE2.png" alt=""&gt;
	&lt;/p&gt;
&lt;p&gt;Staging connection string defined in connectionString.config (staging)
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/101207_2212_EncryptingE3.png" mce_src="http://keepitlocked.net/images/keepitlockednet/101207_2212_EncryptingE3.png" alt=""&gt;
	&lt;/p&gt;
&lt;p&gt;Production connection string defined in connectionString.config (production)
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/101207_2212_EncryptingE4.png" mce_src="http://keepitlocked.net/images/keepitlockednet/101207_2212_EncryptingE4.png" alt=""&gt;
	&lt;/p&gt;
&lt;p&gt;Encrypt the connectionStrings section for the application (production) using aspnet_regiis
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/101207_2212_EncryptingE5.png" mce_src="http://keepitlocked.net/images/keepitlockednet/101207_2212_EncryptingE5.png" alt=""&gt;
	&lt;/p&gt;
&lt;p&gt;Encrypted connectionStrings setting connectionStrings.config (production)
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now, the Web.config file can be deployed without overwriting the connectionStrings attribute, and the production database password is encrypted! It's the best of both worlds - security and convenience playing nicely. Just remember not to deploy the connectionString.config file.
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx&amp;amp;;subject=Encrypting+External+Configuration+Files+Using+Protected+Configuration%2fDPAPI" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx&amp;amp;;title=Encrypting+External+Configuration+Files+Using+Protected+Configuration%2fDPAPI" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx&amp;amp;title=Encrypting+External+Configuration+Files+Using+Protected+Configuration%2fDPAPI" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx&amp;amp;;title=Encrypting+External+Configuration+Files+Using+Protected+Configuration%2fDPAPI" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx&amp;amp;;title=Encrypting+External+Configuration+Files+Using+Protected+Configuration%2fDPAPI&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/12/encrypting-external-configuration-files-using-protected-configuration-dpapi.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=14" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>A Brief History of Applet Security</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx" /><id>http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx</id><published>2007-10-10T20:23:00Z</published><updated>2007-10-10T20:23:00Z</updated><content type="html">
&lt;p&gt;A vast amount of server-side development is J2EE. Huge, multi-national corporations run on it exclusively. But, it wasn't always that way….
&lt;/p&gt;
&lt;p&gt;Back in the early days of Java, the client-side Applet was king. The partnership with Netscape thrust the Java onto the world stage. &lt;a href="http://www.wired.com/wired/archive/3.12/java.saga.html" mce_href="http://www.wired.com/wired/archive/3.12/java.saga.html"&gt;Early&lt;/a&gt;
		&lt;a href="http://www.itworld.com/AppDev/716/swol-1195-java/" mce_href="http://www.itworld.com/AppDev/716/swol-1195-java/"&gt;press&lt;/a&gt;
		&lt;a href="http://www.news.com/JavaSoft-debuts-Java-1.0/2100-1001_3-202980.html?tag=item" mce_href="http://www.news.com/JavaSoft-debuts-Java-1.0/2100-1001_3-202980.html?tag=item"&gt;releases&lt;/a&gt; all focused on the web experience provided by Applets.
&lt;/p&gt;
&lt;p&gt;But there was this pesky security issue - due to the fact that Java Applets are distributed and run through a browser, they can encounter some nasty code on the web. In order to deal with evil code, Applets are run in a &lt;a href="http://en.wikipedia.org/wiki/Sandbox_%28computer_security%29" mce_href="http://en.wikipedia.org/wiki/Sandbox_(computer_security)"&gt;Sandbox&lt;/a&gt; with limited permission. However, Applet developers said that this Sandbox was too restrictive. No access to the file system, or the clipboard, or native code, or really anything useful.
&lt;/p&gt;
&lt;p&gt;So, in Java 1.1, you could digitally sign applets so that they were trusted. This would give the Applet full permission, and theoretically users would manage their own trusted key store.
&lt;/p&gt;
&lt;p&gt;In Java 2, Sun added Certificate Authorities to the Applet specification, so that anyone with enough money to pony up could create a universally trusted Applet. This was tempered by the fact that now the user could create a policy to restrict these signed Applets to a specific set of permissions. So signed Applets ask for permission to run, and are granted AllPermissions, unless there is a specific client-side policy for that Applet, which takes precedence. But no one likes configuring security policies, do they? Remember, this is the unwashed masses of browser users, and they don't know a Java policy file from a can of &lt;a href="http://en.wikipedia.org/wiki/Shinola" mce_href="http://en.wikipedia.org/wiki/Shinola"&gt;Shinola&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;Enter the Java Plugin, which now handles Applets for most browsers. In the previous 1.3 version of the Plugin, Applets signed with invalid certificates (self-signed or expired) would simply fail to load. If the signing certificate was valid, the user got a dialog box asking whether to run the Applet.
&lt;/p&gt;
&lt;p&gt;In the Java Plugin 1.4, the behavior was changed to load Applets even with invalid certificates. The only difference between Applets with valid signatures and invalid signatures is the warning messages.
&lt;/p&gt;
&lt;p&gt;Applets signed with an invalid certificate:
&lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/101007_2015_ABriefHisto1.png" mce_src="http://keepitlocked.net/images/keepitlockednet/101007_2015_ABriefHisto1.png" alt=""&gt;
	&lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/101007_2015_ABriefHisto2.png" mce_src="http://keepitlocked.net/images/keepitlockednet/101007_2015_ABriefHisto2.png" alt=""&gt;
	&lt;/p&gt;
&lt;p&gt;Applets signed with a valid certificate:
&lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/101007_2015_ABriefHisto3.png" mce_src="http://keepitlocked.net/images/keepitlockednet/101007_2015_ABriefHisto3.png" alt=""&gt;
	&lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/101007_2015_ABriefHisto4.png" mce_src="http://keepitlocked.net/images/keepitlockednet/101007_2015_ABriefHisto4.png" alt=""&gt;
	&lt;/p&gt;
&lt;p&gt;To me, this represents a tremendous over-simplification. Signed Applets now basically use the same, all-or-nothing security model as standard executables!
&lt;/p&gt;
&lt;p&gt;The error message for an unsigned .exe file (in IE7):
&lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://keepitlocked.net/images/keepitlockednet/101007_2015_ABriefHisto5.png" mce_src="http://keepitlocked.net/images/keepitlockednet/101007_2015_ABriefHisto5.png" alt=""&gt;
	&lt;/p&gt;
&lt;p&gt;At least this has a red shield (bad) rather than an orange shield (maybe bad)!
&lt;/p&gt;
&lt;p&gt;Nowadays, in addition to the huge amount of server-side Java development, there is Java on mobile devices, smart cards, and entire operating systems in Java. But the original thing that made Java tick – the Applet – is becoming less and less relevant every day, and I can't help thinking it's due to the fatally flawed security model which has now almost completely lost its teeth.
&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;References
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Java Technology: The Early Years: &lt;a href="http://java.sun.com/features/1998/05/birthday.html" mce_href="http://java.sun.com/features/1998/05/birthday.html"&gt;http://java.sun.com/features/1998/05/birthday.html&lt;/a&gt;
	&lt;/p&gt;
&lt;p&gt;Java 2 Platform Security: &lt;a href="http://www.informit.com/articles/article.aspx?p=433382&amp;amp;seqNum=2" mce_href="http://www.informit.com/articles/article.aspx?p=433382&amp;amp;seqNum=2"&gt;http://www.informit.com/articles/article.aspx?p=433382&amp;amp;seqNum=2&lt;/a&gt;
	&lt;/p&gt;
&lt;p&gt;Using JDK 1.1 Signed Applets with Java Plugin: &lt;a href="http://java.sun.com/products/plugin/1.2/docs/signed.html" mce_href="http://java.sun.com/products/plugin/1.2/docs/signed.html"&gt;http://java.sun.com/products/plugin/1.2/docs/signed.html&lt;/a&gt;
	&lt;/p&gt;
&lt;p&gt;Java Security, Evolution and Concepts: &lt;a href="http://java.sun.com/products/plugin/1.2/docs/signed.html" mce_href="http://java.sun.com/products/plugin/1.2/docs/signed.html"&gt;http://java.sun.com/products/plugin/1.2/docs/signed.html&lt;/a&gt;
	&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx&amp;amp;;subject=A+Brief+History+of+Applet+Security" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx&amp;amp;;title=A+Brief+History+of+Applet+Security" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx&amp;amp;title=A+Brief+History+of+Applet+Security" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx&amp;amp;;title=A+Brief+History+of+Applet+Security" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx&amp;amp;;title=A+Brief+History+of+Applet+Security&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/10/a-brief-history-of-applet-security.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=13" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry><entry><title>Input versus Data, Validation versus Sanitization</title><link rel="alternate" type="text/html" href="http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx" /><id>http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx</id><published>2007-10-08T20:41:31Z</published><updated>2007-10-08T20:41:31Z</updated><content type="html">&lt;p&gt;Reading articles, browsing marketing materials, and listening to presentations about application security, you hear variations on a theme:
&lt;/p&gt;&lt;p&gt;"Input validation is absolutely critical to application security, and most application risks involve tainted input at some level." – &lt;a href="http://www.owasp.org/index.php/Input_Validation"&gt;OWASP&lt;/a&gt;
	&lt;/p&gt;&lt;p&gt;While I don't think authors overstate the importance of problems stemming from invalid data, I have noticed these discussions gloss over two key points.
&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Input validation is only part of the problem. Output validation is important as well.
&lt;/li&gt;&lt;li&gt;Validation (in the general sense) has two distinct concerns: validation and sanitization.
&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;em&gt;Input validation is only part of the problem. Output validation is important as well.
&lt;/em&gt;&lt;/p&gt;&lt;p&gt;All data input from an untrusted source should be validated. If you enter a blog comment, I want to make sure it isn't empty, it is less than 500 words, and it isn't spam and won't get my readers &lt;a href="http://wiki.answers.com/Q/What_does_it_mean_to_be_Rickrolled"&gt;RickRolled&lt;/a&gt;. However, as that data is output from the web application, it should be validated as well. Here's why:
&lt;/p&gt;&lt;p&gt;Think about cross-site scripting – we really want to prevent tainted data from exiting the system to the rendered web page on the client. This occurs when the data is output, not input. SQL injection is also tainted data exiting the system (through a SQL query) and parameterized queries are output validation. And since these different validation rules might process the same data (say, a blog comment that is reflected in a subsequent page for approval and then stored to the database), it makes more sense to validate the data upon exit, rather than on entrance.
&lt;/p&gt;&lt;p&gt;It's like international air travel – you pass through customs at your arrival airport (output), because at your departure airport (input), they don't know the rules for what's allowed and what isn't.
&lt;/p&gt;&lt;p&gt;Thus, I propose that "Data Validation" be used in favor of "Input Validation" as a more accurate (although less precise) term to include input and output validation.
&lt;/p&gt;&lt;p&gt;&lt;em&gt;Validation (in the general sense) has two distinct concerns: validation and sanitization.
&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Validation is a Boolean operation which gives a yes or no answer to the question "Is this data acceptable in the current context?"
&lt;/p&gt;&lt;p&gt;Sanitization (which includes encoding, escaping, and stripping) refers to transforming data in some manner so as to make it acceptable in the current context.
&lt;/p&gt;&lt;p&gt;These two approaches can be used independently or in concert and the correct way to perform these operations from a security perspective is highly dependent on the context in which they are used. 
&lt;/p&gt;&lt;p&gt;So validation is (usually) both validation and sanitization.
&lt;/p&gt;&lt;p&gt;Another issue which might be brought up in the subject of validation is canonicalization, which is a separate issue that warrants its own future blog post.
&lt;/p&gt;&lt;p&gt;Just some food for thought when designing validation mechanisms – it's not all yes or no decisions, and it's not all at the front door.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx&amp;amp;;subject=Input+versus+Data%2c+Validation+versus+Sanitization" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx&amp;amp;;title=Input+versus+Data%2c+Validation+versus+Sanitization" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx&amp;amp;title=Input+versus+Data%2c+Validation+versus+Sanitization" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx&amp;amp;;title=Input+versus+Data%2c+Validation+versus+Sanitization" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx&amp;amp;;title=Input+versus+Data%2c+Validation+versus+Sanitization&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2007/10/08/input-versus-data-validation-versus-sanitization.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=11" width="1" height="1"&gt;</content><author><name>Alex</name><uri>http://keepitlocked.net/members/Alex.aspx</uri></author></entry></feed>