I thought it would be interesting to perform an automated code review on it using CheckMarx, to see how they did related to security. The source consisted mainly of C++ code (376,545 lines of code) as well as code written in assembler. The assembler code was not scanned because CheckMarx (or any other automated code scanners) does not support assembler. What came out of the tool was interesting.
CheckMarx indicated that the risk in the code is:
The distribution of risk from Informational to High:
You have to remember that this code is from the 1980s. Many people did not have a concept of secure code and the development tools did not address security at all.
The top five vulnerabilities are as follows:
From the code that I looked at, most of the issues come from the use of unsafe functions. For example:
The function strcpy has been replaced by a safe function strncpy. The function strncpy combats buffer overflow by requiring you to put a length in it. The function strncpy did not exist in the 1980s. The code also contains 123 instances of the goto statement. For example:
From the MSDN web site, Microsoft states, “It is good programming style to use the break, continue, and return statements instead of the goto statement whenever possible. However, because the break statement exits from only one level of a loop, you might have to use a goto statement to exit a deeply nested loop.” I am not sure of the C++ syntax back in the 1980s, but maybe break, continue, and return statements did not exist.
Below is the complete list of issues found in the code:
Vulnerability Type
Occurrences
Severity
Buffer Overflow unbounded
180
High
Buffer Overflow StrcpyStrcat
22
High
Format String Attack
18
High
Buffer Overflow OutOfBound
12
High
Buffer Overflow cpycat
3
High
Use of Uninitialized Pointer
135
Medium
Dangerous Functions
58
Medium
Use of Uninitialized Variable
41
Medium
Char Overflow
35
Medium
Stored Format String Attack
19
Medium
Stored Buffer Overflow cpycat
11
Medium
MemoryFree on StackVariable
4
Medium
Short Overflow
2
Medium
Integer Overflow
1
Medium
Memory Leak
1
Medium
NULL Pointer Dereference
341
Low
Potential Path Traversal
24
Low
Unchecked Array Index
18
Low
Unchecked Return Value
11
Low
Potential Off by One Error in Loops
6
Low
Use of Insufficiently Random Values
3
Low
Potential Precision Problem
2
Low
Size of Pointer Argument
1
Low
Methods Without ReturnType
500
Information
Unused Variable
310
Information
GOTO Statement
132
Information
Empty Methods
9
Information
Potential Off by One Error in Loops
6
Information
This code is a good example of what not to do.
Programming languages and tools have evolved to make your application much more secure, but only if you teach your developers the concepts of secure coding.
Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.
Name
Domain
Purpose
Expiry
Type
YSC
youtube.com
YouTube session cookie.
52 years
HTTP
Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.
Name
Domain
Purpose
Expiry
Type
VISITOR_INFO1_LIVE
youtube.com
YouTube cookie.
6 months
HTTP
Analytics cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.
We do not use cookies of this type.
Preference cookies enable a website to remember information that changes the way the website behaves or looks, like your preferred language or the region that you are in.
We do not use cookies of this type.
Unclassified cookies are cookies that we are in the process of classifying, together with the providers of individual cookies.
We do not use cookies of this type.
Cookies are small text files that can be used by websites to make a user's experience more efficient. The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.
Cookie Settings
Discover why security operations teams choose NetSPI.