Lecture 1
Lecture 1
Ahmed Kosba
1
Today’s Lecture
• Introduction
• Threats against the security of computer systems and communication
• Some real-world attacks
• Class goals and logistics
• Security principles
--
• Buffer overflow vulnerabilities
2
Discussion of Basic Threats/Attacks
This is not a comprehensive list
3
Example 1: Eavesdropping on Communications
Alice Bob
• Defense?
• Would hiding the content, i.e., encryption, prevent all kinds of attacks?
4
Example 2: Unauthorized Modification of
Information
Example: Active man in the middle attacks
Alice Bob
• Defense?
5
Example 3: Denial of Service
• Example: Malicious disruption of a server
Defense?
6
Figure Source: Wikimedia Commons
Example 4: Malicious Software/Hardware
Attackers could develop malicious software or hardware that exploit
vulnerabilities in systems.
Vulnerabilities?
• Vulnerabilities are defects in software or hardware implementations
that could allow attackers to compromise systems security.
Vulnerabilities could be
exploited by attackers to
break confidentiality,
availability and/or integrity.
• Defense?
9
Example 6: Social Engineering Attacks
Social Engineering: Attacks target the human factor through
psychological tricks.
Examples include phishing, spear-phishing, smishing and vishing.
Example 7: Threats against outsourced
data/computations to the cloud
Cloud Services
Client Devices
14
Real-world Attacks
15
Cyberwarfare
Bloomberg
• Attacks against critical infrastructure
• Industrial control systems
• Electrical grids
• Transportation networks
Real-world Vulnerabilities:
Hardware Vulnerability Example
• Meltdown and Spectre vulnerabilities
• Discovered in 2017 and disclosed in early 2018.
• Exploit out-of-order and speculative execution
implemented in many processors.
• Can be used to extract confidential program data.
18
More Attacks ..
• Attacks against Machine Learning
20
Class Logistics
• Grading Policy (Tentative)
• Final Exam: 60%
• Coursework: 40% (25% midterm + 15% assignments)
• Lectures and assignments will be posted on MS teams
• Team code posted to your group
• Tutorials:
• TAs: Eng. Aly Hamdy, Hossam Elshami, Youssef Sameh
• The tutorials' plan will be decided based on class progress.
21
References
• Introduction to Modern Cryptography, 2nd Edition, by Jonathan Katz and Yehuda Lindell.
• Cryptography and Network Security: Principles and Practice, 7th Edition, by William Stallings.
• Introduction to Computer Security, by Michael Goodrich and Roberto Tamassia.
22
Guidelines
• Attend lectures and review the given content weekly to be up to date.
• Ask questions.
• Start working early on the assignments.
• Note: Some questions in the assignments introduce new ideas, and could be
challenging. However, the grading is done based on serious attempts.
• Academic Integrity
• Don’t cheat in any of the assignments.
• Unless mentioned otherwise, you should work individually.
• If any extra source or discussion helped you answer a question, you should
cite that source and write solutions in your own way.
23
Goals of this course
The primary goal is to help you develop a security mindset.
• In this course, you will learn about:
• The basics of computer and network security
• Standard cryptographic schemes
• How some real worlds attacks work
• Some software and web security issues
• The impact on the society
• Some recent trends (This will depend on time)
25
Further notes
• Recent developments in security and cryptography enable
new applications.
• Example of research trends:
• Searchable Encryption
• Hiding Access Patterns
• Zero-knowledge Proofs
• Secure Multi-party Computation
26
Computer and Network
Security Concepts
27
Security Definition and Goals
• Definition of Computer Security [NIST SP 800-14]
“The protection afforded to an automated information system in order to attain the
applicable objectives of preserving the integrity, availability, and confidentiality of
information system resources (including hardware, software, firmware, information
data, and telecommunications).”
CIA Triad:
Confidentiality, Integrity, Availability
- How are the attacks we discussed earlier related? 28
CIA: Confidentiality – Integrity – Availability
• Confidentiality
• Prevent unauthorized access to or disclosure of information
• Integrity
• Data Integrity means that the data has not been altered in any unauthorized
manner. This covers data in storage, during processing, and during transmission.
• System Integrity means that the system performs the intended functions without
unauthorized manipulation.
• Availability
• The systems and services perform the intended functions promptly, and without
interruptions
29
Additional Concepts (related to Integrity)
Authenticity
• The property that statements made by persons/electronic systems are genuine. This
includes being able to verify that messages originated from certain sources.
Non-repudiation
• Definition according to NIST SP 800-53 Rev. 5: “Protection against an individual who
falsely denies having performed a certain action and provides the capability to determine
whether an individual took a certain action, such as creating information, sending a
message, approving information, or receiving a message.”
• This helps with accountability in digital contracts for example.
Note: As we will see during the course, not all integrity primitives provide the same guarantees. For
example, a primitive could enable authentication, but not non-repudiation.
30
OSI Security Architecture
Provides definitions for
• Security Attacks
• Security Mechanism
• A method or process (or a device incorporating it) that is designed for
detecting, preventing and recovering from security attacks
• Examples: Encipherment, Digital Signatures, Access Control, Routing Control, etc.
• Security Service
• A service, provided by a layer of communicating open systems, that ensures
adequate security of the systems or the data transfers.
• Could use one or more security mechanisms
• Examples: Data origin authentication, traffic flow confidentiality, non-repudiation, etc.
Definitions can be found in:
• X.800: Security architecture for Open Systems Interconnection for CCITT applications
32
• RFC 4949: Internet Security Glossary, Version 2
Examples
Security attacks
- Passive Attacks Alice Bob
- Eavesdropping
- Traffic Analysis
- Active Attacks
- Modification of data/information
- Altering system behavior
- DDoS
- Masquerading
- Replay attacks Alice Bob
33
Security Design Principles
• Economy of mechanism • Isolation
• Fail-safe defaults • Encapsulation
• Complete mediation • Modularity
• Open design • Layering
• Separation of privilege
• Least privilege • Compromise recording
• Least common mechanism • Work factor
• Psychological acceptability
35
Security Design Principles [1/4]
• Economy of mechanism
• Simplicity in design
• Fail-safe defaults
• Access decisions should be based on explicit permission, not exclusion.
• Example: When adding a new user to a system, the user should have none or
minimal access rights by default, i.e., the default is lack of access, unless given
explicit access permission.
• Complete mediation
• All accesses to objects must be checked for compliance with the access control
policies or protection schemes in place.
• Note: Checking every access does not always happen in real systems. Some form of
caching could be employed, but this could lead to issues. [Examples – 13.2.4]
• Open design
• The design of a security mechanism should be public. In other words, the security
should not depend on the secrecy of the design.
36
• What about encryption algorithms?
Security Design Principles [2/4]
• Separation of privilege
Definitions appear in different forms.
• Have a different permission for each operation (fine-grained access control).
• Functions should be separate and provide as much granularity as possible.
• This principle can apply to both systems and users.
• In the case of systems, functions such as read, edit, write, and execute should be separate.
• In the case of system operators and users, roles should be as separate as possible. For example,
if resources allow, the role of system administrator should be separate from that of the
database administrator. [NIST 800-123]
• Require more than one condition to achieve access to a restricted resource or
perform a sensitive operation. (similar to separation of duties)
• Least privilege
• Each program/user should operate with the minimum privileges needed to
perform the desired function. 37
Security Design Principles [3/4]
• Least common mechanism
• Minimize the functions/resources shared by different users or programs.
• Sharing resources could lead to undesirable attack channels.
• Psychological acceptability
• Usability: Security mechanisms should be transparent to the users or at most
introduce minimal interference.
• Least astonishment: The UI should match the experience and expectations of the
user.
• Isolation
• Separate public access systems from critical resources.
• Processes and files of individual users should be isolated from each other, unless
desired otherwise. 38
Security Design Principles [4/4]
• Encapsulation
• This is another form of isolation that is similar to encapsulation in OOP.
• The internal structure of a data object is accessible only to the procedures of
the protected subsystem. External operations on data or procedures may be
called only at well-defined entry points.
• Modularity
• Develop security functionalities as separate modules.
• Use a modular architecture for the design and implementation of security
mechanisms.
• Layering
• Use multiple layers of defense.
39
Minimize the Attack Surface!
• An attack surface of a system is the set of ways through which an adversary can
access a system and compromise its security.
• In other words, it’s the software and network parts that are exposed to attacks.
Another Definition: “Reachable and exploitable vulnerabilities in a system” [Textbook]
• Examples
• Open ports, and the code listening on these ports.
• Services used inside a firewall.
Categories
• Software Attack Surface
• Network Attack Surface
• Human Attack Surface 40
Integrating Security with System
Development Life Cycle
• Security must be integrated with all the SDLC stages, since the start.
• Security should never be an afterthought.
• This helps with:
• Early detection and mitigation of potential security vulnerabilities, which
reduces the mitigation cost later.
• Identifying the engineering challenges caused by the needed security
mechanisms
Full list can be found in NIST SP 800-12 REV. 1 –Introduction to Information Security.
42
Software Security
Low-level attacks
44
CWEs and CVEs
• When discussing vulnerabilities, you will usually see these terms:
• CWE: Common Weakness Enumeration
• This describes a common weakness in software or hardware, without referring to a
specific instance. This weakness can lead to exploitable vulnerabilities.
• Example: CWE 119 – Buffer Errors
45
Top 10 CWEs in 2019 [Data from https://cwe.mitre.org/]
Rank ID Name
[1] CWE-119 Improper Restriction of Operations within the Bounds of a Memory Buffer
Improper Neutralization of Input During Web Page Generation ('Cross-site
[2] CWE-79
Scripting')
[3] CWE-20 Improper Input Validation
[4] CWE-200 Information Exposure
[5] CWE-125 Out-of-bounds Read
Improper Neutralization of Special Elements used in an SQL Command
[6] CWE-89
('SQL Injection')
[7] CWE-416 Use After Free
[8] CWE-190 Integer Overflow or Wraparound
[9] CWE-352 Cross-Site Request Forgery (CSRF)
Improper Limitation of a Pathname to a Restricted Directory ('Path
[10] CWE-22
Traversal')
46
See also: https://nvd.nist.gov/vuln/categories
CVEs related to CWE-119
Table from: https://www.cvedetails.com/
Note the different impact of each CVE, although the CWE is the same. 47
Buffer Overflow
• This bug usually appears in C or C++ implementations.
• Many other languages aim to prevent this kind of bugs.
48
0xFFFF…FFFF
Kernel
Space
Text
(code segment)
0x0000…0000
Stack
High Address
.
Calling a Function in C .
.
Stack frame
of main()
void f(int arg1, int arg2){
arg2
int x;
int y; arg1
char s[4];
.. Stack frame
} of f()
x
int main(){ y
f(arg1, arg2);
} s
The content
• The arguments and the local variables are pushed of the local
on top of the stack. buffer s is
stored here.
• Note: Each row in the figure is 4 bytes.
50
Stack
High Address
.
Calling a Function in C .
.
void f(int arg1, int arg2){
arg2
int x;
int y; arg1
char s[4];
..
}
x
int main(){ y
f(arg1, arg2);
} s
Questions
• What do we need in order to resume execution
after f returns?
• When f is compiled, what should be the
addresses of the variables x, y and s? 51
Stack
High Address
.
Calling a Function in C .
.
arg2
• During execution, we need three arg1
registers:
• ESP: Stores the current stack pointer (the
address of the top of the stack) %ebp
x
• EBP: Stores the base pointer for the
current stack frame. y
The caller's %ebp is pushed on top of the stack and %ebp value is updated to the current stack pointer.
53
The arguments are pushed in the code of the caller. The instruction pointer is pushed by the call itself.
Stack
High Address
.
Calling a Function in C .
.
%ebp
arg2
• During execution, we need three arg1
registers:
The caller’s %eip
• ESP: Stores the current stack pointer (the
The caller’s %ebp %ebp
address of the top of the stack)
x
• EBP: Stores the base pointer for the
current stack frame. y
• Note: The following issues don’t apply only to strcpy. You can find
examples for gets, strcat, etc.
56
Stack
High Address
.
Buffer Overflow .
.
%ebp
int main(){
char *t = “ABCDEFG”;
f(t);
}
59
Stack Smashing Attacks
• This report shows how to inject a “shell code”, which opens a shell for the
attacker. The attacker can issue commands as desired.
60
Other Low-level Bugs
• Similar attacks can also apply for the heap.
• Format string attacks
• Integer overflows
62
Format String Vulnerabilities
int main(int argc, char* argv[]){
printf(argv[1]); // vulnerable
printf("%s", argv[1]); // safer
}
• The behavior is the same if the user inputs a normal string, e.g.,
"Hello!".
• The behavior will be different if the user enter a string with format
specifiers, e.g., "Hello %p %p %p %p %p".
• The content of the stack could be printed.
• An Example will be posted on the MS team.
63
Countermeasures
• Use a memory-safe and a type-safe language
• Most modern languages aim to be memory-and type-safe.
• This does not prevent all issues. You need to follow security recommendations.
• What if we still need to use C?
• Use secure coding guidelines.
• Tools that check whether a program is memory-safe.
• Some known countermeasures in the space
• Stack canaries
• Make code on stack or heap not executable.
• However, some types of attack could still work. See Return-to-libc
• Address space layout randomization
• Control flow integrity
However, countermeasures are not perfect.
64
Notes
• Many compilers now rely on techniques that make a subset of the
attacks harder.
• GCC for example has stack smashing protection (SSP).
• But again, don’t assume that these techniques are perfect.
• Note: GCC's stack smashing protection won't prevent all out-of-bound writes.
• A code example will be posted for this.
Notes:
• We won't have time to discuss all possible low-level issues.
• However, you know now that the issues could appear in very simple code and
could be exploited in various ways, so keep learning and follow secure coding
practices.
67