Module 0
Module 0
CSE 628A
Pramod Subramanyan
Indian Institute of Technology Kanpur
1
ADMINISTRIVIA
2
Team
• Instructor: Pramod Subramanyan (spramod@cse)
• Teaching Assistants:
– Bidya Sarkar (bidya@)
– Dixit Kumar (dixit@)
– Hariom (hariom@)
– Mayank Rawat (mayankr@)
– M. Jeevan Kumar (jeevank@)
– Nirjhar Roy (nirjhar@)
– Krishna Kumar Tayal (ktayal@)
– Supriya Suresh (ssuresh@)
3
Links
• Piazza signup link:
– piazza.com/iitk.ac.in/firstsemester2019/cs628
• Moodle course:
– We will add you by the end of the week
– Assignments will be posted on moodle
• Course webpage:
– Slides and readings will be posted under schedule
– https://web.cse.iitk.ac.in/users/spramod/courses/cs628-2019-I/
4
Grading
Weightage
Assignments
10%
Midterm
20%
50% Final
20%
Participation (in class, piazza)
5
Syllabus
6
Expectations/Advice
1. Ensure you have the background knowledge
2. Come to the classes and participate
3. Study after each class
4. Post and answer questions on piazza
5. Please do the the readings
6. Start the homeworks early
In the long run, learning will pay-off over
prioritizing grade maximization
7
Background/Preparation
• Computer organization (assembly language,
TLBs, demand paging, privilege separation)
• Operating systems (processes, threads, heaps,
stacks, page tables, permissions, etc.)
• Networks (IP, TCP, UDP, HTTP, DNS etc.)
• Read, write and understand programs; reason
carefully about the difference between
programmer intent and code behaviour
8
Module 0: Introduction
9
Acknowledgements
• Sandeep Shukla (IIT Kanpur)
• Arvind Narayanan (Princeton University)
• Dan Boneh (Stanford University)
• John C. Mitchell (Stanford University)
• Nicolai Zeldovich (MIT)
• Jungmin Park (Virginia Tech)
• Patrick Schaumont (Virginia Tech)
• Web Resources
10
modern
The computer security problem
Two factors:
• Lots of buggy software (and gullible users)
• Money can be made from finding and
exploiting vulnerabilities
1. Marketplace for vulnerabilities
2010
13
Data shows HW vulns growing
15% of disclosed
vulnerabilities
Insignificant
fraction in
2003
14
Vulnerable applications being exploited
date
16
Introduction
Sample attacks
17
The computer security problem
Two factors:
• Lots of buggy software (and gullible users)
19
Client Side Attacks
20
Why own machines: (1) IP address
and bandwidth stealing
Attacker’s goal: look like a random Internet user
• Denial of Service:
– Services: 1 hour ($20), 24 hours (100$)
• Click fraud (e.g. Clickbot.a)
21
Why own machines: (2) steal user
credentials and/or inject ads
Keyloggers that steal banking passwords, web
passwords, gaming passwords
Example: SilentBanker (and many like it)
User requests login page
22
Server-side attacks
24
Server-side attacks
25
Example: Mpack
• PHP tools installed on compromised web sites
– Embedded as an iframe on infected page
– Infects browsers that visit site
• Features
– Mgmt console provides stats on infection rates
– Sold for several hundred dollars
– Customer care can be purchased, one-year contract
• Impact: 500,000 infected sites (via SQL injection)
– Several defenses: e.g. Google safe browsing
26
Network Attacks
27
MyEtherWallet Hack (Apr 2018)
28
MyEtherWallet Hack
1. Create a fake website that looks like original
2. Ask users to type in email/password
3. Use their data to steal all their money
4. …
5. PROFIT??
30
Insider attacks: example
Hidden trap door in Linux (nov 2003)
See: http://lwn.net/Articles/57135/ 31
Many more examples
• Access to SIPRnet and CD-RW: 260,000 cables ⇒
Wikileaks
• SysAdmin for city of SF government. Changed
passwords, locking out city from router access
– https://www.cio.com.au/article/255165/sorting_facts_te
rry_childs_case/?pp=4&fp=&pf=1&fpid=
• Inside logic bomb took down 2000 UBS servers
– https://www.theregister.co.uk/2006/12/13/ubs_logic_bo
mber_sentenced/
32
Introduction
33
Hacker zoloto offered credit cards for
sale on the Web site HackZone .ru.
34
Marketplace for Vulnerabilities
Option 2:
• ZDI : $2K – $25K
35
Marketplace for Vulnerabilities
Option 3: Black Market
PPI operation:
PPI service
1. Own victim’s machine
2. Download and install client’s code
3. Charge client
Victims
Source: Cabalerro et al. (www.icir.org/vern/papers/ppi-usesec11.pdf) 37
Marketplace for owned machines
clients spam
keylogger
bot
Victims
Source: Cabalerro et al. (www.icir.org/vern/papers/ppi-usesec11.pdf) 38
Ken Thompson’s clever Trojan
Ken Thompson, co-author of UNIX, recounted a story of how he
created a version of the C compiler that, when presented with
the source code for the "login" program, would automatically
compile in a backdoor to allow him entry to the system.
This is only half the story, though. In order to hide this trojan
horse, Ken also added to this version of "cc" the ability to
recognize if it was recompiling itself to make sure that the newly
compiled C compiler contained both the "login" backdoor, and
the code to insert both trojans into a newly compiled C compiler.
In this way, the source code for the C compiler would never show
that these trojans existed.
39
What is Security?
40
What is Security?
• A High Level Plan for Security Centric System
Design
– Policy: “Only X can access file F”
– Common goals: Confidentiality, Integrity, Availability
– Threat Models: “Can Y physically grab the file server?”
– Mechanisms: The knobs that can be controlled to
uphold your security policy, but also be flexible to
uphold a different policy
– Resulting Goal: “No way the adversary in the threat
model to violate policy”
41
Why is security hard?
42
Perfect Security is not achievable
• Best effort
• Need to manage security risk vs. benefit tradeoff
• Risk based security model
• Each system will have breaking point – need to
analyze and understand – e.g., pentesting
• Manual auditing often can help
• Make the cost of attack high – deterrence
– Either by law
– Technologically
43
Why policy matters in security
• Example: Sarah Palin’s email account hacked
– Yahoo accounts have username/password and
security questions
– User can login with username/password
– If user forgets password – can reset by answering
security question
– Security questions are sometimes easier to guess
– Some one guessed Palin’s highschool, birthday etc
– Policy amounts to: can log in with either password
or security questions
44
Policy Matters: iCloud Leaks
• August 2014, 500+ private pictures of
celebrities were posted on 4chan
• Initially believed to have been brute-force
guessing exploiting the fact that iCloud didn’t
rate limit password checks
• Later turned out to be spear-fishing. Attacker
sent emails saying account has been
compromised and made it look like they’re
from Apple/Google
45
Policy Matters
• All three of these examples are not “bugs”
• Code did exactly what it was supposed to do
• Problem was in the policy aka specification
– Should not allow password recovery using only
security questions
– Should not allow bruteforcing of passwords
– Should educate users about phishing attacks
46
What to do?
• Think hard about implications of policy
statements
• Some policy checking tools can help – but you
need to specify ‘what is bad’
• Difficult in distributed systems: don’t know
what everyone is doing
47
What might go wrong in threat
models/assumptions?
• Human factors not accounted for: ex. Phishing attack
• Computational assumptions change over time:
– MIT’s kerberos system used 56-bit DES keys since mid 1980s
– Now it costs about $100 to get it cracked
• All SSL certificate CAs are fully trusted
– To connect to an SSL-enabled website, your browser verifies the
cetificate
• Certificate is a combination of server’s host name, and cryptographic key,
signed by a trusted CA
– 100s of CAs are trusted by most browsers
– In 2011, two CAs were compromised – issued fake certificates for
many domains (google, yahoo, tor, …)
– http://en.wikipedia.org/wiki/Comodo_Group
– http://en.wikipedia.org/wiki/DigiNotar
48
Limitations in Assumptions
• Assuming your hardware is trustworthy
– If NSA is your adversary – it is not necessarily true
• https://www.schneier.com/blog/archives/2013/12/more_about_t
he.html
• Assuming good randomness in cryptography
– Often source of randomness may not be good, and keys
may be compromised
– https://factorable.net/weakkeys12.extended.pdf
• Assuming OS to be secure
– Bugs? Backdoors? Trojans?
• Machine is disconnected from the Network
– Did not stop stuxnet worm
49
What to do to avoid limitations in
threat models?
• More explicit and formalized threat models to
understand possible weaknesses
• Simpler and more general threat models
• Better design may lessen reliance on certain
assumptions
– E.g., alternative trust models that does not rely on
full trust in CAs
– E.g., authentication mechanisms that aren’t
susceptible to phishing
50
Problems with mechanisms
• Bugs in security mechanism (e.g. OS kernel) lead
to vulnerabilities (e.g. CVE-2010-0003)
• Might get pwned by code you didn’t know existed
(e.g., Intel SMM and SMI)
• If application is enforcing security, application
bugs can lead to vulnerabilities
– Example: Missing access control checks in Citigroup’s
credit card website
http://www.nytimes.com/2011/06/14/technology/14security.html?_r=0
51
Some implementation bugs
• Buffer overflow, Use-after-free, Double-free
• Decrementing stack pointer past the end of
stack – into some other memory location
– http://www.invisiblethingslab.com/resources/mis
c-2010/xorg-large-memory-attacks.pdf
• Not checking sanity of inputs
– SQL injection (e.g., see XKCD on next slide)
– Command injection (e.g., ShellShock)
52
What’s the takeaway?
53
This course
Goals:
54
This Course
Part 0: Introduction and Review
• Revisit a few crypto primitives
Part 1: Basics (architecting for security)
• Securing apps, OS, and legacy code
Isolation, authentication, and access control
Part 2: Web security (defending against a web attacker)
• Securing websites, browser security model
Part 3: Network security (defending against a network attacker)
• Monitoring and architecting secure networks.
Part 4: Hardware Security (SGX, Hardware Trojans)
55
Looking Forward
• Next: revisiting crypto primitives
– Assignment #1 (Programming Assgn) goes out
• Then buffer overflows and related attacks
– Assignment #2 (CTF)
• After that, secure system architecture
• …
56
Explaining Clickfraud
57
REVIEW OF CRYPTOGRAPHIC
PRIMITIVES
58
Outline
59
Alice wants to send Bob a message
CIA properties
• Confidentiality: keep message secret
• Integrity: prevent message being tampered with
• Availability: make sure message can reach
60
Alice wants to send Bob a message
Alice Network
Mallory Bob
Focus on integrity
Why?
• Design once and forget
– Tired of build-and-break cycle
• Small set of primitives to focus on
• Doesn’t matter how clever the adversary is
67
Secure MAC game: Us vs. Mallory
Repeat until Mallory says stop
Mallory chooses mi
We tell Mallory f(mi)
Mallory picks m’ ∉ {mi} and guesses f(m’)
f is a secure MAC if
Mallory can’t do better than random guessing
68
Pseudorandom function (PRF)
A random function is too hard to implement
Secret key k
70
Kerckhoffs’s principle
Use a public function family and a
randomly chosen secret key.
Advantages:
1. can quantify probability that key
will be guessed
2. different people can use the same
functions with different keys
3. can change key if needed
(something goes wrong)
71
Attempt at PRF
72
“PRF game”: Us vs. Mallory
We pick with 50/50 probability
either a real random function, or
g = fk for random k
m, fk(m) x, y
m, k k
fk(x) = y?
76
Annoying question:
Do PRFs actually exist?
77
Hash function:
The Swiss army knife of crypto
Popular examples:
– MD5 (has weaknesses, shouldn’t be used)
– SHA-1, SHA-256
Typical construction:
“Merkle-Damgård”
Ralph Merkle
78
Hash function:
takes any string as input
fixed-size output (we’ll use 256 bits)
efficiently computable
Security properties:
collision-free
hiding (preimage resistance)
puzzle-friendly
79
Merkle-Damgård construction
82
Block Cipher
Data Block (128/256/… bits)
aka plaintext • Q: What if I have
message > 256
Key bits in size?
(typically Block Cipher
same size • Easy answer:
as data) (e.g. DES, AES) split into blocks
• How exactly this
is done matters
Encrypted data block (ciphertext) • Different modes
of operation
83
What are some properties of a good
block cipher?
• Should it be deterministic? (Why or why not?)
– A: No, because small messages can be enumerated
• How about a cipher that is as follows:
– E(k, x, r) = (r, r XOR x XOR k)
– We will make sure to use a unique r for each message
• What about an encryption scheme that preserves
order?
– x1 < x2 => E(k, x1) < E(k, x2)
– When might this be useful?
– Why might this be a bad idea?
84
IND-CPA Game
Finalization: Attacker wins if she can determine b with a polynomial number of queries
85
Block ciphers: ECB mode
86
Q: Why do we need the nonce?
A: Almost as bad as ECB without the nonce
87
88
Public key encryption
RSA
89
Encryption: What happens with N people?
91
RSA function
Large random primes
• RSA(N, e, x) = xe % N Inverses
RSA(N, d, y) = yd % N
92
Trapdoor permutation
• Permutation
Easy to compute
• Hard to invert
Except if trapdoor is known
93
RSA Encryption – OAEP encoding
n: RSA modulus length
m: message
000: padding
r: random nonce
G: PRG
H: hash function
k0, k1: 128 bits
PKCS #1 RSA input
https://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding 94
D-H EXCHANGE AND PERFECT
FORWARD SECRECY
95
Strawman SSL
ga mod p
gb mod p
ga mod p