<?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 : SDL</title><link>http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx</link><description>Tags: SDL</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><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>A Declspec SAL to Attribute SAL Rosetta Stone</title><link>http://blogs.msdn.com/sdl/archive/2009/06/11/a-declspec-sal-to-attribute-sal-rosetta-stone.aspx</link><pubDate>Thu, 11 Jun 2009 20:19:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9727129</guid><dc:creator>sdl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9727129.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9727129</wfw:commentRss><description>&lt;p&gt;Hi, Michael here.&lt;/p&gt;  &lt;p&gt;A while back I &lt;a href="http://blogs.msdn.com/michael_howard/archive/2006/05/19/602077.aspx"&gt;wrote a blog&lt;/a&gt; post explaining the Standard Annotation Language (SAL) which is a technology we use to help static analysis tools find more bugs, including security vulnerabilities, in C and C++ code. If you look closely at VC++ 2005 and VC++ 2008, you’ll notice that almost all function prototypes are SAL annotated, which means you get the benefit of all the SAL work we did. But you might have also notice that the annotation style between the two compiler versions is different. &lt;/p&gt;  &lt;p&gt;For example, in Visual C++ 2005, realloc() is annotated like this:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre id="codeSnippet" class="csharpcode"&gt;__checkReturn __bcount_opt(_NewSize) &lt;br /&gt;    &lt;span class="kwrd"&gt;void&lt;/span&gt; * __cdecl realloc(&lt;br /&gt;        __in_opt &lt;span class="kwrd"&gt;void&lt;/span&gt; * _Memory, &lt;br /&gt;        __in size_t _NewSize);&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;But in VC++ 2008, realloc() is annotated like this:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre id="codeSnippet" class="csharpcode"&gt;_Check_return_ _Ret_opt_bytecap_(_NewSize) &lt;br /&gt;    &lt;span class="kwrd"&gt;void&lt;/span&gt; * __cdecl realloc(&lt;br /&gt;        _In_opt_ &lt;span class="kwrd"&gt;void&lt;/span&gt; * _Memory, &lt;br /&gt;        _In_ size_t _NewSize);&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;So what’s going on? In short, there is an updated flavor of SAL that offers greater flexibility and strictness. The older version is usually referred to as ‘declspec’ SAL, and the newer version is called ‘attribute’ SAL. They get their names from the structure of the underlying primitives and the following should make it clear: 
  &lt;table border="1" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" width="173"&gt;
          &lt;p&gt;&lt;strong&gt;SAL Macro&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="465"&gt;
          &lt;p&gt;&lt;strong&gt;SAL Primitives&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="173"&gt;
          &lt;p&gt;&lt;b&gt;Declspec SAL&lt;/b&gt;&lt;/p&gt;

          &lt;div id="codeSnippetWrapper"&gt;
            &lt;div id="codeSnippetWrapper"&gt;
              &lt;pre id="codeSnippet" class="csharpcode"&gt;&lt;span class="kwrd"&gt;void&lt;/span&gt; Foo( &lt;br /&gt;    __in_bcount(cb) BYTE* pBuf, &lt;br /&gt;    size_t cb );&lt;/pre&gt;

              &lt;br /&gt;&lt;/div&gt;

            &lt;br /&gt;&lt;/div&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="465"&gt;
          &lt;p&gt;void Foo( 
            &lt;br /&gt;__declspec(&amp;quot;SAL_pre&amp;quot;) 

            &lt;br /&gt;__declspec(&amp;quot;SAL_valid&amp;quot;) 

            &lt;br /&gt;__declspec(&amp;quot;SAL_pre&amp;quot;) 

            &lt;br /&gt;__declspec(&amp;quot;SAL_deref&amp;quot;) 

            &lt;br /&gt;__declspec(&amp;quot;SAL_readonly&amp;quot;) 

            &lt;br /&gt;__declspec(&amp;quot;SAL_pre&amp;quot;) 

            &lt;br /&gt;__declspec(&amp;quot;SAL_readableTo(byteCount(&amp;quot;&amp;quot;cb&amp;quot;&amp;quot;))&amp;quot;) BYTE* pBuf, size_t cb );&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="173"&gt;
          &lt;p&gt;&lt;b&gt;Attribute SAL&lt;/b&gt;&lt;/p&gt;

          &lt;div id="codeSnippetWrapper"&gt;
            &lt;pre id="codeSnippet" class="csharpcode"&gt;&lt;span class="kwrd"&gt;void&lt;/span&gt; Foo( &lt;br /&gt;    _In_bytecount_(cb) BYTE* pBuf, &lt;br /&gt;    size_t cb );&lt;/pre&gt;
          &lt;/div&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="465"&gt;
          &lt;p&gt;void Foo( 
            &lt;br /&gt;[SA_Pre&amp;#160; (Null=SA_No,ValidBytes=&amp;quot;cb&amp;quot;)] 

            &lt;br /&gt;[SA_Pre(Deref=1,Valid=SA_Yes)] 

            &lt;br /&gt;[SA_Pre(Deref=1,Access=SA_Read)] BYTE* pBuf, size_t cb );&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Aren’t you happy we created macros for the low-level primitives!? You should never have to use the low-level primitives in your code: the table is to show you why the two SAL formats got their names. &lt;/p&gt;

&lt;p&gt;So why a new SAL syntax? I have good news and really good news. First, the good news: other than a simple macro syntax change, there is not a lot new to learn in part because the macros are similar (not identical, however) and the major difference, the low-level primitives, are abstracted away. &lt;/p&gt;

&lt;p&gt;Now for the really good news. Attribute SAL is much more rigorous than declspec SAL, which means analysis tools can find more bugs with lower false positives (‘noise’). For example, declspec SAL is often silent in the face of an incorrect annotation. &lt;/p&gt;

&lt;p&gt;The introduction of attribute SAL does not mean declspec SAL is dead, but it does mean that we will not be investing any more resources into declspec SAL, all our energy improving SAL and our analysis tools use of SAL will be in attribute SAL. At a pragmatic level, this means:&lt;/p&gt;

&lt;p&gt;· If you have already invested in using declspec SAL you should migrate over to attribute SAL as time allows, and use new attribute SAL for new functions. Both syntaxes can co-exist.&lt;/p&gt;

&lt;p&gt;· If you have never used SAL, you should use attribute SAL. As far as you’re concerned, declspec SAL never existed.&lt;/p&gt;

&lt;p&gt;One noticeable difference in macro names is the use of declspec SAL’s “count” and attribute SAL’s “cap” and “count.” The former is a buffer size in elements or bytes, but the latter two are the buffer’s writing capacity and the size of the buffer for reading, respectively.&lt;/p&gt;

&lt;p&gt;An important addition to attribute SAL is _Printf_format_string_ which can be used to find many printf-related format-matching ills.&lt;/p&gt;

&lt;p&gt;The following table shows some of the major differences: 
  &lt;table border="0" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" width="197"&gt;&amp;#160;&lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;&lt;strong&gt;declspec SAL&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;&lt;strong&gt;Attribute SAL&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Loose, allows macros in places they don’t make sense&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Strict, annotations can be only put on parameters and return values &lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;&lt;strong&gt;Consistency checks&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Few, allows wrong macros&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Many, exhaustive set of warnings for wrong\inconsistent annotations &lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;&lt;strong&gt;Wrong annotations&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Ignored&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Flagged&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;&lt;strong&gt;Constant expressions buffer sizes&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Simple expressions only&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Fully supported including templates, but requires different macros. &lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;&lt;strong&gt;Return values&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Loose syntax and consistency rules allow the use of ‘__out’ family&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Special set of macros for return values required&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;&lt;strong&gt;Naming consistency&lt;/strong&gt;&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Overloaded use of ‘count’ for writable and readable&amp;#160; extent. Hard to understand _full and _part postfixes&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="top" width="197"&gt;
          &lt;p&gt;Consistent use of ‘cap’ (capacity) for writable extent and ‘count’ for readable extent&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/p&gt;

&lt;p&gt;As noted in the table above, there is one minor drawback to using attribute SAL. If you use constant expressions as count or cap arguments, you must use a special set of macros, which is a little less elegant than declspec SAL:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Foo( _In_count_c_( 8 ) &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;* rgInt );&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;versus &lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Foo( __in_count( 8 ) &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;* rgInt );&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Note the _c_ portion of the attribute syntax, which is not needed when using declspec macros. With that said, attribute syntax supports accept any C++ conformant constant expression including enums and template arguments, but decspec SAL supports only simple expressions.&lt;/p&gt;

&lt;h4&gt;An Example&lt;/h4&gt;

&lt;p&gt;To put his altogether, let’s look at some simple code, and see how the VC++ 2008 /analyze static analysis performs when faced with the different SAL types. &lt;/p&gt;

&lt;p&gt;First, declspec SAL:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &lt;span style="color: #006080"&gt;&amp;quot;stdafx.h&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;struct&lt;/span&gt; SomeStruct {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; x;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; f;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt; };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; FuncOne(__in_z_opt &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* filename);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; FuncTwo(&lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt; *pFormat, ...);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; FuncThree( __in &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; SomeStruct* setup );&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; FuncFour(__in HWND h, __in &lt;span style="color: #0000ff"&gt;char&lt;/span&gt; *sz); &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; TestWarnings() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;char&lt;/span&gt; b;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;     FuncOne(&amp;amp;b); &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;     FuncTwo(&lt;span style="color: #006080"&gt;&amp;quot;%d %p %d&amp;quot;&lt;/span&gt;, 10.0, &lt;span style="color: #006080"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;     FuncThree(0); &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;     SomeStruct blah;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;     FuncThree(&amp;amp;blah);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;char&lt;/span&gt; buff[100];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;     FuncFour(NULL,buff);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;&lt;/div&gt;

&lt;p&gt;When compiled with /W4 /analyze, the compiler gives us:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre id="codeSnippet" class="csharpcode"&gt;warning C6309: Argument '1' is null: this does not adhere &lt;span class="kwrd"&gt;to&lt;/span&gt; function &lt;br /&gt;specification of 'FuncThree'&lt;br /&gt;warning C6309: Argument '1' is null: this does not adhere &lt;span class="kwrd"&gt;to&lt;/span&gt; function &lt;br /&gt;specification of 'FuncFour'&lt;br /&gt;warning C6387: 'argument 1' might be '0': this does not adhere &lt;span class="kwrd"&gt;to&lt;/span&gt; the &lt;br /&gt;specification &lt;span class="kwrd"&gt;for&lt;/span&gt; the function 'FuncThree': Lines: 14, 15, 16, 17&lt;br /&gt;warning C6387: 'argument 1' might be '0': this does not adhere &lt;span class="kwrd"&gt;to&lt;/span&gt; the &lt;br /&gt;specification &lt;span class="kwrd"&gt;for&lt;/span&gt; the function 'FuncFour': Lines: 14, 15, 16, 17, 18, 19, 21, &lt;br /&gt;22&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Now, let’s take the same code, but decorate the function prototypes with attribute SAL rather than declspec SAL.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &lt;span style="color: #006080"&gt;&amp;quot;stdafx.h&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;struct&lt;/span&gt; SomeStruct {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; x;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; f;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt; };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; FuncOne(_In_opt_z_ &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* filename);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; FuncTwo(_Printf_format_string_ &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt; *pFormat, ...);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; FuncThree(_In_ &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; SomeStruct* setup );&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; FuncFour(_In_ HWND h, _In_ &lt;span style="color: #0000ff"&gt;char&lt;/span&gt; *sz); &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; TestWarnings() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;char&lt;/span&gt; b;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;     FuncOne(&amp;amp;b); &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;     FuncTwo(&lt;span style="color: #006080"&gt;&amp;quot;%d %p %d&amp;quot;&lt;/span&gt;, 10.0, &lt;span style="color: #006080"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;     FuncThree(0); &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;     SomeStruct blah;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;     FuncThree(&amp;amp;blah);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;     &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;char&lt;/span&gt; buff[100];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;     FuncFour(NULL,buff);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre id="codeSnippet" class="csharpcode"&gt;warning C6273: Non-integer passed as parameter '2' when integer is required &lt;br /&gt;&lt;span class="kwrd"&gt;in&lt;/span&gt; call &lt;span class="kwrd"&gt;to&lt;/span&gt; 'FuncTwo': &lt;span class="kwrd"&gt;if&lt;/span&gt; a pointer value is being passed, %p should be used&lt;br /&gt;warning C6064: Missing integer argument &lt;span class="kwrd"&gt;to&lt;/span&gt; 'FuncTwo' that corresponds &lt;span class="kwrd"&gt;to&lt;/span&gt; &lt;br /&gt;conversion specifier '3'&lt;br /&gt;warning C6309: Argument '1' is null: this does not adhere &lt;span class="kwrd"&gt;to&lt;/span&gt; function &lt;br /&gt;specification of 'FuncThree'&lt;br /&gt;warning C6309: Argument '1' is null: this does not adhere &lt;span class="kwrd"&gt;to&lt;/span&gt; function &lt;br /&gt;specification of 'FuncFour'&lt;br /&gt;warning C6001: Using uninitialized memory 'b': Lines: 14, 15&lt;br /&gt;warning C6387: 'argument 1' might be '0': this does not adhere &lt;span class="kwrd"&gt;to&lt;/span&gt; the &lt;br /&gt;specification &lt;span class="kwrd"&gt;for&lt;/span&gt; the function 'FuncThree': Lines: 14, 15, 16, 17&lt;br /&gt;warning C6001: Using uninitialized memory 'blah': Lines: 14, 15, 16, 17, 18, &lt;br /&gt;19&lt;br /&gt;warning C6387: 'argument 1' might be '0': this does not adhere &lt;span class="kwrd"&gt;to&lt;/span&gt; the &lt;br /&gt;specification &lt;span class="kwrd"&gt;for&lt;/span&gt; the function 'FuncFour': Lines: 14, 15, 16, 17, 18, 19, 21, &lt;br /&gt;22&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;As you can see, using attribute SAL found many more code bugs, and all of them are real. I’ll let you sift through the list to see what attribute SAL found over and above declspec SAL! There are some duplicate bugs, however. &lt;/p&gt;

&lt;p&gt;If you want to learn more about SAL, I would recommend you simply open sal.h and read the comments and examples.&lt;/p&gt;

&lt;h4&gt;The Rosetta Stone&lt;/h4&gt;

&lt;p&gt;Below is a partial &lt;a href="http://en.wikipedia.org/wiki/Rosetta_stone"&gt;Rosetta Stone&lt;/a&gt; to help you convert between the two SAL syntaxes if you need to do so. 

  &lt;table border="0" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;&lt;b&gt;Declspec&lt;/b&gt;&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;&lt;b&gt;Attribute&lt;/b&gt;&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td width="227"&gt;
          &lt;p&gt;__in_opt&lt;/p&gt;
        &lt;/td&gt;

        &lt;td width="284"&gt;
          &lt;p&gt;_In_opt_&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_z_opt&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_opt_z_&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_opt&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_opt_&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_opt&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_opt_&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;&amp;#160;&lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;&amp;#160;&lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_ecount(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_count_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_bcount(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_bytecount_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_xcount(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_count_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_ecount_z(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_z_count_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_bcount_z(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_z_bytecount_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_xcount_z(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_z_count_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_ecount_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_opt_count_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_bcount_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_opt_bytecount_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_xcount_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_opt_count_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_ecount_z_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_opt_z_count_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_bcount_z_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_opt_z_bytecount_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__in_xcount_z_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_In_opt_z_count_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;&amp;#160;&lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;&amp;#160;&lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_ecount(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_cap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_bcount(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_bytecap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_xcount(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_cap_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_ecount_z(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_z_cap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_bcount_z(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_z_bytecap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_xcount_z(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_z_cap_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_ecount_part(cap,count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_cap_post_count_(cap, count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_bcount_part(cap,count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_bytecap_post_bytecount_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_ecount_full(capcount)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_capcount_(capcount)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_bcount_full(capcount)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_bytecapcount_(capcount)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_ecount_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_opt_cap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_bcount_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_opt_bytecap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_xcount_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_opt_cap_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_ecount_z_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_opt_z_cap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_bcount_z_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_opt_z_bytecap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_xcount_z_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_opt_z_cap_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_ecount_part_opt(cap,count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_opt_cap_post_count_(cap,count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_bcount_part_opt(cap,count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_opt_bytecap_post_bytecount_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_ecount_full_opt(capcount)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_opt_capcount_(capcount)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__out_bcount_full_opt(capcount)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Out_opt_bytecapcount_(capcount)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;&amp;#160;&lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;&amp;#160;&lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_ecount(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_cap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_bcount(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_bytecap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_xcount(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_cap_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_ecount_full(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_count_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_bcount_full(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_bytecount_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_xcount_full(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_count_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_ecount_z(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_z_cap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_bcount_z(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_z_bytecap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_xcount_z(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_z_cap_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_ecount_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_opt_cap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_bcount_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_opt_bytecap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_xcount_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_opt_cap_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_ecount_full_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_opt_count_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_bcount_full_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_opt_bytecount_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_xcount_full_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_opt_count_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_ecount_z_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_opt_z_cap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_bcount_z_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_opt_z_bytecap_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="bottom" width="227"&gt;
          &lt;p&gt;__inout_xcount_z_opt(count)&lt;/p&gt;
        &lt;/td&gt;

        &lt;td valign="bottom" width="284"&gt;
          &lt;p&gt;_Inout_opt_z_cap_x_(count)&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/p&gt;

&lt;h4&gt;Acknowledgments&lt;/h4&gt;
I would like to thank Hannes Ruescher (Dev Mgr in Office,) Dave Bartolomeo (Principal Software Design Engineer in Visual Studio) and Bruce Dawson (Principal Software Design Engineer in Windows) for their gracious help providing core content for this document. 

&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9727129" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category></item><item><title>New SDL Pro Network Members: SANS and SAIC</title><link>http://blogs.msdn.com/sdl/archive/2009/05/21/new-sdl-pro-network-members-sans-and-saic.aspx</link><pubDate>Thu, 21 May 2009 18:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9633926</guid><dc:creator>sdl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9633926.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9633926</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;When &lt;A href="http://blogs.msdn.com/sdl/archive/2008/09/11/new-addition-to-the-starting-line-up.aspx" mce_href="http://blogs.msdn.com/sdl/archive/2008/09/11/new-addition-to-the-starting-line-up.aspx"&gt;I joined the SDL team&lt;/A&gt; last fall, 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; had launched as a &lt;A href="http://blogs.msdn.com/sdl/archive/2008/09/18/about-the-sdl-pro-network.aspx" mce_href="http://blogs.msdn.com/sdl/archive/2008/09/18/about-the-sdl-pro-network.aspx"&gt;one-year pilot program&lt;/A&gt;.&amp;nbsp; Upon returning from maternity leave, I took over management of the SDL Pro Network.&amp;nbsp; I have been working on formalizing the program in order to bring it from pilot phase into a full blown partner program, to launch after November 2009.&amp;nbsp; I have also been working on bringing new consulting services and training members into the fold, even during this pilot phase of the program.&lt;/FONT&gt;&lt;FONT size=3 face=Calibri&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;On May 19, the SANS Institute, one of the most trusted and largest sources for information security training, certification &amp;amp; research in the world, and SAIC, a company of over 45,000 employees worldwide with expertise in national security, energy and the environment, critical infrastructure and health, were also added to the SDL Pro Network in an effort to further broaden the SDL’s reach. &lt;BR&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 joining forces with these two new SDL Pro Network members, Microsoft’s SDL team is bringing more options for world-renowned security training and consulting services to new developers around the world.&lt;BR&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Please join me in welcoming &lt;A href="http://www.sans.org/sdl.php" mce_href="http://www.sans.org/sdl.php"&gt;SANS&lt;/A&gt; and &lt;A href="http://www.saic.com/" mce_href="http://www.saic.com/"&gt;SAIC&lt;/A&gt; into the SDL Pro Network.&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;-&lt;A href="http://twitter.com/k8em0" mce_href="http://twitter.com/k8em0"&gt;Katie Moussouris&lt;/A&gt;, Senior Security Strategist, SDL&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9633926" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL+Pro+Network/default.aspx">SDL Pro Network</category></item><item><title>Please Join me in welcoming memcpy() to the SDL Rogues Gallery</title><link>http://blogs.msdn.com/sdl/archive/2009/05/14/please-join-me-in-welcoming-memcpy-to-the-sdl-rogues-gallery.aspx</link><pubDate>Fri, 15 May 2009 00:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9617155</guid><dc:creator>sdl</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9617155.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9617155</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Over the last few years I have written a number of articles, papers and books describing some of the dangers of using various buffer-manipulating C runtime functions. Well-known examples of bad function calls include strcpy(), strcat(), strncpy(), strncat(), gets() and their foul brethren. The &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/sdl/archive/2008/10/22/good-hygiene-and-banned-apis.aspx" mce_href="http://blogs.msdn.com/sdl/archive/2008/10/22/good-hygiene-and-banned-apis.aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;SDL bans&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; these and many other functions with dubious security history. But, when it comes to banning functions, we must tread a very fine line because we can’t just ban something because it looks odd, or that gut instinct tells us it’s bad, we can only ban functionality that has been demonstrated to cause security vulnerabilities and only if there is a viable alternative. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Because we have seen many security vulnerabilities in products from Microsoft and many others, including ISVs and competitors, and because we have a viable replacement, I am “proud” to announce that we intend to add memcpy() will to the SDL C and C++ banned API list later this year as we make further revisions to the SDL. Right now, memcpy() is on the SDL Recommended banned list, but will soon be added to the SDL banned API requirement list now that we have more feedback from Microsoft product groups.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The following security updates all have one thing in common: memcpy().&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Symbol; FONT-SIZE: 10pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-size: 11.0pt"&gt;&lt;SPAN style="mso-list: Ignore"&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;MS03-030 (DirectX)&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Symbol; FONT-SIZE: 10pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-size: 11.0pt"&gt;&lt;SPAN style="mso-list: Ignore"&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;MS03-043 (Messenger Service)&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Symbol; FONT-SIZE: 10pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-size: 11.0pt"&gt;&lt;SPAN style="mso-list: Ignore"&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;MS03-044 (Help and Support)&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Symbol; FONT-SIZE: 10pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-size: 11.0pt"&gt;&lt;SPAN style="mso-list: Ignore"&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;MS05-039 (PnP) &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Symbol; FONT-SIZE: 10pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-size: 11.0pt"&gt;&lt;SPAN style="mso-list: Ignore"&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;MS04-011 (PCT) &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Symbol; FONT-SIZE: 10pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-size: 11.0pt"&gt;&lt;SPAN style="mso-list: Ignore"&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;MS05-030 (Outlook Express) &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Symbol; FONT-SIZE: 10pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-size: 11.0pt"&gt;&lt;SPAN style="mso-list: Ignore"&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;CVE-2007-3999 (MIT Kerberos v5)&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Symbol; FONT-SIZE: 10pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-size: 11.0pt"&gt;&lt;SPAN style="mso-list: Ignore"&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;CVE-2007-4000 (MIT Kerberos v5)&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1; tab-stops: list .5in" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Symbol; FONT-SIZE: 10pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-size: 11.0pt"&gt;&lt;SPAN style="mso-list: Ignore"&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;…many more!&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;It’s not just memcpy() that we’re banning; we will also ban CopyMemory() and RtlCopyMemory(), and the replacement function is memcpy_s(). &lt;/FONT&gt;&lt;/P&gt;
&lt;H3 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd size=3 face=Cambria&gt;Banning memcpy() in your code&lt;/FONT&gt;&lt;/H3&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;You too should start banning memcpy() in your new code, here’s what you can do right now:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Add the following line of code to a common header file:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;#pragma&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;deprecated&lt;/SPAN&gt; (memcpy, RtlCopyMemory, CopyMemory)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Every time the compiler sees an instance of the banned functions, you’ll get the following warning:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"&gt;warning C4995: 'memcpy': name was marked as #pragma deprecated&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In Visual C++, you can also add this early in a common header:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;#define&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; _CRT_SECURE_WARNINGS_MEMORY&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;And you will get warnings like:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"&gt;warning C4996: 'memcpy': This function or variable may be unsafe. Consider using memcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. c:\program files\microsoft visual studio 9.0\vc\include\wchar.h(1201) : see declaration of 'memcpy'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;You can deprecate these functions if you’re using gcc by poisoning them:&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: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;#pragma&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; GCC poison memcpy RtlCopyMemory CopyMemory&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd size=3 face=Cambria&gt;Fixing memcpy() calls&lt;/FONT&gt;&lt;/H3&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Thankfully, it’s pretty simple to migrate a call to memcpy() to a safer call to memcpy_s(); the big difference is memcpy_s() takes one extra parameter: the size of the destination buffer. If nothing else, memcpy_s makes you think about the size of the target buffer.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/michael_howard/archive/2006/05/19/a-brief-introduction-to-the-standard-annotation-language-sal.aspx" mce_href="http://blogs.msdn.com/michael_howard/archive/2006/05/19/a-brief-introduction-to-the-standard-annotation-language-sal.aspx"&gt;&lt;FONT color=#0000ff size=3 face=Calibri&gt;SAL-decorated&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; function signature in VC++ 2008 is:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;errno_t &lt;SPAN style="COLOR: blue"&gt;__cdecl&lt;/SPAN&gt; &lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;memcpy_s(&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;_Out_opt_bytecap_post_bytecount_(_DstSize, _MaxCount) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; * _Dst,&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;_In_ rsize_t _DstSize, &lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;_In_opt_bytecount_(_MaxCount) &lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; * _Src, &lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;_In_ rsize_t _MaxCount&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&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="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;All you need to do is update calls to memcpy() by adding the size of the destination buffer. So calls like this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;char dst[32];&lt;o:p&gt;&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: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;memcpy(dst,src,len);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;becomes&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;char dst[32];&lt;o:p&gt;&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: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;memcpy_s(dst,sizeof(dst), src,len);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Of course, you can easily make a call to memcpy_s() insecure by getting the buffer sizes wrong. The following code is no better than memcpy():&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;memcpy_s(dst,len, src,len);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;You’ve been warned!&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;I wonder when Larry, Steve and Linus will start banning strcpy() in their products?&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9617155" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category></item><item><title>The Open Source Quality Challenge</title><link>http://blogs.msdn.com/sdl/archive/2009/05/01/the-open-source-quality-challenge.aspx</link><pubDate>Fri, 01 May 2009 17:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9582398</guid><dc:creator>sdl</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9582398.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9582398</wfw:commentRss><description>&lt;P&gt;Steve Lipner here, &lt;/P&gt;
&lt;P&gt;Steve Bellovin, &lt;A href="http://tools.ietf.org/html/rfc1579" mce_href="http://tools.ietf.org/html/rfc1579"&gt;one&lt;/A&gt; &lt;A href="http://tools.ietf.org/html/rfc1675" mce_href="http://tools.ietf.org/html/rfc1675"&gt;of&lt;/A&gt; &lt;A href="http://tools.ietf.org/html/rfc1948" mce_href="http://tools.ietf.org/html/rfc1948"&gt;the&lt;/A&gt; &lt;A href="http://tools.ietf.org/html/rfc3631" mce_href="http://tools.ietf.org/html/rfc3631"&gt;pioneers&lt;/A&gt; &lt;A href="http://www.wilyhacker.com/1e" mce_href="http://www.wilyhacker.com/1e"&gt;of&lt;/A&gt; &lt;A href="http://tools.ietf.org/html/rfc4107" mce_href="http://tools.ietf.org/html/rfc4107"&gt;Internet&lt;/A&gt; &lt;A href="http://www.cs.columbia.edu/~smb/papers/" mce_href="http://www.cs.columbia.edu/~smb/papers/"&gt;security&lt;/A&gt; wrote a &lt;A href="http://www.cs.columbia.edu/~smb/blog//2009-04/2009-04-29.html" mce_href="http://www.cs.columbia.edu/~smb/blog//2009-04/2009-04-29.html"&gt;blog post &lt;/A&gt;about security, open source, and secure development process.&amp;nbsp; It's worth reading if you're an open source fan, or if you're not.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;My one quibble is that Steve refers to fixing bugs in a way that implies that just fixing bugs improves security.&amp;nbsp; Our experience is that fixing bugs is not enough - you have to use tools and processes that specifically prevent security bugs from getting into the code in the first place. &lt;/P&gt;
&lt;P&gt;But that’s a minor quibble.&amp;nbsp; I think Steve's post is right on and a great read.&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9582398" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category></item><item><title>Security Development Processes and Transparency</title><link>http://blogs.msdn.com/sdl/archive/2009/04/30/security-development-processes-and-transparency.aspx</link><pubDate>Thu, 30 Apr 2009 22:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9581118</guid><dc:creator>sdl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9581118.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9581118</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Hi, Michael 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;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3 face=Calibri&gt;The following article, ”&lt;/FONT&gt;&lt;A href="http://www.sdtimes.com/link/33432"&gt;&lt;FONT size=3 face=Calibri&gt;Major software makers fail security transparency test&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;” caught my eye this morning, because it covers a topic of great interest to me&lt;S&gt;;&lt;/S&gt;: companies documenting their security and privacy-related software development practices for the world to critique and perhaps more important, use.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;As the article noted, Microsoft’s process has been public for nearly half a decade.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;About two years ago I created a short presentation (attached) that asks many of the questions implied by the SD Times article. We support the proposition that vendors should be evaluated by criteria that are closer to the real security properties people want in their systems.&amp;nbsp; Ask your vendors: are you investing in security or certificates?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The industry clearly has a long way to go, both in terms of improving security, and explaining how they achieve or plan to achieve their security objectives. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9581118" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/sdl/attachment/9581118.ashx" length="118784" type="application/vnd.ms-powerpoint" /><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category></item><item><title>You Can’t Outrun the Bear, so Let’s Make a Deal</title><link>http://blogs.msdn.com/sdl/archive/2009/04/23/you-can-t-outrun-the-bear-so-let-s-make-a-deal.aspx</link><pubDate>Thu, 23 Apr 2009 23:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9565425</guid><dc:creator>sdl</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9565425.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9565425</wfw:commentRss><description>&lt;P&gt;Hello, Michael Weiss here. Nothing like having two Michaels around to confuse everyone. At least there are only two here. On a previous team, I was one of five Michaels.&lt;/P&gt;
&lt;P&gt;Over the next several weeks, I’ll be posting a series of entries to help explain why I do what I do for the SDL team. Today marks the first of them. It’s a twofer, since the first part doesn’t fully make sense until you read the second part.&lt;/P&gt;
&lt;H3&gt;You Can’t Outrun the Bear&lt;/H3&gt;
&lt;P&gt;It’s a wild world out there. When you’re walking through the forest of the Internet, there are hungry bears all around you. The thing is, you can’t outrun the bear. Well, you can, but it’s very hard, not worth it, and not necessary, because you can avoid being eaten without having to outrun the bear in the first place. And contrary to popular belief, simply being faster than the other guy won’t necessarily protect you.&lt;/P&gt;
&lt;P&gt;There are two ways you can avoid being eaten. The first is to have little meat, in which case your gross value is low. The other is to be fast enough that it would cost the bear more in energy to catch you than it would gain from eating you, in which case your gross cost is high. In either case, the bear makes a determination of your net value, that is, your gross value minus your gross cost. If the net value is positive, the bear chases you. If the net value is negative, the bear leaves you alone. This graph helps illustrate the point.&lt;/P&gt;
&lt;P&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=image border=0 alt=image align=right src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/YouCantOutruntheBearsoLetsMakeaDeal_BD56/image_3.png" width=285 height=209 mce_src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/YouCantOutruntheBearsoLetsMakeaDeal_BD56/image_3.png"&gt;The blue line represents zero net value. As long as you are above the blue line, you have a negative net value so you’re safe; if you’re under the line, you have a positive net value so you’re dinner. In software, if you’re the green dot in the Dinner Zone, how can you move toward the Safe Zone? One way is to increase the gross cost to your attackers, by closing off the easy avenues of attack. The SDL was created to provide a mechanism to systematically do this.&lt;/P&gt;
&lt;P&gt;While the SDL can move you toward the Safe Zone, it’s not necessarily going to get you all the way there. But that’s OK, because in the real world, you’re not the only bear food.&lt;/P&gt;
&lt;P&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=image border=0 alt=image align=right src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/YouCantOutruntheBearsoLetsMakeaDeal_BD56/image_9.png" width=285 height=206 mce_src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/YouCantOutruntheBearsoLetsMakeaDeal_BD56/image_9.png"&gt; Let’s assume on this second graph that you are represented by the green dot, and some other potential target (your buddy, maybe?) is represented by the orange dot. You have a more secure system than him (your dot is higher up, costing the attacker more), so the orange dot person gets targeted instead of you. But what about that other person (represented by the red dot)? Sure, you have a more secure system, but you’re also a more valuable target (your dot is farther to the right). Since you’re farther from the blue line than the red person is, the attacker will go after you before working on the red person; you have a higher net value, despite having a higher gross cost.&lt;/P&gt;
&lt;P&gt;In other words, just being more secure isn’t enough if you’re also a more valuable target.&lt;/P&gt;
&lt;P&gt;Decreasing your gross value is rarely easy. For example, if you’re a bank, you could choose not to have any money. &lt;A href="http://en.wikipedia.org/wiki/Willie_Sutton" mce_href="http://en.wikipedia.org/wiki/Willie_Sutton"&gt;Willie Sutton&lt;/A&gt; would certainly lose interest in you. At the same time, your value as a bank is gone, too…hardly a sustainable business model. Besides, attackers rarely know exactly what they will gain from a successful attack on you. Sure, they might get control of your machine, but there’s no telling what’s on it. So, other than under extraordinary circumstances, they can at best make educated guesses. Put another way, attackers gamble based on their &lt;I&gt;belief&lt;/I&gt; of your gross value.&lt;/P&gt;
&lt;P&gt;In most cases, it takes far less effort to increase the attacker’s cost than to decrease your gross value. This is why most people will buy security systems for their homes before they give up the big flat-screen TVs. Applying the SDL and increasing the attackers’ costs, therefore, is a great way to protect yourself from those bears out there.&lt;/P&gt;
&lt;P&gt;Based on what I said thus far, it’s easy to conclude that very few of us would be potential victims. After all, if you’re not a bank or some similar high-value target, you’re not worth attacking, right? Attackers have a weapon that deflates this argument.&lt;/P&gt;
&lt;H3&gt;Let’s Make a Deal&lt;/H3&gt;
&lt;P&gt;In the classic game show &lt;I&gt;&lt;A href="http://www.letsmakeadeal.com/" mce_href="http://www.letsmakeadeal.com/"&gt;Let’s Make a Deal&lt;/A&gt;&lt;/I&gt;, host Monty Hall gave contestants a choice between keeping an existing prize or trading it for something hidden behind various doors. The contestant had to determine whether it was worth the gamble for an unknown prize.&lt;/P&gt;
&lt;P&gt;An attacker would have to do the same, investing the same amount of time on the second victim as on the first, were it not for the magic of amortization. With amortization, an attacker can trade current assets (the investment of time, and maybe some equipment and/or money, to craft the attack) to open not only Door #1, but also Doors #2 through 1,000,000, collecting whatever is behind all of them. It’s an offer no contestant could refuse.&lt;/P&gt;
&lt;P&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=image border=0 alt=image align=right src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/YouCantOutruntheBearsoLetsMakeaDeal_BD56/image_8.png" width=285 height=207 mce_src="http://blogs.msdn.com/blogfiles/sdl/WindowsLiveWriter/YouCantOutruntheBearsoLetsMakeaDeal_BD56/image_8.png"&gt; Let’s put this on the graph to see how amortization works.&lt;/P&gt;
&lt;P&gt;So let’s assume you are still represented by the green dot, but note your new location. You’re easy to attack, but you’re not really valuable. On &lt;I&gt;Let’s Make a Deal&lt;/I&gt;, this would be like giving up the diamond ring for a year’s supply of laundry detergent. Congratulations, you’re in the safe zone, so you don’t need to do anything, right?&lt;/P&gt;
&lt;P&gt;Not necessarily. If the vulnerability that you have is shared with others, then the attacker can aggregate all of you at a very small increase in cost. To the attacker, all of the victims aggregate to a single high value at low cost. To the attacker, it’s trading the one diamond ring for a million years’ supply of laundry detergent. The attacker can open a store online to sell the excess and really clean up! Collectively, then, you are represented by the red dot…very high value in aggregate, at a small increase in cost over attacking you alone. So you’re not really in the safe zone at all. You’re deep in the danger zone!&lt;/P&gt;
&lt;P&gt;A real world example of this is the use of vulnerabilities in Windows to create botnets. The same vulnerability existed on millions of machines, so even though a single bot is of sufficiently low value as to render the individual machine safe (i.e., where the green dot is), the low additional cost of applying that same attack to millions of machines made the attack worthwhile to an attacker. Collectively, the botnet is represented by the red dot.&lt;/P&gt;
&lt;P&gt;But you don’t even need to have exactly the same software across multiple machines in order for amortization to work. An entire &lt;I&gt;class&lt;/I&gt; of vulnerability, such as SQL injection, can benefit from amortization. So even if you write your own application, to be used in a single installation, on a singularly low-value machine, you can still find yourself a member of the collective dreaded red dot!&lt;/P&gt;
&lt;P&gt;If you’re a member of such a group, increasing the cost to an attacker pays even bigger dividends. By applying the SDL, you can improve your security, pull you out of the group, and therefore move you up the graph. Furthermore, as you increase your differentiation from the herd, you become harder to aggregate, which (from the attacker’s perspective) moves you to the left as well. The rest of the group you left behind can be bear food.&lt;/P&gt;
&lt;P&gt;So you can see that it’s not only unnecessary to outrun the bear, but it’s also not necessarily enough to be faster than the other guy. By applying a systematic, thorough approach to security, such as through the SDL, you can become hard enough to attack that you can significantly reduce your risk.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9565425" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category></item><item><title>MS08-078 and the SDL</title><link>http://blogs.msdn.com/sdl/archive/2008/12/18/ms08-078-and-the-sdl.aspx</link><pubDate>Fri, 19 Dec 2008 04:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9239665</guid><dc:creator>sdl</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9239665.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9239665</wfw:commentRss><description>Hi, Michael here. 
&lt;P&gt;Every bug is an opportunity to learn, and the security update that fixed the data binding bug that affected Internet Explorer users is no exception.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The Common Vulnerabilities and Exposures (CVE) entry for this bug is &lt;A href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4844" mce_href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4844"&gt;CVE-2008-4844&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Before I get started, I want to explain the goals of the SDL and the security work here at Microsoft. The SDL is designed as a multi-layered process to help systemically reduce security vulnerabilities; if one component of the SDL process fails to prevent or catch a bug, then some other component should prevent or catch the bug. The SDL also mandates the use of security defenses whose impact will be reflected in the "mitigations" section of a security bulletin, because we know that no software development process will catch all security bugs. As we have said many times, the goal of the SDL is to "Reduce vulnerabilities, and reduce the severity of what's missed."&lt;/P&gt;
&lt;P&gt;In this post, I want to focus on the SDL-required code analysis, code review, fuzzing and compiler and operating system defenses and how they fared.&lt;/P&gt;
&lt;H3&gt;Background&lt;/H3&gt;
&lt;P&gt;The bug was an invalid pointer dereference in MSHTML.DLL when the code handles data binding. It's important to point out that there is no heap corruption and there is no heap-based buffer overrun! &lt;/P&gt;
&lt;P&gt;When data binding is used, IE creates an object which contains an array of data binding objects. In the code in question, when a data binding object is released, the array length is not correctly updated leading to a function call into freed memory.&lt;/P&gt;
&lt;P&gt;The vulnerable code looks a little like this (by the way, the real array name is _aryPXfer, but I figured ArrayOfObjectsFromIE is a little more descriptive for people not in the Internet Explorer team.)&lt;/P&gt;&lt;FONT face=Courier&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;int MaxIdx = ArrayOfObjectsFromIE.Size()-1;&lt;/P&gt;
&lt;P&gt;for (int i=0; i &amp;lt;= MaxIdx; i++) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!ArrayOfObjectsFromIE[i])&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArrayOfObjectsFromIE[i]-&amp;gt;TransferFromSource();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;
&lt;P&gt;Here's how the vulnerability manifests itself: if there are two data transfers with the same identifier (so MaxIdx is 2), and the first transfer updates the length of the ArrayOfObjectsFromIE &amp;nbsp;array when its work was done and releases its data binding object, the loop count would still be whatever MaxIdx was at the start of the loop, 2.&lt;/P&gt;
&lt;P&gt;This is a time-of-check-time-of-use (TOCTOU) bug that led to code calling into a freed memory block. The Common Weakness Enumeration (CWE) classification for this vulnerability is &lt;A href="http://cwe.mitre.org/data/definitions/367.html" mce_href="http://cwe.mitre.org/data/definitions/367.html"&gt;CWE-367&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;The fix was to check the maximum iteration count on each loop iteration rather than once before the loop starts; this is the correct fix for a TOCTOU bug - move the check as close as possible to the action because, in this case, the array size might change.&lt;/P&gt;
&lt;H3&gt;Code Analysis and Review&lt;/H3&gt;
&lt;P&gt;Memory-related TOCTOU bugs are hard to find through code review; we teach TOCTOU issues, and we&amp;nbsp;teach memory corruption issues, and issues with using freed memory blocks; but we do not teach memory-related TOCTOU issues. We will update our training to address this. &lt;/P&gt;
&lt;P&gt;Our static analysis tools don't find this because the tools would need to understand the re-entrant nature of the code.&lt;/P&gt;
&lt;H3&gt;Fuzz Testing&lt;/H3&gt;
&lt;P&gt;In theory, fuzz testing could find this bug, but today there is no fuzz test case for this code. Triggering the bug would require a fuzzing tool that builds data streams with multiple data binding constructs with the same identifier. Random (or dumb) fuzzing payloads of this data type would probably not trigger the bug, however.&lt;/P&gt;
&lt;H3&gt;Defenses&lt;/H3&gt;
&lt;P&gt;There is a plethora of defenses available on various versions of Windows, but&amp;nbsp;only a couple came into play owing to the nature of the code.&lt;/P&gt;
&lt;H4&gt;-GS&lt;/H4&gt;
&lt;P&gt;As mandated by the SDL, the code is compiled with -GS to detect some forms of stack-based buffer overruns at runtime, but it's moot because this is not a stack-based buffer overrun.&lt;/P&gt;
&lt;H4&gt;ASLR and NX&lt;/H4&gt;
&lt;P&gt;Even though Windows Vista and Windows Server 2008 have both ASLR and NX enabled by default, Internet Explorer 7 does not opt-in to these defenses owing to compatibility issues with many common applications. &lt;A href="http://blogs.msdn.com/michael_howard/archive/2008/04/08/internet-explorer-8-0-and-data-execution-prevention-dep-nx.aspx" mce_href="http://blogs.msdn.com/michael_howard/archive/2008/04/08/internet-explorer-8-0-and-data-execution-prevention-dep-nx.aspx"&gt;Internet Explorer 8 enables these defenses by default&lt;/A&gt;, but an attack could be mounted by calling a component that does not use these defenses, and then by using an attack technique known as heap-spraying get the attacker's code into the non-ASLR and non-NX memory. This is why it's so important to build components for Windows that use all the available Windows defenses. Matt Thomlinson and I &lt;A href="http://msdn.microsoft.com/en-us/library/bb430720.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb430720.aspx"&gt;wrote an article&lt;/A&gt; on this subject, and David LeBlanc and I wrote &lt;A href="http://www.microsoft.com/mspress/books/10723.aspx" mce_href="http://www.microsoft.com/mspress/books/10723.aspx"&gt;Writing Secure Code for Windows Vista&lt;/A&gt; that covers the subject in much more detail.&lt;/P&gt;
&lt;H4&gt;Heap Termination on Corruption&lt;/H4&gt;
&lt;P&gt;IE7 and IE8 both use the SDL-required process termination if the heap is corrupted (you can read more about this &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" mce_href="http://blogs.msdn.com/michael_howard/archive/2008/02/18/faq-about-heapsetinformation-in-windows-vista-and-heap-based-buffer-overruns.aspx"&gt;here&lt;/A&gt;.) But there is technically no heap corruption, so the defense does not come into play in this instance.&lt;/P&gt;
&lt;H4&gt;Internet Explorer 7 and 8 Protected Mode&lt;/H4&gt;
&lt;P&gt;On Windows Vista and Windows Server 2008, this is a major defense that comes into play against the currently circulating exploits. When the exploit code runs, it's running at low integrity because IE runs at low integrity, and this means the exploit code cannot write to higher integrity portions of the operating system, which is just about everywhere! &lt;/P&gt;
&lt;P&gt;For our server platforms, Windows Server 2003 and Windows Server 2008, Internet Explorer Enhanced Security Configuration also prevents the exploit from working because the vulnerable code is disabled.&lt;/P&gt;
&lt;H3&gt;How was the bug found?&lt;/H3&gt;
&lt;P&gt;We really don't know how the bug was found, but some of the security people in Internet Explorer and the Trustworthy Computing Security teams suggest that the bug was either "stumbled upon" or found through directed fuzzing. The finder could spend as long as he or she wanted to find this one bug. This is one of the things that makes &lt;A href="http://blogs.msdn.com/michael_howard/archive/2007/02/02/what-is-it-that-makes-security-hard.aspx" mce_href="http://blogs.msdn.com/michael_howard/archive/2007/02/02/what-is-it-that-makes-security-hard.aspx"&gt;security hard&lt;/A&gt; - security is a highly asymmetric problem: software developers must get the code right 100% of the time in a very short amount of time, while attackers can spend as long as they want to find one bug.&amp;nbsp; This isn't an excuse; it's a fact of life&lt;/P&gt;
&lt;H3&gt;Summary&lt;/H3&gt;
&lt;P&gt;I think this bug is a great example of "you will never get the code 100% right, so multiple defenses are critical." As you can see from this post, many defenses in Windows did not come into play, but all it takes is one defense to help stop or reduce the chance that an exploit will succeed, and in the case of Windows Vista and Windows Server 2008, Internet Explorer's Protected Mode was that defense.&lt;/P&gt;
&lt;P&gt;If there is one other lesson from this, it's that we, the software industry, need to work harder to make sure applications take advantage of the defenses offered in Windows today.&lt;/P&gt;
&lt;H3&gt;Credits&lt;/H3&gt;
&lt;P&gt;Big thanks to Chengyun Chu, Jonathan Ness, Adam Shostack, Bronwen Matthews, Mike Reavey and Steve Lipner for their valuable edits and input to this post.&lt;/P&gt;I also want to thank the Internet Explorer team and the Microsoft Security Response Center team for such a rapid turn-around under incredible pressure. A job well done.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9239665" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category></item><item><title>Secure Coding Secrets?</title><link>http://blogs.msdn.com/sdl/archive/2008/11/18/secure-coding-secrets.aspx</link><pubDate>Tue, 18 Nov 2008 22:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9120309</guid><dc:creator>sdl</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9120309.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9120309</wfw:commentRss><description>Hi, Michael here. 
&lt;P&gt;A recent article titled &lt;A href="http://www.gcn.com/online/vol1_no1/47333-1.html" mce_href="http://www.gcn.com/online/vol1_no1/47333-1.html"&gt;"NSA posts secrets to writing secure code"&lt;/A&gt; caught my eye in part because the words "&lt;A href="http://www.microsoft.com/mspress/books/5957.aspx" mce_href="http://www.microsoft.com/mspress/books/5957.aspx"&gt;writing secure code&lt;/A&gt;" always get my attention! But also because anything that can advance the science of securing software is of interest to me.&lt;/P&gt;
&lt;P&gt;There is another reason why the article got my attention; my manager, Steve Lipner, is one of the few people to have designed and built a &lt;A href="http://www.boran.com/security/tcsec.html" mce_href="http://www.boran.com/security/tcsec.html"&gt;TCSEC&lt;/A&gt; A1 assured system and lived to tell the tale. None were sold, but they built one!&lt;/P&gt;
&lt;P&gt;The NSA-directed project, the &lt;A href="http://www.adacore.com/home/gnatpro/tokeneer/" mce_href="http://www.adacore.com/home/gnatpro/tokeneer/"&gt;Tokeneer&lt;/A&gt; ID Station (TIS), involved building a low-defect system that conforms "to the Common Criteria requirements for Evaluation Assurance Level 5 (EAL5)" in a "cost effective manner." I'm all for this, because building high-assurance solutions is not cheap. &lt;/P&gt;
&lt;P&gt;There's a &lt;A href="http://www.praxis-his.com/pdfs/issse2006tokeneer.pdf" mce_href="http://www.praxis-his.com/pdfs/issse2006tokeneer.pdf"&gt;paper&lt;/A&gt; with more technical detail about the project that is worth a read.&lt;/P&gt;
&lt;P&gt;In my opinion, the project is only a science project, an experiment, for the following reasons:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;It's tiny. Weighing in at a little under 10 KLOC. &lt;/LI&gt;
&lt;LI&gt;It's only a very small portion of a much larger solution which has not been developed using the same rigor. This bit of context makes the solution as a whole moot. Call me cynical, but my question is "can the entire solution be built with same rigor in a ‘cost effective manner'?" Perhaps it can, but that is not what is presented.&lt;/LI&gt;
&lt;LI&gt;It sits on top of many operating systems (Windows, Mac OS X and Linux) that are not EAL5 certified. So it would be a little like having an EAL5 certified CharMap application running on EAL4 Windows Vista.&lt;/LI&gt;
&lt;LI&gt;It's written in a subset of Ada called &lt;A href="http://www.praxis-his.com/sparkada/intro.asp" mce_href="http://www.praxis-his.com/sparkada/intro.asp"&gt;SPARK&lt;/A&gt;, and SPARK skills are not common in the marketplace. Interestingly, SPARK makes use of annotations to help drive the static analysis process. While not a total analog, we also recommend Microsoft development teams use annotations (&lt;A href="http://blogs.msdn.com/michael_howard/archive/2006/05/19/a-brief-introduction-to-the-standard-annotation-language-sal.aspx" mce_href="http://blogs.msdn.com/michael_howard/archive/2006/05/19/a-brief-introduction-to-the-standard-annotation-language-sal.aspx"&gt;SAL&lt;/A&gt;) to help drive the required static analysis process. &lt;/LI&gt;
&lt;LI&gt;The application has a large number of dependencies that are not part of the project:&lt;/LI&gt;&lt;/UL&gt;&lt;FONT face=Courier&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Directory of C:\tokeneer\data &lt;/P&gt;
&lt;P&gt;18/08/2007 08:51 605,333 &amp;nbsp;&amp;nbsp;&amp;nbsp; libgdk-win32-2.0-0.dll &lt;BR&gt;18/08/2007 08:51 166,177 &amp;nbsp;&amp;nbsp;&amp;nbsp; libgdk_pixbuf-2.0-0.dll &lt;BR&gt;17/08/2007 18:07 642,115 &amp;nbsp;&amp;nbsp;&amp;nbsp; libglib-2.0-0.dll &lt;BR&gt;17/08/2007 18:07 28,853 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; libgmodule-2.0-0.dll &lt;BR&gt;17/08/2007 18:07 223,026 &amp;nbsp;&amp;nbsp;&amp;nbsp; libgobject-2.0-0.dll &lt;BR&gt;18/08/2007 08:52 3,170,609&amp;nbsp;&amp;nbsp;&amp;nbsp;libgtk-win32-2.0-0.dll &lt;BR&gt;08/08/2008 16:32 4,868,618&amp;nbsp;&amp;nbsp;&amp;nbsp;libgtkada-2.10.dll &lt;BR&gt;07/04/2004 11:47 44,100 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; libintl-1.dll &lt;BR&gt;17/08/2007 18:29 522,940 &amp;nbsp;&amp;nbsp; &amp;nbsp;libcairo-2.dll &lt;BR&gt;17/08/2007 18:36 262,784 &amp;nbsp;&amp;nbsp; &amp;nbsp;libpango-1.0-0.dll &lt;BR&gt;17/08/2007 18:36 62,334 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; libpangocairo-1.0-0.dll &lt;BR&gt;17/08/2007 18:37 88,626 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; libpangowin32-1.0-0.dll &lt;BR&gt;07/10/2001 01:52 171,008 &amp;nbsp;&amp;nbsp;&amp;nbsp; libpng-3.dll &lt;BR&gt;07/04/2004 11:46 58,077 &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;libz.dll &lt;BR&gt;07/04/2004 11:47 843,776 &amp;nbsp;&amp;nbsp;&amp;nbsp; iconv.dll &lt;BR&gt;17/08/2007 18:22 142,762 &amp;nbsp;&amp;nbsp; &amp;nbsp;libatk-1.0-0.dll &lt;BR&gt;16/01/2007 12:27 131,784 &amp;nbsp;&amp;nbsp;&amp;nbsp; libjpeg6b.dll&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;
&lt;P&gt;In the SDL we call these files ‘giblets' because they are components needed for your application to operate, but they do not belong to your team. Some of the files look old and highly vulnerable, such as libpng-3.dll from 2001! &lt;A href="http://osvdb.org/search?request=libpng" mce_href="http://osvdb.org/search?request=libpng"&gt;OSVDB lists 23 vulnerabilities&lt;/A&gt; since 2002 in libpng!&lt;/P&gt;
&lt;P&gt;In summary, the TIS project is very interesting to a small number of important but specialized customers, such as the NSA, for whom this kind of research is critical. I too found it interesting, but the process is far from a set of "secrets to writing secure code" and the tools are certainly not within reach of day-to-day applications and not applicable to developing complete solutions. &lt;/P&gt;As usual, all comments are very welcome.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9120309" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category><category domain="http://blogs.msdn.com/sdl/archive/tags/Security+Assurance/default.aspx">Security Assurance</category></item><item><title>MS08-067 and the SDL</title><link>http://blogs.msdn.com/sdl/archive/2008/10/22/ms08-067.aspx</link><pubDate>Thu, 23 Oct 2008 04:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9012073</guid><dc:creator>sdl</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9012073.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9012073</wfw:commentRss><description>&lt;P mce_keep="true"&gt;Hi, Michael here.&lt;/P&gt;
&lt;P&gt;No doubt you are aware of the out-of-band security bulletin issued by the &lt;A href="http://www.microsoft.com/technet/security/Bulletin/MS08-067.mspx" mce_href="http://www.microsoft.com/technet/security/Bulletin/MS08-067.mspx"&gt;Microsoft Security Response Center&lt;/A&gt; today, and like all security vulnerabilities, this is a vulnerability we can learn from and, if necessary, can use to shape future versions of the Security Development Lifecycle (SDL).&lt;/P&gt;
&lt;P&gt;Before I get into some of the details, it's important to understand that the SDL is designed as a multi-pronged security process to help systemically reduce security vulnerabilities. In theory, if one facet of the SDL process fails to prevent or catch a bug, then some other facet should prevent or catch the bug. The SDL also mandates the use of security defenses, because we know full well that the SDL process will never catch all security bugs. As we have said many times, the goal of the SDL is to "Reduce vulnerabilities, and reduce the severity of what's missed."&lt;/P&gt;
&lt;P&gt;In this post, I want to focus on the SDL-required code analysis, code review, fuzzing and compiler and operating system defenses and how they fared.&lt;/P&gt;
&lt;H3&gt;Code Analysis and Review&lt;/H3&gt;
&lt;P&gt;I want to start by analyzing the code to understand why we did not find this bug through manual code review nor through the use of our static analysis tools. First, the code in question is reasonably complex code to canonicalize path names; for example, strip out ‘..' characters and such to arrive at the simplest possible directory name. The bug is a stack-based buffer overflow inside a loop; finding buffer overruns in loops, especially complex loops, is difficult to detect with a high degree of probability without producing many false positives. At a later date I will publish more of the source code for the function. &lt;/P&gt;
&lt;P&gt;The loop inside the function walks along an incoming string to determine if a character in the path might be a dot, dot-dot, slash or backslash and if it is then applies canonicalization algorithms.&lt;/P&gt;
&lt;P&gt;The irony of the bug is it occurs while calling a bounded function call:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;_tcscpy_s(previousLastSlash, pBufferEnd - previousLastSlash, ptr + 2);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This function is a macro that expands to &lt;A href="http://msdn.microsoft.com/en-us/library/td1esda9(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/td1esda9(VS.80).aspx"&gt;wcscpy_s&lt;/A&gt;(dest, len, source); technically, the bug is not in the call to wcscpy_s, but it's in the way the arguments are calculated. As I alluded to, all three arguments are highly dynamic and constantly updated within the while() loop. There is a great deal of pointer arithmetic in this loop. Without going into all the gory attack details, given a specific path, and after the while() loop has been passed through a few times, the pointer, previousLastSlash, gets clobbered. &lt;/P&gt;
&lt;P&gt;In my opinion, hand reviewing this code and successfully finding this bug would require a great deal of skill and luck. So what about tools?&amp;nbsp; It's very difficult to design an algorithm which can analyze C or C++ code for these sorts of errors.&amp;nbsp; The possible variable states grows very, very quickly.&amp;nbsp; It's even more difficult to take such algorithms and scale them to non-trivial code bases. This is made more complex as the function accepts a highly variable argument, it's not like the argument is the value 1, 2 or 3! Our present toolset does not catch this bug. &lt;/P&gt;
&lt;P&gt;Ok, now I'm really going out on a limb with this next section.&lt;/P&gt;
&lt;P&gt;Over the last year or so I've noticed that the security vulnerabilities across Microsoft, but most noticeably in Windows have become bugs of a class I call "onesey - twosies" in other words, one-off bugs. There is a good side and a bad side to this. First the good news; I think perhaps we have removed a good number of the low-hanging security vulnerabilities from many of our products, especially the newer code. The bad news is, we'll continue to have vulnerabilities because you cannot train a developer to hunt for unique bugs, and creating tools to find such bugs is also hard to do without incurring an incredible volume of false positives. With all that said, I will add detail about one-off bugs to our internal education; I think it's important to make people aware that even with great tools and great security-savvy engineers, there are still bugs that are very hard to find.&lt;/P&gt;
&lt;H3&gt;Fuzz Testing&lt;/H3&gt;
&lt;P&gt;I'll be blunt; our fuzz tests did not catch this and they should have. So we are going back to our fuzzing algorithms and libraries to update them accordingly. For what it's worth, we constantly update our fuzz testing heuristics and rules, so this bug is not unique.&lt;/P&gt;
&lt;H3&gt;Defenses&lt;/H3&gt;
&lt;P&gt;If you want the full details of the defenses, and how they come into play on Windows Vista and Windows Server 2008, I urge you to read the SVRD team's in-depth &lt;A href="http://blogs.technet.com/swi/" mce_href="http://blogs.technet.com/swi/"&gt;analysis&lt;/A&gt;&amp;nbsp;once it is posted.&lt;/P&gt;
&lt;P&gt;A big focus of the SDL is to define and require defenses because we have no illusions about finding or preventing all security vulnerabilities by attempting to get the code right all the time, because no-one can do that. No one. &amp;nbsp;See my comment above about one-off bugs! &lt;/P&gt;
&lt;P&gt;Let's look at each SDL mandated requirement and how they fared in light of this vulnerability.&lt;/P&gt;
&lt;H4&gt;-GS&lt;/H4&gt;
&lt;P&gt;The -GS story is not so simple. A lot of code is executed before a cookie check is made and the attacker can control the overflow because the overflow starts at an offset before the stack buffer, rather than at the stack buffer itself. So the attacker can overwrite other frames on the call stack, corresponding to functions that return before a cookie check is made. That's a long way of saying that -GS was not meant to prevent this type of scenario.&lt;/P&gt;
&lt;H4&gt;ASLR and NX&lt;/H4&gt;
&lt;P&gt;The code fully complies with the SDL, and is linked with /DYNAMICBASE and /NXCOMPAT on Windows Vista and Windows Server 2008. There are great defenses when used together, and reduce the chance of a successful attack substantially. Also, the stack offset is randomized too, making a deterministic attack even more unlikely.&lt;/P&gt;
&lt;H4&gt;Service Restart Policy&lt;/H4&gt;
&lt;P&gt;By default the affected service is marked to restart only twice after a crash on Windows Vista and Windows Server 2008, which means the attacker has only two attempts to get the attack right. Prior to Windows Vista, the attacker has unlimited attempts because the service restarts indefinitely. &lt;/P&gt;
&lt;H4&gt;Authentication&lt;/H4&gt;
&lt;P&gt;Thanks to mandatory integrity control (MIC) settings (which comes courtesy of UAC) the networking endpoint that leads to the vulnerable code requires authentication on Windows Vista and Windows Server 2008 by default. Prior to Windows Vista, the end point is always anonymous, so anyone can attack it, so long as the attacker can traverse the firewall. This is a great example of SDL's focus on attack surface reduction; requiring authentication means the number of attackers that can access the entry point is dramatically reduced.&lt;/P&gt;
&lt;H4&gt;Firewall&lt;/H4&gt;
&lt;P&gt;We enabled the firewall by default in Windows XP SP2 and later, this was a direct learning from the Blaster worm. By default, ports 139 and 445 are not opened to the Internet on Windows XP SP2, Windows Vista and Windows Server 2008. &lt;/P&gt;
&lt;H3&gt;Summary&lt;/H3&gt;
&lt;P&gt;The $64,000 question we ask ourselves when we issue any bulletin is "did SDL fail?" and the answer in this case is categorically "No!" No because as I said earlier the goal of the SDL is "Reduce vulnerabilities, and reduce the severity of what you miss." Windows Vista and Windows Server 2008 customers are protected by the defenses in the operating system that have been crafted in part by the SDL. The development team who built the affected component compiled and linked with the appropriate settings as described in "&lt;A href="http://msdn.microsoft.com/en-us/library/bb430720.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb430720.aspx"&gt;Windows Vista ISV Security&lt;/A&gt;" and &lt;A href="http://www.microsoft.com/mspress/books/10723.aspx" mce_href="http://www.microsoft.com/mspress/books/10723.aspx"&gt;Writing Secure Code for Windows Vista&lt;/A&gt; so that their service is protected by the operating system. &lt;/P&gt;
&lt;P&gt;The team did not poke holes through the firewall unnecessarily, in accordance with the SDL.&lt;/P&gt;
&lt;P&gt;The team reduced their attack surface, in accordance with the SDL, by requiring authenticated connections rather than anonymous connections by default.&lt;/P&gt;
&lt;P&gt;We know that the SDL-mandated -GS has very strict heuristics so some functions are not protected by a stack cookie, but in this case, there is no buffer on the stack, so there will be no cookie. We know this. There are no plans to remedy this in the short term. &lt;/P&gt;
&lt;P&gt;Fuzzing missed the bug, so we will update our fuzz testing heuristics, but we continually update our fuzzing heuristics anyway. &lt;/P&gt;
&lt;P&gt;In short, based on what we know right now, Windows Vista and Windows Server 2008 customers are protected because of the SDL-mandated defenses in the operating system, and because the development team adhered to the letter of the SDL to take advantage of those defenses.&lt;/P&gt;
&lt;P&gt;Chalk one up for Windows Vista and later and the SDL!&lt;/P&gt;
&lt;P&gt;As usual, questions and comments are very welcome.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9012073" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category></item><item><title>Good hygiene and Banned APIs</title><link>http://blogs.msdn.com/sdl/archive/2008/10/22/good-hygiene-and-banned-apis.aspx</link><pubDate>Thu, 23 Oct 2008 01:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9011814</guid><dc:creator>sdl</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/sdl/comments/9011814.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=9011814</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Jeremy Dallman here with a quick note about&amp;nbsp;a code sanitizing tool we are making available to support one of the SDL requirements – Remove all Banned APIs from your code. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;This requirement was put in place to prevent use of certain older C runtime functions that lead to buffer overrun flaws and have been deprecated. In the Security Development Lifecycle book, an entire chapter is dedicated to the topic of banned function calls. In the book, we also provide a copy of the banned.h header file on the companion CD. This header file allows you to locate any banned functions in your code.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;On MSDN, we have document the &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/bb288454.aspx"&gt;&lt;FONT face=Calibri size=3&gt;SDL list of Banned Function Calls&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt;, but the header file has not been publicly available outside the SDL book until now. Today, we are providing the banned.h header on the Microsoft Download Center. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;A href="http://download.microsoft.com/download/2/e/b/2ebac853-63b7-49b4-b66f-9fd85f37c0f5/banned.h"&gt;&lt;FONT face=Calibri size=3&gt;Find the banned.h header here&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;By including this header file, then using #include “banned.h”; you will be able to locate any banned functions in your code. The full list of banned APIs is also included in the header file.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Alternately, if you are using the compiler in Visual Studio 2005 or later, you have a built-in way to check for these banned functions. To catch banned C runtime functions, you can compile with /W4 and then triage all C4996 warnings. In code reviews, you should always remove any code that disables the C4996 warnings&amp;nbsp;- e.g.: #pragma warning(disable:4996). This is one simple way to ensure your code is released without banned functions.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Sanitizing your code to remove potentially insecure APIs is a vital protection. Whether you include the banned.h header file or leverage the /W4-C4996 warnings in the Visual Studio 2005 compiler, you now have two ways to check your code and meet another SDL requirement in your development phase.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9011814" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category></item><item><title>Security is bigger than finding and fixing bugs</title><link>http://blogs.msdn.com/sdl/archive/2008/08/14/security-is-bigger-than-finding-and-fixing-bugs.aspx</link><pubDate>Thu, 14 Aug 2008 23:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8867829</guid><dc:creator>sdl</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/sdl/comments/8867829.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=8867829</wfw:commentRss><description>&lt;P&gt;I’ve been catching up on various security-related articles that I’ve been meaning to read, and the following article was on the list &lt;A href="http://www.itnews.com.au/News/73635,google-shares-its-security-secrets.aspx"&gt;http://www.itnews.com.au/News/73635,google-shares-its-security-secrets.aspx&lt;/A&gt; about Google’s “security secrets.” &lt;BR&gt;&amp;nbsp;&lt;BR&gt;Quoting from the article: &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;“In order to keep its products safe, Google has adopted a philosophy of 'security as a cultural value'. The programme includes mandatory security training for developers, a set of in-house security libraries, and code reviews both by Google developers and outside security researchers."&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think it is great that Google has a security program they are willing to talk about and I could not agree more with the ‘security as a cultural value’ philosophy. But isn’t there something really fundamental missing here? Design? There is a lot more to software engineering other than coding and testing. &lt;BR&gt;&amp;nbsp;&lt;BR&gt;The SDL has a very large set of implementation-related requirements, but there are many design-related requirements also.&lt;/P&gt;
&lt;P&gt;Computer security experts have known since the early 1970s that you have to get the design right; and our experiences with the SDL over the last 5 years have taught us that you need to consider security and privacy (but remember, you have to ship too!) very early in the design phase and have a consistent end-to-end process if you truly hope to reduce vulnerabilities and create more secure software. This is how the SDL is helping to create ‘security as a cultural value’ at Microsoft. &lt;/P&gt;
&lt;P&gt;We’ve seen a general trend downward in security vulnerabilities in Microsoft products, and the IBM X-Force 2008 mid-year &lt;A href="http://www-935.ibm.com/services/us/iss/xforce/midyearreport/xforce-midyear-report-2008.pdf" mce_href="http://www-935.ibm.com/services/us/iss/xforce/midyearreport/xforce-midyear-report-2008.pdf"&gt;report&lt;/A&gt; backs the assertion that we’re making progress; according to the report Microsoft’s share of total vulnerabilities decreased from 3.7% in 2007 (1st place) to 2.5% (that’s 2.5% for &lt;STRONG&gt;&lt;U&gt;all&lt;/U&gt;&lt;/STRONG&gt; Microsoft products; a more appropriate comparison might be Windows vs Linux vs Mac OSX, or SQL Server vs Oracle vs DB2) in the first 6 months of 2008 (3rd place.) This is an encouraging signal that the SDL is working on a large scale… of course, it might also show that vulnerability researchers are moving to easier targets, which, to me shows the SDL is working too.&lt;BR&gt;&amp;nbsp;&lt;BR&gt;What do you think?&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8867829" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category></item><item><title>Improve Security with "A Layer of Hurt"</title><link>http://blogs.msdn.com/sdl/archive/2008/07/31/improve-security-with-a-layer-of-hurt.aspx</link><pubDate>Thu, 31 Jul 2008 22:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8794487</guid><dc:creator>sdl</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/sdl/comments/8794487.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=8794487</wfw:commentRss><description>Hello, Michael here. 
&lt;P&gt;I got a lot of interesting comments from my &lt;A href="http://blogs.msdn.com/sdl/archive/2008/06/26/security-thoughts-from-teched-2008.aspx" mce_href="http://blogs.msdn.com/sdl/archive/2008/06/26/security-thoughts-from-teched-2008.aspx"&gt;TechEd 2008 presentation&lt;/A&gt; entitled, "How To Review Your Code And Test For Security Bugs," but the most comments and questions were reserved for fuzz testing; I was blown away by the number of people who thought fuzz testing was hard, or that you only left fuzz testing to ‘leet hackers.&lt;/P&gt;
&lt;P&gt;During the presentation I mentioned in some depth how to perform fuzz testing, and what parts of an application should be fuzz testing targets. I also introduced an idea (that's not new) to help people who have never performed fuzz testing begin fuzz testing with very little cost and friction. The idea is to add a small layer of code to an application to automatically mutate untrusted data as it comes into an application; I called that code layer "a layer of hurt."&lt;/P&gt;
&lt;P&gt;Before I continue, I want to point out that fuzzing is an SDL requirement, but the idea in this blog post is not an SDL requirement, it's just another way to help meet SDL fuzzing requirements.&lt;/P&gt;
&lt;P&gt;Adding a layer of hurt, as shown in the picture below, is pretty simple as it involves adding code to an application to tweak data as it comes into an application. You can work out where to place the fuzzing code by looking at your threat models to see where data crosses trust boundaries. You could also simply grep the code looking for APIs that read data, for example:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Read from files: fread, ReadFile&lt;/LI&gt;
&lt;LI&gt;Reading from sockets: recv, recvfrom&lt;/LI&gt;
&lt;LI&gt;For .NET code, any stream.Read&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;You get the picture.&lt;/P&gt;
&lt;P&gt;The fuzzing code should appear right after the API that reads that data.&lt;/P&gt;
&lt;P mce_keep="true"&gt;For example, C or C++ code that reads from a UDP socket and then fuzzes the data before it's consumed by the rest of the application might look like this:&lt;/P&gt;&lt;FONT size=1 face=Courier&gt;
&lt;P&gt;char RecvBuf[1024];&lt;BR&gt;int&amp;nbsp; BufLen = sizeof(RecvBuf);&lt;/P&gt;
&lt;P mce_keep="true"&gt;int result = recvfrom(&lt;BR&gt;&amp;nbsp;&amp;nbsp; RecvSocket, &lt;BR&gt;&amp;nbsp;&amp;nbsp; RecvBuf, &lt;BR&gt;&amp;nbsp;&amp;nbsp; BufLen, &lt;BR&gt;&amp;nbsp;&amp;nbsp; 0, &lt;BR&gt;&amp;nbsp;&amp;nbsp; (SOCKADDR *)&amp;amp;SenderAddr, &lt;BR&gt;&amp;nbsp;&amp;nbsp; &amp;amp;SenderAddrSize);&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=1 face=Courier&gt;
&lt;P&gt;#ifdef _FUZZ&lt;BR&gt;&amp;nbsp;&amp;nbsp; Fuzz(RecvBuf,&amp;amp;BufLen);&lt;BR&gt;#endif&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Or, in C#, code that reads from an untrusted file:&lt;/P&gt;&lt;FONT size=1 face=Courier&gt;
&lt;P&gt;FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read);&lt;BR&gt;uint len = (uint)(fileStream.Length);&lt;BR&gt;byte[] fileData = new byte[fileStream.Length];&lt;BR&gt;fileStream.Read(fileData, 0, (int)len);&lt;BR&gt;fileStream.Close();&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=1 face=Courier&gt;
&lt;P mce_keep="true"&gt;#if _FUZZ_&lt;BR&gt;&amp;nbsp; Malform pain = new Malform();&lt;BR&gt;&amp;nbsp; fileData = pain.Fuzz(fileData);&lt;BR&gt;#endif&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;In both code examples, Fuzz() mutates the incoming data. In the C++ case, the fuzzing code looks like this:&lt;/P&gt;&lt;FONT size=1 face=Courier&gt;
&lt;P&gt;void Fuzz(_Inout_bytecap_(*pcbBuf) char *pBuf, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _Inout_ size_t *pcbBuf) {&lt;BR&gt;&lt;BR&gt;&amp;nbsp; if (!pcbBuf || !pBuf || !*pcbBuff || *pBuf) return;&lt;BR&gt;&amp;nbsp; if ((rand() % 100) &amp;gt; 5) return; // fuzz about 5% of Buffers&lt;/P&gt;
&lt;P&gt;&amp;nbsp; size_t cLoop = 1 + (rand() % 4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; for (size_t j = 0; j &amp;lt; cLoop; j++) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; size_t i=0,&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iLow = rand() % *pcbBuf,&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iHigh = 1+rand() % *pcbBuf,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iIter = 1+rand() % 8;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (iLow &amp;gt; iHigh)&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {size_t t=iHigh; iHigh=iLow; iLow=t;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char ch=0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch(rand() % 9) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case 0 : // reset upper bits&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i=iLow; i &amp;lt; iHigh; i++)&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pBuf[i] &amp;amp;= 0x7F;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 1 : // set upper bits&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i=iLow; i &amp;lt; iHigh; i++)&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pBuf[i] |= 0x80;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case 2 : // toggle all bits&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i=iLow; i &amp;lt; iHigh; i++)&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pBuf[i] ^= 0xFF;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 3 : // set to random chars&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i=iLow; i &amp;lt; iHigh; i++)&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pBuf[i] = (char)(rand() % 256);&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case 4 : // set NULL chars to (possibly) non-NULL&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i=iLow; i &amp;lt; iHigh; i++)&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!pBuf[i])&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pBuf[i] = (char)(rand() % 256);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 5 : // swap adjacent bytes&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i=iLow; i &amp;lt; __max(iHigh-1,iLow); i+= iIter)&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {char t=pBuf[i]; pBuf[i] = pBuf[i+1]; pBuf[i+1]=t;}&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case 6 : // set to random chars every n-bytes&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i=iLow; i &amp;lt; __max(iHigh-1,iLow); i+= iIter)&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pBuf[i] = (char)(rand()%256);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case 7 : // set bytes to one random char&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ch=(char)(rand() % 256);&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i=iLow; i &amp;lt; iHigh; i++)&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pBuf[i] = ch;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; default: // truncate stream&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *pcbBuf = iHigh;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;The sample C# and C++ fuzzing code is available as a ZIP file at the end of this post.&lt;/P&gt;
&lt;P&gt;This code is an example of dumb-fuzzing, which is fuzzing with little or no regard for the data structure being manipulated. If you've never performed any kind of fuzz testing in the past, then you will probably find bugs with this simple fuzzing technique. Once you have weeded out the low-hanging bugs, you may need to turn your attention to smarter fuzzers. For example, in theory, this code would find few if any bugs in a PNG parser, because PNG files have a built in check-sum, so if you fuzz a PNG file, you'd have to recalculate the checksum to get decent code coverage.&lt;/P&gt;
&lt;P&gt;When I showed this code during my presentation, I urged people to add it to their applications today if they currently don't do fuzz testing, and simply run their applications through their normal testing processes. Within three days of my presentation I received emails from people saying they had found bugs. I have no doubt others did too.&lt;/P&gt;
&lt;P&gt;One of the comments I made during the session was,"If you can't spend the time on great fuzzing, fuzz anyway" and adding a "layer of hurt" is a reasonable start.&lt;/P&gt;
&lt;P&gt;Please feel free to sound off if you have ideas to help improve the code and let us know what you think, either through email or comments to this post.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8794487" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/sdl/attachment/8794487.ashx" length="47747" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category></item><item><title>Wrapping up "Walking" with the SDL</title><link>http://blogs.msdn.com/sdl/archive/2008/07/30/wrapping-up-walking-with-the-sdl.aspx</link><pubDate>Wed, 30 Jul 2008 22:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8792205</guid><dc:creator>sdl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sdl/comments/8792205.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=8792205</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Jeremy Dallman here. Before we move on with our regularly-scheduled programming here at the SDL blog, I wanted to pull all of the “Walking with the SDL” blog posts into a single document to put it all together in another format. You can find that document &lt;A href="http://blogs.msdn.com/sdl/attachment/8792205.ashx" mce_href="http://blogs.msdn.com/sdl/attachment/8792205.ashx"&gt;here&lt;/A&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&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;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;Hopefully the “Walking with the SDL” series provided some valuable guidance that will help you formalize your own Security Development Lifecycle. As always, we welcome your thoughts or questions in the COMMENT section of this blog. If you have specific questions that you would like to discuss with our team, you can use the EMAIL link at the top of the blog and we’ll be sure to reply.&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8792205" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/sdl/attachment/8792205.ashx" length="23343" type="application/vnd.openxmlformats-officedocument.word" /><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category><category domain="http://blogs.msdn.com/sdl/archive/tags/Crawl+Walk+Run/default.aspx">Crawl Walk Run</category></item><item><title>"Walking" with the SDL - Part 4</title><link>http://blogs.msdn.com/sdl/archive/2008/07/25/walking-with-the-sdl-part-4.aspx</link><pubDate>Fri, 25 Jul 2008 23:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8772987</guid><dc:creator>sdl</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sdl/comments/8772987.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sdl/commentrss.aspx?PostID=8772987</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Jeremy Dallman here with the final piece of my multi-part series on “Walking” with the Security Development Lifecycle (SDL) [&lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/sdl/archive/2008/07/18/walking-with-the-sdl-part-1.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;Part 1&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;, &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/sdl/archive/2008/07/21/walking-with-the-sdl-part-2.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;Part 2&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;, &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/sdl/archive/2008/07/23/walking-with-the-sdl-part-3.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;Part 3&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;]. So far I have discussed getting management approval, expanding security training, formalizing security requirements and effective ways to reuse your threat model or attack surface review data. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;In this post, I will wrap up with a look into setting up final security reviews and managing post-release documentation.&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;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Formalize your Final Security Review (FSR) Process&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;A Final Security Review is your final security audit to ensure your software is secure enough to deliver to your customers. I will assume the idea of an FSR is a new concept and try to provide some FAQ-style detail on this topic.&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;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;U&gt;Who is the FSR team?&lt;/U&gt;&lt;/I&gt;&lt;/B&gt; An FSR Team usually consists of a non-product-team security expert (for impartial perspective), a security representative from the product team, and individual representatives from the separate disciplines. However, that size team may not scale to your company. If that is the case, at a minimum, you should have an impartial “outsider” separate from the product team who understands the security requirements as well as the measurements used to validate them. This person along with a project manager can probably perform the bulk of the FSR with development or test leadership providing input as needed.&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;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;U&gt;What is needed to do an FSR?&lt;/U&gt;&lt;/I&gt;&lt;/B&gt; All threat models should be revised to reflect the final product, the code should be complete, and all security-related testing should be completed and documented. In addition, everyone involved in the FSR should have full access to the bug database to review status or exceptions to security bugs.&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;B style="mso-bidi-font-weight: normal"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;U&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;What does an FSR team do? &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI style="MARGIN: 0in 0in 10pt; mso-list: l1 level1 lfo1" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Re-review threat models to verify all mitigations identified in those exercises were fixed or went through an exception process. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0in 0in 10pt; mso-list: l1 level1 lfo1" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Verify that all security issues uncovered during the development process were fixed or granted exceptions by the appropriate people. This is where you verify whether the state of your security bugs meets the “bug bar” requirements you have defined for your products.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0in 0in 10pt; mso-list: l1 level1 lfo1" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;If there is any output from security tools that you have used to define requirements, the FSR team would verify that the results of the tools meet the security requirements.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0in 0in 10pt; mso-list: l1 level1 lfo1" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Review all exceptions to verify that they approve these decisions in the context of the final product. If they identify risks associated with the exceptions, they should communicate those to the business ownership for a final decision before signoff. Any decisions related to known risks should also be reflected in the response plan for future reference.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI style="MARGIN: 0in 0in 10pt; mso-list: l1 level1 lfo1" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Finally, there should be a final signoff exercise where all security people and project leadership jointly approve the decision of the Final Security Review.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;U&gt;How long does an FSR take?&lt;/U&gt;&lt;/I&gt;&lt;/B&gt; If done correctly, the FSR will likely take some time. You should schedule this review well in advance of your release date to give your FSR team some time to complete the review, push issues back to the product team, and respond to any serious issues that may be discovered.&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;Final security reviews are a crucial piece to your Security Development Lifecycle. It would be easy to encourage secure development in your team, but as you expand your process to include formal security requirements and begin enforcing those requirements, it is necessary to perform a final audit of your product before it is released. Your customers will thank you for taking the time to add this layer of quality control to your operations and you will likely save yourself some security embarrassment down the road by adding a FSR to the end of your product cycle.&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;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Document security work for reference&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;After the FSR is complete, there is still work for the security team. The final FSR documentation should be archived along with the symbols and code that represents the finished project. This becomes the time-stamped “snapshot” of your product. Your post-release process should include archiving the following documents in an easily accessible location:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo2" 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&gt;&lt;FONT face=Calibri&gt;All final threat models for future reference. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo2" 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&gt;&lt;FONT face=Calibri&gt;Bug bars, tool settings, and test results related to your project and the supporting tools used to validate. These will be referenced and reused in the next product cycle. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo2" 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&gt;&lt;FONT face=Calibri&gt;All documented security bug exceptions. These need to be rolled into your next product cycle to ensure they are addressed. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo2" 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&gt;&lt;FONT face=Calibri&gt;The final symbols that reflect the product shipped should be archived.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo2" 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&gt;&lt;FONT face=Calibri&gt;The Final Security Report and project signoffs to validate your security audit activity &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo2" 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;Your &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/security/msrc/incident_response.mspx"&gt;&lt;FONT size=3 face=Calibri&gt;Incident Response Plan&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; (discussed in the Crawl post). This must be accessible for quick reference if security incidents occur.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&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; mso-add-space: auto" class=MsoListParagraphCxSpLast&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Archiving this evidence serves a few critical purposes: it shows historic evidence of the work you did to ensure a secure product, allows you to postmortem the results and improves your process each time, and reduces the amount of time your team will have to spend next time around by making the existing resources reusable.&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;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;In closing…&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&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 hope this long series has provided some practical steps you can take to move your Security Development Lifecycle practices to the next level. At Microsoft, creating a lifecycle to match security development practices has faced a fair share of challenges. However, the investment and time has resulted in more secure products. We’ll continue refining how we execute the Security Development Lifecycle and hope to share those ideas with you along the way. We welcome your thoughts and questions as you start “Walking” with the SDL in your own company and look forward to seeing more secure products and customers as a result. &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;I’ve created a unique tag on the SDL Blog to cover this series. To get a full list of the related posts, click the “Crawl Walk Run” tag on the left column. I’ll post a Word document version of the full “Walk” series sometime in the next week.&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=8772987" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sdl/archive/tags/SDL/default.aspx">SDL</category><category domain="http://blogs.msdn.com/sdl/archive/tags/Crawl+Walk+Run/default.aspx">Crawl Walk Run</category></item></channel></rss>