Title: CS 352 Network Security
1CS 352- Network Security
2Why Network Security?
- Malicious people share your network
- Same motivations as traditional world
- Peepers, vandals, graffiti-artists, joy riders,
thieves, burglars, blackmailers. - Problem made more severe the more the Internet
became commercialized
3Classic Security Issues
- Confidentiality can a 3rd party see it?
- Authentication Who am I talking to?
- Non-repudiation can you claim you didnt send it
even if you really did? - Integrity was it altered before I got it?
- Authorization Are you allowed to perform the
action (method)?
4Available Security Tools
- Cryptography/Encryption
- Encode a message in a way that only the
communicating parties can interpret it - Used for secrecy and authentication
- Signatures
- Allow for the authentication of a messages
sender and the messages integrity - Used for authentication, non-repudiation and
integrity control
5Cryptography
- Encoding a message in a way that only the
communicating parties can interpret it
Encryption
Plaintext (P)
Ciphertext (C)
Key (K)
Notation Encryption CEK (P)
Decryption P DK(P)
6Rules for Encryption
- Encryption requires both an encryption algorithm
and an encryption key - Key is a string which controls how the algorithm
encrypts - Algorithm
- Should be public and known to all
- Inspires trust that the algorithm works
- Keys
- Should be long enough to prevent easy breaking of
the encryption - Should be short enough to keep algorithm
efficient - Typical key lengths 56-bit, 128-bit, 256-bit,
512-bit
7Types of Encryption Algorithms
- Substitution Ciphers
- Every letter (or group of letters) is replaced by
another letter (or group of letters) - Example
- Caesar cipher
- a/D, b/E, c/F, d/G, , z/C
- Monoalphabetic cipher
- a/Q, b/W, c/E,
- Easy to break by analyzing statistical properties
of written language
8Types of Encryption (contd)
- Transposition Ciphers
- Instead of substituting letters in the plaintext,
we change their order
A N D R E W 1 4 2 5 3 6 t h i s i s a m e s s a g
e i w o u l d l i k e t o e n c r y p t n o w
Key ANDREW Plaintext thisisamessageiwould
liketoencryptnow Ciphertext
tagltyieiletisokco
hmedopsswinnsauerw
Also easy to break by analyzing structure of
language
9Types of Encryption (contd)
- One-Time Pads
- Unbreakable form of encryption
- Select a random bit string that is just as long
as the message being sent, and perform an
EXCLUSIVE OR on the two bit strings to perform
the encryption - Cannot be broken every possible plaintext is an
equally probable candidate - Problems
- not efficient requires large keys
- if one-time pad is stolen, message can be
decrypted by thief - vulnerability to lost or inserted characters in
one-time pad ? integrity
10Types of Encryption (contd)
- Most actual encryption algorithms use a complex
combination of substitution and transposition - Examples
- Data Encryption Standard (DES)
- Multiple iterations of substitution and
transposition using a 56-bit key - designed by IBM with input from the NSA
- DES chaining
- Multiple stages of DES coding, in which the input
of each stage is the output of previous stages - International Data Encryption Algorithm (IDEA)
- uses a 128-bit key
11Types of Encryption (contd)
- Problem with all the cryptography algorithms used
so far - How to communicate the shared key safely
- Is there a way to do cryptography without
worrying about this concern?
Yes, public key cryptography
12Public Key Cryptography
- Uses two different keys an encryption key and a
decryption key - Each user holds
- a private decryption key to decrypt messages sent
to her - a public encryption key that everyone else should
use to encrypt messages that are sent to her - Important property of public key cryptography
algorithms - Private decryption key cannot be easily
determined by knowing the public encryption key
13Public Key Cryptography
- public key cryptography
- radically different approach Diffie-Hellman76,
RSA78 - sender, receiver do not share secret key
- public encryption key known to all
- private decryption key known only to receiver
- symmetric key crypto
- requires sender, receiver know shared secret key
- Q how to agree on key in first place
(particularly if never met)?
14Public key cryptography
Bobs public key
K
B
-
Bobs private key
K
B
encryption algorithm
decryption algorithm
plaintext message
plaintext message, m
ciphertext
15Public key encryption algorithms
Requirements
.
.
-
- need K ( ) and K ( ) such that
B
B
given public key K , it should be impossible to
compute private key K
B
-
B
RSA Rivest, Shamir, Adelson algorithm
16RSA Choosing keys
1. Choose two large prime numbers p, q.
(e.g., 1024 bits each)
2. Compute n pq, z (p-1)(q-1)
3. Choose e (with eltn) that has no common
factors with z. (e, z are relatively prime).
4. Choose d such that ed-1 is exactly divisible
by z. (in other words ed mod z 1 ).
5. Public key is (n,e). Private key is (n,d).
17RSA Encryption, decryption
0. Given (n,e) and (n,d) as computed above
2. To decrypt received bit pattern, c, compute
d
(i.e., remainder when c is divided by n)
Magic happens!
c
18RSA example
Bob chooses p5, q7. Then n35, z24.
e5 (so e, z relatively prime). d29 (so ed-1
exactly divisible by z.
e
m
m
letter
encrypt
l
12
1524832
17
c
letter
decrypt
17
12
l
481968572106750915091411825223071697
19RSA Why is that
Useful number theory result If p,q prime and n
pq, then
(using number theory result above)
(since we chose ed to be divisible by (p-1)(q-1)
with remainder 1 )
20RSA another important property
The following property will be very useful later
use public key first, followed by private key
use private key first, followed by public key
Result is the same!
21Authentication
- Goal Bob wants Alice to prove her identity to
him
Protocol ap1.0 Alice says I am Alice
I am Alice
Failure scenario??
22Authentication
- Goal Bob wants Alice to prove her identity to
him
Protocol ap1.0 Alice says I am Alice
in a network, Bob can not see Alice, so Trudy
simply declares herself to be Alice
I am Alice
23Authentication another try
Protocol ap2.0 Alice says I am Alice in an IP
packet containing her source IP address
Failure scenario??
24Authentication another try
Protocol ap2.0 Alice says I am Alice in an IP
packet containing her source IP address
Trudy can create a packet spoofing Alices
address
25Authentication another try
Protocol ap3.0 Alice says I am Alice and sends
her secret password to prove it.
Failure scenario??
26Authentication another try
Protocol ap3.0 Alice says I am Alice and sends
her secret password to prove it.
Alices password
Alices IP addr
Im Alice
playback attack Trudy records Alices packet and
later plays it back to Bob
27Authentication yet another try
Protocol ap3.1 Alice says I am Alice and sends
her encrypted secret password to prove it.
Failure scenario??
28Authentication another try
Protocol ap3.1 Alice says I am Alice and sends
her encrypted secret password to prove it.
encrypted password
Alices IP addr
record and playback still works!
Im Alice
29Authentication yet another try
Goal avoid playback attack
Nonce number (R) used only once in-a-lifetime
ap4.0 to prove Alice live, Bob sends Alice
nonce, R. Alice must return R, encrypted with
shared secret key
I am Alice
R
Alice is live, and only Alice knows key to
encrypt nonce, so it must be Alice!
Failures, drawbacks?
30Authentication ap5.0
- ap4.0 requires shared symmetric key
- can we authenticate using public key techniques?
- ap5.0 use nonce, public key cryptography
I am Alice
Bob computes
R
and knows only Alice could have the private key,
that encrypted R such that
send me your public key
31ap5.0 security hole
- Man (woman) in the middle attack Trudy poses as
Alice (to Bob) and as Bob (to Alice)
I am Alice
I am Alice
R
R
Send me your public key
Send me your public key
Trudy gets
sends m to Alice encrypted with Alices public key
32ap5.0 security hole
- Man (woman) in the middle attack Trudy poses as
Alice (to Bob) and as Bob (to Alice)
- Difficult to detect
- Bob receives everything that Alice sends, and
vice versa. (e.g., so Bob, Alice can meet one
week later and recall conversation) - problem is that Trudy receives all messages as
well!
Problem to solve public key distribution
33Distribution key distribution center
Key Distribution Center
34Distribution Public key certification
Certification Authority
CAs private key
Alices CA-signed certificate containing her
public key
Encryption algorithm
( , Alice)
35Digital Signatures
- Cryptographic technique analogous to hand-written
signatures. - sender (Bob) digitally signs document,
establishing he is document owner/creator. - verifiable, nonforgeable recipient (Alice) can
prove to someone that Bob, and no one else
(including Alice), must have signed document
36Digital Signatures
- Simple digital signature for message m
- Bob signs m by encrypting with his private key
KB, creating signed message, KB(m)
-
-
Bobs private key
Bobs message, m
(m)
Dear Alice Oh, how I have missed you. I think of
you all the time! (blah blah blah) Bob
Bobs message, m, signed (encrypted) with his
private key
Public key encryption algorithm
37Digital Signatures (more)
-
- Suppose Alice receives msg m, digital signature
KB(m) - Alice verifies m signed by Bob by applying Bobs
public key KB to KB(m) then checks KB(KB(m) )
m. - If KB(KB(m) ) m, whoever signed m must have
used Bobs private key.
-
-
-
- Alice thus verifies that
- Bob signed m.
- No one else signed m.
- Bob signed m and not m.
- Non-repudiation
- Alice can take m, and signature KB(m) to court
and prove that Bob signed m.
-
38Message Digests
- Computationally expensive to public-key-encrypt
long messages - Goal fixed-length, easy- to-compute digital
fingerprint - apply hash function H to m, get fixed size
message digest, H(m).
- Hash function properties
- many-to-1
- produces fixed-size msg digest (fingerprint)
- given message digest x, computationally
infeasible to find m such that x H(m)
39Internet checksum poor crypto hash function
- Internet checksum has some properties of hash
function - produces fixed length digest (16-bit sum) of
message - is many-to-one
But given message with given hash value, it is
easy to find another message with same hash
value
message
ASCII format
message
ASCII format
I O U 9 0 0 . 1 9 B O B
49 4F 55 39 30 30 2E 31 39 42 D2 42
I O U 1 0 0 . 9 9 B O B
49 4F 55 31 30 30 2E 39 39 42 D2 42
B2 C1 D2 AC
B2 C1 D2 AC
different messages but identical checksums!
40Digital signature signed message digest
Bob sends digitally signed message
- Alice verifies signature and integrity of
digitally signed message
H(m)
Bobs private key
Bobs public key
equal ?
41Hash Function Algorithms
- MD5 hash function widely used (RFC 1321)
- computes 128-bit message digest in 4-step
process. - arbitrary 128-bit string x, appears difficult to
construct msg m whose MD5 hash is equal to x. - SHA-1 is also used.
- US standard NIST, FIPS PUB 180-1
- 160-bit message digest
42System Security Issues
- Stack Smashing
- Worm and Virus propagation
- Spoofing
- Scanning
- DDOS attacks
- Intrusion Detection
43Stack Vulnerability
- Any program written without memory protection
(i.e., pointers) writable stacks - Recall from architecture/compilers
- local variables in a function/procedure/method
are kept on a stack - So is the return address of the program counter.
- Stack smashing Give bad data to a program that
- Writes executable code into the program somewhere
(most often the stack) - corrupts return address on stack to jump to code
44Stack Smashing Code Example
- include ltstdio.hgt
- char shellcode "\xeb\x1f\x5e\x89\x76\x08\x31\x
c0\x88\x46\x07\x89\x46\x0c\xb0\x0b\x89\xf3\x8d\x4e
\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd\x
80\xe8\xdc\xff\xff\xff/bin/sh" - char large string128
- int i
- long long_ptr
- int main()
- char buffer96
- long ptr (long )large_string
- for (i0 ilt32 i)
- (long_ptri) (int)buffer
- for (i0 ilt(int)strlen(shellcode) i)
- large_stringi shellcodei
- strcpy(buffer, large string)
- return 0
45Terminology
- Virus
- A program which copies itself into the machine
(host) via user-action (e.g. opening an
attachment). - Worm
- Like a virus, but self-propagates (e.g. scans for
open ports) - Script-kiddies
- People who download worms/viruses and do not know
how they work, only how to use - Spyware
- A program to monitor functions on a machine w/o
the users knowledge - Malware
- Any bad software
46Internet security threats
- Packet sniffing
- broadcast media
- promiscuous NIC reads all packets passing by
- can read all unencrypted data (e.g. passwords)
- e.g. C sniffs Bs packets
C
A
B
Countermeasures?
47Internet security threats
- Packet sniffing countermeasures
- all hosts in organization run software that
checks periodically if host interface in
promiscuous mode. - one host per segment of broadcast media (switched
Ethernet at hub)
C
A
B
48Internet security threats
- IP Spoofing
- can generate raw IP packets directly from
application, putting any value into IP source
address field - receiver cant tell if source is spoofed
- e.g. C pretends to be B
C
A
B
Countermeasures?
49Internet security threats
- IP Spoofing ingress filtering
- routers should not forward outgoing packets with
invalid source addresses (e.g., datagram source
address not in routers network) - great, but ingress filtering can not be mandated
for all networks
C
A
B
50Internet security threats
- Denial of service (DOS)
- flood of maliciously generated packets swamp
receiver - Distributed DOS (DDOS) multiple coordinated
sources swamp receiver - e.g., C and remote host SYN-attack A
C
A
B
Countermeasures?
51Internet security threats
- Denial of service (DOS) countermeasures
- filter out flooded packets (e.g., SYN) before
reaching host throw out good with bad - traceback to source of floods (most likely an
innocent, compromised machine)
C
A
B
52Firewalls
isolates organizations internal net from larger
Internet, allowing some packets to pass, blocking
others.
firewall
53Firewalls Why
- prevent denial of service attacks
- SYN flooding attacker establishes many bogus TCP
connections, no resources left for real
connections. - prevent illegal modification/access of internal
data. - e.g., attacker replaces CIAs homepage with
something else - allow only authorized access to inside network
(set of authenticated users/hosts) - two types of firewalls
- application-level
- packet-filtering
54Packet Filtering
Should arriving packet be allowed in? Departing
packet let out?
- internal network connected to Internet via router
firewall - router filters packet-by-packet, decision to
forward/drop packet based on - source IP address, destination IP address
- TCP/UDP source and destination port numbers
- ICMP message type
- TCP SYN and ACK bits
55Packet Filtering
- Example 1 block incoming and outgoing datagrams
with IP protocol field 17 and with either
source or dest port 23. - All incoming and outgoing UDP flows and telnet
connections are blocked. - Example 2 Block inbound TCP segments with ACK0.
- Prevents external clients from making TCP
connections with internal clients, but allows
internal clients to connect to outside.
56Application gateways
gateway-to-remote host telnet session
host-to-gateway telnet session
- Filters packets on application data as well as on
IP/TCP/UDP fields. - Example allow select internal users to telnet
outside.
application gateway
router and filter
1. Require all telnet users to telnet through
gateway. 2. For authorized users, gateway sets up
telnet connection to dest host. Gateway relays
data between 2 connections 3. Router filter
blocks all telnet connections not originating
from gateway.
57Limitations of firewalls and gateways
- IP spoofing router cant know if data really
comes from claimed source - if multiple apps. need special treatment, each
has own app. gateway. - client software must know how to contact gateway.
- e.g., must set IP address of proxy in Web browser
- filters often use all or nothing policy for UDP.
- tradeoff degree of communication with outside
world, level of security - many highly protected sites still suffer from
attacks.