Lecture 3 - Program Security
Lecture 3 - Program Security
Lecture 3
Week 3
Topics
Security principles
Vulnerabilities
Secure Program
Malicious Code
Top 10 Web application vulnerabilities
Safeguard to Program threat
Pillar to Software Security
2
Principles for Building Secure
Systems
Security is economics
• No system is completely, 100% secure against all attacks. Rather,
systems may only need to resist a certain level of attack.
Least privilege
• Give a program the set of access privileges that it legitimately
needs to do its job but nothing more. Try to minimize how much
privilege you give each program and system component.
3
Principles for Building Secure
Systems
Separation of responsibilities
• Split up privilege, so no one person or program has complete
power. Require more than one party to approve before access is
granted.
Defense in depth
• if you use multiple redundant protections, then all of them would
need to be breached before the system's security will be
endangered.
Physiological acceptability
• It is important that your users buy into the security model
6
Secure Programs
Different people have different perspective on
software quality.
8
Non-malicious Program Errors?
Buffer Overflows
Accidental not checking array bounds Example C
program
9
Non-malicious Program Errors?
Incomplete Mediation - data exposed or
uncontrolled
http://www.testing.com/order.asp?cutID=115&part=66
6&qty=3&price=500&total=1500
10
Malicious Codes
unanticipated
or undesired effects in programs
generated on the intent of damage
11
Malicious code ‐ some observations
Malicious code is any code added, changed or removed
from a software system in order to intentionally cause harm
or subvert the intended function of the system.
13
Malicious code ‐ some recent
trends
Previously malware was normally of one specific kind.
Nowadays, it is “multifunctional” and complicated.
• Malware is targeting end users through Web‐based
attacks (Symantec Internet Security Report xiv)
Most viruses today are non‐destructive. Rather, they try
to take control over your computer to
• collect financial information or
• using it for malicious purposes, becoming a zombie, e.g.
to distribute spam. (claim is that 70% of all email is
spam)
All kinds of malware tend to be called “virus”.
• Bagle, Mydoom, Netsky, Sasser, Kargo and Sober (2004)
• Conficker (2009)
14
Malicious code ‐ reasons for
increase
A few trends that largely influence the wide spread of
malicious code:
Growing number and connectivity of computers
• “everybody” is connected and dependant on computers
• the number of attacks increases
• attacks can be launched easily (automated attacks)
Growing system complexity
• unsafe programming languages
• Heterogeneity
• hiding code is easy
• verification and validation is impossible (let alone proofs)
Systems are easily extensible
• mobile code, dynamically loadable modules
• incremental evolution of systems
15
Taxanomy of Malicious Programs
Malicious
Programs
16
Malware
Ismalicious software that is designed specifically to
damage or disrupt a system
Also known as malicious programs. Figure shows the
total malware to-date.
17
The problem of Malware
How does Malware manage to run?
Attacks a network-accessible vulnerable service
Vulnerable client connects to remote system that
sends over an attack (a driveby)
Social engineering: trick user into running/installing
“Autorun” functionality (esp. from plugging in USB
device)
Slipped into a system component (at manufacture;
compromise of software provider; substituted via
MITM)
Attacker with local access downloads/runs it directly
• Might include using a “local root” exploit for privileged access
18
What Can Malware Do?
Pretty much anything
Payload generally decoupled from how manages to
run
Only subject to permissions under which it runs
Examples:
Brag or exhort or extort (pop up a message/display)
Trash files (just to be nasty)
Damage hardware (!)
Launch external activity (spam, click fraud, DoS)
Steal information (exfiltrate)
Keylogging; screen / audio / camera capture
Encrypt files (ransomware)
Possibly delayed until condition occurs
“time bomb” / “logic bomb”
19
Malware That Automatically
Propagates
Virus = code that propagates (replicates) across
systems by arranging to have itself eventually executed,
creating a new additional instance
• Generally infects by altering stored code
20
The Problem of Viruses
Opportunistic = code will eventually execute
• Generally due to user action
• Running an app, booting their system, opening
an attachment
22
Examples of malicious codes:
Trojan Horse - a program which performs a
useful function, but also performs an
unexpected action as well.
24
Examples of malicious codes:
Spyware - This is new and can be non-malicious or
malicious.
Can steal your information (Identity Theft) This is
done with a keystroke logger and even though you
use encryption on connections the damage is already
done before you can send it.
Can steal your email addresses
Can see what Web sites you visit
Can see contents of files
PopUp ads
Slow down your computer
Crash your computer
25
How Viruses Attach
Append viruses - execute first then transfers
control to original program.
26
Virus Appended to a Program
+ or
Original Virus, B
Original Original
Program, A
Program, A Program, A
+ +
Virus, B Virus, B
27
28
How Viruses Gain Control
The virus needs to have the CPU execute it to be
in control.
29
Homes for Viruses
Install
itself in the boot sector (MBR)
master boot record.
31
The Source of Viruses
Virusprogram can be small so it hides
very easily in a large program.
Might
hide in a compiler, a data base
manager or a file manager.
32
Virus Phases
Dormant phase - the virus is idle
34
Truths and Misconceptions About
Viruses
Although other computers/operating systems are
vulnerable to Viruses, it seems the mentality of the
programmers of Viruses is more common on PCs.
Viruses can modify hidden and read only files. True
Viruses can appear only in data files or Word docs, or
in programs. False
Viruses spread only on disks or in e-mail. False
Viruses can not live in memory when the computer is
shut off, but they can still be on other storage devices.
Also Reboot (warm start) is vulnerable to Viruses in
memory. True
Viruses cannot infect hardware. True
Viruses can be malevolent, benign, or benevolent. True
35
Large-scale Malware
Worm = code that self-propagates/replicates across
systems by arranging to have itself immediately
executed
Generally infects by altering running code
No user intervention required
Propagation includes notions of targeting & exploit
How does the worm find new prospective victims?
How does worm get code to automatically run?
37
How Worm Attack
+ + +
Original Worm, B
Program, A Original Worm, B Worm, B
Program, A
38
Worms
Characteristics of a worm:
self-contained, do not require a host
replication
activated by creating process
for network worms, replication occurs across
communication links
Worms exploit flaws in the operating system
or inadequate system management to
replicate.
Release of a worm usually results in brief but
spectacular outbreaks, shutting down entire
networks.
39
Worms
Protection against Worms
requires a combination of basic system security and good
network security
add-on tools:
configuration review tools
checksum-based change detection tools
intrusion detection tools
network security tools:
wrapper program : filter network connections
firewall system
The most important means of defense is the
identification & authentication (I&A) controls, which
are usually integrated into the system. If poorly
managed, these controls become a vulnerability which
is easily exploited.
40
Targeted Malicious Code
Salami Attack
41
Trapdoors and the Salami Attack
Trapdoors are often caused by programmers leaving
debug routines in the code. Or failure to check array
bounds which lets code overrun the array bounds and
get placed on the stack.
Causes of Trapdoors:
Programmer forgets to remove them.
Programmer intentionally leaves them in for testing.
Leaves them in intentionally for maintenance of the
finished product.
5
44
Cross Site Scripting: Reflected XSS
45
Virus Signatures
Virus cannot be completely invisible but can be
very hard to detect, especially if it has self-
modifying code.
47
Safeguard to Program Threat
Preventing Virus Infection
Protection against viruses
detection tools
example : scanners, vulnerability monitors,
modification detection programs
identification tools
example : scanners
removal tools
example : disinfectors
50
Preventing Web application attack
Input validation.
Strong output encoding.
Do not use "blacklist" validation
Do not use GET requests (URLs) for sensitive data or to perform value
transactions
Disable or limit detailed error handling
errors from all layers are adequately checked and configured to prevent
error messages from being exploited by intruders
Do not allow the login process to start from an unencrypted page
Encrypt Password
Check the old password when the user changes to a new password
Do not create cryptographic algorithms
Do not use weak algorithms
Ensure the access control matrix is part of the business, architecture, and
design of the application
More….refer to OWASP TOP 10 Official document
http://www.owasp.org/images/e/e8/OWASP_Top_10_2007.pdf
51
Controls Against Program Threats
Software Engineering
Modularity, Encapsulation, and Information Hiding
Peer reviews
Hazard Analysis HAZOP, FMEA, FTA
Independent Testing
Good Design
Prediction
Static Analysis
Configuration Management
Proofs of Program Correctness
Operating System Controls - trusted software,
confinement, audit log
Administrative Controls - Standards of program
development
52
Pillar of software security
Risk Management
Touchpoints
Knowledge
53
Risk Management
Business understands the idea of risk even
software risk
Technical perfection is impossible
There no such thing as 100% security
Perfect quality is a myth
Technical problem do not always spur
action
Answer the So what? Question explicitly
Help user undesrtand what they should do
about risk
Build better software
54
Touchpoints
55
Knowledge catalog
Principles
Guidelines
Rules
Attack patterns
Vulnerabilities
Historical Risks
56
57
Summary of Program Threats and
Controls