<?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: false]]></title>
    <link>http://securityratty.com/tag/false</link>
    <description></description>
    <pubDate>Mon, 04 Aug 2008 10:11:14 +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[Two-way formatted data binding in ASP.NET]]></title>
      <link>http://securityratty.com/article/defaefd1679588644fb6df7a435f5f6a</link>
      <guid>http://securityratty.com/article/defaefd1679588644fb6df7a435f5f6a</guid>
      <description><![CDATA[Two way data binding in ASP.NET is easy, just use the Bind expression and data will flow between your web controls and your data source flawlessly. Until that is, you try to use a format string...]]></description>
      <content:encoded><![CDATA[<p>Two way data binding in ASP.NET is easy, just use the Bind expression and data will flow between your web controls and your data source flawlessly. Until that is, you try to use a format string:</p> <p>Bind(&quot;AmountCharged&quot;, &quot;{0:C}&quot;)</p> <p>While this displays just as you&#39;d expect (e.g., $200), it doesn&#39;t do so well when you submit an edit that includes the same value ($200):</p> <p><span style="font-weight:normal;font-size:14pt;color:maroon;font-family:&#39;Verdana&#39;;"><i>Input string was not in a correct format.</i></span></p> <p>I searched around and didn&#39;t find much in the way of a clean solution, but I did solve the problem with just a few lines of code. The trick is to handle the data-bound control&#39;s Updating event. Since I was working with a GridView, my solution looked a bit like this:</p><pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">asp:GridView</span> <span class="attr">DataSourceID</span><span class="kwrd">=&#39;myDataSource&#39;</span>
              <span class="attr">OnRowUpdating</span><span class="kwrd">=&#39;FixFormatting&#39;</span>
              <span class="attr">AutoGenerateColumns</span><span class="kwrd">=&#39;false&#39;</span>
              <span class="attr">CellPadding</span><span class="kwrd">=&quot;3&quot; ...&gt;</span></pre>
<p>Notice the OnRowUpdating handler that I&#39;ve installed in my grid view. That code looks like this:</p><pre class="csharpcode"><span class="kwrd">protected</span> <span class="kwrd">void</span> FixFormatting(<span class="kwrd">object</span> sender, GridViewUpdateEventArgs args)
{
    <span class="kwrd">decimal</span> amountPaid = ParseDecimal((<span class="kwrd">string</span>)args.NewValues[<span class="str">&quot;AmountPaid&quot;</span>]);
    args.NewValues[<span class="str">&quot;AmountPaid&quot;</span>] = amountPaid;
}</pre>
<p>When you handle this event, you&#39;re given a dictionary of old and new values, which appear to come directly from the controls (in my case, a TextBox was used to gather the updated data AmountPaid, so the type of object that I found in NewValues[&quot;AmountPaid&quot;] was a string. I wrote a little helper method called ParseDecimal that parses a string into a decimal value, allowing currency characters, decimal points, and thousands separators. I also allowed a blank value to indicate zero:</p><pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">decimal</span> ParseDecimal(<span class="kwrd">string</span> <span class="kwrd">value</span>)
{
    <span class="kwrd">if</span> (<span class="kwrd">string</span>.IsNullOrEmpty(<span class="kwrd">value</span>))
        <span class="kwrd">return</span> 0;
    <span class="kwrd">return</span> Decimal.Parse(<span class="kwrd">value</span>,
        NumberStyles.AllowThousands |
        NumberStyles.AllowDecimalPoint |
        NumberStyles.AllowCurrencySymbol,
        CultureInfo.InstalledUICulture);
}
</pre>
<p>This solved the problem quite nicely. Now two-way binding works with formatted data.</p><div style="clear:both;"></div><img src="http://www.pluralsight.com/community/aggbug.aspx?PostID=52504" width="1" height="1">]]></content:encoded>
      <pubDate>Fri, 15 Aug 2008 16:22:37 +0000</pubDate>
      <category domain="http://securityratty.com/tag/data">data</category>
      <category domain="http://securityratty.com/tag/data amountpaid">data amountpaid</category>
      <category domain="http://securityratty.com/tag/amountpaid">amountpaid</category>
      <category domain="http://securityratty.com/tag/data-bound control">data-bound control</category>
      <category domain="http://securityratty.com/tag/decimal amountpaid">decimal amountpaid</category>
      <category domain="http://securityratty.com/tag/return decimal">return decimal</category>
      <category domain="http://securityratty.com/tag/return">return</category>
      <category domain="http://securityratty.com/tag/data source flawlessly">data source flawlessly</category>
      <category domain="http://securityratty.com/tag/decimal">decimal</category>
      <source url="http://www.pluralsight.com/community/blogs/keith/archive/2008/08/15/two-way-formatted-data-binding-in-asp-net.aspx">Two-way formatted data binding in ASP.NET</source>
    </item>
    <item>
      <title><![CDATA[Data Mining to Detect Pump-and-Dump Scams]]></title>
      <link>http://securityratty.com/article/a5878a5dbedbdb06b13ea9db23d0e411</link>
      <guid>http://securityratty.com/article/a5878a5dbedbdb06b13ea9db23d0e411</guid>
      <description><![CDATA[I don't know any of the details, but this seems like a good use of data mining: Mr Tancredi said Verisign's fraud detection kit would help &quot;decrease the time between the attack being launched and the...]]></description>
      <content:encoded><![CDATA[<p>I don't know any of the details, but <a href="http://news.bbc.co.uk/1/hi/technology/7552009.stm">this</a> seems like a good use of data mining:</p>

<blockquote>Mr Tancredi said Verisign's fraud detection kit would help "decrease the time between the attack being launched and the brokerage being able to respond".

<p>Before now, he said, brokerages relied on counter measures such as restrictive stock trading or analysis packages that only spotted a problem when money had gone.</p>

<p>Verisign's software is a module that brokers can add to their in-house trading system that alerts anti-fraud teams to look more closely at trades that exhibit certain behaviour patterns.</p>

<p>"What this self-learning behavioural engine does is look at the different attributes of the event, not necessarily about the computer or where you are logging on from but about the actual transaction, the trade, the amount of the trade," said Mr Tancredi.</p>

<p>"For example have you liquidated all of your assets in stock that you own in order to buy one penny stock?" he said. "Another example is when a customer who normally trades tech stock on Nasdaq all of a sudden trades a penny stock that has to do with health care and is placing a trade four times more than normal."</blockquote></p>

<p>This is a good use of data mining because, as I <a href="http://www.schneier.com/blog/archives/2006/03/data_mining_for.html">said</a> previously:</p>

<blockquote>Data mining works best when there's a well-defined profile you're searching for, a reasonable number of attacks per year, and a low cost of false alarms.</blockquote>

<p>Another news article <a href="http://news.yahoo.com/s/zd/20080811/tc_zd/230711">here</a>.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/schneier/fulltext?a=MmnOWK"><img src="http://feeds.feedburner.com/~f/schneier/fulltext?i=MmnOWK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/schneier/fulltext?a=pZdBMK"><img src="http://feeds.feedburner.com/~f/schneier/fulltext?i=pZdBMK" border="0"></img></a>
</div>]]></content:encoded>
      <pubDate>Thu, 14 Aug 2008 02:10:34 +0000</pubDate>
      <category domain="http://securityratty.com/tag/stock">stock</category>
      <category domain="http://securityratty.com/tag/penny stock">penny stock</category>
      <category domain="http://securityratty.com/tag/restrictive stock">restrictive stock</category>
      <category domain="http://securityratty.com/tag/data">data</category>
      <category domain="http://securityratty.com/tag/trades tech stock">trades tech stock</category>
      <category domain="http://securityratty.com/tag/trades">trades</category>
      <category domain="http://securityratty.com/tag/fraud detection kit">fraud detection kit</category>
      <category domain="http://securityratty.com/tag/alerts anti-fraud teams">alerts anti-fraud teams</category>
      <category domain="http://securityratty.com/tag/trade">trade</category>
      <source url="http://www.schneier.com/blog/archives/2008/08/data_mining_to.html">Data Mining to Detect Pump-and-Dump Scams</source>
    </item>
    <item>
      <title><![CDATA[MBTA vs MIT students case continues]]></title>
      <link>http://securityratty.com/article/4eeed89c9d2338f565503a6939c3100f</link>
      <guid>http://securityratty.com/article/4eeed89c9d2338f565503a6939c3100f</guid>
      <description><![CDATA[A hearing will be held in Boston tommorow to decide whether or not the restraining order gagging the MIT students from talking about the vulnerabilities they have found should be lifted. Even though...]]></description>
      <content:encoded><![CDATA[<p>A hearing will be held in Boston tommorow to decide whether or not the restraining order gagging the MIT students from talking about the vulnerabilities they have found should be lifted. Even though the Defcon presentation is widely available and the MBTA disclosed the &#8220;Confidential&#8221; memo from the MIT students in their court filings, they are seeking a permanent speech injunction.  An august group of computer scientists has <a href="http://cryptome.org/mbta-v-zack/mbta-v-profs.pdf">signed a letter</a> which will be entered into the record for the case.  This list includes: Dave Farber of Carnegie Mellon University, Steve Bellovin from Columbia University, David Wagner from UC Berkeley, Dan Wallach from Rice University, Matt Blaze from the University of Pennsylvania, and Bruce Schneier. An excerpt:</p>
<blockquote><p>We write to express our firm belief that research on security vulnerabilities, and the sensible publication of the results of the research, are critical for scientific advancement, public safety and a robust market for secure technologies. Generally speaking, the norm in our field is that researchers take reasonable steps to protect the individuals using the systems studied. We understand that the student researchers took such steps with regard to their research, notably by planning not to present a critical element of a flaw they found.  They did this so that their audience would be unable to exploit the security flaws they uncovered. . . .</p>
<p>The restraining order at issue in this case also fosters a dangerous information imbalance. In this case, for example, it allows the vendors of the technology and the MBTA to claim greater efficacy and security than their products warrant, then use the law to silence those who would reveal the technologies&#8217; flaws. In this case, the law gives the public a false sense of security, achieved through law, not technical effectiveness. Preventing researchers from discussing a technology&#8217;s vulnerabilities does not make them go away - in fact, it may exacerbate them as more people and institutions use and come to rely upon the illusory protection. Yet the commercial purveyors of such technologies often do not want truthful discussions of their products&#8217; flaws, and will likely withhold the prior approval or deny researchers access for testing if the law supports that effort. . . .</p>
<p>Yet at the same time that researchers need to act responsibly, vendors should not be granted complete control of the publication of such information, as it appears MBTA sought here. As noted above, vendors and users of such technologies often have an incentive to hide the flaws in the system rather than come clean with the public and take the steps necessary to remedy them.  Thus, while researchers often refrain from publishing the technical details necessary to exploit the flaw, a legal ban on discussion of security flaws, such as that contained in the temporary restraining order, is especially troubling.</p></blockquote>
<p>It will be interesting to see what arguments the MBTA uses to keep the students from speaking on a topic where all the important vulnerability information seems to have already disclosed.  Sure the students haven&#8217;t presented a cookbook exploit tool but they have also stated they have no intention of doing so.</p>
<p>Perhaps the court will investigate what the MBTA&#8217;s and their technology vendors response has been to the MiFare card vulnerabilities that were <a href="http://eprint.iacr.org/2008/166">disclosed responsibly</a>. If there has been no vigorous response to responsibly disclosed vulnerabilities of many months ago how can they say with a straight face that are truly responding to new security information and just need more time.</p>
]]></content:encoded>
      <pubDate>Wed, 13 Aug 2008 18:47:34 +0000</pubDate>
      <category domain="http://securityratty.com/tag/technologies flaws">technologies flaws</category>
      <category domain="http://securityratty.com/tag/flaws">flaws</category>
      <category domain="http://securityratty.com/tag/vulnerabilities">vulnerabilities</category>
      <category domain="http://securityratty.com/tag/technologys vulnerabilities">technologys vulnerabilities</category>
      <category domain="http://securityratty.com/tag/mifare card vulnerabilities">mifare card vulnerabilities</category>
      <category domain="http://securityratty.com/tag/students">students</category>
      <category domain="http://securityratty.com/tag/security vulnerabilities">security vulnerabilities</category>
      <category domain="http://securityratty.com/tag/mit students">mit students</category>
      <category domain="http://securityratty.com/tag/mbta">mbta</category>
      <source url="http://www.veracode.com/blog/?p=232">MBTA vs MIT students case continues</source>
    </item>
    <item>
      <title><![CDATA[MBTA vs MIT Students Case Continues]]></title>
      <link>http://securityratty.com/article/064a464f9437ecbf32f46f66c2142979</link>
      <guid>http://securityratty.com/article/064a464f9437ecbf32f46f66c2142979</guid>
      <description><![CDATA[A hearing will be held in Boston tomorrow to decide whether or not the restraining order gagging the MIT students from talking about the vulnerabilities they have found should be lifted. Even though...]]></description>
      <content:encoded><![CDATA[<p>A hearing will be held in Boston tomorrow to decide whether or not the restraining order gagging the MIT students from talking about the vulnerabilities they have found should be lifted. Even though the Defcon presentation is widely available and the MBTA disclosed the &#8220;Confidential&#8221; memo from the MIT students in their court filings, they are seeking a permanent speech injunction.  An august group of computer scientists has <a href="http://cryptome.org/mbta-v-zack/mbta-v-profs.pdf">signed a letter</a> which will be entered into the record for the case.  This list includes: Dave Farber of Carnegie Mellon University, Steve Bellovin from Columbia University, David Wagner from UC Berkeley, Dan Wallach from Rice University, Matt Blaze from the University of Pennsylvania, and Bruce Schneier. An excerpt:</p>
<blockquote><p>We write to express our firm belief that research on security vulnerabilities, and the sensible publication of the results of the research, are critical for scientific advancement, public safety and a robust market for secure technologies. Generally speaking, the norm in our field is that researchers take reasonable steps to protect the individuals using the systems studied. We understand that the student researchers took such steps with regard to their research, notably by planning not to present a critical element of a flaw they found.  They did this so that their audience would be unable to exploit the security flaws they uncovered. . . .</p>
<p>The restraining order at issue in this case also fosters a dangerous information imbalance. In this case, for example, it allows the vendors of the technology and the MBTA to claim greater efficacy and security than their products warrant, then use the law to silence those who would reveal the technologies&#8217; flaws. In this case, the law gives the public a false sense of security, achieved through law, not technical effectiveness. Preventing researchers from discussing a technology&#8217;s vulnerabilities does not make them go away - in fact, it may exacerbate them as more people and institutions use and come to rely upon the illusory protection. Yet the commercial purveyors of such technologies often do not want truthful discussions of their products&#8217; flaws, and will likely withhold the prior approval or deny researchers access for testing if the law supports that effort. . . .</p>
<p>Yet at the same time that researchers need to act responsibly, vendors should not be granted complete control of the publication of such information, as it appears MBTA sought here. As noted above, vendors and users of such technologies often have an incentive to hide the flaws in the system rather than come clean with the public and take the steps necessary to remedy them.  Thus, while researchers often refrain from publishing the technical details necessary to exploit the flaw, a legal ban on discussion of security flaws, such as that contained in the temporary restraining order, is especially troubling.</p></blockquote>
<p>It will be interesting to see what arguments the MBTA uses to keep the students from speaking on a topic where all the important vulnerability information seems to have already disclosed.  Sure the students haven&#8217;t presented a cookbook exploit tool but they have also stated they have no intention of doing so.</p>
<p>Perhaps the court will investigate what the MBTA&#8217;s and their technology vendors response has been to the MiFare card vulnerabilities that were <a href="http://eprint.iacr.org/2008/166">disclosed responsibly</a>. If there has been no vigorous response to responsibly disclosed vulnerabilities of many months ago how can they say with a straight face that are truly responding to new security information and just need more time.</p>
]]></content:encoded>
      <pubDate>Wed, 13 Aug 2008 18:47:34 +0000</pubDate>
      <category domain="http://securityratty.com/tag/technologies flaws">technologies flaws</category>
      <category domain="http://securityratty.com/tag/flaws">flaws</category>
      <category domain="http://securityratty.com/tag/vulnerabilities">vulnerabilities</category>
      <category domain="http://securityratty.com/tag/technologys vulnerabilities">technologys vulnerabilities</category>
      <category domain="http://securityratty.com/tag/mifare card vulnerabilities">mifare card vulnerabilities</category>
      <category domain="http://securityratty.com/tag/students">students</category>
      <category domain="http://securityratty.com/tag/security vulnerabilities">security vulnerabilities</category>
      <category domain="http://securityratty.com/tag/mit students">mit students</category>
      <category domain="http://securityratty.com/tag/mbta">mbta</category>
      <source url="http://www.veracode.com/blog/2008/08/mbta-vs-mit-students-case-continues/">MBTA vs MIT Students Case Continues</source>
    </item>
    <item>
      <title><![CDATA[Pinch Vulnerable to Remotely Exploitable Flaw]]></title>
      <link>http://securityratty.com/article/8cbf69361bdc83216c6de0e5e5d551a0</link>
      <guid>http://securityratty.com/article/8cbf69361bdc83216c6de0e5e5d551a0</guid>
      <description><![CDATA[In the very same way a cybercrime analyst is reverse engineering and sandboxing a particular piece of malware in order to get a better understanding of who's being it, and how successful the campaign...]]></description>
      <content:encoded><![CDATA[<div style="text-align: left;"></div><div class="separator" style="text-align: center; clear: both;"></div><a href="http://3.bp.blogspot.com/_wICHhTiQmrA/SJr2wBCCcbI/AAAAAAAACAU/4ibYnLwvG5E/s1600-h/olly_pinch1.jpg" imageanchor="1" style="border: 0pt none ; background-color: transparent; clear: left; margin-bottom: 1em; float: left; margin-right: 1em;"><img src="http://3.bp.blogspot.com/_wICHhTiQmrA/SJr2wBCCcbI/AAAAAAAACAU/vIpz-Oz9m-I/s200-R/olly_pinch1.jpg" style="border: 0pt none ;" /></a>In the very same way a cybercrime analyst is reverse engineering and sandboxing a particular piece of malware in order to get a better understanding of who's being it, and how successful the campaign is once access to the command and control interface is obtained, cybercriminals themselves are actively reverse engineering the most popular crimeware kits, looking, and actually finding remotely exploitable vulnerabilities allowing them to competely hijack someone's command and control, and consequently, their botnet. <a href="http://ddanchev.blogspot.com/2008/06/zeus-crimeware-kit-vulnerable-to.html">The Zeus crimeware kit</a>, which I've been discussing and analyzing for a while, is the perfect example of how once a popular underground kit start acting as the default crimeware kit, cybercriminals themselves start looking for vulnerabilities that they could take advantage of. And those who look, usually end up finding.<br />
<br />
<a href="http://2.bp.blogspot.com/_wICHhTiQmrA/SJr4tst_etI/AAAAAAAACAc/CS74dFmlSnI/s1600-h/olly_pinch2.jpg" imageanchor="1" style="border: 0pt none ; background-color: transparent; clear: left; margin-bottom: 1em; float: left; margin-right: 1em;"><img src="http://2.bp.blogspot.com/_wICHhTiQmrA/SJr4tst_etI/AAAAAAAACAc/bsEI2r8i-pQ/s200-R/olly_pinch2.jpg" style="border: 0pt none ;" /></a>A remotely exploitable flaw allowing cybercriminals to remotely inject a web shell within another cybercriminal's web command and control interface of the popular Pinch crimeware that's been around VIP underground forums since June, 2007, is starting to receive the necessary attention from script kiddies catching up with the possibility of hijacking someone's malware campaign due to misconfigured command and control servers.<br />
<br />
<a href="http://2.bp.blogspot.com/_wICHhTiQmrA/SJsF-ZurkWI/AAAAAAAACAs/LVKZqt0ByJ8/s1600-h/pinchy_xploit_2007.jpg" imageanchor="1" style="border: 0pt none ; background-color: transparent; clear: left; margin-bottom: 1em; float: left; margin-right: 1em;"><img src="http://2.bp.blogspot.com/_wICHhTiQmrA/SJsF-ZurkWI/AAAAAAAACAs/QG5JJkQkpdA/s200-R/pinchy_xploit_2007.jpg" style="border: 0pt none ;" /></a>With the exploit now in the wild, retro cybercriminals still taking advantege of the ubiqutous command and control interface that could be easily used by other malware rathar than Pinch, "cybercriminals are advised" to randomize the default file name of the gate, and apply the appropriate directory permissions.<br />
&nbsp; <br />
<div style="text-align: left;"></div><div class="separator" style="text-align: center; clear: both;"></div><div style="text-align: left;"></div><div class="separator" style="text-align: center; clear: both;"></div><a href="http://2.bp.blogspot.com/_wICHhTiQmrA/SJr8JNV5sSI/AAAAAAAACAk/11YT40IAhXY/s1600-h/pinchy.jpg" imageanchor="1" style="border: 0pt none ; background-color: transparent; clear: left; margin-bottom: 1em; float: left; margin-right: 1em;"><img src="http://2.bp.blogspot.com/_wICHhTiQmrA/SJr8JNV5sSI/AAAAAAAACAk/uR5fQjtRtb4/s200-R/pinchy.jpg" style="border: 0pt none ;" /></a>Monocultural insecurities are ironically started to emerge in the IT underground with the increasing commoditization of what used to be a proprietary web exploitation malware kit or a banker malware kit, allowing easy entry into the malware industry through the unregulated use of what some would refer to as an "advanced technology" that only a few cybercriminals used to have access to an year ago.&nbsp; Just like legitimate software vendors, <a href="https://forums.symantec.com/syment/blog/article?message.uid=319059">authors of crimeware kits are also trying to enforce their software licenses</a> and forbidding any reverse engineering of their kits in order to enjoy the false feeling of security provided by the security through obscurity. The result? <a href="http://blogs.zdnet.com/security/?p=1598">Cybercrime groups filing for bankruptcy unable to achieve a positive return on investment</a> due to their intellectual property getting pirated and their inability to enforce the licenses that they issue to their customers.<br />
<br />
We're definitely going to see more trivial, but then again, remotely exploitable vulnerabilities within popular crimeware kits, which can assist both the cybercrime analysts and naturally the cybercriminals themselves. For the time being, even the most sophisticated malware campaigns aren't fully taking advantage of the evasive and stealth tactics that the kits, or their common sense allows them to - let's see for how long.<br />
<br />
<b>Related posts:</b><br />
<a href="http://ddanchev.blogspot.com/2007/12/russias-fsb-vs-cybercrime.html">Russia's FSB vs Cybercrime </a><b><br />
</b><a href="http://ddanchev.blogspot.com/2008/04/crimeware-in-middle-zeus.html">Crimeware in the Middle - Zeus </a><br />
<a href="http://ddanchev.blogspot.com/2008/06/zeus-crimeware-kit-vulnerable-to.html">The Zeus Crimeware Kit Vulnerable to Remotely Exploitable Flaw</a><br />
<a href="http://ddanchev.blogspot.com/2008/07/coding-spyware-and-malware-for-hire.html">Coding Spyware and Malware for Hire</a><b><b><br />
</b></b><br />
<div style="text-align: left;"></div><div class="separator" style="text-align: center; clear: both;"></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?a=D62EBK"><img src="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?i=D62EBK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?a=mvg6vK"><img src="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?i=mvg6vK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?a=GZqrpk"><img src="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?i=GZqrpk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?a=iQ5kkk"><img src="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?i=iQ5kkk" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?a=3Od80K"><img src="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?i=3Od80K" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?a=063dRK"><img src="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?i=063dRK" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?a=v5CZlk"><img src="http://feeds.feedburner.com/~f/DanchoDanchevOnSecurityAndNewMedia?i=v5CZlk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DanchoDanchevOnSecurityAndNewMedia/~4/358495127" height="1" width="1"/>]]></content:encoded>
      <pubDate>Thu, 07 Aug 2008 06:22:01 +0000</pubDate>
      <category domain="http://securityratty.com/tag/popular crimeware kits">popular crimeware kits</category>
      <category domain="http://securityratty.com/tag/crimeware kits">crimeware kits</category>
      <category domain="http://securityratty.com/tag/pinch">pinch</category>
      <category domain="http://securityratty.com/tag/crimeware">crimeware</category>
      <category domain="http://securityratty.com/tag/zeus crimeware kit">zeus crimeware kit</category>
      <category domain="http://securityratty.com/tag/popular pinch crimeware">popular pinch crimeware</category>
      <category domain="http://securityratty.com/tag/malware">malware</category>
      <category domain="http://securityratty.com/tag/banker malware kit">banker malware kit</category>
      <category domain="http://securityratty.com/tag/default crimeware kit">default crimeware kit</category>
      <source url="http://feeds.feedburner.com/~r/DanchoDanchevOnSecurityAndNewMedia/~3/358495127/pinch-vulnerable-to-remotely.html">Pinch Vulnerable to Remotely Exploitable Flaw</source>
    </item>
    <item>
      <title><![CDATA[Red Herring Fallacies: The Straw Man Argument]]></title>
      <link>http://securityratty.com/article/fd8b4d90abc87b580bec45cf10aafeeb</link>
      <guid>http://securityratty.com/article/fd8b4d90abc87b580bec45cf10aafeeb</guid>
      <description><![CDATA[According to our friend Wikipedia, the Straw Man argument is a red-herring fallacy where one party in a debate describes a position that, on the surface, resembles an opponents actual view but is...]]></description>
      <content:encoded><![CDATA[<p>According to our friend Wikipedia, the <a href="http://en.wikipedia.org/wiki/Straw_man" target="_blank">Straw Man argument</a> is a <a href="http://en.wikipedia.org/wiki/List_of_fallacies" target="_blank">red-herring fallacy</a> where one party in a debate describes a position that, on the surface, resembles an opponent&#8217;s actual view but is easier to refute.  Then, in counterpoint, the debating partner attributes an easily refutable position to the opponent (for example, deliberately overstating the opponent&#8217;s position). Wikipedia says:</p>
<blockquote><p><strong>1. Person A has position X.</strong></p>
<p><strong>2. Person B ignores X and instead presents position Y.</strong><br />
Y is a distorted version of X and can be set up in several ways, including:</p>
<ol>
<li>Presenting a misrepresentation of the opponent&#8217;s position and then refuting it, thus giving the appearance that the opponent&#8217;s actual position has been refuted.</li>
<li>Quoting an opponent&#8217;s words out of context — i.e., choosing quotations that are not representative of the opponent&#8217;s actual intentions.<a title="Quote mining" href="http://en.wikipedia.org/wiki/Quote_mining"> </a></li>
<li>Presenting someone who defends a position poorly as <em>the</em> defender and then refuting that person&#8217;s arguments, thus giving the appearance that <em>every</em> upholder of that position, and thus the position itself, has been defeated.</li>
<li>Inventing a fictitious persona with actions or beliefs that are criticized, such that the person represents a group of whom the speaker is critical.</li>
<li>Oversimplifying an opponent&#8217;s argument, then attacking the simplified version.</li>
</ol>
<p><strong>3. Person B attacks position Y.</strong></p>
<p><strong>4. Person B draws a conclusion that X is false/incorrect/flawed.</strong><br />
This sort of &#8220;reasoning&#8221; is fallacious because attacking a distorted version of a position simply does not constitute an attack on the position itself.</p></blockquote>
<p>For example, there has been some lively discussions recently around the notion that CEP is overhyped.</p>
<blockquote><p>Debate:      &#8220;CEP is Overhyped.&#8221;</p>
<p>Person A:   &#8220;CEP has been overhyped.&#8221;</p>
<p>Person B:     &#8220;CEP is just hype.&#8221;</p></blockquote>
<p>The point of the discussion by person A was to point out that CEP has been overhyped.  Person B has exaggerated this to a harder to defend position, &#8220;CEP is mere hype.&#8221; or &#8220;CEP is just hype.&#8221;</p>
<p>From the customer perspective, I don&#8217;t think that fallacies and red-herring arguments are good for CEP.   Believe me, if we could take an &#8220;out of the box&#8221; stream processing rules-engine and bolt it on to a network and insure a client it would detect complex fraud, or diagnose network faults accurately, and not put my entire professional reputation on the line, I would do it in a heartbeat.</p>
<p>It is not the speed of the an engine which makes a good CEP engine, it is the capability of the analytics to deliver high-quality, high-confidence complex event detection in real-time.</p>
]]></content:encoded>
      <pubDate>Thu, 07 Aug 2008 05:40:11 +0000</pubDate>
      <category domain="http://securityratty.com/tag/position">position</category>
      <category domain="http://securityratty.com/tag/defend position">defend position</category>
      <category domain="http://securityratty.com/tag/easily refutable position">easily refutable position</category>
      <category domain="http://securityratty.com/tag/opponents position">opponents position</category>
      <category domain="http://securityratty.com/tag/position simply">position simply</category>
      <category domain="http://securityratty.com/tag/position poorly">position poorly</category>
      <category domain="http://securityratty.com/tag/cep engine">cep engine</category>
      <category domain="http://securityratty.com/tag/cep">cep</category>
      <category domain="http://securityratty.com/tag/attacks position">attacks position</category>
      <source url="http://www.thecepblog.com/2008/08/07/red-herring-fallacies-the-straw-man-argument/">Red Herring Fallacies: The Straw Man Argument</source>
    </item>
    <item>
      <title><![CDATA[Massive Spam Campaign Spreads False CNN News Items With Fake Flash Player Malware]]></title>
      <link>http://securityratty.com/article/a225a716b4a000ec8b1b874643067ce6</link>
      <guid>http://securityratty.com/article/a225a716b4a000ec8b1b874643067ce6</guid>
      <description><![CDATA[Known social engineering tactic involving Adobe Flash Player is exploited in currently active malware campaign. Spammed user is encouraged to click on a site with a fake news item in order to install...]]></description>
      <content:encoded><![CDATA[Known social engineering tactic involving Adobe Flash Player is exploited in currently active malware campaign. Spammed user is encouraged to click on a site with a fake news item in order to install a fake Flash player update (file names might be flashupdate.exe, get_flash_update.exe, watchmovie.mpg.exe). If user clicks &#8220;Cancel&#8221; in the dialog that prompts for [...]]]></content:encoded>
      <pubDate>Thu, 07 Aug 2008 05:28:44 +0000</pubDate>
      <category domain="http://securityratty.com/tag/flash">flash</category>
      <category domain="http://securityratty.com/tag/fake flash player">fake flash player</category>
      <category domain="http://securityratty.com/tag/adobe flash player">adobe flash player</category>
      <category domain="http://securityratty.com/tag/user">user</category>
      <category domain="http://securityratty.com/tag/user clicks cancel">user clicks cancel</category>
      <category domain="http://securityratty.com/tag/fake news item">fake news item</category>
      <category domain="http://securityratty.com/tag/active malware campaign">active malware campaign</category>
      <category domain="http://securityratty.com/tag/exe">exe</category>
      <category domain="http://securityratty.com/tag/file names">file names</category>
      <source url="http://cyberinsecure.com/massive-spam-campaign-spreads-false-cnn-news-items-with-fake-flash-player-malware/">Massive Spam Campaign Spreads False CNN News Items With Fake Flash Player Malware</source>
    </item>
    <item>
      <title><![CDATA[8 ways to fight spam filter frustration]]></title>
      <link>http://securityratty.com/article/0437d0e3a664f77f454a9c0b4ea8a890</link>
      <guid>http://securityratty.com/article/0437d0e3a664f77f454a9c0b4ea8a890</guid>
      <description><![CDATA[False positives -- &quot;good&quot; e-mail messages incorrectly labeled as spam -- are the scourge of spam filters. Whether you're sending or receiving, here are some steps you can take to keep good e-mail out...]]></description>
      <content:encoded><![CDATA[False positives -- "good" e-mail messages incorrectly labeled as spam -- are the scourge of spam filters. Whether you're sending or receiving, here are some steps you can take to keep good e-mail out of the slush pile.
<p><a href="http://feeds.computerworld.com/~a/Computerworld/Security/News?a=3wYbw7"><img src="http://feeds.computerworld.com/~a/Computerworld/Security/News?i=3wYbw7" border="0"></img></a></p><img src="http://feeds.computerworld.com/~r/Computerworld/Security/News/~4/357032429" height="1" width="1"/>]]></content:encoded>
      <pubDate>Wed, 06 Aug 2008 02:31:30 +0000</pubDate>
      <category domain="http://securityratty.com/tag/spam">spam</category>
      <category domain="http://securityratty.com/tag/e-mail messages incorrectly">e-mail messages incorrectly</category>
      <category domain="http://securityratty.com/tag/e-mail">e-mail</category>
      <category domain="http://securityratty.com/tag/spam filters">spam filters</category>
      <category domain="http://securityratty.com/tag/false positives">false positives</category>
      <category domain="http://securityratty.com/tag/slush pile">slush pile</category>
      <category domain="http://securityratty.com/tag/steps">steps</category>
      <category domain="http://securityratty.com/tag/scourge">scourge</category>
      <source url="http://feeds.computerworld.com/~r/Computerworld/Security/News/~3/357032429/article.do">8 ways to fight spam filter frustration</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>
  </channel>
</rss>
