<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Casaba Security &#187; SDL</title>
	<atom:link href="http://www.casaba.com/blog/tag/sdl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.casaba.com/blog</link>
	<description>Building and breaking software and robots</description>
	<lastBuildDate>Wed, 11 Jan 2012 18:08:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SDL Requirements and Release Videos Now Online</title>
		<link>http://www.casaba.com/blog/2011/02/sdl-requirements-and-release-videos-now-online/</link>
		<comments>http://www.casaba.com/blog/2011/02/sdl-requirements-and-release-videos-now-online/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 09:03:45 +0000</pubDate>
		<dc:creator>Robert Mooney</dc:creator>
				<category><![CDATA[SDL]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.casaba.com/blog/?p=246</guid>
		<description><![CDATA[Not too long ago Chris, Jason, and myself did a handful of videos with the folks over in the Microsoft SDL and Azure teams on applying the SDL to various phases of the software development process. Give them a watch! Microsoft SDL Requirements Phase: Security Practices http://technet.microsoft.com/en-us/edge/Gg520839 Applying Microsoft SDL Requirements Practices within Windows Azure [...]]]></description>
			<content:encoded><![CDATA[<p>Not too long ago Chris, Jason, and myself did a handful of videos with the folks over in the Microsoft SDL and Azure teams on applying the SDL to various phases of the software development process.</p>
<p>Give them a watch!</p>
<p><strong>Microsoft SDL Requirements Phase: Security Practices</strong><br />
<a href="http://technet.microsoft.com/en-us/edge/Gg520839">http://technet.microsoft.com/en-us/edge/Gg520839</a></p>
<p><strong>Applying Microsoft SDL Requirements Practices within Windows Azure</strong><br />
<a href="http://technet.microsoft.com/en-us/edge/Video/gg482149">http://technet.microsoft.com/en-us/edge/Video/gg482149</a></p>
<p><strong>Microsoft SDL Release Phase: Security Practices</strong><br />
<a href="http://technet.microsoft.com/en-us/edge/video/gg583895">http://technet.microsoft.com/en-us/edge/video/gg583895</a></p>
<p><strong>Applying Microsoft SDL Release Practices within Windows Azure</strong><br />
<a href="http://technet.microsoft.com/en-US/edge/Gg583898">http://technet.microsoft.com/en-US/edge/Gg583898</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.casaba.com/blog/2011/02/sdl-requirements-and-release-videos-now-online/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Around Conditionally Banned APIs When Using Microsoft&#8217;s banned.h Header File</title>
		<link>http://www.casaba.com/blog/2009/12/getting-around-conditionally-banned-apis-when-using-microsofts-banned-h-header-file/</link>
		<comments>http://www.casaba.com/blog/2009/12/getting-around-conditionally-banned-apis-when-using-microsofts-banned-h-header-file/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 23:42:28 +0000</pubDate>
		<dc:creator>Ramsey Dow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SDL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[This code sample makes use of banned.h, a Microsoft-supplied header file that deprecates dangerous CRT functions. Microsoft also poisons these functions on UNIX if you include banned.h there. This is a Good Thing, but what about the fact that they banned strlen? The banned API page states: For critical functions, such as those accepting anonymous [...]]]></description>
			<content:encoded><![CDATA[<p>This code sample makes use of <a href="http://download.microsoft.com/download/2/e/b/2ebac853-63b7-49b4-b66f-9fd85f37c0f5/banned.h" target="new"><code>banned.h</code></a>, a Microsoft-supplied header file that deprecates dangerous CRT functions. Microsoft also poisons these functions on UNIX if you include <code>banned.h</code> there. This is a Good Thing, but what about the fact that they banned <a href="http://msdn.microsoft.com/en-us/library/78zh94ax%28VS.71%29.aspx" target="new"><code>strlen</code></a>? The <a href="http://msdn.microsoft.com/en-us/library/bb288454.aspx" target="new">banned API page</a> states:</p>
<p><em>For critical functions, such as those accepting anonymous Internet connections, <code>strlen</code> must also be replaced.</em></p>
<p>That&#8217;s good advice for cases where you want to operate on untrusted data. In those cases they tell you that you should use <a href="http://msdn.microsoft.com/en-us/library/z50ty2zh.aspx" target="new"><code>strnlen_s</code></a>. The problem is, <code>banned.h</code> straight out bans <code>strlen</code>. There is no way to tell it that hey, this particular invocation is safe because I control the buffer in all aspects. Nope, sorry. You can&#8217;t use <code>strlen</code>. Or can you?</p>
<p>Here is a code sample that uses <code>banned.h</code> to deprecate unsafe APIs, yet still manages to invoke <code>strlen</code> when necessary. The sample works in both <a href="http://msdn.microsoft.com/en-us/vstudio/default.aspx" target="new">Visual Studio</a> on Windows and <a href="http://gcc.gnu.org/" target="new">GCC</a> on UNIX.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5code2'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p52"><td class="code" id="p5code2"><pre class="c" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//  banned_test.c</span>
<span style="color: #666666; font-style: italic;">//  20091208 ramsey@casabasecurity.com</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//  A sample program that illustrates how to &quot;grandfather in&quot; banned APIs</span>
<span style="color: #666666; font-style: italic;">//  for use when they are marked deprecated (Windows) or poisoned (UNIX)</span>
<span style="color: #666666; font-style: italic;">//  by the compiler.</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//  to compile on Windows:</span>
<span style="color: #666666; font-style: italic;">//  cl /GS /W4 /WX banned_test.c</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//  to compile on UNIX:</span>
<span style="color: #666666; font-style: italic;">//  gcc -Wall -Werror banned_test.c</span>
&nbsp;
<span style="color: #339933;">#if defined _WIN32</span>
&nbsp;
<span style="color: #339933;">#include &lt;windows.h&gt;</span>
<span style="color: #339933;">#endif    // _WIN32</span>
&nbsp;
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;string.h&gt;</span>
<span style="color: #339933;">#if defined _WIN32</span>
&nbsp;
size_t my_strlen<span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #993333;">string</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  size_t len<span style="color: #339933;">;</span>
  <span style="color: #339933;">#pragma warning(push)</span>
  <span style="color: #339933;">#pragma warning(disable:4995)</span>
  len <span style="color: #339933;">=</span> strlen<span style="color: #009900;">&#40;</span><span style="color: #993333;">string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #339933;">#pragma warning(pop)</span>
  <span style="color: #b1b100;">return</span> len<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">#else</span>
<span style="color: #339933;">#define my_strlen strlen</span>
<span style="color: #339933;">#endif    // _WIN32</span>
&nbsp;
<span style="color: #339933;">#include &quot;banned.h&quot;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> ac<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">**</span>av<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>str <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;foo&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #339933;">#if defined _WIN32</span>
  UNREFERENCED_PARAMETER<span style="color: #009900;">&#40;</span>ac<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  UNREFERENCED_PARAMETER<span style="color: #009900;">&#40;</span>av<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #339933;">#endif    // _WIN32</span>
  <span style="color: #339933;">#if defined _WIN32</span>
  <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;len is %Id<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> strlen<span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #339933;">#else</span>
  <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;len is %zd<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> strlen<span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #339933;">#endif    // _WIN32</span>
  <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Note that this code requires the use of Microsoft&#8217;s <code>banned.h</code> header file, which can be downloaded <a href="http://download.microsoft.com/download/2/e/b/2ebac853-63b7-49b4-b66f-9fd85f37c0f5/banned.h" target="new">here</a>. Stick it in the same directory as the above source file.</p>
<p>To compile the sample in Windows from a Visual Studio Command Prompt:</p>
<pre>

cl banned_test.c /GS /W4 /WX
</pre>
<p>As expected, this program will generate an error when run:</p>
<pre>

banned_test.c

banned_test.c(50) : error C2220: warning treated as error - no 'object' file generated

banned_test.c(50) : warning C4995: 'strlen': name was marked as #pragma deprecated
</pre>
<p>Now edit <code>banned_test.c</code> and change the <code>strlen</code> on line 50 to <code>my_strlen</code> and recompile:</p>
<pre>

cl banned_test.c /GS /W4 /WX
</pre>
<p>It should compile without error. Now run it and you should see:</p>
<pre>

len is 3
</pre>
<p>Nifty.</p>
<p>The same code works without change on UNIX (tested on NetBSD):</p>
<pre>

gcc -Wall -Werror banned_test.c
</pre>
<p>As with the Windows example, running the program will generate an error, as expected:</p>
<pre>

banned_test.c:52:31: error: attempt to use poisoned "strlen"
</pre>
<p>Again, change the occurrence of <code>strlen</code> (this time on line 52) to <code>my_strlen</code> and recompile. It will work and when run, it will say:</p>
<pre>

len is 3
</pre>
<p>What&#8217;s going on here is simple. While we are banning use of the <code>strlen</code> function, we are still allowing its use selectively through a wrapper that we have &#8220;grandfathered in.&#8221; This is easy to accomplish in UNIX: we simply
<pre>#define my_strlen strlen</pre>
<p> prior to including <code>banned.h</code> and use that function call entry point instead. Problem solved. This is not as easy to accomplish with Windows, however, as <code>cl.exe</code> has no notion of &#8220;grandfathering in&#8221; deprecated APIs. So what we do is wrap <code>strlen</code> in another function. We ignore the deprecation warning that occurs where we make the call to <code>strlen</code> through the judicious application of some Visual Studio-specific <code>pragma</code> instructions. Now all need to do is call in to our new function entry point. We&#8217;re good to go. The Windows solution requires a little more work up front, but turns out to be not so hard to accomplish after all.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.casaba.com/blog/2009/12/getting-around-conditionally-banned-apis-when-using-microsofts-banned-h-header-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On the Importance of Good Developer Documentation</title>
		<link>http://www.casaba.com/blog/2009/11/on-the-importance-of-good-developer-documentation/</link>
		<comments>http://www.casaba.com/blog/2009/11/on-the-importance-of-good-developer-documentation/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 19:01:27 +0000</pubDate>
		<dc:creator>Ramsey Dow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SDL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Programmers rely on documentation. It&#039;s how we learn to use APIs. Misusing APIs is a leading source of vulnerability. You might think that documentation is a cure to this ailment. Unfortunately, as someone who has been in software development for a long time, I can tell you that documentation quality is not always what it [...]]]></description>
			<content:encoded><![CDATA[<p>Programmers rely on documentation. It&#039;s how we learn to use APIs. Misusing APIs is a leading source of vulnerability. You might think that documentation is a cure to this ailment. Unfortunately, as someone who has been in software development for a long time, I can tell you that documentation quality is not always what it should be. API documentation serves as a reference. I have yet to meet the programmer who can recall every nuance about every API for all the languages they program in. (Were such a programmer to exist, its name might well be <a href="http://en.wikipedia.org/wiki/Robby_the_Robot">Robby the Robot</a>.) </p>
<p>Recently I was converting strings using the <a href="http://msdn.microsoft.com/en-us/library/eyktyxsx.aspx">mbstowcs_s</a> and <a href="http://msdn.microsoft.com/en-us/library/s7wzt4be.aspx">wcstombs_s</a> functions. (These are from from the bounds checking extensions to the C Library specified in ISO/IEC TR 24731-1.) These functions allow you to convert multibyte character sequences to and from wide character sequences. These functions are available to C and C++ programmers using Microsoft&#039;s Visual Studio compiler. (I am not yet aware of any UNIX compatible compiler that supports the draft TR 24731-1 standard.)</p>
<p>Since these two functions convert strings, it is worth looking at the parameters they expect. (Not doing so is a sure fire way to do something stupid, like enable a buffer overflow.) Looking at the relevant parameters for these two functions, we see:</p>
<p><strong>mbstowcs_s</strong>:<br />
[in] <em>sizeInWords</em><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The size of the wcstr buffer in words.<br />
[in] <em>count</em><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The maximum number of wide characters to store in the wcstr buffer, not including the terminating null, or <a href="http://msdn.microsoft.com/en-us/library/ms175769.aspx">_TRUNCATE</a>.</p>
<p><strong>wcstombs_s</strong>:<br />
[in] <em>sizeInBytes</em><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The size in bytes of the mbstr buffer.<br />
[in] <em>count</em><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The maximum number of bytes to be stored in the mbstr buffer, or <a href="http://msdn.microsoft.com/en-us/library/ms175769.aspx">_TRUNCATE</a>.</p>
<p>Does count in wcstombs_s account for the terminating NULL or not? Failure to account for this could introduce an off-by-one error which, in turn, may lead to an exploitable condition, such as a buffer overflow. How can we determine this from the documentation? Well, in its current state, we can&#039;t. This is what we call a &#8220;doc bug.&#8221;</p>
<p>Luckily, Microsoft includes the source code for the C Runtime with most Visual Studio SKUs. Assuming you installed Visual Studio in Program Files, you should be able to find the CRT source code in Program Files\Microsoft Visual Studio 9.0\VC\crt\src. CRT source code is included with all Visual Studio SKUs except for the Express Editions. Luckily for Express Edition users, the forthcoming Visual Studio 2010 release finally opens up the CRT sources to Express Edition users. If you are using an Express Edition of VS2008 or earlier, consider grabbing the VS2010 Express beta from <a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx">here</a>.</p>
<p>In any case, if you have the CRT source code, it is easy to track down the source for wcstombs_s and check to see if the terminating NULL is intended to be accounted for or not. Looking into wcstombs.c we discover this bit of text in the comment for the wcstombs_s function:<br />
<code><br />
size_t n = maximum number of bytes to store in s (not including the terminating NULL)<br />
</code></p>
<p>Clearly, the terminating NULL is not meant to be included. This is as we suspected, but now we have verified it instead of blindly assuming that it would be the case. As security practitioners we should be careful not to make assumptions. Verify instead!</p>
<p>This documentation bug has been reported to Microsoft. With any luck it will get addressed prior to the VS 2010 release on March 22, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.casaba.com/blog/2009/11/on-the-importance-of-good-developer-documentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use the Source, Luke!</title>
		<link>http://www.casaba.com/blog/2009/10/use-the-source-luke/</link>
		<comments>http://www.casaba.com/blog/2009/10/use-the-source-luke/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 19:35:13 +0000</pubDate>
		<dc:creator>Ramsey Dow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SDL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[If there&#039;s one thing that I&#039;ve learned throughout the years as a programmer, it is not always safe to trust the documentation. In fact, there is an old saying, &#8220;Use the source, Luke!&#8221; When possible, you should do just that. While looking over the CERT Secure C Coding Standard I noticed the following recommendation: ERR30-C. [...]]]></description>
			<content:encoded><![CDATA[<p>If there&#039;s one thing that I&#039;ve learned throughout the years as a programmer, it is not always safe to trust the documentation. In fact, there is an old saying, &#8220;Use the source, Luke!&#8221; When possible, you should do just that.</p>
<p>While looking over the <a href="http://www.cert.org/">CERT</a> <a href="https://www.securecoding.cert.org/confluence/display/seccode/CERT+C+Secure+Coding+Standard">Secure C Coding Standard</a> I noticed the following recommendation: <a href="https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=6619179">ERR30-C. Set <code>errno</code> to zero before calling a library function known to set <code>errno</code>, and check <code>errno</code> only after the function returns a value indicating failure</a>. CERT goes on to write, &#8220;[s]ome functions lack documentation regarding <code>errno</code> in the C99 standard.&#8221; They follow this up with an example for Windows: &#8220;[i]n this compliant solution, <code>errno</code> is not checked because <code>fopen()</code> makes no promise of setting it.&#8221; This would be fine, were it true. However, it is false. Let us take a closer look.</p>
<p>It is true that the symbol, <code>errno</code>, appears nowhere in the MSDN documentation for <a href="http://msdn.microsoft.com/en-us/library/yeby3zcb%28VS.71%29.aspx">fopen</a>. However, one need only look to <code>fopen.c</code> (included with all commercial Visual C implementations) to see that <code>errno.h</code> is <code>#include</code>&#039;d and <code>errno</code> is indeed set for locked streams, bad names (e.g., empty string), et al.</p>
<p>The use of <code>errno</code> is not as robust in the case of Microsoft&#039;s <code>fopen</code> implementation as it is in the implementation on my <a href="http://www.netbsd.org/">NetBSD</a> box, but that&#039;s not the point. The point is that CERT stated something was true based on documentation when in fact, it was not true. The lesson here is that one cannot simply rely on assumptions based on documentation, one must also look to the source to see what is happening.</p>
<p>In the case of Microsoft&#039;s C and secure C runtimes, the source code is available for you to look at, provided you have Visual Studio installed. (Caveat: you don&#039;t get the CRT source code if you install Visual C++ Express.) I found the code living on my box under Program Files at Microsoft Visual Studio 9.0\VC\crt\src.</p>
<p>Of course, if you&#039;re programming on Windows you should prefer <a href="http://msdn.microsoft.com/en-us/library/z5hh6ee9%28VS.80%29.aspx"><code>fopen_s</code></a> to <code>fopen</code> anyway. For the record, the MSDN documentation for <code>fopen_s</code> clearly states that it returns an <code>errno_t</code>, which is the <a href="http://msdn.microsoft.com/en-us/library/8ef0s5kh%28VS.80%29.aspx">Secure CRT</a>&#039;s answer to <code>errno</code>.</p>
<p>Update: I just found out from a source inside the Visual Studio team at Microsoft that Visual Studio 2010 Beta 2&#039;s Express Edition SKU contains the CRT source code. That&#039;s good news. You can get more information on Visual Studio 2010 Beta 2 <a href="http://blogs.msdn.com/webdevtools/archive/2009/10/21/web-tools-beta-2-overview.aspx">here</a>, and you can download it <a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.casaba.com/blog/2009/10/use-the-source-luke/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Vim plugin for highlighting APIs banned by the Microsoft SDL</title>
		<link>http://www.casaba.com/blog/2009/08/a-vim-plugin-for-highlighting-apis-banned-by-the-microsoft-sdl/</link>
		<comments>http://www.casaba.com/blog/2009/08/a-vim-plugin-for-highlighting-apis-banned-by-the-microsoft-sdl/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 01:03:46 +0000</pubDate>
		<dc:creator>Ramsey Dow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SDL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I do a lot of programming, so I live in my editor. I use Vim. If you also use Vim then I&#039;ve got something to share with you: a new syntax plugin that highlights function calls banned by Microsoft&#039;s Security Development Lifecycle (SDL). You can obtain the banned.vim syntax plugin from the Vim script archive. [...]]]></description>
			<content:encoded><![CDATA[<p>I do a lot of programming, so I live in my editor. I use <a target="new" href="http://www.vim.org/">Vim</a>. If you also use Vim then I&#039;ve got something to share with you: a new syntax plugin that highlights function calls banned by Microsoft&#039;s <a target="new" href="http://msdn.microsoft.com/en-us/security/cc448177.aspx">Security Development Lifecycle</a> (SDL). You can obtain the <strong>banned.vim</strong> syntax plugin from the <a target="new" href="http://www.vim.org/scripts/script.php?script_id=2753">Vim script archive</a>.</p>
<p>The <strong>banned.vim</strong> syntax plugin will highlight C function calls that have been banned by the SDL. It adds functionality to the existing C and C++ Vim syntax plugins. Banned APIs, such as <code>strcpy</code> and others, will appear visually in Vim as if they were errors. It is my hope that this extra attention will cause you to reconsider using the banned API and replace it instead with a safer alternative. Although many of these banned function calls are Windows-specific, there are quite a few that are also available in UNIX and should be avoided. Details on the APIs banned by Microsoft&#039;s SDL can be found on <a target="new" href="http://msdn.microsoft.com/en-us/library/bb288454.aspx">Microsoft&#039;s site</a>.</p>
<p>Here&#039;s a screen shot of <strong>banned.vim</strong> in action. In this case we&#039;re editing <code>str_cat.c</code>, one of the entries from the <a target="new" href="http://www.sans-ssi.org/resources/Winners_of_insecure_coding_contest_20080721.pdf">2008 SANS Awards for Finding Coding Books with Secure programming Flaws</a>. Notice the banned APIs in the code below?</p>
<p><img alt="banned.vim in action" height="362" width="541" style="display: block; margin-left: auto; margin-right: auto" src="http://www.casabasecurity.com/images/banned.png" /></p>
<p>Installing <strong>banned.vim</strong> is easy. First, you need to know what your <em>runtimepath</em> is, which varies from operating system to operating system. If you don&#039;t know what your <em>runtimepath</em> is, check the <a target="new" href="http://vimdoc.sourceforge.net/htmldoc/options.html#%27runtimepath%27">Vim documentation</a>. Second, create the directory structure <code>after/syntax</code> in your <em>runtimepath</em> directory if it doesn&#039;t already exist. Third, copy <strong>banned.vim</strong> into <code><em>runtimepath</em>/after/syntax</code> as both <code>c.vim</code> and <code>cpp.vim</code>. That&#039;s all there is to installation. There is no need to edit your <code>.vimrc</code> or anything.</p>
<p>I would like to thank Rob Mooney for suggesting this plugin in the first place.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.casaba.com/blog/2009/08/a-vim-plugin-for-highlighting-apis-banned-by-the-microsoft-sdl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

