What is network security
- confidentiality(机密性): only sender, intended receiver should “understand” message contents
- sender encrypts message
- receiver decrypts message
authentication(身份验证): sender, receiver want to confirm identity of each other
message integrity(完整性): sender, receiver want to ensure message not altered (in transit, or afterwards) without detection
access and availability(可用性): services must be accessible and available to users
Friends and enemies: Alice, Bob, Trudy
- well-known in network security world
- Bob, Alice (lovers!) want to communicate “securely”
- Trudy (intruder) may intercept, delete, add messages
- There are bad guys (and girls) out there!
- Q: What can a “bad guy” do?
- A: A lot! See section 1.6
- eavesdrop(窃听): intercept messages
- actively insert messages into connection
- impersonation: can fake (spoof) source address in packet (or any field in packet)
- hijacking(劫持): “take over” ongoing connection by removing sender or receiver, inserting himself in place
- denial of service(拒绝服务): prevent service from being used by others (e.g., by overloading resources)
Principles of cryptography
The language of cryptography
- $m$ : plaintext message
- $K_A(m) : ciphertext, encrypted with key KA
- $m = K_B(K_A(m))$
Breaking an encryption scheme(破解加密方案)
- cipher-text only attack: Trudy has ciphertext she can analyze
- two approaches:
- brute force: search through all keys
- statistical analysis
known-plaintext attack: Trudy has plaintext corresponding to ciphertext
- e.g., in monoalphabetic cipher, Trudy determines pairings for a,l,i,c,e,b,o,
chosen-plaintext attack: Trudy can get ciphertext for chosen plaintext
Symmetric key cryptography
- symmetric key crypto(对称密钥加密): Bob and Alice share same (symmetric) key: $K_S$
- e.g., key is knowing substitution pattern in mono alphabetic substitution cipher
- Q: how do Bob and Alice agree on key value?
Simple encryption scheme
- substitution cipher: substituting one thing for another
- monoalphabetic cipher: substitute one letter for another
A more sophisticated encryption approach
- n substitution ciphers, M1,M2,…,Mn
- cycling pattern:
- e.g., n=4: M1,M3,M4,M3,M2; M1,M3,M4,M3,M2; ..
- for each new plaintext symbol, use subsequent substitution pattern in cyclic pattern
- dog: d from M1, o from M3, g from M4
Symmetric key crypto: DES
- DES: Data Encryption Standard
- US encryption standard [NIST 1993]
- 56-bit symmetric key, 64-bit plaintext input
- block cipher with cipher block chaining
- how secure is DES?
- DES Challenge: 56-bit-key-encrypted phrase decrypted (brute force) in less than a day
- no known good analytic attack
- making DES more secure:
- 3DES: encrypt 3 times with 3 different keys
DES operation
- initial permutation
- 16 identical “rounds” of function application, each using different 48 bits of key
- final permutation
AES: Advanced Encryption Standard
- symmetric-key NIST standard, replaced DES (Nov 2001)
- processes data in 128 bit blocks
- 128, 192, or 256 bit keys
- brute force decryption (try each key) taking 1 sec on DES, takes 149 trillion years for AES
Public Key Cryptography
- symmetric key crypto requires sender, receiver know shared secret key
Q: how to agree on key in first place (particularly if never “met”)?
public key crypto
- 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
Public key encryption algorithms
requirements:
- need $K_B^{+}( )$ and $K_B^{-}( )$ such that $K_B^{-}(K_B^{+}(m)) = m $
- given public key $K_B^{+}$, it should be impossible to compute private key $K_B^{-}$
RSA: Rivest, Shamir, Adelson algorithm
Authentication
- 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
- ap4.0 requires shared symmetric key
- can we authenticate using public key techniques?
- ap5.0: use nonce, public key cryptography
- man (or 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!
Message integrity
Digital 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
simple digital signature for message m:
- Bob signs m by encrypting with his private key $K_B^{-}$, creating “signed” message, $K_B^{-}(m)$
- suppose Alice receives msg m, with signature: m, $K_B^{-}(m)$
- Alice verifies m signed by Bob by applying Bob’s public key $K_B^{+}$ to $K_B^{-}(m)$ then checks $K_B^{+}(K_B^{-}(m)) = m$.
If $K_B^{+}(K_B^{-}(m)) = m$, whoever signed m must have used Bob’s 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 $K_B^{-}(m)$ to court and prove that Bob signed m
Message 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)
Digital signature = signed message digest
Bob sends digitally signed message:
Alice verifies signature, integrity of digitally signed message:
Hash 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
Certification authorities
certification authority (CA): binds public key to particular entity, E.
E (person, router) registers its public key with CA.
- E provides “proof of identity” to CA.
- CA creates certificate binding E to its public key.
- certificate containing E’s public key digitally signed by CA – CA says “this is E’s public key”
- when Alice wants Bob’s public key:
- gets Bob’s certificate (Bob or elsewhere).
- apply CA’s public key to Bob’s certificate, get Bob’s public key
Secure e-mail
- Alice wants to send confidential e-mail, m, to Bob.
- Alice:
- generates random symmetric private key, $K_S$
- encrypts message with $K_S$ (for efficiency)
- also encrypts $K_S$ with Bob’s public key
- sends both $K_S(m)$ and $K_B(K_S)$ to Bob
Bob:
- uses his private key to decrypt and recover $K_S$
- uses $K_S$ to decrypt $K_S(m)$ to recover m
Alice wants to provide sender authentication message integrity
- Alice digitally signs message
sends both message (in the clear) and digital signature
Alice wants to provide secrecy, sender authentication, message integrity.
- Alice uses three keys: her private key, Bob’s public key, newly created symmetric key
Securing TCP connections: SSL
SSL: Secure Sockets Layer
- widely deployed security protocol
- supported by almost all browsers, web servers
- https
- billions $/year over SSL
- mechanisms: [Woo 1994], implementation: Netscape
- variation -TLS: transport layer security, RFC 2246
- provides
- confidentiality(机密性)
- integrity(完整性)
- authentication(身份验证)
original goals:
- Web e-commerce transactions
- encryption (especially credit-card numbers)
- Web-server authentication
- optional client authentication
- minimum hassle in doing business with new merchant
available to all TCP applications
- secure socket interface
SSL and TCP/IP
- SSL provides application programming interface (API) to applications
C and Java SSL libraries/classes readily available
Could do something like PGP:
- but want to send byte streams & interactive data
- want set of secret keys for entire connection
- want certificate exchange as part of protocol: handshake phase
Toy SSL: a simple secure channel
- handshake: Alice and Bob use their certificates, private keys to authenticate each other and exchange shared secret
- key derivation: Alice and Bob use shared secret to derive set of keys
- data transfer: data to be transferred is broken up into series of records
- connection closure: special messages to securely close connection
SSL cipher suite
- cipher suite(加密套件)
- public-key algorithm
- symmetric encryption algorithm
- MAC algorithm
- SSL supports several cipher suites
- negotiation: client, server agree on cipher suite
- client offers choice
- server picks one
common SSL symmetric ciphers
- DES – Data Encryption Standard: block
- 3DES – Triple strength: block
- RC2 – Rivest Cipher 2: block
- RC4 – Rivest Cipher 4: stream
- SSL Public key encryption
- RSA
Real SSL: handshake
- Purpose
- server authentication
- negotiation: agree on crypto algorithms
- establish keys
- client authentication (optional)
client sends list of algorithms it supports, along with client nonce
server chooses algorithms from list; sends back: choice + certificate + server nonce
client verifies certificate, extracts server’s public key, generates pre_master_secret, encrypts with server’s public key, sends to server
client and server independently compute encryption and MAC keys from pre_master_secret and nonces
client sends a MAC of all the handshake messages
server sends a MAC of all the handshake messages
- last 2 steps protect handshake from tampering(篡改)
- client typically offers range of algorithms, some strong, some weak
- man-in-the middle could delete stronger algorithms from list
- last 2 steps prevent this
- last two messages are encrypted
why two random nonces?
- suppose Trudy sniffs all messages between Alice & Bob
- next day, Trudy sets up TCP connection with Bob, sends exact same sequence of records
- Bob (Amazon) thinks Alice made two separate orders for the same thing
- solution: Bob sends different random nonce for each connection. This causes encryption keys to be different on the two days
- Trudy’s messages will fail Bob’s integrity check
SSL record protocol
- record header: content type; version; length
- MAC: includes sequence number, MAC key $M_x$
- fragment: each SSL fragment 2^14 bytes (~16 Kbytes)
SSL record format:
- data and MAC encrypted (symmetric algorithm)
Real SSL connection
Key derivation
- client nonce, server nonce, and pre-master secret input into pseudo random-number generator.
- produces master secret
- master secret and new nonces input into another random-number generator: “key block”
- because of resumption: TBD
- key block sliced and diced:
- client MAC key
- server MAC key
- client encryption key
- server encryption key
- client initialization vector (IV)
- server initialization vector (IV)
Network layer security: IPsec
Virtual Private Networks (VPNs)
- motivation:
- institutions often want private networks for security.
- costly: separate routers, links, DNS infrastructure.
- VPN: institution’s inter-office traffic is sent over public Internet instead
- encrypted before entering public Internet
- logically separate from other traffic
IPsec services
- data integrity
- origin authentication
- replay attack(重放攻击) prevention
confidentiality
two protocols providing different service models:
- AH
- ESP
IPsec transport mode
- IPsec datagram emitted and received by end-system
- protects upper level protocols
IPsec – tunneling mode
Two IPsec protocols
- Authentication Header (AH) protocol
- provides source authentication & data integrity but not confidentiality
- Encapsulation Security Protocol (ESP)
- provides source authentication, data integrity, and confidentiality
- more widely used than AH
Four combinations are possible:
Security associations (SAs)
- before sending data, “security association (SA)” established from sending to receiving entity
- SAs are simplex: for only one direction
ending, receiving entitles maintain state information about SA
- recall: TCP endpoints also maintain state info
- IP is connectionless; IPsec is connection-oriented!
how many SAs in VPN w/ headquarters, branch office, and n traveling salespeople?
R1 stores for SA:
32-bit SA identifier: Security Parameter Index (SPI)
origin SA interface (200.168.1.100)
destination SA interface (193.68.2.23)
type of encryption used (e.g., 3DES with CBC)
encryption key
type of integrity check used (e.g., HMAC with MD5)
authentication key
- Security Association Database (SAD)
- endpoint holds SA state in security association database (SAD), where it can locate them during processing.
- with n salespersons, 2 + 2n SAs in R1’s SAD
- when sending IPsec datagram, R1 accesses SAD to determine how to process datagram.
- when IPsec datagram arrives to R2, R2 examines SPI in IPsec datagram, indexes SAD with SPI, and processes datagram accordingly.
IPsec datagram
- focus for now on tunnel mode with ESP
- ESP trailer: Padding for block ciphers
- ESP header:
- SPI, so receiving entity knows what to do
- Sequence number, to thwart replay attacks
- MAC in ESP auth field is created with shared secret key
R1: convert original datagram to IPsec datagram
- appends to back of original datagram (which includes original header fields!) an “ESP trailer” field.
- encrypts result using algorithm & key specified by SA.
- appends to front of this encrypted quantity the “ESP header, creating “enchilada”.
- creates authentication MAC over the whole enchilada, using algorithm and key specified in SA;
- appends MAC to back of enchilada, forming payload;
- creates brand new IP header, with all the classic IPv4 header fields, which it appends before payload
IPsec sequence numbers
- for new SA, sender initializes seq. # to 0
- each time datagram is sent on SA:
- sender increments seq # counter
- places value in seq # field
- goal:
- prevent attacker from sniffing and replaying a packet
- receipt of duplicate, authenticated IP packets may disrupt service
- method:
- destination checks for duplicates
- doesn’t keep track of all received packets; instead uses a window
Security Policy Database (SPD)
- policy: For a given datagram, sending entity needs to know if it should use IPsec
- needs also to know which SA to use
- may use: source and destination IP address; protocol number
- info in SPD indicates “what” to do with arriving datagram
- info in SAD indicates “how” to do it
IKE: Internet Key Exchange
- previous examples: manual(手动) establishment of IPsec SAs in IPsec endpoints:
|
|
- manual keying is impractical for VPN with 100s of endpoints
- instead use IPsec IKE (Internet Key Exchange)
IKE: PSK and PKI
- authentication (prove who you are) with either
- pre-shared secret (PSK) or
- with PKI (pubic/private keys and certificates).
PSK: both sides start with secret
- run IKE to authenticate each other and to generate IPsec SAs (one in each direction), including encryption, authentication keys
PKI: both sides start with public/private key pair, certificate
- run IKE to authenticate each other, obtain IPsec SAs (one in each direction).
- similar with handshake in SSL.
IKE phases
- IKE has two phases
- phase 1: establish bi-directional IKE SA
- note: IKE SA different from IPsec SA
- aka ISAKMP security association
- phase 2: ISAKMP is used to securely negotiate IPsec pair of SAs
phase 1 has two modes: aggressive mode and main mode
- aggressive mode uses fewer messages
- main mode provides identity protection and is more flexible
IPsec summary
- IKE message exchange for algorithms, secret keys, SPI numbers
- either AH or ESP protocol (or both)
- AH provides integrity, source authentication
- ESP protocol (with AH) additionally provides encryption
- IPsec peers can be two end systems, two routers/firewalls, or a router/firewall and an end system
Securing wireless LANs
WEP design goals
- symmetric key crypto
- confidentiality
- end host authorization
- data integrity
- self-synchronizing: each packet separately encrypted
- given encrypted packet and key, can decrypt; can continue to decrypt packets when preceding packet was lost (unlike Cipher Block Chaining (CBC) in block ciphers)
- Efficient
- implementable in hardware or software
symmetric stream ciphers:
Stream cipher and packet independence
- recall design goal: each packet separately encrypted
- if for frame n+1, use keystream from where we left off for frame n, then each frame is not separately encrypted
- need to know where we left off for packet n
- WEP approach: initialize keystream with key + new IV for each packet:
WEP encryption
- sender calculates Integrity Check Value (ICV, four-byte hash/CRC over data
- each side has 104-bit shared key
- sender creates 24-bit initialization vector (IV), appends to key: gives 128-bit key
- sender also appends keyID (in 8-bit field)
- 128-bit key inputted into pseudo random number generator to get keystream
- data in frame + ICV is encrypted with RC4:
- bytes of keystream are XORed with bytes of data & ICV
- IV & keyID are appended to encrypted data to create payload
- payload inserted into 802.11 frame
WEP decryption
- receiver extracts IV
- inputs IV, shared secret key into pseudo random generator, gets keystream
- XORs keystream with encrypted data to decrypt data + ICV
- verifies integrity of data with ICV
- note: message integrity approach used here is different from MAC (message authentication code) and signatures (using PKI).
WEP authentication
- Notes:
- not all APs do it, even if WEP is being used
- AP indicates if authentication is necessary in beacon frame
- done before association
Breaking 802.11 WEP encryption
- security hole:
- 24-bit IV, one IV per frame, -> IV’s eventually reused
- IV transmitted in plaintext -> IV reuse detected
attack:
- Trudy causes Alice to encrypt known plaintext d1 d2 d3 d4 …
- Trudy sees: $c_i$ = $d_i$ XOR $k_i^{IV}$
- Trudy knows $c_i$ $d_i$, so can compute $k_i^{IV}$
- Trudy knows encrypting key sequence $k_1^{IV}$ $k_2^{IV}$ $k_3^{IV}$ …
- Next time IV is used, Trudy can decrypt!
802.11i: improved security
- numerous (stronger) forms of encryption possible
- provides key distribution
- uses authentication server separate from access point
four phases of operation
EAP: extensible authentication protocol
- EAP: end-end client (mobile) to authentication server protocol
- EAP sent over separate “links”
- mobile-to-AP (EAP over LAN)
- AP to authentication server (RADIUS over UDP)
Operational security: firewalls and IDS
Firewalls
- firewall : isolates organization’s internal net from larger Internet, allowing some packets to pass, blocking others
- 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 CIA’s homepage with something else
- prevent illegal modification/access of internal data
- e.g., attacker replaces CIA’s homepage with something else
- three types of firewalls:
- stateless packet filters
- stateful packet filters
- application gateways
Stateless packet filtering
- 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
example 1: block incoming and outgoing datagrams with IP protocol field = 17 and with either source or dest port = 23
- result: all incoming, outgoing UDP flows and telnet connections are blocked
example 2: block inbound TCP segments with ACK=0.
- result: prevents external clients from making TCP connections with internal clients, but allows internal clients to connect to outside.
Access Control Lists
- ACL: table of rules, applied top to bottom to incoming packets: (action, condition) pairs: looks like OpenFlow forwarding (Ch. 4)!
Stateful packet filtering
- stateless packet filter: heavy handed tool
- admits packets that “make no sense,” e.g., dest port = 80, ACK bit set, even though no TCP connection established:
stateful packet filter: track status of every TCP connection
- track connection setup (SYN), teardown (FIN): determine whether incoming, outgoing packets “makes sense”
- timeout inactive connections at firewall: no longer admit packets
ACL augmented to indicate need to check connection state table before admitting packet
Application gateways
- filter packets on application data as well as on IP/TCP/UDP fields.
- example: allow select internal users to telnet outside
require all telnet users to telnet through gateway.
for authorized users, gateway sets up telnet connection to dest host. Gateway relays data between 2 connections
router filter blocks all telnet connections not originating from gateway.
Limitations of firewalls, gateways
- IP spoofing: router can’t know if data “really” comes from claimed source
- if multiple app’s. 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
Intrusion detection systems(入侵检测系统)
- packet filtering:
- operates on TCP/IP headers only
- no correlation check among sessions
IDS: intrusion detection system
- deep packet inspection: look at packet contents (e.g., check character strings in packet against database of known virus, attack strings)
- examine correlation among multiple packets
- port scanning
- network mapping
- DoS attack
multiple IDSs: different types of checking at different locations