Chapter 3 - Program Security
Chapter 3 - Program Security
Chapter 3
Program Security
Chapter 3
In this chapter
Malicious code
Chapter 3
Programs Security
Chapter 3
Secure Programs
Chapter 3
Secure Programs
One way to assess security or quality is to ask
people to name the characteristics of software
that contribute to its overall security
Chapter 3
Secure Programs
An assessment of security can also be influenced by
someone's general perspective on software quality
in this view, the manufacturer (mentioned above) clearly had room for
improvement
Chapter 3
Secure Programs
In general, practitioners often look at quantity
and types of faults for evidence of a product's
quality (or lack of it)
Chapter 3
Fixing Faults
You might argue that a module in which 100
faults were discovered and fixed is better than
another in which only 20 faults were discovered
and fixed
Chapter 3
Fixing Faults
Early work in computer security was based on the
paradigm of "penetrate and patch,"
Chapter 3
10
Chapter 3
Unexpected Behavior
A better approach than "penetrate and patch," is to
compare the requirements with the behavior
They range from a misunderstanding of program requirements to a onecharacter error in coding or even typing
"it doesn't matter whether the stone hits the pitcher or the pitcher hits the
stone, it's going to be bad for the pitcher."
11
Chapter 3
Security Flaws
So we often find ourselves trying to secure last year's technology while software developers are
rapidly adopting today's and next year's technology.
12
Chapter 3
Types of Flaws
13
Chapter 3
Types of Flaws
14
Chapter 3
15
Chapter 3
Buffer Overflows
It is an example on Boundary condition violation
Definition
16
Chapter 3
Buffer Overflows
Example
char sample[10];
One byte for elements sample[0] through sample[9]
Now we execute the statement:
sample[10] = 'B';
sample[i] = 'B';
we could not identify the problem until i was set during execution
17
Chapter 3
Buffer Overflows
Example
18
Chapter 3
19
Chapter 3
In the second case, the 'B' goes into the user's program
area
no effect
the machine will try to execute an instruction with operation code 0x42
20
Chapter 3
21
Chapter 3
22
Chapter 3
Integer Overflow
http://www.phrack.org/issues.html?issue=60&id=10
Since an integer is a fixed size (32 bits for the purposes of this
paper), there is a fixed maximum value it can store. When an
attempt is made to store a value greater than this maximum value it
is known as an integer overflow.
Most compilers seem to ignore the overflow, resulting in an
unexpected or erroneous result being stored.
This can get dangerous if the calculation has to do with the size of a
buffer or how far into an array to index.
What happens then!!
a = 0xffffffff
b = 0x1
r = a + b r = (0xffffffff + 0x1) % 0x100000000
r = (0x100000000) % 0x100000000 = 0
This is often called a "wrap around", as the result appears to wrap around to 0.
23
Example 1
#include <stdio.h>
int main(void){
unsigned int num = 0xffffffff;
printf("num = %u (0x%x)\n", num, num);
printf("num + 1 = 0x%x\n", num + 1);
return 0;
}
/* EOF */
Chapter 3
24
Chapter 3
John Fiore
25
Chapter 3
26
Chapter 3
27
Chapter 3
Time-of-Check-to-Time-of-Use Errors(TOCTTOU)
Real Example:
What was checked is no longer valid when the object (that is, the sculpture)
is accessed
28
Chapter 3
Time-of-Check-to-Time-of-Use Errors(TOCTTOU)
Computing Example:
Attacker
29
Chapter 3
30
Chapter 3
Malicious Code
31
Chapter 3
Malicious Code
malicious code is still around, and its effects are
more pervasive
32
Code Type
Characteristics
Virus
Worm
Trojan horse
Logic bomb
Time bomb
Trapdoor/backdoor
Rabbit
Chapter 3
33
Chapter 3
34
Chapter 3
If any one of these programs contains a virus, the virus code could be activated
However, ease-of-use often trumps security, so programs such as browsers, email handlers, and viewers often "helpfully" open files without asking the user
first
35
Chapter 3
Appended Viruses
A program virus attaches itself to a program;
then, whenever the program is run, the virus is
activated.
36
Chapter 3
Appended Viruses
An alternative to the attachment is a virus that
runs the original program but has control before
and after its execution
37
Chapter 3
Appended Viruses
A third situation occurs when the virus replaces
some of its target, integrating itself into the
original code of the target.
38
Chapter 3
39
Chapter 3
40
Chapter 3
Memory-Resident Viruses
For very frequently used parts of the operating system and for a
few specialized user programs, it would take too long to reload
the program each time it was needed
41
Chapter 3
Virus Signatures
The pattern which distinguishes a virus is called
a signature.
42
Chapter 3
Hard-to-Find Viruses
Properties
It is hard to detect.
It is not easily destroyed or deactivated.
It spreads infection widely.
It can reinfect its home program or other programs.
It is easy to create.
It is machine independent and operating system
independent.
Few viruses meet all these criteria. The virus writer
chooses from these objectives when deciding what the
virus will do and where it will reside.
43
Chapter 3
Polymorphic Viruses
A virus that can change its appearance is called
a polymorphic virus. (Poly means "many" and
morph means "form.")
44
Chapter 3
45
Chapter 3
46
Chapter 3
2 November 1988
caused serious damage to the network
The perpetrator was Robert T. Morris, Jr., a graduate
student at Cornell University
47
Chapter 3
48
Chapter 3
Code Red
49
Chapter 3
Keystroke Logging
50
Chapter 3
Man-in-the-Middle Attacks
A keystroke logger is a special form of the more
general man-in-the-middle attack
malicious program interjects itself between two
other programs
One example of a man-in-the-middle attack
could be a program that operated between your
word processor and the file system
each time you thought you were saving your file, the
middle program prevented that, or scrambled your
text or encrypted your file
51
development controls
Chapter 3
administrative controls
52