<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
  <channel>
    <title><![CDATA[[SecurityRatty] tag: class]]></title>
    <link>http://securityratty.com/tag/class</link>
    <description></description>
    <pubDate>Tue, 29 Jul 2008 02:01:52 +0000</pubDate>
    <generator>iRatty Engine</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <item>
      <title><![CDATA[Serializable XmlDocument]]></title>
      <link>http://securityratty.com/article/94c84cd2ea7a6ea71c9712991d27722d</link>
      <guid>http://securityratty.com/article/94c84cd2ea7a6ea71c9712991d27722d</guid>
      <description><![CDATA[It's surprising that XmlDocument isn't marked [Serializable], because it's very natural to serialize one into a stream. I wanted to put an object into ASP.NET ViewState the other day, and quickly ran...]]></description>
      <content:encoded><![CDATA[<p>It&#39;s surprising that XmlDocument isn&#39;t marked [Serializable], because it&#39;s very natural to serialize one into a stream. I wanted to put an object into ASP.NET ViewState the other day, and quickly ran into this roadblock, because part of the object included an XmlDocument, which is not serializable. A quick search revealed that most people deal with this problem by storing a string instead. Indeed, that was where I started, but I quickly realized that there are multiple places in my code where I want to do this sort of thing, and I don&#39;t want to have to mess with it in each data structure that contains an XmlDocument.</p>
<p>So I put together a simple class that holds an XmlDocument and implements ISerializable and called it SerializableXmlDocument. I&#39;m sharing the source code here in the hopes that</p>
<blockquote>
<p>a) somebody will find it useful, and</p>
<p>b) somebody smarter than I am will point out how I screwed it up and help me make it better.</p>
</blockquote>
<p>SerializableXmlDocument includes implicit conversion operators to make it easy to convert to/from an XmlDocument. It holds the actual document in a property called Value. This &quot;isomorph&quot; pattern is one that I picked up from <a href="http://www.pluralsight.com/community/blogs/craig/default.aspx" target="_blank">Craig</a>.</p>
<p>While writing this code, I also wrote a helpful extension method for getting a byte array out of a MemoryStream that is exactly the length of the data written to the stream so far (CopyUpToSeekPointer). So don&#39;t go looking in the docs for MemoryStream for this method :) This is obviously not the most efficient way to consume bytes written to a MemoryStream since it copies the data into a new byte array, but it&#39;s very convenient in many scenarios.</p>
<p>Here is SerializableXmlDocument.cs:</p>
<pre class="csharpcode"><span class="kwrd">using</span> System;<br /><span class="kwrd">using</span> System.Runtime.Serialization;<br /><span class="kwrd">using</span> System.Xml;<br /><span class="kwrd">using</span> System.IO;<br /><br /><span class="kwrd">namespace</span> Pluralsight.Samples<br />{<br />    [Serializable]<br />    <span class="kwrd">public</span> <span class="kwrd">class</span> SerializableXmlDocument : ISerializable<br />    {<br />        <span class="kwrd">public</span> SerializableXmlDocument() { }<br />        <span class="kwrd">public</span> SerializableXmlDocument(XmlDocument <span class="kwrd">value</span>)<br />        {<br />            <span class="kwrd">this</span>.Value = <span class="kwrd">value</span>;<br />        }<br /><br />        <span class="kwrd">public</span> XmlDocument Value { get; set; }<br /><br />        <span class="preproc">#region</span> ISerializable implementation<br />        <span class="kwrd">public</span> SerializableXmlDocument(SerializationInfo info,<br />                                       StreamingContext context)<br />        {<br />            <span class="kwrd">byte</span>[] serializedData = (<span class="kwrd">byte</span>[])info.GetValue(<span class="str">&quot;doc&quot;</span>,<br />                <span class="kwrd">typeof</span>(<span class="kwrd">byte</span>[]));<br />            <span class="kwrd">if</span> (<span class="kwrd">null</span> != serializedData)<br />                <span class="kwrd">this</span>.Value = Deserialize(serializedData);<br />        }<br /><br />        <span class="kwrd">public</span> <span class="kwrd">void</span> GetObjectData(SerializationInfo info,<br />                                  StreamingContext context)<br />        {<br />            <span class="kwrd">byte</span>[] serializedData = <span class="kwrd">null</span>;<br />            <span class="kwrd">if</span> (<span class="kwrd">null</span> != Value)<br />                serializedData = Serialize(Value);<br />            info.AddValue(<span class="str">&quot;doc&quot;</span>, serializedData);<br />        }<br />        <span class="preproc">#endregion</span><br /><br />        <span class="preproc">#region</span> <span class="kwrd">implicit</span> conversion to/from XmlDocument<br />        <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">implicit</span> <span class="kwrd">operator</span> SerializableXmlDocument(<br />            XmlDocument doc)<br />        {<br />            <span class="kwrd">return</span> <span class="kwrd">new</span> SerializableXmlDocument(doc);<br />        }<br />        <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">implicit</span> <span class="kwrd">operator</span> XmlDocument(<br />            SerializableXmlDocument sdoc)<br />        {<br />            <span class="kwrd">return</span> sdoc.Value;<br />        }<br />        <span class="preproc">#endregion</span><br /><br />        <span class="preproc">#region</span> Xml serialization helper methods<br />        <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">byte</span>[] Serialize(XmlDocument doc)<br />        {<br />            MemoryStream stream = <span class="kwrd">new</span> MemoryStream();<br />            doc.Save(stream);<br />            <span class="kwrd">return</span> stream.CopyUpToSeekPointer();<br />        }<br />        <span class="kwrd">private</span> <span class="kwrd">static</span> XmlDocument Deserialize(<span class="kwrd">byte</span>[] serializedData)<br />        {<br />            XmlDocument doc = <span class="kwrd">new</span> XmlDocument();<br />            doc.Load(<span class="kwrd">new</span> MemoryStream(serializedData, <span class="kwrd">false</span>));<br />            <span class="kwrd">return</span> doc;<br />        }<br />        <span class="preproc">#endregion</span><br />    }<br />}</pre>
<p>...and here&#39;s the CopyUpToSeekPointer extension method for MemoryStream:</p>
<pre class="csharpcode"><span class="kwrd">using</span> System;<br /><span class="kwrd">using</span> System.IO;<br /><br /><span class="kwrd">namespace</span> Pluralsight.Samples<br />{<br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">class</span> MemoryStreamExtensionMethods<br />    {<br />        <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">byte</span>[] CopyUpToSeekPointer(<br />            <span class="kwrd">this</span> MemoryStream stream)<br />        {<br />            <span class="rem">// copy only the part of the buffer</span><br />            <span class="rem">// that contains the serialized document</span><br />            <span class="kwrd">long</span> length = stream.Position;<br />            <span class="kwrd">byte</span>[] buffer = stream.GetBuffer();<br />            <span class="kwrd">byte</span>[] result = <span class="kwrd">new</span> <span class="kwrd">byte</span>[length];<br />            <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; length; ++i)<br />                result[i] = buffer[i];<br />            <span class="kwrd">return</span> result;<br />        }<br />    }<br />}</pre>
<p>...and here&#39;s a sample object that uses SerializableXmlDocument:</p>
<pre class="csharpcode"><span class="kwrd">using</span> System;<br /><br /><span class="kwrd">namespace</span> Pluralsight.Samples<br />{<br />    [Serializable]<br />    <span class="kwrd">public</span> <span class="kwrd">class</span> Item<br />    {<br />        <span class="kwrd">public</span> <span class="kwrd">string</span> Name { get; set; }<br />        <span class="kwrd">public</span> SerializableXmlDocument Data { get; set; }<br /><br />        <span class="kwrd">public</span> <span class="kwrd">void</span> Print()<br />        {<br />            Console.WriteLine(<span class="str">&quot;Name: {0}&quot;</span>, Name);<br />            Console.WriteLine(Data.Value.OuterXml);<br />        }<br />    }<br />}</pre>
<p>...and here&#39;s a sample program that creates an instance of Item, serializes it, then deserializes it, printing diagnostics along the way to show that it&#39;s working properly.</p>
<pre class="csharpcode"><span class="kwrd">using</span> System;<br /><span class="kwrd">using</span> System.Xml;<br /><span class="kwrd">using</span> System.Runtime.Serialization.Formatters.Binary;<br /><span class="kwrd">using</span> System.IO;<br /><span class="kwrd">using</span> Pluralsight.Samples;<br /><br /><span class="kwrd">class</span> DemoProgram<br />{<br />    <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)<br />    {<br />        XmlDocument doc = <span class="kwrd">new</span> XmlDocument();<br />        doc.LoadXml(<span class="str">&quot;&lt;root&gt;&lt;child&gt;text&lt;/child&gt;&lt;/root&gt;&quot;</span>);<br /><br />        Item item = <span class="kwrd">new</span> Item<br />        {<br />            Name = <span class="str">&quot;Testing 123&quot;</span>,<br />            Data = doc,<br />        };<br /><br />        <span class="rem">// print object before serialization</span><br />        item.Print();<br /><br />        BinaryFormatter formatter = <span class="kwrd">new</span> BinaryFormatter();<br />        MemoryStream stream = <span class="kwrd">new</span> MemoryStream();<br />        formatter.Serialize(stream, item);<br /><br />        <span class="kwrd">byte</span>[] serializedItem = stream.CopyUpToSeekPointer();<br /><br />        Console.WriteLine(<span class="str">&quot;Serialized data (base64): {0}&quot;</span>,<br />            Convert.ToBase64String(serializedItem));<br /><br />        item = (Item)formatter.Deserialize(<br />            <span class="kwrd">new</span> MemoryStream(serializedItem, <span class="kwrd">false</span>));<br /><br />        <span class="rem">// print object after deserialization</span><br />        item.Print();<br />    }<br />}</pre>
<p>Here&#39;s the output of the previous sample program:</p>
<p><a href="http://www.pluralsight.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/keith/sample_2D00_output_5F00_2.jpg"><img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" alt="sample-output" src="http://www.pluralsight.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/keith/sample_2D00_output_5F00_thumb.jpg" width="422" border="0" height="214" /></a>&nbsp;</p>
<p>Flame away!</p><div style="clear:both;"></div><img src="http://www.pluralsight.com/community/aggbug.aspx?PostID=52538" width="1" height="1">]]></content:encoded>
      <pubDate>Mon, 18 Aug 2008 22:58:00 +0000</pubDate>
      <category domain="http://securityratty.com/tag/public class item">public class item</category>
      <category domain="http://securityratty.com/tag/public">public</category>
      <category domain="http://securityratty.com/tag/public void getobjectdata">public void getobjectdata</category>
      <category domain="http://securityratty.com/tag/public static byte">public static byte</category>
      <category domain="http://securityratty.com/tag/xmldocument">xmldocument</category>
      <category domain="http://securityratty.com/tag/return doc">return doc</category>
      <category domain="http://securityratty.com/tag/return">return</category>
      <category domain="http://securityratty.com/tag/static byte">static byte</category>
      <category domain="http://securityratty.com/tag/public class">public class</category>
      <source url="http://www.pluralsight.com/community/blogs/keith/archive/2008/08/18/serializable-xmldocument.aspx">Serializable XmlDocument</source>
    </item>
    <item>
      <title><![CDATA[Facebook faces class-action suit over Beacon]]></title>
      <link>http://securityratty.com/article/ff6b5ab70cab7503321baa487c8b207e</link>
      <guid>http://securityratty.com/article/ff6b5ab70cab7503321baa487c8b207e</guid>
      <description><![CDATA[A class-action suit filed in California charges Facebook and a handful of other companies, including Blockbuster, Fandango and Overstock, with violating online privacy and computer fraud laws related...]]></description>
      <content:encoded><![CDATA[A class-action suit filed in California charges Facebook and a handful of other companies, including Blockbuster, Fandango and Overstock, with violating online privacy and computer fraud laws related to Facebook's controversial Beacon system.<p><A href="http://ad.doubleclick.net/jump/idg.us.nwf.rss/security;sz=468x60;ord=59428?">
<IMG src="http://ad.doubleclick.net/ad/idg.us.nwf.rss/security;sz=468x60;ord=59428?" border="0" width="468" height="60"></A>
</p>]]></content:encoded>
      <pubDate>Tue, 12 Aug 2008 20:00:00 +0000</pubDate>
      <category domain="http://securityratty.com/tag/facebook">facebook</category>
      <category domain="http://securityratty.com/tag/california charges facebook">california charges facebook</category>
      <category domain="http://securityratty.com/tag/class-action suit filed">class-action suit filed</category>
      <category domain="http://securityratty.com/tag/controversial beacon system">controversial beacon system</category>
      <category domain="http://securityratty.com/tag/computer fraud laws">computer fraud laws</category>
      <category domain="http://securityratty.com/tag/online privacy">online privacy</category>
      <category domain="http://securityratty.com/tag/fandango">fandango</category>
      <category domain="http://securityratty.com/tag/overstock">overstock</category>
      <category domain="http://securityratty.com/tag/companies">companies</category>
      <source url="http://www.networkworld.com/news/2008/081308-facebook-faces-class-action-suit-over.html?fsrc=rss-security">Facebook faces class-action suit over Beacon</source>
    </item>
    <item>
      <title><![CDATA[BlackHat Recap]]></title>
      <link>http://securityratty.com/article/bec2ea65daab94e0e7001ef1ba7b1b9a</link>
      <guid>http://securityratty.com/article/bec2ea65daab94e0e7001ef1ba7b1b9a</guid>
      <description><![CDATA[Another BlackHat has come and gone. As usual, it was a very busy week juggling customer meetings, recruiting, conference planning, vendor parties, and, oh yes, the actual BlackHat presentations. I had...]]></description>
      <content:encoded><![CDATA[<p>Another BlackHat has come and gone.  As usual, it was a very busy week juggling customer meetings, recruiting, conference planning, vendor parties, and, oh yes, the actual BlackHat presentations.  I had a fantastic time catching up with old friends and finally getting the opportunity to meet more of the <a href="http://n0where.org/security-twits/">Security Twits</a> and others in the security community.  I didn&#8217;t submit a talk this year, but nevertheless, fake Dan Kaminsky was still excited to see me.</p>
<p><a href="http://www.veracode.com/blog/wp-content/uploads/2008/08/chris_2742966251_1b47297b33_b.jpg"><center><img src="http://www.veracode.com/blog/wp-content/uploads/2008/08/chris_2742966251_1b47297b33_b-300x225.jpg" alt="" title="chris_2742966251_1b47297b33_b" width="300" height="225" class="aligncenter size-medium wp-image-215 photoborder" /></center></a></p>
<p>My favorite talk, as expected, was the Sotirov/Dowd talk on <a href="http://taossa.com/archive/bh08sotirovdowd.pdf">How To Impress Girls With Browser Memory Protection Bypasses</a>.  The attack is a conceptually simple, yet completely reliable technique for exploiting vulnerabilities in web browsers.  Of course, the media has <a href="http://searchsecurity.techtarget.com/news/article/0,289142,sid14_gci1324395,00.html">sensationalized </a> the impact of their findings, but ultimately, this is still significant as far as browser-based exploits are concerned.  It&#8217;s worth mentioning that part of the technique allowing them to load a .NET DLL at an arbitrary location under Vista was reliant on an implementation bug wherein the OS disables ASLR if the version in the .NET COR header was below a certain value.  However, the address space spraying and stack spraying techniques are likely to be extended to other platforms utilizing similar memory protection mechanisms.  </p>
<p>As for the girls?  I can report first-hand that the ladies at TAO on Wednesday night were hanging on <a href="http://twitter.com/alexsotirov">Alex</a>&#8217;s every word.  They were particularly impressed when he whipped out the laptop for a live demo.  Unfortunately, none of the dozen iPhone owners in the immediate vicinity thought to snap a picture (too busy Twittering).  Oh well.  </p>
<p>I also enjoyed Hovav Shacham&#8217;s talk on return-oriented programming.  Simply put, he described a generalization of the return-to-libc shellcode approach with the intent to demonstrate that one could achieve Turing-complete computation using &#8220;found code&#8221; in process images.  By chaining together series of mini-computations ending in return (RET) instructions, it was possible to build higher-level programming constructs such as branches and loops.  The nature of the x86 instruction set provides some flexibility because instructions are interpreted differently depending on how you align the instruction pointer (i.e. the old shellcode trick of searching the process image for any JMP EBX instruction and using that as your EIP).  In RISC architectures such as SPARC, however, you don&#8217;t have that luxury; if your %pc isn&#8217;t aligned properly you get a bus error.  So it was quite interesting to see that they were able to extend the concept to RISC.  The practicality of the attack technique is limited by the fact that the shellcode is tuned to a particular binary image &#8212; if the shellcode was built using instructions extrapolated from glibc 2.3.5, it won&#8217;t work for a system running glibc 2.4.  </p>
<p>I thought Scott Stender&#8217;s talk on <a href="http://isecpartners.com/files/iSEC%20Partners%20-%20Concurrency%20Attacks%20in%20Web%20Applications.pdf">Concurrency Attacks in Web Applications</a> was interesting as well.  In a nutshell, spewing thousands of simultaneous requests at web application transactions that are not thread-safe can create interesting problems.  In the presentation, Scott ran his demo against a VM running on the attack machine.  I found myself wondering how effective the same attack would be over the Internet &#8212; would it be significantly less reliable (or not at all)?  Race conditions are generally easier to exploit locally than remotely due to more predictable execution conditions.  Certainly this is an under-tested vulnerability class though.</p>
<p>One presentation I wasn&#8217;t able to attend but want to follow up on is <a href="http://twitter.com/nate_mcfeters">Nate McFeters</a>, John Heasman, and Rob Carter&#8217;s talk which discussed the GIFAR attack I&#8217;ve been hearing so much about lately.  The gist is that you can create a file that is both a valid GIF and a valid JAR, then use some Java applet tricks to initiate HTTP requests on behalf of the victim.  </p>
<p>Finally, the <a href="http://pwnie-awards.org/2008/">Pwnie Awards</a> didn&#8217;t fail to disappoint.  Drama ensued over the Most Overhyped award, but at least this year some of the winners showed up to claim their awards!  <a href="http://twitter.com/halvarflake">Halvar</a> rapping Symantec lyrics was also quite memorable.</p>
<p>All in all, a fun and informative week, but as usual, I was relieved to get the hell out of Vegas and head home on Friday morning. </p>
<p>P.S. For a much more entertaining BlackHat/Defcon Recap, read <a href="http://securityuncorked.net/2008/08/anecdotes-blackhat-defcon/">Jennifer Jabbusch&#8217;s account</a> of the week&#8217;s events.  It&#8217;s my favorite one so far!</p>
]]></content:encoded>
      <pubDate>Tue, 12 Aug 2008 18:43:18 +0000</pubDate>
      <category domain="http://securityratty.com/tag/favorite">favorite</category>
      <category domain="http://securityratty.com/tag/favorite talk">favorite talk</category>
      <category domain="http://securityratty.com/tag/talk">talk</category>
      <category domain="http://securityratty.com/tag/sotirovdowd talk">sotirovdowd talk</category>
      <category domain="http://securityratty.com/tag/scott stenders talk">scott stenders talk</category>
      <category domain="http://securityratty.com/tag/completely reliable technique">completely reliable technique</category>
      <category domain="http://securityratty.com/tag/reliable">reliable</category>
      <category domain="http://securityratty.com/tag/attack">attack</category>
      <category domain="http://securityratty.com/tag/technique">technique</category>
      <source url="http://www.veracode.com/blog/?p=202">BlackHat Recap</source>
    </item>
    <item>
      <title><![CDATA[BlackHat Recap]]></title>
      <link>http://securityratty.com/article/6b779e65a6ad790dd8e631057208ff77</link>
      <guid>http://securityratty.com/article/6b779e65a6ad790dd8e631057208ff77</guid>
      <description><![CDATA[Another BlackHat has come and gone. As usual, it was a very busy week juggling customer meetings, recruiting, conference planning, vendor parties, and, oh yes, the actual BlackHat presentations. I had...]]></description>
      <content:encoded><![CDATA[<p>Another BlackHat has come and gone.  As usual, it was a very busy week juggling customer meetings, recruiting, conference planning, vendor parties, and, oh yes, the actual BlackHat presentations.  I had a fantastic time catching up with old friends and finally getting the opportunity to meet more of the <a href="http://n0where.org/security-twits/">Security Twits</a> and others in the security community.  I didn&#8217;t submit a talk this year, but nevertheless, <a href="http://flickr.com/photos/fakedankaminsky/">fake Dan Kaminsky</a> was still excited to see me.</p>
<p><a href="http://www.veracode.com/blog/wp-content/uploads/2008/08/chris_2742966251_1b47297b33_b.jpg"><center><img src="http://www.veracode.com/blog/wp-content/uploads/2008/08/chris_2742966251_1b47297b33_b-300x225.jpg" alt="" title="chris_2742966251_1b47297b33_b" width="300" height="225" class="aligncenter size-medium wp-image-215 photoborder" /></center></a></p>
<p>My favorite talk, as expected, was the Sotirov/Dowd talk on <a href="http://taossa.com/archive/bh08sotirovdowd.pdf">How To Impress Girls With Browser Memory Protection Bypasses</a>.  The attack is a conceptually simple, yet completely reliable technique for exploiting vulnerabilities in web browsers.  Of course, the media has <a href="http://searchsecurity.techtarget.com/news/article/0,289142,sid14_gci1324395,00.html">sensationalized</a> the impact of their findings, but ultimately, this is still significant as far as browser-based exploits are concerned (here is a <a href="http://blogs.zdnet.com/Bott/?p=513">more accurate report</a>).  It&#8217;s worth mentioning that part of the technique allowing them to load a .NET DLL at an arbitrary location under Vista was reliant on an implementation bug wherein the OS disables ASLR if the version in the .NET COR header was below a certain value.  However, the address space spraying and stack spraying techniques are likely to be extended to other platforms utilizing similar memory protection mechanisms.  </p>
<p>As for the girls?  I can report first-hand that the ladies at TAO on Wednesday night were hanging on <a href="http://twitter.com/alexsotirov">Alex</a>&#8217;s every word.  They were particularly impressed when he whipped out the laptop for a live demo.  Unfortunately, none of the dozen iPhone owners in the immediate vicinity thought to snap a picture (too busy Twittering).  Oh well.  </p>
<p>I also enjoyed Hovav Shacham&#8217;s talk on return-oriented programming.  Simply put, he described a generalization of the return-to-libc shellcode approach with the intent to demonstrate that one could achieve Turing-complete computation using &#8220;found code&#8221; in process images.  By chaining together series of mini-computations ending in return (RET) instructions, it was possible to build higher-level programming constructs such as branches and loops.  The nature of the x86 instruction set provides some flexibility because instructions are interpreted differently depending on how you align the instruction pointer (i.e. the old shellcode trick of searching the process image for any JMP EBX instruction and using that as your EIP).  In RISC architectures such as SPARC, however, you don&#8217;t have that luxury; if your %pc isn&#8217;t aligned properly you get a bus error.  So it was quite interesting to see that they were able to extend the concept to RISC.  The practicality of the attack technique is limited by the fact that the shellcode is tuned to a particular binary image &#8212; if the shellcode was built using instructions extrapolated from glibc 2.3.5, it won&#8217;t work for a system running glibc 2.4.  </p>
<p>I thought Scott Stender&#8217;s talk on <a href="http://isecpartners.com/files/iSEC%20Partners%20-%20Concurrency%20Attacks%20in%20Web%20Applications.pdf">Concurrency Attacks in Web Applications</a> was interesting as well.  In a nutshell, spewing thousands of simultaneous requests at web application transactions that are not thread-safe can create interesting problems.  In the presentation, Scott ran his demo against a VM running on the attack machine.  I found myself wondering how effective the same attack would be over the Internet &#8212; would it be significantly less reliable (or not at all)?  Race conditions are generally easier to exploit locally than remotely due to more predictable execution conditions.  Certainly this is an under-tested vulnerability class though.</p>
<p>One presentation I wasn&#8217;t able to attend but want to follow up on is <a href="http://twitter.com/nate_mcfeters">Nate McFeters</a>, John Heasman, and Rob Carter&#8217;s talk which discussed the GIFAR attack I&#8217;ve been hearing so much about lately.  The gist is that you can create a file that is both a valid GIF and a valid JAR, then use some Java applet tricks to initiate HTTP requests on behalf of the victim.  </p>
<p>Finally, the <a href="http://pwnie-awards.org/2008/">Pwnie Awards</a> didn&#8217;t fail to disappoint.  Drama ensued over the Most Overhyped award, but at least this year some of the winners showed up to claim their awards!  <a href="http://twitter.com/halvarflake">Halvar</a> rapping Symantec lyrics was also quite memorable.</p>
<p>All in all, a fun and informative week, but as usual, I was relieved to get the hell out of Vegas and head home on Friday morning. </p>
<p>P.S. For a much more entertaining BlackHat/Defcon Recap, read <a href="http://securityuncorked.net/2008/08/anecdotes-blackhat-defcon/">Jennifer Jabbusch&#8217;s account</a> of the week&#8217;s events.  It&#8217;s my favorite one so far!</p>
]]></content:encoded>
      <pubDate>Tue, 12 Aug 2008 18:43:18 +0000</pubDate>
      <category domain="http://securityratty.com/tag/favorite">favorite</category>
      <category domain="http://securityratty.com/tag/favorite talk">favorite talk</category>
      <category domain="http://securityratty.com/tag/talk">talk</category>
      <category domain="http://securityratty.com/tag/sotirovdowd talk">sotirovdowd talk</category>
      <category domain="http://securityratty.com/tag/scott stenders talk">scott stenders talk</category>
      <category domain="http://securityratty.com/tag/completely reliable technique">completely reliable technique</category>
      <category domain="http://securityratty.com/tag/reliable">reliable</category>
      <category domain="http://securityratty.com/tag/attack">attack</category>
      <category domain="http://securityratty.com/tag/technique">technique</category>
      <source url="http://www.veracode.com/blog/2008/08/blackhat-recap/">BlackHat Recap</source>
    </item>
    <item>
      <title><![CDATA[Black Hat wrap up - secure@microsoft, booth babes and bloggers]]></title>
      <link>http://securityratty.com/article/bd7d7b3698d05a16a10cc4d0a21e2bfd</link>
      <guid>http://securityratty.com/article/bd7d7b3698d05a16a10cc4d0a21e2bfd</guid>
      <description><![CDATA[You can read plenty of other blogs about some of the great presentations at Black Hat. So I thought I would take another angle and talk about some of the other stuff that may be important to you
1....]]></description>
      <content:encoded><![CDATA[<p></p>  <p>You can read plenty of other blogs about some of the great presentations at Black Hat.  So I thought I would take another angle and talk about some of the other stuff that may be important to you.</p>  <p>1.  <a href="mailto:secure@microsoft.com"><font face="Courier"><a href="http://www.stillsecureafteralltheseyears.com/ashimmy/WindowsLiveWriter/Picture%20049.jpg"><img title="Picture 049" style="border-right: 0px; border-top: 0px; margin: 5px 10px 5px 0px; border-left: 0px; border-bottom: 0px" height="184" alt="Picture 049" src="http://www.stillsecureafteralltheseyears.com/ashimmy/WindowsLiveWriter/Picture%20049_thumb.jpg" width="244" align="left" border="0"></img></a></font><font face="Courier New">secure@microsoft.com</font></a> – This years hottest party was again the Microsoft party.  This year it was at the LAX club in the Luxor.  As usual there were quite a number of people at the door who thought they could talk their way in or worse yet were told they “were one the list”.  I was happy to be able to go and saw many of the usual suspects there as well. I had to leave the party early to go catch my red eye flight home, so went right to the airport from the party.  As I wrote earlier, Microsoft is trying really hard on security.  But I couldn’t help but notice the irony of this grainy, lousy picture of the DJ booth at the party.  If you can, notice the computers that the <a href="mailto:secure@microsoft.com">secure@microsoft.com</a> DJs are using. That’s right they are Macs!</p>  <p>2. A new low for booth babes – What would a Shimel review of a trade show be without a booth babe rant.  Hey I recognize it is Vegas and all, but EdgeOS went way over the line this year.  A booth babe dressed as a Las Vegas showgirl or some other type of costume makes a statement.  I personally don’t like exploiting woman to make that statement, but I understand.  However, these guys had woman who were dressed so raunchy and classless, that I could not bring myself to post a picture of them.  Come on guys!  You want to resort to the booth babe thing (and BTW I think the Black Hat crowd does not respond to that), at least have a little class.  These girls looked like street walkers and do you and your company no favors.  Is that really the image you want to promote?  Grow up!</p>  <p>3.  The Security Bloggers Network – We are back!  With the end of the Black Hat show, the SBN is going back to being the<a href="http://www.stillsecureafteralltheseyears.com/ashimmy/WindowsLiveWriter/securitybloggers.gif"><img title="securitybloggers" style="margin: 5px 5px 5px 10px" height="147" alt="securitybloggers" src="http://www.stillsecureafteralltheseyears.com/ashimmy/WindowsLiveWriter/securitybloggers_thumb.gif" width="112" align="right" border="0"></img></a> SBN.  The old logo is back and our promotion with Black Hat is at an end.  However, I want to personally thank so many of you SBN members who blogged about Black Hat.  The Black Hat marketing folks made it a point to come over to me and thank us for the overwhelming support and help of the community.  Our network delivered big time with them and they are already thinking about ways we can work together next year.  I will keep you all posted on that.</p>  <p>We have several new promotions we are working on with the SBN and will have more on that soon. Also, we learned some valuable lessons.  Next time we will work with the network members more closely in doing these affiliations.  Also, for any show like this we need to have an official bloggers get together.  Not because we don’t want to buy our own drinks (thanks to Chris Hoff for doing more than his share in picking up a big bar tab), but frankly we need to reserve a place that has enough space for us.  Security bloggers are big time. We have a great community of people who get together. Lets make it better.</p>  <p>I have some other ideas around the SBN I am working on too and want to form a committee to help. If you are a member and want to get involved, please drop me a line or comment.</p>  <p>Anyway, another year of Black Hat is in the books. It was a good one and I can’t wait until next year!</p>
<p><a href="http://feeds.feedburner.com/~a/StillsecureAfterAllTheseYears?a=mqB9CC"><img src="http://feeds.feedburner.com/~a/StillsecureAfterAllTheseYears?i=mqB9CC" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?a=rP6xlK"><img src="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?i=rP6xlK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?a=fhzqOK"><img src="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?i=fhzqOK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?a=roBQzK"><img src="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?i=roBQzK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?a=yW5ceK"><img src="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?i=yW5ceK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?a=zosCbk"><img src="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?i=zosCbk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?a=XDP8lk"><img src="http://feeds.feedburner.com/~f/StillsecureAfterAllTheseYears?i=XDP8lk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/StillsecureAfterAllTheseYears/~4/359668026" height="1" width="1"/>]]></content:encoded>
      <pubDate>Fri, 08 Aug 2008 10:46:21 +0000</pubDate>
      <category domain="http://securityratty.com/tag/booth">booth</category>
      <category domain="http://securityratty.com/tag/black hat">black hat</category>
      <category domain="http://securityratty.com/tag/booth babes">booth babes</category>
      <category domain="http://securityratty.com/tag/booth babe rant">booth babe rant</category>
      <category domain="http://securityratty.com/tag/black hat crowd">black hat crowd</category>
      <category domain="http://securityratty.com/tag/security bloggers network">security bloggers network</category>
      <category domain="http://securityratty.com/tag/network">network</category>
      <category domain="http://securityratty.com/tag/security bloggers">security bloggers</category>
      <category domain="http://securityratty.com/tag/booth babe">booth babe</category>
      <source url="http://feeds.feedburner.com/~r/StillsecureAfterAllTheseYears/~3/359668026/black-hat-wrap.html">Black Hat wrap up - secure@microsoft, booth babes and bloggers</source>
    </item>
    <item>
      <title><![CDATA[Apptis and USNS Mercy Monitoring on the High Seas]]></title>
      <link>http://securityratty.com/article/32ab3189b54d8e46b467ebbf87db32e0</link>
      <guid>http://securityratty.com/article/32ab3189b54d8e46b467ebbf87db32e0</guid>
      <description><![CDATA[Meet Mike Lawson, Pre-Sales Engineer at Apptis, a leading system integrator and ScienceLogic partner that has deployed EM7 to meet the network, systems and application management needs of several...]]></description>
      <content:encoded><![CDATA[<p><img style="border-right: 0px; border-top: 0px; margin: 0px 10px 10px 0px; border-left: 0px; border-bottom: 0px" height="244" alt="mike2 (Small)" src="http://blog.sciencelogic.com/wp-content/uploads/2008/08/mike2-small.jpg" width="204" align="left" border="0"> Meet Mike Lawson, Pre-Sales Engineer at Apptis, a leading system integrator and ScienceLogic partner that has deployed EM7 to meet the network, systems and application management needs of several customers. We thought Mike would have an interesting perspective to share on EM7, having recently come from the “customer side” and already with a few deployments under his belt.
<p><b>ScienceLogic: Mike, what’s your background working with network and management system tools?</b>
<p><b>Mike Lawson: </b>Before joining Apptis, I worked for the Air Force, mainly in satellite communications for almost nine years. I’m probably most familiar with HP OpenView and BMC Remedy. I managed a team that used them but wasn’t involved in tool selection; like many other federal IT workers, we didn’t have a choice of tools because there were existing enterprise licenses and maintenance contracts.
<p>I also saw a large systems integrator do a full Remedy/Crystal Systems/OpenView installation. It took 6 weeks to stand up and customize to meet just the basic monitoring requirements, and it cost something like half a million dollars. At the time, I thought that wasn’t bad and was a pretty typical experience.
<p><b>ScienceLogic: Coming from where you did, what’s your take on EM7?</b>
<p><strong>Mike Lawson:</strong> Honestly, I didn’t believe that EM7 could really do all that it claimed. In many ways, it was the complete opposite of what I had seen first-hand with other monitoring solutions. Could it really cover that much functionality? At relatively much lower cost to the customer and without the licensing nightmare?
<p>That quickly changed when I needed to understand the system enough to run it at a customer’s site. I went back over the training docs I received during my initial training class and jumped in; now, 6 months later, I’m the EM7 expert and can tell you that it delivers on all those promises. (But I still need to show people to get them to believe it too)
<p>I preach the “EM7 gospel” and when anyone wants to talk monitoring, I ask about the universal pain points: cost, maintenance contracts and licensing, and then I explain EM7. The cost difference is real; the solution is based on capacity, so there’s no licensing and it’s easy to use. They are shocked to learn that they can buy multiple EM7 appliances and years of maintenance for what they paid for most other tools.
<p><b>ScienceLogic: Apptis won the contract for monitoring aboard the USNS Mercy. We love that you’re using EM7 for one of the Navy’s hospital ships. Can you tell us more?</b>
<p><strong>Mike Lawson:</strong> The USNS Mercy is a Military Sealift Command hospital ship. <a href="http://www.navy.mil/navydata/fact_display.asp?cid=4400&amp;tid=400&amp;ct=4" target="_blank">Some stats</a>:
<ul>
<li>849 feet long (nearly the size of a football field)
<li>12 fully-equipped operating rooms, a 1,000 bed hospital facility, digital radiological services, a diagnostic and clinical laboratory, a pharmacy, an optometry lab, a CAT scan and two oxygen producing plants
<li>Crew: 61 civilian mariners, 956 Naval medical staff, and 259 Naval support staff</li>
</ul>
<p>The USNS recently departed on a five-month humanitarian mission in the Western Pacific and Southeast Asia in support of Pacific Partnership 2008. The partnership provides international medical, dental and engineering teams this summer to provide humanitarian support and conduct joint, combined, and cooperative Civil-Military Operations in order to improve regional stability and build partner capacity to respond to natural disasters and pandemic.
<p>For the most part, the ship’s network is self-contained, but can also use a landline when docked. The network covers 400 devices, including Windows/Exchange servers and VMware for server virtualization. Prior to using EM7, none of the monitoring was integrated; each system was independently monitored through individual vendor-specific consoles.
<p>Out of the box, EM7 provided integrated systems, application and network management for all network gear, applications and virtual machines in one solution. We didn’t have to do a lot of customization – EM7 includes best-practice based thresholds, event and monitoring templates and this covered what USNS Mercy needed to monitor.
<p><b>ScienceLogic: You’re a systems integrator with a very useful “customer point of view” when it comes to looking at tools. From that perspective, can you share what you think are the biggest benefits that EM7 provides?</b>
<p><strong>Mike Lawson:</strong> First of all, EM7 stands up right away. We’re talking days, not weeks. In contrast to the lengthy installation of OpenView and Remedy I witnessed during my military career, I was able to configure, customize, and implement the EM7 solution for the USNS Mercy in three days.
<p>Second, it’s easy to train people on and the support is outstanding. This judgment is from first-hand experience. Right before the USNS Mercy departed on its latest voyage, the system administrator I had trained on EM7 left, so I had all of a day to train some new EM7 admins. I prepared a seven-page “cheat sheet” and over a 3-hour conference call, we walked through the entire EM7 solution; I haven’t gotten a support call since.
<p>And when a problem did crop up with a device being discovered incorrectly, ScienceLogic was very responsive. We contacted ScienceLogic support on a Saturday and they created and emailed us a video to help troubleshoot the same day. Within 30 seconds of watching the video, the problem was resolved.
<p>Finally, EM7 helps us be good stewards of the government’s money. This is very important to me personally and to Apptis as a company. Because EM7 is cheaper and deploys so quickly and easily, you might think that it’s just the opposite of what a system integrator would want to use. But that’s short-term thinking. We believe in deliver the most value for customers every time. It’s what creates trust and long-term relationships with our customers. Instead of that half million spent on standing up the solution and basic setup, I’d much rather (and I know the customer would rather) spend that on fine-tuning or extending the solution to do much, much more.
<p>As a former government employee, I know what it’s like to use a tool that doesn’t fit my needs. EM7 proves that the best solution can totally break the old model of costly, lengthy installations. EM7 has the right model: the right solution and the right price delivered as an appliance that is easy to deploy, train on and use. </p>
<p><a href="http://sharethis.com/item?&wp=abc&amp;publisher=ea11358c-69de-4e80-9804-e964a8930b70&amp;title=Apptis+and+USNS+Mercy+%26ndash%3B+Monitoring+on+the+High+Seas&amp;url=http%3A%2F%2Fblog.sciencelogic.com%2Fapptis-and-usns-mercy-monitoring-on-the-high-seas%2F08%2F2008">ShareThis</a></p>]]></content:encoded>
      <pubDate>Thu, 07 Aug 2008 11:59:40 +0000</pubDate>
      <category domain="http://securityratty.com/tag/solution">solution</category>
      <category domain="http://securityratty.com/tag/entire em7 solution">entire em7 solution</category>
      <category domain="http://securityratty.com/tag/em7">em7</category>
      <category domain="http://securityratty.com/tag/em7 gospel">em7 gospel</category>
      <category domain="http://securityratty.com/tag/em7 proves">em7 proves</category>
      <category domain="http://securityratty.com/tag/em7 admins">em7 admins</category>
      <category domain="http://securityratty.com/tag/multiple em7 appliances">multiple em7 appliances</category>
      <category domain="http://securityratty.com/tag/em7 solution">em7 solution</category>
      <category domain="http://securityratty.com/tag/explain em7">explain em7</category>
      <source url="http://blog.sciencelogic.com/apptis-and-usns-mercy-monitoring-on-the-high-seas/08/2008">Apptis and USNS Mercy Monitoring on the High Seas</source>
    </item>
    <item>
      <title><![CDATA[Better exception reporting in ASP.NET part 2]]></title>
      <link>http://securityratty.com/article/b878f7921917b371086606df6d043229</link>
      <guid>http://securityratty.com/article/b878f7921917b371086606df6d043229</guid>
      <description><![CDATA[This is the third post in a series
The first post described the problem: ASP.NET wasn't reporting inner exception stack traces
The second post described my solution
This post shows the code I used to...]]></description>
      <content:encoded><![CDATA[<p>This is the third post in a series.</p> <p>The <a href="http://www.pluralsight.com/community/blogs/keith/archive/2008/08/01/asp-net-health-monitoring-doesn-t-log-inner-exception-stack-trace.aspx" target="_blank">first post</a> described the problem: ASP.NET wasn&#39;t reporting inner exception stack traces.</p> <p>The <a href="http://www.pluralsight.com/community/blogs/keith/archive/2008/08/01/better-exception-reporting-in-asp-net.aspx" target="_blank">second post</a> described my solution.</p> <p>This post shows the code I used to solve the problem: a custom email provider for the Health Monitoring system in ASP.NET. Enjoy!</p> <p>Here&#39;s the provider. Note that I opted *not* to build a buffering provider to keep things simple:</p><pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyMailWebEventProvider : WebEventProvider
{
    <span class="kwrd">string</span> to;
    <span class="kwrd">string</span> from;
    <span class="kwrd">string</span> subjectPrefix;

    <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> Initialize(<span class="kwrd">string</span> name,
        NameValueCollection config)
    {
        <span class="kwrd">base</span>.Initialize(name, config);

        to = GetAndRemoveStringAttribute(config, <span class="str">&quot;to&quot;</span>, <span class="kwrd">true</span>);
        from = GetAndRemoveStringAttribute(config, <span class="str">&quot;from&quot;</span>, <span class="kwrd">true</span>);
        subjectPrefix = GetAndRemoveStringAttribute(config,
            <span class="str">&quot;subjectPrefix&quot;</span>, <span class="kwrd">false</span>);
    }
    <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> ProcessEvent(WebBaseEvent raisedEvent)
    {
        SendMail(raisedEvent);
    }

    <span class="kwrd">private</span> <span class="kwrd">void</span> SendMail(WebBaseEvent raisedEvent)
    {
        <span class="kwrd">string</span> subject = ComputeEmailSubject(raisedEvent);
        <span class="kwrd">string</span> body = ComputeEmailBody(raisedEvent);

        MailMessage msg = <span class="kwrd">new</span> MailMessage(from, to, subject, body);
        <span class="kwrd">new</span> SmtpClient().Send(msg);
    }

    <span class="kwrd">private</span> <span class="kwrd">string</span> ComputeEmailBody(WebBaseEvent raisedEvent)
    {
        WebRequestErrorEvent errorEvent =
            raisedEvent <span class="kwrd">as</span> WebRequestErrorEvent;
        <span class="kwrd">if</span> (<span class="kwrd">null</span> != errorEvent)
            <span class="kwrd">return</span> ErrorEventFormattingHelper.FormatRequestErrorEvent(errorEvent);
        <span class="kwrd">else</span> <span class="kwrd">return</span> raisedEvent.ToString();
    }

    <span class="kwrd">private</span> <span class="kwrd">string</span> ComputeEmailSubject(WebBaseEvent raisedEvent)
    {
        StringBuilder subjectBuilder = <span class="kwrd">new</span> StringBuilder();

        <span class="rem">// surface some details in subject about error events</span>
        WebBaseErrorEvent errorEvent = raisedEvent <span class="kwrd">as</span> WebBaseErrorEvent;
        <span class="kwrd">if</span> (<span class="kwrd">null</span> != errorEvent)
        {
            Exception unhandledException = errorEvent.ErrorException;

            <span class="rem">// drill through reflection exceptions to show the root cause</span>
            TargetInvocationException invocationException =
                unhandledException <span class="kwrd">as</span> TargetInvocationException;
            <span class="kwrd">if</span> (<span class="kwrd">null</span> != invocationException)
            {
                Exception innerException =
                    DrillIntoTargetInvocationException(invocationException);
                subjectBuilder.AppendFormat(<span class="str">&quot;{0}&quot;</span>,
                    (innerException ?? invocationException).GetType().Name);
                <span class="kwrd">if</span> (<span class="kwrd">null</span> != innerException)
                    subjectBuilder.Append(<span class="str">&quot; (via reflection)&quot;</span>);
            }
            <span class="kwrd">else</span> subjectBuilder.Append(unhandledException.GetType().Name);
        }

        <span class="rem">// if we&#39;ve not got anything better</span>
        <span class="rem">// just show the event type in the subject</span>
        <span class="kwrd">if</span> (0 == subjectBuilder.Length)
            subjectBuilder.AppendFormat(<span class="str">&quot;Event type: {0}&quot;</span>,
                raisedEvent.GetType().Name);

        <span class="kwrd">if</span> (!<span class="kwrd">string</span>.IsNullOrEmpty(subjectPrefix)) {
            subjectBuilder.Insert(0, <span class="str">&#39; &#39;</span>);
            subjectBuilder.Insert(0, subjectPrefix);
        }
        <span class="kwrd">return</span> subjectBuilder.ToString();
    }

    <span class="rem">/// &lt;summary&gt;</span>
    <span class="rem">/// Reflection often hides exception details, so we try to drill down</span>
    <span class="rem">/// through the plumbing exceptions to find a likely cause</span>
    <span class="rem">/// &lt;/summary&gt;</span>
    <span class="kwrd">private</span> Exception DrillIntoTargetInvocationException(
        TargetInvocationException outerException)
    {
        Exception innerException = outerException.InnerException;
        TargetInvocationException innerInvocationException =
            innerException <span class="kwrd">as</span> TargetInvocationException;
        <span class="kwrd">if</span> (<span class="kwrd">null</span> != innerInvocationException)
            <span class="kwrd">return</span> DrillIntoTargetInvocationException(innerInvocationException);
        <span class="kwrd">else</span> <span class="kwrd">if</span> (<span class="kwrd">null</span> != innerException)
            <span class="kwrd">return</span> innerException;
        <span class="kwrd">else</span> <span class="kwrd">return</span> <span class="kwrd">null</span>;
    }

    <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">string</span> GetAndRemoveStringAttribute(NameValueCollection config,
        <span class="kwrd">string</span> attributeName, <span class="kwrd">bool</span> required)
    {
        <span class="kwrd">string</span> <span class="kwrd">value</span> = config.Get(attributeName);
        <span class="kwrd">if</span> (required &amp;&amp; <span class="kwrd">string</span>.IsNullOrEmpty(<span class="kwrd">value</span>))
            <span class="kwrd">throw</span> <span class="kwrd">new</span> ConfigurationErrorsException(<span class="kwrd">string</span>.Format(
                <span class="str">&quot;Expected attribute {0}, which is missing or empty.&quot;</span>,
                attributeName));
        config.Remove(attributeName);
        <span class="kwrd">return</span> <span class="kwrd">value</span>;
    }

    <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> Flush()
    {
        <span class="rem">// nothing to do - this is not a buffering provider</span>
    }

    <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> Shutdown()
    {
        <span class="rem">// nothing to do here either</span>
    }
}</pre>
<p>Here&#39;s a helper class that formats the error messages the way I want to see them. Note that I&#39;ve omitted some fields that I personally didn&#39;t care about, and I&#39;ve reordered things a bit, so you might want to tweak this if you&#39;re going to use it in your own system.</p><pre class="csharpcode"><span class="kwrd">internal</span> <span class="kwrd">static</span> <span class="kwrd">class</span> ErrorEventFormattingHelper
{
    <span class="kwrd">internal</span> <span class="kwrd">static</span> <span class="kwrd">string</span> FormatRequestErrorEvent(
        WebRequestErrorEvent errorEvent)
    {
        CustomEventFormatter formatter = 
            <span class="kwrd">new</span> CustomEventFormatter();

        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Unhandled Exception in {0}:&quot;</span>,
            WebBaseEvent.ApplicationInformation
            .ApplicationVirtualPath));
        formatter.Indent();
        EmitExceptionAtAGlance(formatter, 
            errorEvent.ErrorException);
        formatter.RevertIndent();

        formatter.AppendLine();
        formatter.AppendLine(<span class="str">&quot;Exception stack trace(s):&quot;</span>);
        EmitExceptionStackTrace(formatter, 
            errorEvent.ErrorException);

        formatter.AppendLine();
        formatter.AppendLine(<span class="str">&quot;Event information:&quot;</span>);
        formatter.Indent();
        EmitEventInfo(formatter, errorEvent);
        formatter.RevertIndent();

        formatter.AppendLine();
        formatter.AppendLine(<span class="str">&quot;Application information:&quot;</span>);
        formatter.Indent();
        EmitApplicationInfo(formatter, 
            WebBaseEvent.ApplicationInformation);
        formatter.RevertIndent();

        formatter.AppendLine();
        formatter.AppendLine(<span class="str">&quot;Process/thread information:&quot;</span>);
        formatter.Indent();
        EmitProcessInfo(formatter, 
            errorEvent.ProcessInformation);
        formatter.RevertIndent();

        formatter.AppendLine();
        formatter.AppendLine(<span class="str">&quot;Request information:&quot;</span>);
        formatter.Indent();
        EmitRequestInfo(formatter, 
            errorEvent.RequestInformation);
        formatter.RevertIndent();

        <span class="kwrd">return</span> formatter.ToString();
    }

    <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> EmitEventInfo(
        CustomEventFormatter formatter,
        WebBaseEvent theEvent)
    {
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Event code: {0}&quot;</span>,
            theEvent.EventCode.ToString(
            CultureInfo.InvariantCulture)));
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Event message: {0}&quot;</span>, 
            theEvent.Message));
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Event time: {0}&quot;</span>, 
            theEvent.EventTime.ToString(
            CultureInfo.InvariantCulture)));
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Event ID: {0}&quot;</span>, 
            theEvent.EventID.ToString(<span class="str">&quot;N&quot;</span>, 
            CultureInfo.InvariantCulture)));
    }

    <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> EmitApplicationInfo(
        CustomEventFormatter formatter, 
        WebApplicationInformation appInfo)
    {
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Application domain: {0}&quot;</span>, 
            appInfo.ApplicationDomain));
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Application Virtual Path: {0}&quot;</span>, 
            appInfo.ApplicationVirtualPath));
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Application Physical Path: {0}&quot;</span>, 
            appInfo.ApplicationPath));
    }

    <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> EmitProcessInfo(
        CustomEventFormatter formatter, 
        WebProcessInformation webProcessInfo)
    {
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Process ID: {0}&quot;</span>, 
            webProcessInfo.ProcessID.ToString(
            CultureInfo.InvariantCulture)));
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Process name: {0}&quot;</span>, 
            webProcessInfo.ProcessName));
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Account name: {0}&quot;</span>, 
            webProcessInfo.AccountName));
    }

    <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> EmitRequestInfo(
        CustomEventFormatter formatter, 
        WebRequestInformation webRequestInfo)
    {
        <span class="kwrd">string</span> name = <span class="kwrd">null</span>;
        <span class="kwrd">if</span> (webRequestInfo.Principal != <span class="kwrd">null</span>)
            name = webRequestInfo.Principal.Identity.Name;

        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Request URL: {0}&quot;</span>, 
            webRequestInfo.RequestUrl));
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Request path: {0}&quot;</span>, 
            webRequestInfo.RequestPath));
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;User name: {0}&quot;</span>, 
            name ?? <span class="str">&quot;[ANONYMOUS]&quot;</span>));
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;User host address: {0}&quot;</span>, 
            webRequestInfo.UserHostAddress));
    }

    <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> EmitExceptionAtAGlance(
        CustomEventFormatter formatter, 
        Exception exception)
    {
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Type: {0}&quot;</span>, 
            exception.GetType().Name));
        formatter.AppendLine(<span class="kwrd">string</span>.Format(
            <span class="str">&quot;Message: {0}&quot;</span>, 
            exception.Message));
        <span class="kwrd">if</span> (<span class="kwrd">null</span> != exception.InnerException)
        {
            formatter.Indent();
            formatter.AppendLine(<span class="str">&quot;--&gt;Inner Exception&quot;</span>);
            EmitExceptionAtAGlance(formatter, 
                exception.InnerException);
            formatter.RevertIndent();
        }
    }

    <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> EmitExceptionStackTrace(
        CustomEventFormatter formatter, Exception exception)
    {
        formatter.AppendLine(exception.StackTrace);

        <span class="kwrd">if</span> (<span class="kwrd">null</span> != exception.InnerException)
        {
            <span class="rem">// no point indenting</span>
            <span class="rem">// since stack traces typically wrap like crazy</span>
            formatter.AppendLine();
            formatter.AppendLine(<span class="str">&quot;--&gt;Inner exception stack trace:&quot;</span>);
            EmitExceptionStackTrace(formatter, exception.InnerException);
        }
    }
}
</pre>
<p>And finally, here&#39;s a helper class that manages indentation levels for the output email message:</p><pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> CustomEventFormatter
{
    <span class="kwrd">const</span> <span class="kwrd">int</span> TabSpaces = 4;

    StringBuilder sb = <span class="kwrd">new</span> StringBuilder();
    <span class="kwrd">private</span> <span class="kwrd">int</span> indentLevel;
    <span class="kwrd">private</span> <span class="kwrd">bool</span> startingNewLine = <span class="kwrd">true</span>;

    <span class="kwrd">public</span> <span class="kwrd">void</span> Indent()
    {
        ++indentLevel;
    }

    <span class="kwrd">public</span> <span class="kwrd">void</span> RevertIndent()
    {
        <span class="kwrd">if</span> (indentLevel &gt; 0)
            --indentLevel;
    }

    <span class="kwrd">public</span> <span class="kwrd">void</span> Append(<span class="kwrd">string</span> text)
    {
        <span class="kwrd">if</span> (startingNewLine)
            EmitIndent();
        sb.Append(text);
        startingNewLine = <span class="kwrd">false</span>;
    }

    <span class="kwrd">public</span> <span class="kwrd">void</span> AppendLine(<span class="kwrd">string</span> lineOfText)
    {
        <span class="kwrd">if</span> (startingNewLine)
            EmitIndent();
        EmitIndent();
        sb.AppendLine(lineOfText);
        startingNewLine = <span class="kwrd">true</span>;
    }

    <span class="kwrd">private</span> <span class="kwrd">void</span> EmitIndent()
    {
        sb.Append(<span class="str">&#39; &#39;</span>, TabSpaces * indentLevel);
    }

    <span class="kwrd">public</span> <span class="kwrd">void</span> AppendLine()
    {
        AppendLine(<span class="kwrd">string</span>.Empty);
    }

    <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">string</span> ToString()
    {
        <span class="kwrd">return</span> sb.ToString();
    }
}
</pre>
<p>Build this into a library application and reference it in your config file. Here&#39;s an example:</p><pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">healthMonitoring</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">providers</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;mailWebEventProvider&quot;</span>
         <span class="attr">type</span><span class="kwrd">=&quot;MyMailWebEventProvider&quot;</span>
         <span class="attr">to</span><span class="kwrd">=&quot;web-fault@fabrikam.com&quot;</span>
         <span class="attr">from</span><span class="kwrd">=&quot;website@fabrikam.com&quot;</span>
         <span class="attr">buffer</span><span class="kwrd">=&quot;false&quot;</span>
         <span class="attr">subjectPrefix</span><span class="kwrd">=&quot;[WEB-ERROR]&quot;</span>
       <span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">providers</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">rules</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;All Errors Email&quot;</span>
         <span class="attr">eventName</span><span class="kwrd">=&quot;All Errors&quot;</span>
         <span class="attr">provider</span><span class="kwrd">=&quot;mailWebEventProvider&quot;</span>
         <span class="attr">profile</span><span class="kwrd">=&quot;Default&quot;</span>
         <span class="attr">minInstances</span><span class="kwrd">=&quot;1&quot;</span>
         <span class="attr">maxLimit</span><span class="kwrd">=&quot;Infinite&quot;</span>
         <span class="attr">minInterval</span><span class="kwrd">=&quot;00:01:00&quot;</span>
         <span class="attr">custom</span><span class="kwrd">=&quot;&quot;</span><span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">rules</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">healthMonitoring</span><span class="kwrd">&gt;</span>
</pre><div style="clear:both;"></div><img src="http://www.pluralsight.com/community/aggbug.aspx?PostID=52349" width="1" height="1">]]></content:encoded>
      <pubDate>Mon, 04 Aug 2008 10:11:14 +0000</pubDate>
      <category domain="http://securityratty.com/tag/return">return</category>
      <category domain="http://securityratty.com/tag/return subjectbuilder">return subjectbuilder</category>
      <category domain="http://securityratty.com/tag/return formatter">return formatter</category>
      <category domain="http://securityratty.com/tag/exception">exception</category>
      <category domain="http://securityratty.com/tag/formatter">formatter</category>
      <category domain="http://securityratty.com/tag/crazy formatter">crazy formatter</category>
      <category domain="http://securityratty.com/tag/static void">static void</category>
      <category domain="http://securityratty.com/tag/static void emitprocessinfo">static void emitprocessinfo</category>
      <category domain="http://securityratty.com/tag/return null">return null</category>
      <source url="http://www.pluralsight.com/community/blogs/keith/archive/2008/08/04/better-exception-reporting-in-asp-net-part-2.aspx">Better exception reporting in ASP.NET part 2</source>
    </item>
    <item>
      <title><![CDATA[Take advantage of this settlement at TransUnion]]></title>
      <link>http://securityratty.com/article/06301614285539371821183e606aa740</link>
      <guid>http://securityratty.com/article/06301614285539371821183e606aa740</guid>
      <description><![CDATA[Hey, it could save you against a theft of your personal data


clipped from peterhgregory.wordpress.com
Apparent misdeeds result in free credit monitoring for?millions


A class action lawsuit against...]]></description>
      <content:encoded><![CDATA[<div > Hey, it could save you against a theft of your personal data. </div>
<table cellpadding="0" cellspacing="0" width="100%" style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;">
<tr>
<td valign="top">
<table cellpadding="0" cellspacing="0" width="100%" class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;">
<tr>
<td valign="top">
<table cellpadding="0" cellspacing="0" width="100%" style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;">
<tr>
<td valign="top"><a href="http://clipmarks.com/clipmark/31EE423B-BFD0-4AF7-8882-4C1BC3F6B7F0/" title="go to this clipmark"><img src="http://content.clipmarks.com/blog_icon/432a97be-bc8a-46f3-93fd-adf2ecf0b27f/31EE423B-BFD0-4AF7-8882-4C1BC3F6B7F0/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://peterhgregory.wordpress.com/2008/07/31/listclassaction/" href="http://peterhgregory.wordpress.com/2008/07/31/listclassaction/" style="font-size: 11px;">peterhgregory.wordpress.com</a></td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" width="100%" style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;">
<tr>
<td valign="top"><!-- CLIPPED FROM: http://peterhgregory.wordpress.com/2008/07/31/listclassaction/ -->Apparent misdeeds result in free credit monitoring for?millions</td>
</tr>
</table>
<div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div>
<table cellpadding="0" cellspacing="0" width="100%" style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;">
<tr>
<td valign="top"><!-- CLIPPED FROM: http://peterhgregory.wordpress.com/2008/07/31/listclassaction/ --><P>A class action lawsuit against credit reporting bureau TransUnion has resulted in a settlement that will result in millions of U.S. citizens getting free credit monitoring for as long as nine months.</P></td>
</tr>
</table>
</td>
</tr>
</table>
<div style="margin: 0px 6px 6px 4px;">
<table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="background:transparent;border-width:0px;padding:0px;">&nbsp;</td>
<td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/31EE423B-BFD0-4AF7-8882-4C1BC3F6B7F0/blog/" title="blog or email this clip"><img src="http://content7.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
]]></content:encoded>
      <pubDate>Sat, 02 Aug 2008 11:31:04 +0000</pubDate>
      <category domain="http://securityratty.com/tag/free credit">free credit</category>
      <category domain="http://securityratty.com/tag/credit">credit</category>
      <category domain="http://securityratty.com/tag/apparent misdeeds result">apparent misdeeds result</category>
      <category domain="http://securityratty.com/tag/result">result</category>
      <category domain="http://securityratty.com/tag/class action lawsuit">class action lawsuit</category>
      <category domain="http://securityratty.com/tag/bureau transunion">bureau transunion</category>
      <category domain="http://securityratty.com/tag/millions">millions</category>
      <category domain="http://securityratty.com/tag/personal data">personal data</category>
      <category domain="http://securityratty.com/tag/settlement">settlement</category>
      <source url="http://spywarebiz.com/spywarebizblog/?p=528">Take advantage of this settlement at TransUnion</source>
    </item>
    <item>
      <title><![CDATA[Simulating Email in .NET]]></title>
      <link>http://securityratty.com/article/0c454dbe28b5b63d07ee0089e019de77</link>
      <guid>http://securityratty.com/article/0c454dbe28b5b63d07ee0089e019de77</guid>
      <description><![CDATA[I use email as a notification mechanism a lot, and often in class I'll demo sending email via a technique that I use frequently when developing code. It allows you to simulate sending an email...]]></description>
      <content:encoded><![CDATA[<p>I use email as a notification mechanism a lot, and often in class I&#39;ll demo sending email via a technique that I use frequently when developing code. It allows you to simulate sending an email message.</p> <p>The trick to doing this is not to hardcode things like host, port, etc. for your SMTP server when you use System.Net.Mail to send mail. Instead, use the default ctor for <a href="http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx" target="_blank">SmtpClient</a> as I&#39;ve done in the code below.</p> <blockquote><pre class="csharpcode"><span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
{
    <span class="rem">// note the use of the MailAddress class</span>
    <span class="rem">// this allows me to specify display names as well as email addresses</span>
    MailAddress from = <span class="kwrd">new</span> MailAddress(<span class="str">&quot;admin@fabrikam.com&quot;</span>, <span class="str">&quot;Fabrikam Website&quot;</span>);
    MailAddress to = <span class="kwrd">new</span> MailAddress(<span class="str">&quot;mari@fabrikam.com&quot;</span>, <span class="str">&quot;Mari Joyce&quot;</span>);

    MailMessage msg = <span class="kwrd">new</span> MailMessage(from, to);
    msg.Subject  = <span class="str">&quot;Testing 123&quot;</span>;
    msg.Body = <span class="str">&quot;This is only a test!&quot;</span>;

    <span class="rem">// note use of default ctor</span>
    <span class="rem">// this looks in config to figure out how to send mail</span>
    <span class="kwrd">new</span> SmtpClient().Send(msg);
}</pre></blockquote>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }


<p>What you&#39;re telling .NET by using the default ctor for SmtpClient is, &quot;please use my config file to figure out how to send mail&quot;. Now you can use the system.net/mailSettings/smtp section in config to specify the details of your mail server, and all of the code in your app that is written to use the default SmtpClient ctor will inherit these settings. Here&#39;s an example of what the config on a production server might look like (if you put passwords in your config files, be sure to <a href="http://msdn.microsoft.com/en-us/library/ms998283.aspx" target="_blank">encrypt those sections</a>): </p><pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">configuration</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">system.net</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">mailSettings</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">smtp</span> <span class="attr">deliveryMethod</span><span class="kwrd">=&quot;Network&quot;</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">network</span> <span class="attr">host</span><span class="kwrd">=&quot;mail.fabrikam.com&quot;</span>
                 <span class="attr">port</span><span class="kwrd">=&quot;25&quot;</span>
                 <span class="attr">userName</span><span class="kwrd">=&quot;WebsiteMailAccount&quot;</span>
                 <span class="attr">password</span><span class="kwrd">=&quot;whatever&quot;</span><span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">smtp</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">mailSettings</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">system.net</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">configuration</span><span class="kwrd">&gt;</span></pre><pre class="csharpcode">&nbsp;</pre>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }


<p>During development, I use different settings because I don&#39;t usually want to deal with the hassle of installing an SMTP server on my development box. Instead, I want email messages delivered as individual files in a directory on my hard drive (I always have a c:\mail directory on my development box for just this purpose):</p>
<blockquote><pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">configuration</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">system.net</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">mailSettings</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">smtp</span> <span class="attr">deliveryMethod</span><span class="kwrd">=&quot;SpecifiedPickupDirectory&quot;</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">specifiedPickupDirectory</span> <span class="attr">pickupDirectoryLocation</span><span class="kwrd">=&quot;c:\mail&quot;</span><span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">smtp</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">mailSettings</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">system.net</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">configuration</span><span class="kwrd">&gt;</span></pre></blockquote>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }


<p>Now when I run the program above, I get a .EML file in my c:\mail directory:</p>
<p><a href="http://www.pluralsight.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/keith/image_5F00_2.png"><img style="border-right:0px;border-top:0px;margin:0px 0px 0px 35px;border-left:0px;border-bottom:0px;" height="230" alt="image" src="http://www.pluralsight.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/keith/image_5F00_thumb.png" width="404" border="0" /></a> </p>
<p>Outlook Express is normally registered as the viewer for .EML files, so double-click the file to view it:</p>
<p><a href="http://www.pluralsight.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/keith/image_5F00_4.png"><img style="border-right:0px;border-top:0px;margin:0px 0px 0px 35px;border-left:0px;border-bottom:0px;" height="287" alt="image" src="http://www.pluralsight.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/keith/image_5F00_thumb_5F00_1.png" width="292" border="0" /></a> </p>
<p>If you&#39;ve never seen this method of simulating email before, I hope you find it as useful as I have. Happy coding!</p><div style="clear:both;"></div><img src="http://www.pluralsight.com/community/aggbug.aspx?PostID=52305" width="1" height="1">]]></content:encoded>
      <pubDate>Fri, 01 Aug 2008 09:59:01 +0000</pubDate>
      <category domain="http://securityratty.com/tag/csharpcode pre">csharpcode pre</category>
      <category domain="http://securityratty.com/tag/pre">pre</category>
      <category domain="http://securityratty.com/tag/csharpcode">csharpcode</category>
      <category domain="http://securityratty.com/tag/color">color</category>
      <category domain="http://securityratty.com/tag/email">email</category>
      <category domain="http://securityratty.com/tag/email addresses mailaddress">email addresses mailaddress</category>
      <category domain="http://securityratty.com/tag/mailaddress">mailaddress</category>
      <category domain="http://securityratty.com/tag/mail server">mail server</category>
      <category domain="http://securityratty.com/tag/mail">mail</category>
      <source url="http://www.pluralsight.com/community/blogs/keith/archive/2008/08/01/simulating-email-in-net.aspx">Simulating Email in .NET</source>
    </item>
    <item>
      <title><![CDATA[The DNS Vulnerability]]></title>
      <link>http://securityratty.com/article/2fa89601e50143e1b069f4876ad01123</link>
      <guid>http://securityratty.com/article/2fa89601e50143e1b069f4876ad01123</guid>
      <description><![CDATA[Despite the best efforts of the security community, the details of a critical internet vulnerability discovered by Dan Kaminsky about six months ago have leaked. Hackers are racing to produce exploit...]]></description>
      <content:encoded><![CDATA[<p>Despite the best efforts of the security community, the details of a critical internet vulnerability discovered by Dan Kaminsky about six months ago have leaked. Hackers are racing to produce exploit code, and network operators who haven't already patched the hole are scrambling to catch up. The whole mess is a good illustration of the problems with researching and disclosing flaws like this.</p>

<p>The <a href="http://darkoz.com/?p=15">details</a> of the <a href="http://blog.invisibledenizen.org/2008/07/kaminskys-dns-issue-accidentally-leaked.html">vulnerability</a> aren't important, but basically it's a form of DNS cache poisoning. The DNS system is what translates domain names people understand, like www.schneier.com, to IP addresses computers understand: 204.11.246.1. There is a whole family of vulnerabilities where the DNS system on your computer is fooled into thinking that the IP address for www.badsite.com is really the IP address for www.goodsite.com -- there's no way for you to tell the difference -- and that allows the criminals at www.badsite.com to trick you into doing all sorts of things, like giving up your bank account details. Kaminsky discovered a particularly nasty variant of this cache-poisoning attack.</p>

<p>Here's the way the timeline was supposed to work: Kaminsky discovered the vulnerability about six months ago, and quietly worked with vendors to patch it. (There's a fairly straightforward fix, although the implementation nuances are complicated.) Of course, this meant describing the vulnerability to them; why would companies like Microsoft and Cisco believe him otherwise? On July 8, he held a <a href="http://news.bbc.co.uk/2/hi/technology/7496735.stm">press conference</a> to <a href="http://www.doxpara.com/?p=1162">announce</a> the <a href="http://www.kb.cert.org/vuls/id/800113">vulnerability</a> -- but not the details -- and reveal that a patch was available from a long list of vendors. We would all have a month to patch, and Kaminsky would release details of the vulnerability at the <a href="http://www.blackhat.com/html/bh-usa-08/bh-us-08-main.html">BlackHat</a> conference early next month.</p>

<p>Of course, the details <a href="http://it.slashdot.org/it/08/07/21/2212227.shtml">leaked</a>. <a href="http://blog.wired.com/27bstroke6/2008/07/details-of-dns.html">How</a> isn't important; it could have leaked a zillion different ways. Too many people knew about it for it to remain secret. Others who knew the general idea were too smart <a href="http://addxorrol.blogspot.com/2008/07/on-dans-request-for-no-speculation.html">not to speculate</a> on the details. I'm kind of amazed the details remained secret for this long; undoubtedly it had leaked into the underground community before the public leak two days ago. So now everyone who back-burnered the problem is rushing to patch, while the hacker community is racing to produce working exploits. </p>

<p>What's the moral here? It's easy to condemn Kaminsky: If he had shut up about the problem, we wouldn't be in this mess. But that's just wrong. Kaminsky found the vulnerability by accident. There's no reason to believe he was the first one to find it, and it's ridiculous to believe he would be the last. Don't shoot the messenger. The problem is with the DNS protocol; it's insecure.</p>

<p>The real lesson is that the <a href="http://www.schneier.com/crypto-gram-0103.html#1">patch treadmill</a> doesn't work, and it hasn't for years. This cycle of finding security holes and rushing to patch them before the bad guys exploit those vulnerabilities is expensive, inefficient and incomplete. We need to design security into our systems right from the beginning. We need <a href="http://www.schneier.com/blog/archives/2007/08/assurance.html">assurance</a>. We need security engineers involved in system design. This process won't prevent every vulnerability, but it's much more secure -- and cheaper -- than the patch treadmill we're all on now.</p>

<p>What a security engineer brings to the problem is a particular <a href="http://www.schneier.com/blog/archives/2008/03/the_security_mi.html">mindset</a>. He thinks about systems from a security perspective. It's not that he discovers all possible attacks before the bad guys do; it's more that he anticipates potential types of attacks, and defends against them even if he doesn't know their details. I see this all the time in good cryptographic designs. It's over-engineering based on intuition, but if the security engineer has good intuition, it generally works.</p>

<p>Kaminsky's vulnerability is a perfect example of this. Years ago, cryptographer Daniel J. Bernstein <a href="http://cr.yp.to/djbdns/forgery.html">looked at DNS security</a> and decided that Source Port Randomization was a smart design choice. That's exactly the work-around being rolled out now following Kaminsky's discovery. Bernstein didn't discover Kaminsky's attack; instead, he saw a general class of attacks and realized that this enhancement could protect against them. Consequently, the DNS program he wrote in 2000, <a href="http://cr.yp.to/djbdns/dnscache.html">djbdns</a>, doesn't need to be patched; it's already immune to Kaminsky's attack.</p>

<p>That's what a good design looks like. It's not just secure against known attacks; it's also secure against unknown attacks. We need more of this, not just on the internet but in voting machines, ID cards, transportation payment cards ... everywhere. Stop assuming that systems are secure unless demonstrated insecure; start assuming that systems are insecure unless designed securely.</p>

<p>This essay <a href="http://www.wired.com/politics/security/commentary/securitymatters/2008/07/securitymatters_0723">previously appeared</a> on Wired.com.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/schneier/fulltext?a=mOWtcJ"><img src="http://feeds.feedburner.com/~f/schneier/fulltext?i=mOWtcJ" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/schneier/fulltext?a=xoZIeJ"><img src="http://feeds.feedburner.com/~f/schneier/fulltext?i=xoZIeJ" border="0"></img></a>
</div>]]></content:encoded>
      <pubDate>Tue, 29 Jul 2008 02:01:52 +0000</pubDate>
      <category domain="http://securityratty.com/tag/vulnerability">vulnerability</category>
      <category domain="http://securityratty.com/tag/kaminsky">kaminsky</category>
      <category domain="http://securityratty.com/tag/dan kaminsky">dan kaminsky</category>
      <category domain="http://securityratty.com/tag/details">details</category>
      <category domain="http://securityratty.com/tag/critical internet vulnerability">critical internet vulnerability</category>
      <category domain="http://securityratty.com/tag/bank account details">bank account details</category>
      <category domain="http://securityratty.com/tag/discover kaminsky">discover kaminsky</category>
      <category domain="http://securityratty.com/tag/patch">patch</category>
      <category domain="http://securityratty.com/tag/release details">release details</category>
      <source url="http://www.schneier.com/blog/archives/2008/07/the_dns_vulnera.html">The DNS Vulnerability</source>
    </item>
  </channel>
</rss>
