Secure Coding in C and C++
Secure Coding in C and C++
Chapter 1
Running with Scissors
Secure Coding with C and C++
1. Gauging the Threat
2. Security Concepts
3. C and C++
4. Development Platforms
Running With Scissors
The W32.Blaster.Worm
Discovered on August 11, 2003.
Infected unpatched system connected to the
Hackers
Insiders
Criminals
Competitive Intelligence Professionals
Terrorists
Information Warriors.
Hackers
Motivated by curiosity and peer recognition
from other hackers.
Write programs that expose vulnerabilities in
computer software.
The methods used to disclose these
vulnerabilities varies from a policy of responsible
disclosure to a policy of full disclosure.
Insiders
The threat comes from a current or former employee
or contractor of an organization.
Has legitimate access to the information that was
compromised.
Do not need to be technically sophisticated to carry
out attacks.
Technically sophisticated insiders can launch attacks
with immediate and widespread impact.
Technical insiders can cover their tracks.
Criminals
Common crimes include:
Auction fraud,
Identity theft.
Extortion.
Phishing
develop them.
Twenty-three nations have targeted
U.S. systems.
Software Security
The CERT/CC monitors public sources of
vulnerability information and regularly receives
reports of vulnerabilities.
Vulnerabilities reported to
CERT/CC (1995-2004)
Vulnerabilities Reported
7000
6000 5990
5000
4000 4129
3780
3784
3000
2437
2000
1000 1090
345 311 262
417
171
0
1994 1996 1998 2000 2002 2004 2006
Secure Coding with C and C++
1. Gauging the Threat
2. Security Concepts
3. C and C++
4. Development Platforms
Security Concepts
Computer security is preventing attackers from
The attacker:
achieve an objective.
These objectives vary depending on the threat.
Software Defects:
A software defect is the encoding of a human error
into the software, including omissions.
Security Flaw:
A security flaw is a software defect that poses a
potential security risk.
Eliminating software defects eliminate security flaws.
Vulnerabilities
exploitation.
Exploits can take many forms, including
properly managed.
Proof-of-concept exploit in the wrong hands
C and C++:
160
140
Vulnerabilities
120
100
80
60
40
20
0
6
Ja 0
Ja 3
4
97
98
99
00
01
02
03
04
05
l-9
l-9
l-9
l-9
l-0
l-0
l-0
l-0
l-0
n-
n-
n-
n-
n-
n-
n-
n-
n-
Ju
Ju
Ju
Ju
Ju
Ju
Ju
Ju
Ju
Ja
Ja
Ja
Ja
Ja
Ja
Ja
Figure 1-6 Windows 98 and Windows XP vulnerabilities (July 98-Jan. 04)
Development Platforms