In today’s webcast we had the opportunity to explore the buffer overrun attack in depth which is considered one of the worst vulnerabilities that exist.  Any code that is written in C or C++ --without proper security code reviews--on any platform is susceptible to buffer overrun.  It is becoming easier and easier to create shell code to pass as a parameter to our C or C++ code.  For example, Kevin Lam --lead author of Assessing Network Security book--showed everyone the http://metasploit.com/shellcode.html web site.

 

In our Security November’s Webcasts we explored other common attacks such as:

  • SQL Injection
  • Cross Site Scripting
  • Canonical representation

But the underlying theme to prevent all of these types of attacks is validation our input, by checking and constraining all users’s input before passing the value to our resources.  We should never pass user input directly into our code path and if we also ensure that our code runs as least privilege (hence the topic of our last two talks) then many of these attacks will become history.

 

Why was today’s webcast relevant to manage code?  Because, a lot of us write manage code that p/invoke into Native code.  Therefore, your manage code can be the path to vulnerabilities that may exist in native code.

 

In the second half of today’s presentation we explored code scanning tools such as:

Each tool has their own pros and cons but the one thing that is common between all them of these tools by Microsoft or all other vendors is they are not a silver bullet.  Code scanning tools have to limit the number of false positive to a minimal therefore; they will catch a lot of the low hanging fruit but miss a lot of the subtle security vulnerabilities.  Code scanning tools on average will pick up about 50% of the security vulnerabilities in your applications and furthermore these tools can not verify a poor design that can lead to other security vulnerabilities.  Therefore, your application is not designed with security in mind then code scanning tools will be of no value in these areas.  I refer you to Michael Howard blog entry on his thoughts on code scanning tools.

 

Code Scanning tools need to become part of our security development lifecycle and not a replacement for proper security testing.  Even with the best code scanning tools we will still need to do proper security code reviews, threat modeling and penetration testing.

 

The skill testing question today--is very open ended, but I have a list of few things I am looking for—is what are the cons with just using code scanning tools alone for securing your applications?  I have three books “Writing Secure Code Edition 2” for the first three people that email me the correct answer through my blog.

 

Below is the snippet to the buffer overrun attack written in C:

 

/* ownMe.c : Buffer Overflow Demonstration
// Compile command from command-line: cl /Zi /GS- ownMe.c
// Command to execute: ownMe
// Works for: XP SP2 Tablet PC Version
// Additional instructions: For all three demos follow instructions then
// compile and run. The lines of code mantioned below are in main().
// Demo1 (No overflow): Uncomment line SayHello(Name); Comment other two lines
// Demo2 (Overflow and process crashes): Uncomment line SayHello(LongName); Comment other two lines
*/


#include "stdio.h"
#include "string.h"


char Name[] = "Mats Sundin";

char LongName[] =
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
 "AAAAAAAAAAAAA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