<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The Security Development Lifecycle</title><link>http://blogs.msdn.com/sdl/default.aspx</link><description /><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>SDL at TechEd Europe and Platforma</title><link>http://blogs.msdn.com/sdl/archive/2009/11/05/sdl-at-teched-europe-and-platforma.aspx</link><pubDate>Thu, 05 Nov 2009 21:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918243</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9918243.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9918243</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Hi everyone, Bryan here. I’m going to be presenting two sessions on the SDL next week, one for TechEd Europe and one for the Microsoft Platforma event in Moscow. If you’re attending either of these conferences, stop by and introduce yourself, or better yet stay for the session!&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;A href="http://www.msteched.com/europe/Public/SessionList.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;TechEd Europe&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;SIA-205: SDL-Agile: Microsoft’s Approach to Security for Agile Projects&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Monday 11/9 9:00-10:15, Berlin 1 Hall 7-3a&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;A href="http://msplatforma.ru/schedule/default.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;Platforma&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;FF-206: The Microsoft Security Development Lifecycle&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Thursday 11/12 4:30-5:30, Red Congress-Hall&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Hope to see you there!&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918243" width="1" height="1"&gt;</description></item><item><title>SIR Volume 7 Released</title><link>http://blogs.msdn.com/sdl/archive/2009/11/04/sir-volume-7-released.aspx</link><pubDate>Wed, 04 Nov 2009 16:16:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9917371</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9917371.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9917371</wfw:commentRss><description>&lt;p&gt;Hi everyone, Bryan here. Earlier this week, Microsoft released the latest volume of the &lt;a href="http://www.microsoft.com/sir"&gt;Security Intelligence Report (SIR)&lt;/a&gt;, which covers the first half of 2009. There are many interesting statistics in this report, but there’s one that I’d like to draw particular attention to: the number of industry-wide reported vulnerabilities as broken down by OS vulns vs. browser vulns vs. application vulns.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/SIRVolume7Released_7462/clip_image001_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/SIRVolume7Released_7462/clip_image001_thumb.png" width="474" height="249" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It is gratifying to see a sharp decline in the number of application vulnerabilities reported in the first half of 2009, but it’s important to note that they still make up the vast majority of vulns. Attackers are still largely focusing on the long tail of third-party applications. It’s more important than ever for all development shops, no matter how small, to bake security practices into their development lifecycles and ensure that their products don’t end up contributing to next year’s blue Application Vulnerabilities bar.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9917371" width="1" height="1"&gt;</description></item><item><title>Ninjas are cool, but engineers build bridges</title><link>http://blogs.msdn.com/sdl/archive/2009/10/23/ninjas-are-cool-but-engineers-build-bridges.aspx</link><pubDate>Fri, 23 Oct 2009 18:20:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9912176</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9912176.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9912176</wfw:commentRss><description>&lt;p&gt;Cory at Matasano has a &lt;a href="http://chargen.matasano.com/chargen/2009/10/20/ninja-threat-modeling.html"&gt;new blog post&lt;/a&gt; explaining “Ninja threat modeling.” Ninja threat modeling is Matasano’s approach to threat modeling as part of a penetration test. I’m really happy that they’ve given their approach a name. A few years back, we would just talk about “threat modeling” and it got confusing. With that said, Adam here, and I wanted to offer up our perspective. I’ll do that by first comparing and contrasting the SDL and ninja approaches, and then respond to on some Cory’s impressions of the STRIDE-per-Element approach to threat modeling which we’re using in the SDL.&lt;/p&gt;  &lt;h4&gt;Pirates are Way Cooler than Ninjas, but Engineering Got us to the Moon&lt;/h4&gt;  &lt;p&gt;There’s a lot to be said for giving your approach a cool name, and we love cool names too, like “The SDL Threat Modeling Tool.” How cool is that? Ok, ninja is much cooler. It seems from Cory’s post that Matasano’s customers are coming to them for security at the end of their process, rather than at the start. I think we all agree that threat modeling late produces less value. Here at Microsoft, we’ve invested in making it possible for any software engineer to threat model at the start of development. We’ve made enough progress in this that Forrester has said “Many application architects and developers don’t know enough about developing secure applications… Microsoft’s SDL Threat Modeling Tool is a unique new tool that helps developers identify and mitigate security risks to make applications more secure from the get-go.” (“&lt;a href="http://www.forrester.com/go?docid=53877"&gt;Use Threat Modeling To Develop More-Secure Applications&lt;/a&gt;,” March, 2009.)&lt;/p&gt;  &lt;p&gt;I do think that we can map between the current SDL approach and the Ninja approach: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/Ninjasarecoolbutengineersbuildbridges_9F5D/dd206731.ThreatModelingTool1(en-us)%5B1%5D_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="dd206731.ThreatModelingTool1(en-us)[1]" border="0" alt="dd206731.ThreatModelingTool1(en-us)[1]" src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/Ninjasarecoolbutengineersbuildbridges_9F5D/dd206731.ThreatModelingTool1(en-us)%5B1%5D_thumb.jpg" width="244" height="168" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="266"&gt;         &lt;p&gt;Stage &lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="266"&gt;         &lt;p&gt;STRIDE/Element&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="266"&gt;         &lt;p&gt;Ninja&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="266"&gt;         &lt;p&gt;Model&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="266"&gt;         &lt;p&gt;DFD&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="266"&gt;         &lt;p&gt;App overview, data flow&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="266"&gt;         &lt;p&gt;Identify Threats&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="266"&gt;         &lt;p&gt;STRIDE/Element&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="266"&gt;         &lt;p&gt;Assumptions, deadly sins&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="266"&gt;         &lt;p&gt;Mitigate&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="266"&gt;         &lt;p&gt;Redesign/standard/custom/accepted&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="266"&gt;         &lt;p&gt;?&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="266"&gt;         &lt;p&gt;Validate&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="266"&gt;         &lt;p&gt;Check model, all threats have bugs&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="266"&gt;         &lt;p&gt;Test plan&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;For a summary of their process, I looked at the boxed text “Ninja threat modeling at a glance.” I wish Cory had explained the approach a bit more: what’s the difference between an app overview and a data flow? Why are there 2 threat enumeration checklists (assumptions, deadly sins)? I think it might be interesting to combine the two threat enumerations. I also think that the risk management step could be formalized a bit more.&lt;/p&gt;  &lt;p&gt;So I’m glad that Matasano has a way to help you if you haven’t threat modeled. Our experience and observations over many, many years has shown that most people don’t want (or haven’t budgeted for) ninjas to drop into their process and slice up their design at the last minute. That’s why we’ve been sharing the &lt;a href="http://msdn.microsoft.com/en-us/security/dd221356.aspx"&gt;SDL optimization model&lt;/a&gt;, building out the &lt;a href="http://msdn.microsoft.com/en-us/security/dd219581.aspx"&gt;SDL Pro Network&lt;/a&gt; and sharing our approaches. We think that most people want to engineer a good and secure product from the start. We all need to work to make that easier, more predictable, and more effective. I also recognize that many organizations are not building security into their development processes yet. So it’s great to see Matasano think through what a threat model at the end of the dev process should look like, and share that thinking.&lt;/p&gt;  &lt;p&gt;I wanted to reply to one thing that Cory said:&lt;/p&gt;  &lt;p&gt;“It has spawned not just one, but two, Visio-driven toolsets from Microsoft and countless data-flow diagrams, attack trees, consulting engagements, and perplexed developers. When performed by a skilled and experienced team member, the model can be used to identify architectural weaknesses, guide default application behavior, and outline functional requirements for the product.”&lt;/p&gt;  &lt;p&gt;Cory’s right. We have two tools, and it’s confusing. We’ll be making that much clearer soon. Additionally, we’ve presented a lot of information about our many approaches over the &lt;a href="http://blogs.msdn.com/sdl/archive/2009/08/27/the-threats-to-our-products.aspx"&gt;years&lt;/a&gt;.Today, we have one authoritative site at &lt;a href="http://microsoft.com/sdl "&gt;microsoft.com/sdl&lt;/a&gt; which presents the most current guidance. We no longer use attack trees. We’re working hard to speak clearly. Is it working for you? Let us know what’s not clear. Yes, there are a lot of books and what-have-you that can’t be updated, but we aim to publish and maintain guidance on the SDL portal that is authoritative, current, and understandable. Kicking attack trees is sort of like commenting on the security of Win98: we’ve learned a lot since then.&lt;/p&gt;  &lt;p&gt;One of the most important things we’ve learned is that we needed to simplify the model, the approach, and the training, and we’ve done all three of those things. Having done those things, we’ve seen non-experts pick up the tool and create good threat models. We’ve heard from partners who are using the tool successfully, and we’ve received great feedback from analysts about efforts. None of which means we’re perfect. We’re still continuing to innovate with the aim of making the process better, and seeking the feedback from anyone who’s downloaded and applied our &lt;a href="http://msdn.microsoft.com/en-us/security/cc421514.aspx"&gt;free tools&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/security/cc420639.aspx"&gt;guidance&lt;/a&gt;. We’ve got some tricks up our sleeve, and while we don’t want to play them too close to the chest, we’re going to continue to innovate, and are glad to see a profusion of ideas for making things better.&amp;#160; Finally, we work to share our &lt;a href="http://blogs.msdn.com/sdl/attachment/8991806.ashx"&gt;experience&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Ninjas and Engineers Agree: Threat Model&lt;/h4&gt;  &lt;p&gt;We’ve seen the STRIDE-per-element approach work for non-experts. We suggest you give it a try. But far more important than which approach you try is when you try it. Start early. Take a look at the optimization model. If you want some consulting help, go to one of our Pro Network partners or even to Matasano. If you have a few hours, experiment with both approaches and see which fits. But start early and find a threat modeling approach that helps you deliver more secure software.&lt;/p&gt;  &lt;p&gt;Pirates and script kiddies would prefer you just fuzzed.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9912176" width="1" height="1"&gt;</description></item><item><title>MS09-050, SMBv2 and the SDL</title><link>http://blogs.msdn.com/sdl/archive/2009/10/15/ms09-050-smbv2-and-the-sdl.aspx</link><pubDate>Thu, 15 Oct 2009 21:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9907851</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9907851.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9907851</wfw:commentRss><description>&lt;P&gt;&lt;EM&gt;10/20/2009: Updated with correct CVE&amp;nbsp;- thanks&amp;nbsp;to Matthieu Suiche for pointing this out to me.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Hi, Michael here.&lt;/P&gt;
&lt;P&gt;When I wrote the first analysis of why the SDL had missed a security vulnerability, I made a comment that I would continue to write these posts, but only for bugs that interested me. To be honest, all security bugs interest me, but this one really got me to sit up because it’s in new code. &lt;/P&gt;
&lt;P&gt;For reference, the security update that fixes this is &lt;A href="http://www.microsoft.com/technet/security/bulletin/ms09-050.mspx" mce_href="http://www.microsoft.com/technet/security/bulletin/ms09-050.mspx"&gt;MS09-050&lt;/A&gt;, and the bug is &lt;A href="http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2009-3103" mce_href="http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2009-3103"&gt;CVE-2009-3103&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;What makes the bug of concern is it’s in networking code; thankfully, there are some mitigations available, such as the Windows Firewall, that reduce exposure to attacks.&lt;/P&gt;
&lt;P&gt;First, let’s take a look at the vulnerable code. Can you spot the bug?&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; Smb2GetWorkItem( WI ) ((PSMB2_WORK_ITEM)(WI-&amp;gt;ProviderWorkItem))&lt;/PRE&gt;&lt;PRE&gt;...&lt;/PRE&gt;&lt;PRE class=alt&gt;typedef &lt;SPAN class=kwrd&gt;struct&lt;/SPAN&gt; _SRV_WORK_ITEM&lt;/PRE&gt;&lt;PRE&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;...&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=rem&gt;//&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=rem&gt;// This is the Receive Buffer for the incoming request&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=rem&gt;//&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    PSRVBUFFER ReceiveBuffer;&lt;/PRE&gt;&lt;PRE&gt;    PSRVBUFFER ResponseBuffer;&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;...&lt;/PRE&gt;&lt;PRE class=alt&gt;} SRV_WORK_ITEM, *PSRV_WORK_ITEM;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;...&lt;/PRE&gt;&lt;PRE&gt;NTSTATUS&lt;/PRE&gt;&lt;PRE class=alt&gt;Smb2ValidateProviderCallback( PSRV_WORK_ITEM WorkItem )&lt;/PRE&gt;&lt;PRE&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;    PSMB2_HEADER pHeader = (PSMB2_HEADER)WorkItem-&amp;gt;ReceiveBuffer-&amp;gt;Buffer;&lt;/PRE&gt;&lt;PRE&gt;    PSMB2_WORK_ITEM pWI = Smb2GetWorkItem( WorkItem );&lt;/PRE&gt;&lt;PRE class=alt&gt;    PSMB2_CONNECTION pC = Smb2GetConnection( WorkItem-&amp;gt;Connection );&lt;/PRE&gt;&lt;PRE&gt;    NTSTATUS status;&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;    pWI-&amp;gt;ParentWorkItem = WorkItem;&lt;/PRE&gt;&lt;PRE class=alt&gt;    pWI-&amp;gt;AsyncId = RFSTABLE64_INVALID_ITEM;&lt;/PRE&gt;&lt;PRE&gt;    WorkItem-&amp;gt;ProviderWorkItemCleanupRoutine = Smb2CleanupWorkItem;&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;...&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;( pHeader-&amp;gt;ProtocolId != SMB2_PROTOCOL_ID )&lt;/PRE&gt;&lt;PRE class=alt&gt;    {&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;( pHeader-&amp;gt;ProtocolId == SMB_PROTOCOL_ID &amp;amp;&amp;amp;&lt;/PRE&gt;&lt;PRE class=alt&gt;            pC-&amp;gt;Dialect == 0xFFFF )&lt;/PRE&gt;&lt;PRE&gt;        {&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=rem&gt;//&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=rem&gt;// Handle downlevel multi-negotiate&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=rem&gt;//&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;            pWI-&amp;gt;Command = SMB2_0_COMMAND_NEGOTIATE;&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=kwrd&gt;goto&lt;/SPAN&gt; process_packet;&lt;/PRE&gt;&lt;PRE&gt;        }&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        {&lt;/PRE&gt;&lt;PRE class=alt&gt;            WorkItem-&amp;gt;DisconnectConnection = TRUE;&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; STATUS_INVALID_PARAMETER;&lt;/PRE&gt;&lt;PRE class=alt&gt;        }&lt;/PRE&gt;&lt;PRE&gt;    }&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;    pWI-&amp;gt;Command = pHeader-&amp;gt;Command;&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;...&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;process_packet:&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;( SRVWPP_LOG_MESSAGE( DEBUG_MODULE_SRV2, DEBUG_PERF ) )&lt;/PRE&gt;&lt;PRE class=alt&gt;    {&lt;/PRE&gt;&lt;PRE&gt;        Smb2OutputWorkItemRequest( WorkItem );&lt;/PRE&gt;&lt;PRE class=alt&gt;    }&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;( ValidateRoutines[pHeader-&amp;gt;Command ] == NULL )&lt;/PRE&gt;&lt;PRE&gt;    {&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; Smb2ValidateNotImplemented( WorkItem );&lt;/PRE&gt;&lt;PRE&gt;    }&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    {&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; (ValidateRoutines[pHeader-&amp;gt;Command])( WorkItem );&lt;/PRE&gt;&lt;PRE&gt;    }&lt;/PRE&gt;&lt;PRE class=alt&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.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; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;If you can’t see the bug, here’s the fix:&lt;/P&gt;&lt;PRE class=csharpcode&gt;    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;( SRVWPP_LOG_MESSAGE( DEBUG_MODULE_SRV2, DEBUG_PERF ) )
    {
        Smb2OutputWorkItemRequest( WorkItem );
    }

    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;( ValidateRoutines[pWI-&amp;gt;Command] == NULL )
    {
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; Smb2ValidateNotImplemented( WorkItem );
    }
    &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt;
    {
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; (ValidateRoutines[pWI-&amp;gt;Command])( WorkItem );
    }
}&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.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; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;Look at the two array references to ValidateRoutines[] near the end, the array index to both is the wrong variable: pHeader-&amp;gt;Command should be pWI-&amp;gt;Command. &lt;/P&gt;
&lt;P&gt;So why did the SDL miss this bug?&lt;/P&gt;
&lt;P&gt;There is only one current SDL requirement or recommendation that could potentially find this, and that is fuzz testing. In fact we did find it very late in the Windows 7 development process through network fuzzing and that is why post-RC versions of Windows 7 do not have this bug. &lt;/P&gt;
&lt;P&gt;Right now there is no static analysis tool I know of that would point out the developer used the wrong variable, and our analysis tools didn’t spot the potential array bounds problem in part because it’s hard to do so with generate a very large quantity of false positives. With that said, we’re looking deeper into the latter challenge now. &lt;/P&gt;
&lt;P&gt;The only other method that could find this kind of bug is very slow and painstaking code review. This code &lt;I&gt;was&lt;/I&gt; peer-reviewed prior to check-in into Windows Vista; but the bug was missed. Humans are fallible, after all.&lt;/P&gt;
&lt;P&gt;Some years ago I created a “How to review code for Security Bugs” class and toward the end I explain that code reviewers need to question all coding logic assumptions when the code deals with untrusted data; I will add a new bullet point: are the correct variables used?&lt;/P&gt;
&lt;H4&gt;Going Out on a Limb!&lt;/H4&gt;
&lt;P&gt;I’ve mentioned this before, but it’s worth mentioning again. I think we’re getting to a stage at Microsoft where the SDL has whittled away most of the ‘low-hanging’ bugs. Of course, I might be proven wrong, but looking at all the bugs over the last year in Windows, the only pattern I can spot is there is no pattern! The majority of the bugs I see in Windows are one-off bugs that can’t be found easily through static analysis or education, which leaves only manual code review, and for some bug classes, fuzz testing. But fuzz testing is hardly perfect, because the malformed data might not hit the vulnerable code path or trigger a failure in the code.&lt;/P&gt;
&lt;P&gt;I would say that this is a great argument for software developers spending more time on defenses against unknown vulnerabilities, as well as trying to prevent or remove vulnerabilities. The SDL mantra of “Reduce the number of vulnerabilities and reduce the severity of the bugs you miss” is very consistent with this belief.&lt;/P&gt;
&lt;P&gt;- Michael&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#ffffff&gt;luv u kim x&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9907851" width="1" height="1"&gt;</description></item><item><title>Cross-Domain Security</title><link>http://blogs.msdn.com/sdl/archive/2009/10/12/cross-domain-security.aspx</link><pubDate>Tue, 13 Oct 2009 00:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9906361</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9906361.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9906361</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Hi everyone, Bryan here. Peleus Uhley, Senior Security Researcher at Adobe, has written a guest post for the &lt;/FONT&gt;&lt;A href="http://blogs.technet.com/bluehat/archive/2009/10/06/collaborating-on-ria-security.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;BlueHat blog&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; on potential security issues with cross-domain access permissions for web sites. I’d like to encourage you to read Peleus’ post and also to expand on it a little to talk about the SDL requirements around cross-domain access.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Normally, the Same Origin Policy prevents web pages from interacting with resources hosted on domains other than the one they were loaded from. This is done for security reasons; without the SOP it would be trivial for malicious sites to steal or alter data on other sites. However, there are so many great legitimate uses for cross-domain access (like creating client-side mashups) that several technologies have been developed to allow it under limited, opt-in circumstances. These technologies include:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;Flash’s crossdomain.xml policy file, also used by Silverlight&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;Silverlight’s clientaccesspolicy.xml policy file&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;IE8 &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/cc288060(VS.85).aspx"&gt;&lt;FONT size=3 face=Calibri&gt;XDomainRequest&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; object&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;XMLHttpRequest Level 2 &lt;/FONT&gt;&lt;A href="http://www.w3.org/TR/2008/WD-access-control-20080912/"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;Access-Control&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; headers &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;JavaScript document.domain property redefinition&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Now, there’s nothing inherently wrong with any of these (although I have argued in the past that cross-domain XMLHttpRequest would &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/bryansul/archive/2008/04/04/cross-domain-xhr-will-destroy-the-internet.aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;destroy the internet&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;). The problem with using these is that it’s easy to inadvertently expose data to sites you don’t intend to expose data to. Using wildcard domains when determining which domains have access permissions exacerbates this problem. The canonical example of this (no pun intended) is the crossdomain.xml setting&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&amp;lt;allow-access-from domain="*"/&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;This setting basically opens the web site up to cross-domain access from the entire internet.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;To help prevent sites from unintentionally exposing data to malicious external domains, the SDL requires any site with authenticated access to enumerate the specific domains it is allowing access to – no wildcards allowed. Otherwise, the site is free to make its cross-domain access as permissive as desired.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The original draft of the SDL cross-domain requirement was slightly different. Initially, the requirement included restrictions on the use of wildcards based on the depth of the wildcard (i.e. two-dots vs. one-dot vs. no-dots) and whether or not the site provided a “private API”. If a site contained only completely public resources, then it was allowed to use wildcards at the two-dots level or greater; for example, *.live.com would be allowed (two dots) but *.com would not (one dot). If a site had any resources only accessible by authenticated users, then no wildcards were allowed; all domains with cross-domain privileges had to be explicitly enumerated in the appropriate policy file or header.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;However, we later realized that this requirement draft was both overly complicated and overly restrictive. If a site is completely public – no authenticated access, no private or sensitive data – then there’s really no reason to restrict its access at all. The reason for this is that cross-domain attacks are luring attacks. To succeed, the attacker needs to lure a victim into performing some action on the attacker’s behalf. For example, a cross-domain attack against a stock trading web site might cause the victim to send the attacker the complete details of his stock portfolio, or might cause the victim to make unintended trades. But in a completely public site, there’s no personal data to steal and no possible authenticated actions to forge. There’s no reason for an attacker to perform a luring attack – they already have the same access to the same data that everyone else has. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;When we realized that our requirement was too restrictive, we changed it to its current form. However, let’s re-examine the requirement in light of Peleus’ research on cross-domain access chaining. (To give an extremely brief summary for those who haven’t read it yet: cross-domain permissions are transitive. If site A grants privileges to site B, and site B grants privileges to site C, then site A is implicitly and perhaps unknowingly granting privileges to site C.) For the completely public site the potential of privilege chaining is a non-issue in terms of SDL requirements; we’ve already said it’s acceptable to grant global access if desired. However, the situation is more complicated for the site with authenticated actions.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;It is true that even with wildcard domains being prohibited, there is still the possibility that one of an authenticated site’s allowed domains could chain access to a potentially malicious third site. Unfortunately, short of banning cross-domain access entirely, there is no way to completely prevent this possibility. In most situations it would be impossible to map out a list of 3&lt;SUP&gt;rd&lt;/SUP&gt; and 4&lt;SUP&gt;th&lt;/SUP&gt; and n&lt;SUP&gt;th&lt;/SUP&gt; order chained domains at development time, and furthermore it would be pointless since the list could change at any time even after the app has been deployed.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In light of this research, we will be evaluating ways in which we can adapt the cross-domain requirement to continue to prevent unintended access from third-party domains. However, the requirement as it stands now remains useful and relevant. It raises the bar for attackers while imposing minimal design constraints and minimal time investments on the part of the development team.&lt;/FONT&gt;&lt;/P&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: PMingLiU; mso-ascii-theme-font: minor-latin; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA"&gt;Please let us know if you have any feedback on this requirement. Do you feel it’s too restrictive? Or maybe it’s not restrictive enough? Feel free to write us or leave a comment here.&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9906361" width="1" height="1"&gt;</description></item><item><title>Getting the Most for Your Security Investment</title><link>http://blogs.msdn.com/sdl/archive/2009/10/05/getting-the-most-for-your-security-investment.aspx</link><pubDate>Tue, 06 Oct 2009 02:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9903471</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9903471.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9903471</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Hi everyone, this is Eleanor Saitta with &lt;/FONT&gt;&lt;A href="https://www.isecpartners.com/"&gt;&lt;FONT size=3 face=Calibri&gt;iSEC Partners&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;, with a brief post about return on investment and structured security.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;A few weeks ago, Microsoft and iSEC Partners published a joint &lt;/FONT&gt;&lt;A href="http://go.microsoft.com/?linkid=9684360"&gt;&lt;FONT size=3 face=Calibri&gt;whitepaper&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; titled, “Microsoft SDL: Return On Investment”, and I'd like to highlight a contradiction the paper discusses between what return on investment numbers show and common industry practice.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In many cases, we see companies spending most of their security budget on gatekeeper-style security projects &lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;—&lt;/SPAN&gt; right before the product is released, a security team gets called in to try to find vulnerabilities.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is more expensive and less effective than building security in from the start of a project and throughout the project’s development.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Vulnerabilities are missed with the gatekeeper approach because in any large and complex system there's rarely time to look at every line of code and every function.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;That's not the worst of it, though &lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;—&lt;/SPAN&gt; the cost of fixing the vulnerabilities found by the team can end up being huge because fixing security problems found late in the game may require a product be pushed back several stages in the development cycle and then retested to make sure no regressions are introduced and that the intended functionality didn't change.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;This type of late-development churn is inefficient.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In fact, the difference in cost between finding and fixing vulnerabilities early and fixing them once an application is about to deploy can be a factor of 30 or more (per a 2002 NIST study &lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;—&lt;/SPAN&gt; see the whitepaper for more details) For example, if you're writing a web application and you perform an architectural security review, protecting against Cross-Site Scripting can be built-into the software as a functional requirement, and you can ensure that the application is designed so all output is correctly encoded.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Putting in a point-fix at the right place in the framework and verifying that developers used the routine correctly is much easier and cheaper than trying to hunt down widely scattered cross-site scripting issues just as your ship deadline is approaching.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Similar platform-level mitigations can solve a wide range of what are commonly considered low-level issues.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Application platform vulnerabilities like Cross-Site Scripting or Cross-Site Request Forgery are what penetration testing is best at finding, but solving them up front with architectural review and secure design is still easier, cheaper, and more reliable than finding them in a gatekeeper-style penetration test and patching them.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In comparison, higher-level vulnerabilities in business rules, authentication, authorization or similar design issues can be both difficult to find and extremely time-consuming to fix if you only look for them once development has finished. Developers may have to change the core architecture of the system, leading to cascading code changes and regressions.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;On the other hand, a high-level security analysis (via threat modeling, security design review and related techniques) can be very effective at finding these types of issues.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You can do this analysis even before development starts, preventing expensive architecture changes.&lt;/FONT&gt;&lt;/P&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: PMingLiU; mso-bidi-theme-font: minor-bidi; mso-ascii-theme-font: minor-latin; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;For both design and implementation vulnerabilities, looking at the return on investment shows that engaging with security early in a structured fashion is more effective than common gatekeeper-style security practices.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When you’re making strategic decisions like this about how to approach security, good metrics that show what you’re getting for your investment make choices easier and your organization more efficient.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Take a look at the whitepaper &lt;A href="http://go.microsoft.com/?linkid=9684360"&gt;here&lt;/A&gt; for more information.&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9903471" width="1" height="1"&gt;</description></item><item><title>Known issue: Using MiniFuzz on Windows XP or Server2003</title><link>http://blogs.msdn.com/sdl/archive/2009/09/25/known-issue-using-minifuzz-on-windows-xp-or-server2003.aspx</link><pubDate>Fri, 25 Sep 2009 22:04:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9899660</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9899660.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9899660</wfw:commentRss><description>&lt;p&gt;Michael Howard here with a quick update on &lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=b2307ca4-638f-4641-9946-dc0a5abe8513"&gt;MiniFuzz File Fuzzer&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;We have received sporadic reports that a few MiniFuzz users are encountering an issue when attempting to run MiniFuzz on Windows Server 2003 or Windows XP platforms. This is a known issue that results from some missing registry keys on Windows XP and Server 2003 that are present in Vista and Server 2008 by default. We had documented this issue on the download site, but I wanted to also mention it here. &lt;/p&gt;  &lt;p&gt;Below is a quick snapshot of the error and a simple command-line script that will automatically create the necessary registry settings and allow you to use MiniFuzz on these platforms. This should get you up and fuzzing immediately.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;b&gt;The error:&lt;/b&gt;&lt;/p&gt;    &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/KnownissueUsingMiniFuzzonWindowsXPorServ_A9CC/clip_image002_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/KnownissueUsingMiniFuzzonWindowsXPorServ_A9CC/clip_image002_thumb.jpg" width="438" height="315" /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;b&gt;The manual fix:&lt;/b&gt;&lt;/p&gt;    &lt;p&gt;Run the following command-line script to automatically create the necessary registry settings:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;REG add &amp;quot;HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows Error Reporting&amp;quot; /f      &lt;br /&gt;REG add &amp;quot;HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows Error Reporting&amp;quot; /v DontShowUI /t REG_DWORD /d 1       &lt;br /&gt;REG add &amp;quot;HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows Error Reporting&amp;quot; /v ExcludedApplications /t REG_MULTI_SZ&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;b&gt;What we are doing about it:&lt;/b&gt;&lt;/p&gt;    &lt;p&gt;We will be fixing this issue in MiniFuzz and putting up a fixed version of MiniFuzz in the future. &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Thank you for downloading MiniFuzz. We apologize for this inconvenience, but hope this manual fix will help you begin fuzzing your applications.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9899660" width="1" height="1"&gt;</description></item><item><title>New and Improved AntiXss 3.1, Now With Sanitization</title><link>http://blogs.msdn.com/sdl/archive/2009/09/23/new-and-improved-antixss-3-1-now-with-sanitization.aspx</link><pubDate>Wed, 23 Sep 2009 23:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9898658</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9898658.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9898658</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Hi everyone, Bryan here.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;As we’ve talked about on this blog many times in the past, the SDL requires the use of the &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=051EE83C-5CCF-48ED-8463-02F56A6BFC09&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=051EE83C-5CCF-48ED-8463-02F56A6BFC09&amp;amp;displaylang=en"&gt;&lt;FONT size=3 face=Calibri&gt;Microsoft AntiXss library&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; to defend against cross-site scripting attacks. However, we haven’t talked about the fact that until now, there have been two separate versions of AntiXss: one freely available to external users, and one restricted to use only inside Microsoft hosted data centers. Both versions include functionality to encode HTML output, so that injected script will be harmlessly rendered as text instead of executed by the target’s browser. However, the internal version also includes functionality to sanitize user input and remove potentially malicious script.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;We have wanted to bring this internal technology to the external developer community for some time, so I’m excited to announce that the &lt;/FONT&gt;&lt;A href="http://www.msinfosec.com/" mce_href="http://www.msinfosec.com/"&gt;&lt;FONT size=3 face=Calibri&gt;Information Security&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; Tools team is including the HTML sanitization functionality in the new public version of AntiXss (version 3.1) and releasing the entire library under the Ms-PL open source license. Let’s take a quick look at how this functionality works and when you might want to use it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;When used correctly, output encoding is very effective at preventing XSS. However, a side effect of this is that it’s also very effective at preventing any type of user-specified HTML markup, whether malicious or benign. Yes, “&amp;lt;script&amp;gt;document.location='evil.com'&amp;lt;/script&amp;gt;” should probably be blocked, but what about “I like &amp;lt;b&amp;gt;strong&amp;lt;/b&amp;gt; coffee”? This is not malicious in any way and it seems overly restrictive to block it. (I’ll leave it to your own sense of good taste to decide whether the use of the &amp;lt;marquee&amp;gt; tag is malicious under any circumstances.)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Until now, the preferred way to selectively allow only certain HTML tags like &amp;lt;b&amp;gt; and &amp;lt;i&amp;gt; was to regex the input to ensure it contained only valid Unicode letter and number characters and those specified tags, something like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;CODE&gt;if (!Regex.IsMatch(input, @"^([\p{L}\p{N}'\s]|&amp;lt;b&amp;gt;|&amp;lt;/b&amp;gt;|&amp;lt;i&amp;gt;|&amp;lt;/i&amp;gt;){1,40}$")) throw new Exception();&lt;o:p&gt;&lt;/o:p&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This approach will prevent all unwanted tags, but it will also prevent all attributes on the allowed tags. Sometimes this is good – attackers can add malicious script to onmouseover attributes of &amp;lt;b&amp;gt; and &amp;lt;i&amp;gt; tags – but again, sometimes this is overkill and blocks the use of benign attributes like lang or title. It would be theoretically possible to extend the regular expression to allow these attributes, as well as other safe HTML tags and their attributes, but realistically that would be an incredibly difficult regex both to develop and maintain.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;AntiXss 3.1 takes care of all of this logic for you, using the same whitelist approach: it filters the input using a list of known good tags and attributes and strips out all other text. Simply pass the untrusted input through the AntiXss.GetSafeHtml or GetSafeHtmlFragment method to sanitize it:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;CODE&gt;string output = AntiXss.GetSafeHtml(input);&lt;o:p&gt;&lt;/o:p&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;I strongly encourage everyone to download the new AntiXss 3.1 and incorporate it into your applications starting today. It’s a very effective defense, especially when used in conjunction with the output encoding functionality that’s been a part of AntiXss from the beginning. And again, both output encoding and input sanitization are required by the SDL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Finally, I’d like to thank both the Exchange team (whose &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.exchange.data.textconverters.htmltohtml.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.exchange.data.textconverters.htmltohtml.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;HtmlToHtml&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; library provides the sanitization logic) and the &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/securitytools" mce_href="http://blogs.msdn.com/securitytools"&gt;&lt;FONT size=3 face=Calibri&gt;Information Security Tools&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; team for bringing this functionality to the public, where it can do the most good for the most people.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9898658" width="1" height="1"&gt;</description></item><item><title>Two New Security Tools for your SDL tool belt (Bonus: a “7-easy-steps” whitepaper)</title><link>http://blogs.msdn.com/sdl/archive/2009/09/16/two-new-security-tools-for-your-sdl-tool-belt-bonus-a-7-easy-steps-whitepaper.aspx</link><pubDate>Wed, 16 Sep 2009 16:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9895836</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9895836.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9895836</wfw:commentRss><description>&lt;P&gt;Jeremy Dallman here to announce the release of two new security tools that will help you test and verify the security of your software – and meet some of the most critical requirements of the SDL. In addition, we are responding to customer requests and providing a &lt;A href="http://go.microsoft.com/?linkid=9683340" mce_href="http://go.microsoft.com/?linkid=9683340"&gt;basic 7-step guide&lt;/A&gt; for manually integrating key elements of the SDL Process Template into your existing Visual Studio Team System project. &lt;/P&gt;
&lt;P&gt;As secure coding becomes an increasingly important piece of software development across the indus&lt;A title=_GoBack name=_GoBack&gt;&lt;/A&gt;try, we realize that security tools become a critical piece of your “security tool belt” and help ease adoption of security development best practices in your organization. In today’s economy, the tools that will get deployed are the inexpensive (or free) tools that effectively identify security issues, work seamlessly with your existing development environment and help teams implement the basics of the SDL. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;Today we are making available &lt;/B&gt;&lt;A href="http://go.microsoft.com/?linkid=9678113" mce_href="http://go.microsoft.com/?linkid=9678113"&gt;&lt;B&gt;BinScope Binary Analyzer&lt;/B&gt;&lt;/A&gt;&lt;B&gt; and &lt;/B&gt;&lt;A href="http://go.microsoft.com/?linkid=9678112" mce_href="http://go.microsoft.com/?linkid=9678112"&gt;&lt;B&gt;MiniFuzz File Fuzzer&lt;/B&gt;&lt;/A&gt;&lt;B&gt; as no cost downloads.&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;We put together a couple of demo videos also.&amp;nbsp;You can find them here: &lt;A href="http://edge.technet.com/Media/binscope-overview-and-demo/" target=_blank mce_href="http://edge.technet.com/Media/binscope-overview-and-demo/"&gt;BinScope video&lt;/A&gt;&amp;nbsp;&amp;amp; &lt;A href="http://edge.technet.com/Media/minifuzz-overview-and-demo/" target=_blank mce_href="http://edge.technet.com/Media/minifuzz-overview-and-demo/"&gt;MiniFuzz video&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Let me briefly introduce you to each of these tools and explain why we think they are ideal tools to download and immediately include in your development lifecycle to verify the security of your code.&lt;/P&gt;
&lt;H4&gt;BinScope Binary Analyzer&lt;/H4&gt;
&lt;H5&gt;What it does&lt;/H5&gt;
&lt;P&gt;The BinScope Binary Analyzer is an SDL-required security tool that has been used by Microsoft teams since the early days of the SDL. It analyzes your binaries for a wide variety of security protections with a very straightforward and easy-to-use interface. At Microsoft, developers and testers are required to use this tool in the &lt;A href="http://msdn.microsoft.com/en-us/library/cc307418.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc307418.aspx"&gt;Verification Phase of the SDL&lt;/A&gt; to ensure that they have built their code using the compiler/linker protections required by the Microsoft SDL.&lt;/P&gt;
&lt;P&gt;The analyzer performs a diverse set of security checks. These checks include:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/8dbf701c(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/8dbf701c(VS.80).aspx"&gt;/GS flag &lt;/A&gt;&lt;B&gt;&lt;/B&gt;is being set to detect stack-based buffer overflows&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/9a89h429(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/9a89h429(VS.80).aspx"&gt;/SafeSEH flag&lt;/A&gt;&lt;B&gt; &lt;/B&gt;is being set to enable and ensure safe exception handling&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ms235442(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms235442(VS.80).aspx"&gt;/NXCOMPAT flag&lt;/A&gt;&lt;B&gt; &lt;/B&gt;is being set to enforce data execution prevention (NX)&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/bb384887.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb384887.aspx"&gt;/DYNAMICBASE flag&lt;/A&gt;&lt;B&gt; &lt;/B&gt;is being set to enable Address Space Layout Randomization (ASLR)&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/wd40t7ad.aspx" mce_href="http://msdn.microsoft.com/en-us/library/wd40t7ad.aspx"&gt;.NET Strong-Named Assemblies &lt;/A&gt;&lt;B&gt;&lt;/B&gt;are being used to ensure unique key pairs and strong integrity checks are in place&lt;/LI&gt;
&lt;LI&gt;Known good &lt;A href="http://msdn.microsoft.com/en-us/visualc/ee309358.aspx" mce_href="http://msdn.microsoft.com/en-us/visualc/ee309358.aspx"&gt;ATL headers&lt;/A&gt; are being used&lt;/LI&gt;
&lt;LI&gt;Up-to-date compiler and linker versions are being used&lt;B&gt; &lt;/B&gt;(minimum Visual Studio 2005 SP2)&lt;/LI&gt;
&lt;LI&gt;Reports on dangerous constructs&lt;STRONG&gt; &lt;/STRONG&gt;that are prohibited/discouraged by the SDL (e.g. read/write shared sections, global function pointers). &lt;/LI&gt;&lt;/UL&gt;
&lt;H5&gt;How you use it&lt;/H5&gt;
&lt;P&gt;The BinScope Binary Analyzer can be downloaded as a standalone tool or as a tool that can be integrated into Visual Studio 2008. By offering these two options, this tool can easily and quickly help you build your code to meet the SDL compiler/linker protections.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image002_2.png" mce_href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image002_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=clip_image002 border=0 alt=clip_image002 src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image002_thumb.png" width=414 height=278 mce_src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image002_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(Figure above: stand-alone BinScope)&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image004_2.png" mce_href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image004_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=clip_image004 border=0 alt=clip_image004 src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image004_thumb.png" width=417 height=285 mce_src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image004_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(Figure above: BinScope integrated in Visual Studio)&lt;/P&gt;
&lt;H5&gt;Extra Goodness&lt;/H5&gt;
&lt;P&gt;With an integrated installation of the BinScope Binary Analyzer for Visual Studio, validation is readily available in the development environment. In addition, BinScope integrates with Microsoft Team Foundation Server (TFS) to output results into work items. Finally, if your project is using the &lt;A href="http://msdn.microsoft.com/en-us/security/dd670265.aspx" mce_href="http://msdn.microsoft.com/en-us/security/dd670265.aspx"&gt;Microsoft SDL Process Template for VSTS&lt;/A&gt;, BinScope will seamlessly integrate with the template’s security work items and SDL Final Security Review reporting. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image006_2.png" mce_href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image006_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=clip_image006 border=0 alt=clip_image006 src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image006_thumb.png" width=427 height=169 mce_src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image006_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(Figure above: Easy output to TFS to create bugs and speed triage)&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image008_2.png" mce_href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image008_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=clip_image008 border=0 alt=clip_image008 src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image008_thumb.png" width=431 height=314 mce_src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image008_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(Figure above: Seamless integration with the SDL Process Template reporting)&lt;/P&gt;
&lt;H4&gt;MiniFuzz File Fuzzer&lt;/H4&gt;
&lt;H5&gt;What it does&lt;/H5&gt;
&lt;P&gt;The MiniFuzz File Fuzzer is a very simple fuzzer designed to ease adoption of fuzz testing by non-security people who are unfamiliar with file fuzzing tools or have never used them in their software development processes. A less capable and non-graphical version of this tool was originally published on the CD that came with the book &lt;A href="http://www.microsoft.com/learning/en/us/Book.aspx?ID=8753&amp;amp;locale=en-us" mce_href="http://www.microsoft.com/learning/en/us/Book.aspx?ID=8753&amp;amp;locale=en-us"&gt;&lt;I&gt;The Security Development Lifecycle&lt;/I&gt;&lt;/A&gt;&lt;U&gt; &lt;/U&gt;by Steve Lipner and Michael Howard. Since that tool was effective at finding quality bugs, we wanted to offer it more widely along with our other SDL tools, improve the user experience, and provide integration with Visual Studio and Team foundation Server.&lt;/P&gt;
&lt;P&gt;Because fuzzing is effective at finding bugs, it is a required activity in the Verification Phase of the Microsoft Security Development Lifecycle (SDL). With the release of the MiniFuzz File Fuzzer, we have made a simple file fuzzer available to assist developer efforts to find and address more security bugs in code before it ships to customers. Simply provide the tool with a set of correctly formed files to serve as templates, and it will generate corrupted versions for testing. The effectiveness of fuzz testing can be increased by providing more variation in the template files.&lt;/P&gt;
&lt;H5&gt;&lt;A href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image010_2.png" mce_href="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image010_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; MARGIN-LEFT: 0px; BORDER-TOP: 0px; MARGIN-RIGHT: 0px; BORDER-RIGHT: 0px" title=clip_image010 border=0 alt=clip_image010 src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image010_thumb.png" width=376 height=383 mce_src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/TwoNewSecurityToolsforyourSDLtoolbeltBon_134B3/clip_image010_thumb.png"&gt;&lt;/A&gt;&lt;/H5&gt;
&lt;H5&gt;How you use it&lt;/H5&gt;
&lt;P&gt;When you install the MiniFuzz File Fuzzer, it is provided as a stand-alone fuzzing tool that can be launched from your Start Menu. However, if you are using Visual Studio 2008, you can easily include the tool in Visual Studio as an Add-in Tool and launch it from there. In addition, the tool can also output to Team Foundation Server and integrate with the Microsoft SDL Process Template for Visual Studio Team System similar to the BinScope Binary Analyzer.&lt;/P&gt;
&lt;H4&gt;Whitepaper: Manually Integrating the SDL Process Template&lt;/H4&gt;
&lt;P&gt;&lt;A href="http://go.microsoft.com/?linkid=9683340" mce_href="http://go.microsoft.com/?linkid=9683340"&gt;The whitepaper can be downloaded here&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;After a successful release of the SDL Process Template for VSTS, we heard from some customers that they would like to include the key elements of the SDL into their existing team project. So, we figured out how to do that in 7 easy steps and wrote a whitepaper! This paper outlines the steps for manually extracting the key elements of the SDL Process Template and integrating them into an existing Visual Studio 2008 team project. By completing each of these manual steps, you can include the key elements of the SDL into your project without waiting until you start or build your next team project.&lt;/P&gt;
&lt;P&gt;~~~~~~~~~~~~~~~~&lt;/P&gt;
&lt;P&gt;That’s a lot of news for one day, but I hope you are as excited as we are to be releasing these tools and making it possible for more development teams to write secure code and adopt the SDL. We welcome your comments and questions as you download and begin using these tools!&lt;/P&gt;
&lt;P&gt;[edited: 9/16/09 11AM - added links to videos]&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9895836" width="1" height="1"&gt;</description></item><item><title>Application Security Street Fighting</title><link>http://blogs.msdn.com/sdl/archive/2009/09/03/application-security-street-fighting.aspx</link><pubDate>Thu, 03 Sep 2009 23:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9891077</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9891077.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9891077</wfw:commentRss><description>&lt;P&gt;Hi, this is Johannes Ullrich from SANS. &lt;/P&gt;
&lt;P&gt;As CTO of the SANS Internet Storm Center &lt;A href="http://www.isc.sans.org/" mce_href="http://www.isc.sans.org"&gt;www.isc.sans.org&lt;/A&gt; , I lead the development of complex and exposed applications. Recently, SANS &lt;A href="http://www.sans.org/" mce_href="http://www.sans.org"&gt;www.sans.org&lt;/A&gt; became a member of the &lt;A href="http://msdn.microsoft.com/en-us/security/dd219581.aspx" mce_href="http://msdn.microsoft.com/en-us/security/dd219581.aspx"&gt;SDL Pro Network&lt;/A&gt;. I am happy that I will be able to teach the SDL curriculum in San Diego September 15&lt;SUP&gt;th&lt;/SUP&gt; &lt;A href="http://www.sans.org/ns2009/" mce_href="http://www.sans.org/ns2009/"&gt;http://www.sans.org/ns2009/&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;As a developer, you are faced with an almost impossible task. Even small projects process hundreds of pieces of input data, provide access control to multiple users and interact with multiple systems like databases and browsers. If you make one mistake, one single SQL injection flaw, one function with insufficient access control, you lose. On the other hand, an attacker only has to find one single flaw in order to breach the application.&lt;/P&gt;
&lt;P&gt;How do you “win” given these unfavorable odds? One mistake made by developers is to worry too much about individual lines of code forgetting about the big picture. As part of teaching developers about secure coding and defending web applications, I have started to adopt a philosophy I describe as “application security street fighting”. This philosophy focuses on easy and repeatable coding techniques. These techniques do not require developers to become security experts. Instead the approach focuses on using the right tools and principles to guide developers to create secure applications that can be efficiently implemented and maintained. &lt;/P&gt;
&lt;P&gt;1 – Simple repeatable coding techniques&lt;/P&gt;
&lt;P&gt;One aspect of street fighting, as compared to martial arts practiced in dojos and exhibited in competition is the fact that complex techniques don’t work. A quick kick to the groin usually beats the complicated judo throw. For a developer, this means that standard problems have to be solved in simple, repeatable ways. For example, the ever-present issue of SQL injection is easily addressed. By writing a simple library to enforce the use of prepared statements, the need to implement and secure SQL statements one at a time will diminish. &lt;/P&gt;
&lt;P&gt;Another example is user input validation. We typically teach developers to write two lines of code. One line is to retrieve the data from the user, and another line to validate that the data is in the expected format. In my opinion, this is one line of code too much. Instead, write a library once that will retrieve the data and validate it. Going forward, the developer will now only call one function, which will retrieve and validate the data. To illustrate, a little bit of pseudo code:&lt;/P&gt;
&lt;P&gt;First the traditional way:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Userdata=GetInput(‘email’);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;If ( ! is_email(Userdata) {&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Next the better version:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Userdata=GetEmail(‘email’); &lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;2 – Threat Focused Coding&lt;/P&gt;
&lt;P&gt;Once we get past simple issues like SQL injection and input validation, our developer is able to focus on more challenging security problems such as: How am I going to accurately describe the business logic?; or Which techniques could an attacker use to bypass access control restrictions? The developer’s focus will shift from individual lines of code to the larger threat. Threat modeling, an important part of the SDL, will now become much more meaningful to the developer. To apply a street fighting metaphor: Don’t look at your gun, look at your target. You need to know what is happening on a macro level and not get lost focusing on details.&lt;/P&gt;
&lt;P&gt;3 – Training&lt;/P&gt;
&lt;P&gt;Even simple techniques will not work if they haven’t been taught and practiced properly. There is a point for “dojo” style training in which you are presented with a set scenario and a safe environment in which to practice. This training needs to be applicable and based on real life situations in order to be effective. One thing I liked about the SDL curriculum developed by Microsoft is that it comes from a company that is able to apply these techniques in its own products. Software security training should not just come from security people, but be strongly influenced by developers. Aside from classroom training, there are plenty of other opportunities to learn and practice in your day-to-day job. It is also important to distinguish between training and practice. Training focuses on learning new skills, usually from an outsider. Practice on the other hand is all about applying what you learned and repeating it. Practice can benefit from outside feedback, but it can also be done on your own. Classroom training should illustrate how you are able to practice what you learned once you get back home. At SANS, one of our long-standing promises has been that what you learn in class, you will be able to apply the day you come home. If it would be any other way, we would only teach skills which you will never use and eventually forget.&lt;/P&gt;
&lt;P&gt;4 – Conclusion&lt;/P&gt;
&lt;P&gt;The SDL starts with training. Training your developers to reuse code and, to use simple and repeatable techniques to code securely will pay off later during implementation. Code reviews will be easier and faster if developers adhere to these guidelines. Even your response plan can harness the same principles by automating the detection and response to common attacks.&lt;/P&gt;
&lt;P&gt;As I’ve discussed here, Application Security requires a combination of knowledge, basic skills and practice so that defending applications through secure coding is done instinctively. The MS SDL process is a great toolkit and leverages the hard lessons learned over the years in security. If you’d like to learn the basics in a one day class, I’ll be teaching the MS SDL in San Diego on September 15&lt;SUP&gt;th&lt;/SUP&gt;. Check it out and register at &lt;A href="http://www.sans.org/ns2009/" mce_href="http://www.sans.org/ns2009/"&gt;http://www.sans.org/ns2009/&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9891077" width="1" height="1"&gt;</description></item><item><title>"The Threats to Our Products"</title><link>http://blogs.msdn.com/sdl/archive/2009/08/27/the-threats-to-our-products.aspx</link><pubDate>Fri, 28 Aug 2009 00:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9887486</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9887486.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9887486</wfw:commentRss><description>&lt;P&gt;Adam here. &lt;/P&gt;
&lt;P&gt;I’ve learned to love STRIDE as a framework for thinking about threats, but it makes a lousy classification system. That is, I can look at a system to find information disclosure threats, but once I have an attack that leaks, say, the location of a DLL in memory to a remote attacker, is that Information Disclosure or Elevation of Privilege? It’s likely to make the latter easy, and down the classification rat-hole we go.&amp;nbsp;&amp;nbsp; I’d like to suggest that calling it ‘the STRIDE &lt;STRONG&gt;framework&lt;/STRONG&gt; is the most clear wording we can use.’&lt;/P&gt;
&lt;P&gt;I found the 1999 internal Microsoft article written by (then) Microsoft employees Loren Kohnfelder and Praerit Garg, and was pleased to discover that they intended STRIDE “to help you identify potential vulnerabilities in your product during a security analysis.” They also make repeated reference to a “proactive security analysis process,” and shows some of the thinking that led to the SDL. &amp;nbsp;I thought it was neat look into history, and so without further ado, &lt;A href="http://blogs.msdn.com/sdl/attachment/9887486.ashx" mce_href="http://blogs.msdn.com/sdl/attachment/9887486.ashx"&gt;it's attached&lt;/A&gt;.&amp;nbsp; (59KB .docx)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9887486" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/sdl/attachment/9887486.ashx" length="60331" type="application/vnd.openxmlformats-officedocument.word" /><category domain="http://blogs.msdn.com/sdl/archive/tags/threat+modeling/default.aspx">threat modeling</category></item><item><title>A Gritty Policy</title><link>http://blogs.msdn.com/sdl/archive/2009/08/13/a-gritty-policy.aspx</link><pubDate>Thu, 13 Aug 2009 23:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9868798</guid><dc:creator>sdl</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9868798.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9868798</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Hi, Bryan here.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;For any of you that might not have seen the movie &lt;/FONT&gt;&lt;A href="http://www.imdb.com/title/tt0105435/" mce_href="http://www.imdb.com/title/tt0105435/"&gt;&lt;FONT color=#000000 size=3 face=Calibri&gt;Sneakers&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;, I’ll try to not spoil the plot completely for you, but the main storyline revolves around a “little black box” that a scientist has developed that can automatically defeat asymmetric encryption. It’s a fun movie, but what if this happened in real life? After all, crypto algorithms are broken all the time – either through little black box cleverness or simply through improved access to brute force processing power. If RSA, AES, SHA-2 or any of the other current &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/sdl/archive/2009/07/16/banned-crypto-and-the-sdl.aspx" mce_href="http://blogs.msdn.com/sdl/archive/2009/07/16/banned-crypto-and-the-sdl.aspx"&gt;&lt;FONT color=#000000 size=3 face=Calibri&gt;SDL crypto standard algorithms&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; were to be broken tomorrow, what kind of changes would you have to make to your applications? If you’ve hardcoded that algorithm into your apps, you’ll probably have to make some emergency code changes to use a new algorithm, issue patches to all of your users, and then hope that the new algorithm you chose doesn’t also get compromised. However, there is a better way to handle this scenario.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The SDL requires all applications to be able to upgrade the algorithms they use over time. This is usually referred to as the SDL crypto agility requirement. Both the .NET framework and the Cryptography API: Next Generation (CNG) include some useful features that can help you make your code more cryptographically agile; in fact, if you write your application the right way, you’ll be able to change algorithms with simple configuration file edits – no code changes required.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;For .NET code, the first step in crypto agility is to avoid hardcoding any particular algorithm or algorithm implementation into your code, and instead refer only to the abstract class of algorithm you need. Instead of instantiating a SHA256CryptoServiceProvider object (for example), you would declare an abstract HashAlgorithm. Instead of instantiating an AesManaged object, you would declare an abstract SymmetricAlgorithm. You can’t instantiate an abstract class, but System.Security.Cryptography abstract algorithm classes expose static Create methods. So instead of this code:&lt;/FONT&gt;&lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;SHA512Cng sha = new SHA512Cng(); // not agile!&lt;/P&gt;&lt;/CODE&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;You would use this code:&lt;/FONT&gt;&lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;HashAlgorithm hash = HashAlgorithm.Create(“SHA512”); // more agile&lt;/P&gt;&lt;/CODE&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;This new code doesn’t look any better than the old code – it looks like we’ve still hardcoded SHA512 into the application. But we actually haven’t; we’ve only hardcoded the string “SHA512” into the application, and we can edit the machine.config file to redefine which class actually gets instantiated when an application tries to create a “SHA512” object.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;An even better alternative is to define application-specific configuration strings and write these both into the code and into the machine.config files of systems where the app is deployed. This is safer than redefining a common algorithm string like “SHA512”, because you can upgrade the algorithm used by an individual application without affecting any other apps:&lt;/FONT&gt;&lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;HashAlgorithm hash = HashAlgorithm.Create(“MyApplication_PreferredHash”); // most agile&lt;/P&gt;&lt;/CODE&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;If you’re writing native C++ code, you can accomplish the same goal with CNG. Again, the first step is to avoid hardcoding algorithm names into your code:&lt;/FONT&gt;&lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;BCRYPT_ALG_HANDLE hAlg = NULL;&lt;BR&gt;NTSTATUS ret = BCryptOpenAlgorithmProvider(&amp;amp;hAlg, L"SHA256", NULL, 0); // not agile!&lt;/P&gt;&lt;/CODE&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Instead, load the desired algorithm provider string from a configuration file, or the registry, or some other location. Just be sure to apply an appropriate ACL to the resource where you’re storing your setting! You don’t want unauthorized users reducing the security strength of the application by reconfiguring it to use a weaker algorithm.&lt;/FONT&gt;&lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;LPCWSTR algName = NULL;&lt;BR&gt;// load desired algName from the registry&lt;BR&gt;…&lt;BR&gt;NTSTATUS ret = BCryptOpenAlgorithmProvider(&amp;amp;hAlg, algName, NULL, 0); // more agile&lt;/P&gt;&lt;/CODE&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In most cases, some additional work will be required in order to make crypto agility code work correctly. For example, if you’re storing password hashes for an authentication system, you can’t change just the comparing algorithm and expect the system to work. If the stored hashes are MD5 and you start comparing them to computed SHA-2 hashes, no one will be able to log in. In this case, you’ll need to store metadata about the algorithm used along with the stored password hash. When authenticating the user, instantiate the exact algorithm they originally used to create the password hash. Once they’ve authenticated, check whether the algorithm used to create their hash is out of date. If so, prompt them to create a new password, then create and store the new password hash using the new preferred algorithm.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Of course, this example is just the tip of the iceberg. If you’re interested in reading more about crypto agility, including more code and configuration samples, be sure to check out the &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/magazine/ee321570.aspx" mce_href="http://msdn.microsoft.com/en-us/magazine/ee321570.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;Security Briefs&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; column of the current MSDN Magazine, the Cryptographic Enhancements chapter of &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/learning/en/us/Book.aspx?ID=10723&amp;amp;locale=en-us" mce_href="http://www.microsoft.com/learning/en/us/Book.aspx?ID=10723&amp;amp;locale=en-us"&gt;&lt;FONT color=#000000 size=3 face=Calibri&gt;Writing Secure Code for Windows Vista&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;, or Shawn Farkas’ (of the CLR Security team) &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/shawnfa/archive/2008/12/02/cryptoconfig.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2008/12/02/cryptoconfig.aspx"&gt;&lt;FONT color=#000000 size=3 face=Calibri&gt;blog&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;. As always, questions and comments are welcome.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9868798" width="1" height="1"&gt;</description></item><item><title>Setting SDL memory-related Requirements before your Application Starts</title><link>http://blogs.msdn.com/sdl/archive/2009/08/06/setting-sdl-memory-related-requirements-before-your-application-starts.aspx</link><pubDate>Thu, 06 Aug 2009 21:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9859454</guid><dc:creator>sdl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9859454.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9859454</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Hello, Michael here.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;A word of warning, this is purely an “FYI” post that has very little to do with SDL policy!&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;I get this question, “How do I call various SDL-mandated APIs before my code starts?” about once a month, so I decided to write about it so I don’t have keep dragging up the same email over and over! The question roughly translates into “Can I call some setup code before main() starts?”&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The answer is ‘yes’! But why would you want to do it? One reason is perhaps you want to call the &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/michael_howard/archive/2008/01/29/new-nx-apis-added-to-windows-vista-sp1-windows-xp-sp3-and-windows-server-2008.aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;SetProcessDEPPolicy&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; API because you don’t have access to a compiler with the /NXCOMPAT option, or perhaps you want to call &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/michael_howard/archive/2008/02/18/faq-about-heapsetinformation-in-windows-vista-and-heap-based-buffer-overruns.aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;HeapSetInformation&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; very early in your code because main() handles untrusted data. Or perhaps you want to create a library for your developers to link with and not require them to add new API calls to their code. But probably the most important reason is if you want to update many EXEs but don’t want to change the code, all you need to do is link with the OBJ file. That’s it!&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Visual C++ allows you to define your own code sections that are called by the C startup runtime code prior to calling main(). The following code snippet could be compiled to a .OBJ and then linked with your C or C++ project and will call the SetProcessDEPPolicy API to set the NX bit on your process. You can add most any API in here. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;static&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;__cdecl&lt;/SPAN&gt; SDLSetup(&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt;) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;HMODULE hmodKernel32 = GetModuleHandleW(L&lt;SPAN style="COLOR: #a31515"&gt;"KERNEL32.DLL"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;BOOL (WINAPI *pfnSetProcessDEPPolicy)(DWORD);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;*(FARPROC *) &amp;amp;pfnSetProcessDEPPolicy &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;= GetProcAddress(hmodKernel32, &lt;SPAN style="COLOR: #a31515"&gt;"SetProcessDEPPolicy"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (pfnSetProcessDEPPolicy != 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(*pfnSetProcessDEPPolicy)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;(PROCESS_DEP_ENABLE | PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt;(0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt;static&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt; mso-bidi-font-family: Consolas"&gt; &lt;SPAN style="COLOR: blue"&gt;__declspec&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;allocate&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;".CRT$XIAA"&lt;/SPAN&gt;)) &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; (&lt;SPAN style="COLOR: blue"&gt;__cdecl&lt;/SPAN&gt; *pfnSDLSetup)(&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt;) &lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;= &amp;amp;SDLSetup;&lt;/SPAN&gt;&lt;A name=_GoBack&gt;&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9859454" width="1" height="1"&gt;</description></item><item><title>ATL, MS09-035 and the SDL</title><link>http://blogs.msdn.com/sdl/archive/2009/07/28/atl-ms09-035-and-the-sdl.aspx</link><pubDate>Tue, 28 Jul 2009 20:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9851201</guid><dc:creator>sdl</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9851201.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9851201</wfw:commentRss><description>&lt;P&gt;Hello, Michael here.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;lt;updated: 7/31 - changed the compiler 'warning' to 'error'&amp;gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Today, the &lt;A href="http://blogs.technet.com/msrc/" mce_href="http://blogs.technet.com/msrc/"&gt;Microsoft Security Response Center&lt;/A&gt; (MSRC) released two out-of-band security bulletins, &lt;A href="http://www.microsoft.com/technet/security/bulletin/ms09-034.mspx" mce_href="http://www.microsoft.com/technet/security/bulletin/ms09-034.mspx"&gt;MS09-034&lt;/A&gt; and &lt;A href="http://www.microsoft.com/technet/security/bulletin/ms09-035.mspx" mce_href="http://www.microsoft.com/technet/security/bulletin/ms09-035.mspx"&gt;MS09-035&lt;/A&gt;, and a &lt;A href="http://www.microsoft.com/technet/security/advisory/973882.mspx" mce_href="http://www.microsoft.com/technet/security/advisory/973882.mspx"&gt;Security Advisory&lt;/A&gt;, to address security bugs in the Active Template Library (ATL) and I think it’s appropriate that I explain why the SDL did not find these bugs and what we learned.&lt;/P&gt;
&lt;P&gt;I’ve said this many times, but I’ll say it again, because I think it bears repeating. A bug of any kind is an opportunity to learn and then adjust your development practices if appropriate. In this post I will only outline the bugs fixed in ATL, not any of the defense-in-depth mechanisms added to Internet Explorer as part of &lt;A href="http://www.microsoft.com/technet/security/bulletin/ms09-034.mspx" mce_href="http://www.microsoft.com/technet/security/bulletin/ms09-034.mspx"&gt;MS09-034&lt;/A&gt;. You can find more information about the IE update in Dave Ross’s blog post at &lt;A href="http://blogs.technet.com/srd/archive/2009/07/28/internet-explorer-mitigations-for-atl-data-stream-vulnerabilities.aspx" mce_href="http://blogs.technet.com/srd/archive/2009/07/28/internet-explorer-mitigations-for-atl-data-stream-vulnerabilities.aspx"&gt;Security Research &amp;amp; Defense.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;But before I explain the bugs, I want to spend a couple of minutes to explain ATL. The Active Template Library (ATL) is a set of lightweight C++ classes originally designed to make creating COM objects easier. ATL handles all the object reference counting and handles common COM tasks with ease. But ATL is not restricted to COM; there are &lt;A href="http://msdn.microsoft.com/en-us/library/awt7k7f5(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/awt7k7f5(VS.80).aspx"&gt;classes&lt;/A&gt; to handle &lt;A href="http://msdn.microsoft.com/en-us/library/txda4x5t(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/txda4x5t(VS.80).aspx"&gt;smart pointers&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/bwea7by5(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bwea7by5(VS.80).aspx"&gt;images&lt;/A&gt;, the &lt;A href="http://msdn.microsoft.com/en-us/library/xka57xy4(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/xka57xy4(VS.80).aspx"&gt;registry&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/zt6e0acy(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/zt6e0acy(VS.80).aspx"&gt;ACLs&lt;/A&gt; and more.&lt;/P&gt;
&lt;P&gt;When a developer creates a C++ project in Visual Studio, they are given the option to create an ATL project and if the developer opts to do so, the most important headers are automatically added to the project.&lt;/P&gt;
&lt;P&gt;One final point before I discuss the bugs, the ATL source code is available for you to review; in the case of Visual Studio 2008, in the %ProgramFiles%\Microsoft Visual Studio 9.0\vc\atlmfc folder. &lt;/P&gt;
&lt;P&gt;Now let’s dig into the bugs.&lt;/P&gt;
&lt;H3&gt;Bug #1: A Typo!&lt;/H3&gt;
&lt;P&gt;This is the core issue in the MSVidCtl ActiveX control. The bug is in a modified version of an older version of ATL, and is not in the public ATL code, but in a privately updated version of the ATL code. &lt;/P&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=2 width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD bgColor=#d3d3d3 vAlign=top width="100%"&gt;
&lt;H4&gt;Sidebar: How do ActiveX and COM differ?&lt;/H4&gt;
&lt;P&gt;Skip this section if you want to focus on the core security issues; I added this to answer to a question I get a lot. The Component Object Model (COM) is a binary specification that defines how objects can interact. An ActiveX object is a COM object. The major feature that characterizes ActiveX objects is their ability to be used from scripting languages. Doing so is often called ‘automation’. ActiveX objects use a COM interface named &lt;A href="http://msdn.microsoft.com/en-us/library/ms221608.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms221608.aspx"&gt;IDispatch&lt;/A&gt; which allows the script engine to resolve and call methods in the object at runtime. This is often called ‘late binding.’&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;The bug is simply a typo, can you spot it? I have removed extraneous code and error checking to make it easier to spot, and removed references to the &lt;FONT face="Courier New"&gt;psa&lt;/FONT&gt; variable (it’s a &lt;A href="http://msdn.microsoft.com/en-us/library/bb401745.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb401745.aspx"&gt;SAFEARRAYBOUND&lt;/A&gt; if you need to know)&lt;/P&gt;&lt;PRE class=csharpcode&gt;__int64 cbSize;
hr = pStream-&amp;gt;Read((&lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt;*) &amp;amp;cbSize, &lt;SPAN class=kwrd&gt;sizeof&lt;/SPAN&gt;(cbSize), NULL);
BYTE *pbArray;
HRESULT hr = SafeArrayAccessData(psa, reinterpret_cast&amp;lt;LPVOID *&amp;gt;(&amp;amp;pbArray));
hr = pStream-&amp;gt;Read((&lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt;*)&amp;amp;pbArray, (ULONG)cbSize, NULL);&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;






.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", 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; }&lt;/STYLE&gt;

&lt;P&gt;I’ll give you one more clue – it’s a one character typo. &lt;/P&gt;
&lt;P&gt;Give up? Look at the last line. The first argument is incorrect. It should be:&lt;/P&gt;&lt;PRE class=csharpcode&gt;hr = pStream-&amp;gt;Read((&lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt;*)pbArray, (ULONG)cbSize, NULL);&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;






.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", 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; }&lt;/STYLE&gt;

&lt;P&gt;The extra ‘&lt;FONT face="Courier New"&gt;&amp;amp;&lt;/FONT&gt;’ character in the vulnerable code causes the code to write potentially untrusted data, of size &lt;FONT face="Courier New"&gt;cbSize&lt;/FONT&gt;, to the address of the pointer to the array, &lt;FONT face="Courier New"&gt;pbArray&lt;/FONT&gt;, rather than write the data into the array, and the pointer is on the stack. This is a stack-based buffer overrun vulnerability.&lt;/P&gt;
&lt;P&gt;I contend that this would be very difficult to spot in a code review, and is not picked up by the C/C++ compiler owing to the &lt;FONT face="Courier New"&gt;(void*)&lt;/FONT&gt; cast. If the cast is removed, the compiler issues an error&amp;nbsp;like this:&lt;/P&gt;&lt;PRE class=csharpcode&gt;C2664: &lt;SPAN class=str&gt;'&amp;lt;function&amp;gt;'&lt;/SPAN&gt; : cannot convert parameter 1 from &lt;SPAN class=str&gt;'BYTE **'&lt;/SPAN&gt; to &lt;SPAN class=str&gt;'BYTE *'&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;






.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", 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; }&lt;/STYLE&gt;

&lt;P&gt;I despise C-style casting because it’s utterly unsafe; &lt;A href="http://msdn.microsoft.com/en-us/library/x9wzb5es(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/x9wzb5es(VS.80).aspx"&gt;C++ casting&lt;/A&gt; is safer, although the &lt;FONT face="Courier New"&gt;reinterpret_cast&lt;/FONT&gt; operator is almost as bad as C-style casting. &lt;/P&gt;
&lt;P&gt;So why did we miss this? &lt;/P&gt;
&lt;P&gt;Our static analysis tools don’t flag this one because the cast tells the compiler and tools, “I know what I’m doing!” I looked over a few dozen instances of casting code like this in various code bases and they were all correct, so adding a rule to flag this kind of code would be prone to false positives and I would not want to subject anyone to a potentially massive amount of noise.&lt;/P&gt;
&lt;P&gt;In the SDL we require that teams fuzz their controls, but our fuzzing tools didn’t find this because the method in question requires a specially formed input stream that includes many sentinel bytes. I explain the weaknesses of fuzzing &lt;A href="http://blogs.msdn.com/sdl/archive/2009/02/12/one-tool-does-not-rule-them-all.aspx" mce_href="http://blogs.msdn.com/sdl/archive/2009/02/12/one-tool-does-not-rule-them-all.aspx"&gt;here&lt;/A&gt;. We are in the process of adding more heuristics to our fuzzing engine so it can include these COM-specific bytes if needed.&lt;/P&gt;
&lt;P&gt;Our banned API removal doesn’t find this because there is no banned API in play.&lt;/P&gt;
&lt;P&gt;Some of the defenses such as &lt;A href="http://blogs.msdn.com/michael_howard/archive/2006/05/26/608315.aspx" mce_href="http://blogs.msdn.com/michael_howard/archive/2006/05/26/608315.aspx"&gt;ASLR&lt;/A&gt; and &lt;A href="http://support.microsoft.com/default.aspx?scid=kb;en-us;875352" mce_href="http://support.microsoft.com/default.aspx?scid=kb;en-us;875352"&gt;DEP&lt;/A&gt; in Windows might come into play, depending on the component in question. That seems like a vague answer, but I say “depending” because ATL is a source code template library that is used to build software, and it is up to the developers to use these defenses. Customers using Internet Explorer 8 on Windows Vista SP1 and later are better protected because ASLR and DEP are enabled by default.&lt;/P&gt;
&lt;P&gt;The code is compiled with /GS, but there is no stack cookie for the vulnerable function because there are no local variables to protect, so /GS protection is ineffective in this instance.&lt;/P&gt;
&lt;H3&gt;Bug #2: Using ATL Property Maps to Instantiate a COM object&lt;/H3&gt;
&lt;P&gt;ATL allows COM objects to easily persist their properties to a stream of bytes and that byte-stream can then be re-constituted by the object at a later time. ATL does this using a ‘property map.’ The stream can be comprised of a series of tuples. When using tuples, the first portion of the tuple is the data type and, depending on the data type, a size (for example, an &lt;EM&gt;n&lt;/EM&gt;-byte string [&lt;FONT face="Courier New"&gt;VT_BSTR&lt;/FONT&gt;]) and the second portion is the data itself.&lt;/P&gt;
&lt;P&gt;If the data type in the stream is &lt;FONT face="Courier New"&gt;VT_DISPATCH&lt;/FONT&gt; or &lt;FONT face="Courier New"&gt;VT_UNKNOWN&lt;/FONT&gt;, then the control might be vulnerable.&lt;/P&gt;
&lt;P&gt;The vulnerable code is in the shipping ATL source code, it’s in the &lt;FONT face="Courier New"&gt;CComVariant::ReadFromStream()&lt;/FONT&gt; method. &lt;/P&gt;
&lt;P&gt;So how did we miss this? The SDL offers no requirements or recommendations about using ATL property maps; in fact, the SDL offers few practices about hosting COM containers, mainly because there are so few of them, the most well-known COM container is Internet Explorer. We do require that teams use tools to identify their Safe-for-Scripting and Safe-for-Instantiation controls, however.&lt;/P&gt;
&lt;P&gt;In theory fuzzing should have found this, but our fuzzing engine does not build the correct stream and the stream is rejected. See the previous bug.&lt;/P&gt;
&lt;H3&gt;What We’re Doing&lt;/H3&gt;
&lt;P&gt;I want to point out that this is all very fluid right now owing to our rapid turn-around getting the bulletin out and I want to make sure we do the right thing in the SDL rather than rushing things and getting it wrong.&lt;/P&gt;
&lt;P&gt;First and foremost, we are updating our fuzzing tools to help find COM stream-related issues quickly, and we will update the SDL to tell teams to fuzz any COM object they have using any of the risky interfaces (like &lt;FONT face="Courier New"&gt;IPersistStream*&lt;/FONT&gt;, &lt;FONT face="Courier New"&gt;IPersistStorage&lt;/FONT&gt;, etc.)&lt;/P&gt;
&lt;P&gt;Second, we’re going to tell teams they must use the new ATL libraries. Today we have a “minimum compiler and linker toolset” requirement, but we don’t explicitly tell people which ATL to use. We’re going to change that!&lt;/P&gt;
&lt;P&gt;Finally, I want to drill a little deeper into casting issues. This will be a side project for me over the next few months, as I wade through bug databases and code to see if there are other related issues. I’ll also speak to various static analysis and C/C++ language experts here at Microsoft and across the industry to get their views and insight. If you have a professional opinion on casting issues, please feel free to let me know through this blog.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9851201" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category></item><item><title>URL Rewriting Session at Black Hat</title><link>http://blogs.msdn.com/sdl/archive/2009/07/27/url-rewriting-session-at-black-hat.aspx</link><pubDate>Tue, 28 Jul 2009 00:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9850326</guid><dc:creator>sdl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9850326.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9850326</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Hi everyone, Bryan here. I wanted to make a quick (and shameless) plug for &lt;/FONT&gt;&lt;A href="http://www.blackhat.com/html/bh-usa-09/bh-usa-09-speakers.html#Sullivan"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;my session&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; at Black Hat this week. I’ll be talking about the use of URL rewriting as a defense against XSS, XSRF, open-redirect phishing and browser history theft that I’ve discussed in the past both on &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/sdl/archive/2009/04/09/improving-security-with-url-rewriting.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;this blog&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; and in &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/magazine/dvdarchive/dd458793.aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;MSDN magazine&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In conjunction with my talk, I’d also like to announce availability of a proof-of-concept URL rewriting tool that implements the concepts illustrated in the talk. The rewriter is implemented as an HttpModule for ASP.NET applications – activating this module for use in your own code will typically require one new line of code and one change to your web.config file.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;You can download the tool &lt;/FONT&gt;&lt;A href="http://download.microsoft.com/download/5/3/8/53806626-DB11-4C0C-A71A-45A14E302B32/AltResourceLocator.zip"&gt;&lt;FONT size=3 face=Calibri&gt;here&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;, but again I’d like to stress that this is a proof-of-concept and should not be used for any production code. Please do feel free to test it out and even decompile it if you like – just let us know where it works, where it doesn’t, and how it can be improved.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9850326" width="1" height="1"&gt;</description></item></channel></rss>