EECS 122 Introduction to Computer Networks Network Security

  • Slides: 54
Download presentation
EECS 122: Introduction to Computer Networks Network Security Computer Science Division Department of Electrical

EECS 122: Introduction to Computer Networks Network Security Computer Science Division Department of Electrical Engineering and Computer Sciences University of California, Berkeley, CA 94720 -1776 EECS 122 - UCB Katz, Stoica F 04

Motivation § Internet currently used for important services - Financial transactions, medical records §

Motivation § Internet currently used for important services - Financial transactions, medical records § Used in near future for even more critical services - 911 (Vo. IP), surgical operations, energy system control, transportation system control § Networks more open than ever before - Global, ubiquitous Internet, wireless § Malicious Users - Selfish users: want more network resources than you - Malicious users: would hurt you even if it doesn’t get them more network resources Katz, Stoica F 04 2

Network Security Problems § Host Compromise - Attacker gains control of a host §

Network Security Problems § Host Compromise - Attacker gains control of a host § Denial-of-Service - Attacker prevents legitimate users from gaining service § Attack can be both - E. g. , host compromise that provides resources for denial-of-service Katz, Stoica F 04 3

Host Compromise § One of earliest major Internet security incidents - Internet Worm (1988):

Host Compromise § One of earliest major Internet security incidents - Internet Worm (1988): compromised almost every BSD-derived machine on Internet § § Today: estimated that a single worm could compromise 10 M hosts in < 5 min Attacker gains control of a host - Reads data Erases data Compromises another host Launches denial-of-service attack on another host Katz, Stoica F 04 4

Definitions § Worm - Replicates itself - Usually relies on stack overflow attack §

Definitions § Worm - Replicates itself - Usually relies on stack overflow attack § Virus - Program that attaches itself to another (usually trusted) program § Trojan horse - Program that allows a hacker a “back door” - Usually relies on user exploitation Katz, Stoica F 04 5

Host Compromise: Stack Overflow § § § Typical code has many bugs because those

Host Compromise: Stack Overflow § § § Typical code has many bugs because those bugs are not triggered by common input Network code is vulnerable because it accepts input from the network Network code that runs with high privileges (i. e. , as root) is especially dangerous - E. g. , web server Katz, Stoica F 04 6

Example § What is wrong here? // Copy a variable length user name from

Example § What is wrong here? // Copy a variable length user name from a packet #define MAXNAMELEN 64 int offset = OFFSET_USERNAME; char username[MAXNAMELEN]; int name_len; name_len = packet[offset]; memcpy(&username, packet[offset + 1], name_len); 0 34 packet name_len name Katz, Stoica F 04 7

Example Stack void foo(packet) { #define MAXNAMELEN 64 int offset = OFFSET_USERNAME; char username[MAXNAMELEN];

Example Stack void foo(packet) { #define MAXNAMELEN 64 int offset = OFFSET_USERNAME; char username[MAXNAMELEN]; int name_len; name_len = packet[offset]; memcpy(&username, packet[offset + 1], name_len); … } X X-4 X-8 “foo” return address offset username X-72 X-76 name_len Katz, Stoica F 04 8

Example Stack void foo(packet) { #define MAXNAMELEN 64 int offset = OFFSET_USERNAME; char username[MAXNAMELEN];

Example Stack void foo(packet) { #define MAXNAMELEN 64 int offset = OFFSET_USERNAME; char username[MAXNAMELEN]; int name_len; name_len = packet[offset]; memcpy(&username, packet[offset + 1], name_len); … } X X-4 X-8 “foo” return address offset username X-72 X-76 name_len Katz, Stoica F 04 9

Effect of Stack Overflow § Write into part of the stack or heap -

Effect of Stack Overflow § Write into part of the stack or heap - Write arbitrary code to part of memory - Cause program execution to jump to arbitrary code § Worm - Probes host for vulnerable software - Sends bogus input - Attacker can do anything that the privileges of the buggy program allows • Launches copy of itself on compromised host - Spread at exponential rate - 10 M hosts in < 5 minutes Katz, Stoica F 04 10

Worm Spreading Epidemic Models f = (e K(t-T) – 1) / (1+ e K(t-T)

Worm Spreading Epidemic Models f = (e K(t-T) – 1) / (1+ e K(t-T) ) § f – fraction of hosts infected § K – rate at which one host can compromise others § T – start time of the attack f 1 T t Katz, Stoica F 04 11

Worm Examples § Morris worm (1988) Code Red (2001) MS Slammer (January 2003) MS

Worm Examples § Morris worm (1988) Code Red (2001) MS Slammer (January 2003) MS Blaster (August 2003) § Worm History Site: § § § http: //en. wikipedia. org/wiki/Notable_computer_viruses_and_worms § Latest listing at: http: //enterprisesecurity. symantec. com/article. cfm? articleid=2420 Katz, Stoica F 04 12

Morris Worm (1988) § Infect multiple types of machines (Sun 3 and VAX) -

Morris Worm (1988) § Infect multiple types of machines (Sun 3 and VAX) - Spread using a Sendmail bug § Attack multiple security holes including - Buffer overflow in fingerd - Debugging routines in Sendmail - Password cracking § Intend to be benign but it had a bug - Fixed probability that the worm wouldn’t quit after re-infecting a machine number of worm on a host built up rendering the machine unusable Katz, Stoica F 04 13

Code Red Worm (2001) § § Attempts to connect to TCP port 80 on

Code Red Worm (2001) § § Attempts to connect to TCP port 80 on a randomly chosen host If successful, the attacking host sends a crafted HTTP GET request to the victim, attempting to exploit a buffer overflow See http: //www. cert. org/advisories/CA-2001 -19. html Worm “bug”: all copies of the worm use the same random generator to scan new hosts - Do. S attack on those hosts - Slow to infect new hosts § 2 nd gen Code Red fixed this bug! - Result: it spread much faster Katz, Stoica F 04 14

MS SQL Slammer (January 2003) § Uses UDP port 1434 to exploit a buffer

MS SQL Slammer (January 2003) § Uses UDP port 1434 to exploit a buffer overflow in MS SQL server - See http: //www. cert. org/advisories/CA-2003 -04. html § Effect - Generate massive amounts of network packets - Brought down 5 of the 13 Internet root name servers § Others - Worm only spreads as an in-memory process: it never writes itself to the hard drive • Solution: close UDP port on firewall and reboot Katz, Stoica F 04 15

MS SQL Slammer (January 2003) § xx (From http: //www. f-secure. com/v-descs/mssqlm. shtml) Katz,

MS SQL Slammer (January 2003) § xx (From http: //www. f-secure. com/v-descs/mssqlm. shtml) Katz, Stoica F 04 16

MS SQL Slammer (January 2003) § xx (From http: //www. f-secure. com/v-descs/mssqlm. shtml) Katz,

MS SQL Slammer (January 2003) § xx (From http: //www. f-secure. com/v-descs/mssqlm. shtml) Katz, Stoica F 04 17

MS Blaster (August 2003) § § § Exploit a buffer overflow vulnerability of the

MS Blaster (August 2003) § § § Exploit a buffer overflow vulnerability of the RPC (Remote Procedure Call) service Scan a random IP range to look for vulnerable systems on TCP port 135 Open TCP port 4444 (system shell), which could allow an attacker to execute commands on the system Generated Do. S attack on windowsupdate. com for certain versions of Windows See http: //www. cert. org/advisories/CA-2003 -20. html Katz, Stoica F 04 18

Hall of Shame § Software that have had many stack overflow bugs: - BIND

Hall of Shame § Software that have had many stack overflow bugs: - BIND (most popular DNS server) - RPC (Remote Procedure Call, used for NFS) • NFS (Network File System), widely used at UCB - Sendmail (most popular UNIX mail delivery software) - IIS (Windows web server) - SNMP (Simple Network Management Protocol, used to manage routers and other network devices) Katz, Stoica F 04 19

Potential Solutions § Don’t write buggy software - It’s not like people try to

Potential Solutions § Don’t write buggy software - It’s not like people try to write buggy software § Type-safe Languages - Unrestricted memory access of C/C++ contributes to problem - Use Java, Perl, or Python instead § OS architecture - Compartmentalize programs better, so one compromise doesn’t compromise the entire system - E. g. , DNS server doesn’t need total system access § Firewalls Katz, Stoica F 04 20

Firewall § § Security device whose goal is to prevent computers from outside to

Firewall § § Security device whose goal is to prevent computers from outside to gain control to inside machines Hardware or software Attacker Firewall Internet Katz, Stoica F 04 21

Firewall (cont’d) § Restrict traffic between Internet and devices (machines) behind it based on

Firewall (cont’d) § Restrict traffic between Internet and devices (machines) behind it based on - Source address and port number - Payload - Stateful analysis of data § Examples of rules - Block any external packets not for port 80 - Block any email with an attachment - Block any external packets with an internal IP address • Ingress filtering Katz, Stoica F 04 22

Firewalls: Properties § § § Easier to deploy firewall than secure all Internal hosts

Firewalls: Properties § § § Easier to deploy firewall than secure all Internal hosts Doesn’t prevent user exploitation Tradeoff between availability of services (firewall passes more ports on more machines) and security - If firewall is too restrictive, users will find way around it, thus compromising security - E. g. , have all services use port 80 Katz, Stoica F 04 23

Host Compromise: User Exploitation § Some security architectures rely on the user to decide

Host Compromise: User Exploitation § Some security architectures rely on the user to decide if a potentially dangerous action should be taken, e. g. , - Run code downloaded from the Internet • “Do you accept content from Microsoft? ” - Run code attached to email • “subject: You’ve got to see this!” - Allow a macro in a data file to be run • “Here is the latest version of the document. ” Katz, Stoica F 04 24

User Exploitation § Users not good at making this decision - Which of the

User Exploitation § Users not good at making this decision - Which of the following is the real name Microsoft uses when you download code from them? • Microsoft, Inc. • Microsoft Corporation § Typical email attack - Attacker sends email to some initial victims - Reading the email / running its attachment / viewing its attachment opens the hole - Worm/trojan/virus mails itself to everyone in address book Katz, Stoica F 04 25

Solutions § § § OS architecture Don’t ask the users questions which they don’t

Solutions § § § OS architecture Don’t ask the users questions which they don’t know how to answer anyway Separate code and data - Viewing data should not launch attack § Be very careful about installing new software Katz, Stoica F 04 26

Denial of Service § Huge problem in current Internet - Major sites attacked: Yahoo!,

Denial of Service § Huge problem in current Internet - Major sites attacked: Yahoo!, Amazon, e. Bay, CNN, Microsoft - 12, 000 attacks on 2, 000 organizations in 3 weeks - Some more that 600, 000 packets/second • More than 192 Mb/s - Almost all attacks launched from compromised hosts § General Form - Prevent legitimate users from gaining service by overloading or crashing a server - E. g. , SYN attack Katz, Stoica F 04 27

Effect on Victim § § Buggy implementations allow unfinished connections to eat all memory,

Effect on Victim § § Buggy implementations allow unfinished connections to eat all memory, leading to crash Better implementations limit the number of unfinished connections - Once limit reached, new SYNs are dropped § Effect on victim’s users - Users can’t access the targeted service on the victim because the unfinished connection queue is full Do. S Katz, Stoica F 04 28

SYN Attack (Recap: 3 -Way Handshaking) § Goal: agree on a set of parameters:

SYN Attack (Recap: 3 -Way Handshaking) § Goal: agree on a set of parameters: the start sequence number for each side - Starting sequence numbers are random Server Client (initiator) SYN, Seq Num = x SYN and Ack = d n a y = Num ACK, Seq ACK, Ack x+1 =y+1 Katz, Stoica F 04 29

SYN Attack § Attacker: send at max rate TCP SYN with random spoofed source

SYN Attack § Attacker: send at max rate TCP SYN with random spoofed source address to victim - Spoofing: use a different source IP address than own - Random spoofing allows one host to pretend to be many § Victim receives many SYN packets - Send SYN+ACK back to spoofed IP addresses - Holds some memory until 3 -way handshake completes • Usually never, so victim times out after long period (e. g. , 3 minutes) Katz, Stoica F 04 30

Solution: SYN Cookies § § Special calculations to create initial sequence number Server: send

Solution: SYN Cookies § § Special calculations to create initial sequence number Server: send SYN-ACK with sequence number y, where - y = H(client_IP_addr, client_port) - H(): one-way hash function § Client: send ACK containing y+1 - Note: Client has to be real and has to have initiated the transaction § Server: - Verify if y = H(client_IP_addr, client_port) - If verification passes, allocate memory § Server doesn’t allocate memory if client’s address is spoofed Katz, Stoica F 04 31

Dealing with Attacks § § Distinguish attack from flash crowd (i. e. , surge

Dealing with Attacks § § Distinguish attack from flash crowd (i. e. , surge in traffic) Prevent damage - Distinguish attack from legitimate traffic - Rate limit attack traffic § Stop attack - Identify attacking machines - Shutdown attacking machines - Usually done manually, requires cooperation of ISPs, other users § Identify attacker - Very difficult, except … - Usually brags/gloats about attack on IRC - Also done manually, requires cooperation of ISPs, other users Katz, Stoica F 04 37

Incomplete Solutions § § § Fair queueing, rate limiting (e. g. , token bucket)

Incomplete Solutions § § § Fair queueing, rate limiting (e. g. , token bucket) Prevent a user from sending at 10 Mb/s and hurting a user sending at 1 Mb/s Does not prevent 10 users from sending at 1 Mb/s and hurting a user sending a 1 Mb/s Katz, Stoica F 04 38

Identifying and Stop Attacking Machines § § § Defeat spoofed source addresses Does not

Identifying and Stop Attacking Machines § § § Defeat spoofed source addresses Does not stop or slow attack Egress filtering - A domain’s border router drop outgoing packets which do not have a valid source address for that domain - If universal, could abolish spoofing § IP Traceback - Routers probabilistically tag packets with an identifier - Destination can infer path to true source after receiving enough packets Katz, Stoica F 04 39

Summary § Network security is possibly the Internet’s biggest problem - Preventing Internet from

Summary § Network security is possibly the Internet’s biggest problem - Preventing Internet from expanding into critical applications § Host Compromise - Poorly written software - Solutions: better OS security architecture, type-safe languages, firewalls § Denial-of-Service - No easy solution: Do. S can happen at many levels Katz, Stoica F 04 40

What You Need to Know § § § Buffer overflow attack Worms Denial of

What You Need to Know § § § Buffer overflow attack Worms Denial of service (Do. S) attack Katz, Stoica F 04 41

Security Requirements § Authentication - Ensures sender and receiver are who they claim to

Security Requirements § Authentication - Ensures sender and receiver are who they claim to be § Data integrity - Ensure that data is not changed from source to destination § Confidentiality - Ensures that data is read only by authorized users § Non-repudiation - Ensures that the sender has strong evidence that receiver has received the message, and the receiver has strong evidence of the sender identity, strong enough such that the sender cannot deny that it has sent the message and the receiver cannot deny that it has received the message (not discussed in this lecture) Katz, Stoica F 04 42

Cryptographic Algorithms § Security foundation: cryptographic algorithms - Secret key cryptography, Data Encryption Standard

Cryptographic Algorithms § Security foundation: cryptographic algorithms - Secret key cryptography, Data Encryption Standard (DES) - Public key cryptography, RSA algorithm - Message digest, MD 5 Katz, Stoica F 04 43

Public-Key Cryptography: RSA (Rivest, Shamir, Adleman) § Sender uses a public key - Advertised

Public-Key Cryptography: RSA (Rivest, Shamir, Adleman) § Sender uses a public key - Advertised to everyone § Receiver uses a private key Plaintext Encrypt with public key Internet Decrypt with private key Ciphertext Katz, Stoica F 04 47

Generating Public and Private Keys § § § Choose two large prime numbers p

Generating Public and Private Keys § § § Choose two large prime numbers p and q (~ 256 bit long) and multiply them: n = p*q Chose encryption key e such that e and (p-1)*(q-1) are relatively prime Compute decryption key d, where d = e-1 mod ((p-1)*(q-1)) (equivalent to d*e = 1 mod ((p-1)*(q-1))) Public key consist of pair (n, e) Private key consists of pair (d, n) Katz, Stoica F 04 48

RSA Encryption and Decryption § Encryption of message block m: - c = me

RSA Encryption and Decryption § Encryption of message block m: - c = me mod n § Decryption of ciphertext c: - m = cd mod n Katz, Stoica F 04 49

Properties § § Confidentiality Receiver A computes n, e, d, and sends out (n,

Properties § § Confidentiality Receiver A computes n, e, d, and sends out (n, e) - To send message to A, use (n, e) to encrypt it § § § How difficult is to recover d ? (Someone that can do this can decrypt any message sent to A!) Recall that d = e-1 mod ((p-1)*(q-1)) So to find d, you need to find primes factors p and q - This is provable very difficult Katz, Stoica F 04 50

Public Key Infrastructure (PKI) § § § System managing public key distribution on a

Public Key Infrastructure (PKI) § § § System managing public key distribution on a wide-scale Trust distribution mechanism Allow any arbitrary level of trust Katz, Stoica F 04 54

PKI Properties § § Authentication via Digital Certificates Confidentiality via Encryption Integrity via Digital

PKI Properties § § Authentication via Digital Certificates Confidentiality via Encryption Integrity via Digital Signatures Non–Repudiation via Digital Signatures Katz, Stoica F 04 55

Components of a PKI Katz, Stoica F 04 56

Components of a PKI Katz, Stoica F 04 56

Digital Certificate § Signed data structure that binds an entity with its corresponding public

Digital Certificate § Signed data structure that binds an entity with its corresponding public key - Signed by a recognized and trusted authority, i. e. , Certification Authority (CA) - Provide assurance that a particular public key belongs to a specific entity Katz, Stoica F 04 57

Certification Authority § § People, processes responsible for creation, delivery and management of digital

Certification Authority § § People, processes responsible for creation, delivery and management of digital certificates Organized in an hierarchy Root CA CA-1 CA-2 Katz, Stoica F 04 58

Registration Authority § People, processes and/or tools responsible for - Authenticating identity of new

Registration Authority § People, processes and/or tools responsible for - Authenticating identity of new entities (users or computing devices) - Requiring certificates from CA’s. Katz, Stoica F 04 59

Certificate Repository § Database that is accessible to all users of a PKI, contains:

Certificate Repository § Database that is accessible to all users of a PKI, contains: - Digital certificates, - Certificate revocation information - Policy information Katz, Stoica F 04 60

Example § Alice generates her own key pair. private key Alice public key Alice

Example § Alice generates her own key pair. private key Alice public key Alice § Bob generates his own key pair. private key Bob public key Bob § Both sent their public key to a CA and receive a digital certificate Katz, Stoica F 04 61

Example § Alice gets Bob’s public key from the CA private key Alice §

Example § Alice gets Bob’s public key from the CA private key Alice § y ke lic b b o pu B Bob gets Alice’s public key from the CA pu bl Al ic k ic ey e private key Bob Katz, Stoica F 04 62

Example § Alice use private key to sign: use public key cryptography to provide

Example § Alice use private key to sign: use public key cryptography to provide integrity Alice Message Bob Hash Encryption Decryption Alice Private Message ? = Hash Alice Public Katz, Stoica F 04 63

Certificate Revocation § § Process of publicly announcing that a certificate has been revoked

Certificate Revocation § § Process of publicly announcing that a certificate has been revoked and should no longer be used Approaches: - Use certificates that automatically time out - Use certificate revocation list - Use list that itemizes all revoked certificates in an online directory Katz, Stoica F 04 64

What You Need To Know § § Security requirements Cryptographic algorithms - How does

What You Need To Know § § Security requirements Cryptographic algorithms - How does DES and RSA work (no proof for RSA) § § Authentication algorithms Public key management, digital certificates (high level) Katz, Stoica F 04 69