网络安全(Security)

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

security.png

  • 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

cryptography_language.png

  • $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_cryptography.png

  • 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

simple_encryption_scheme.png

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

more_sophisticated_encryption_approach.png

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

DES_operation.jpg

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_cryptography.png

Public key encryption algorithms

requirements:

    1. need $K_B^{+}( )$ and $K_B^{-}( )$ such that $K_B^{-}(K_B^{+}(m)) = m $
    1. 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

authentication_ap5.0.png

  • man (or woman) in the middle attack: Trudy poses as Alice (to Bob) and as Bob (to Alice)

authentication_ap5.0_securityHole.png

  • 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)$

digital_signature.png

  • 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:

signed_message_digest.png

Alice verifies signature, integrity of digitally signed message:

signed_message_digest2.png

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”

certification_authorities.png

  • 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

certification_authorities2.png

Secure e-mail

  • Alice wants to send confidential e-mail, m, to Bob.

secure_email.png

  • 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

secure_email2.png

  • Alice digitally signs message
  • sends both message (in the clear) and digital signature

  • Alice wants to provide secrecy, sender authentication, message integrity.

secure_email3.png

  • 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_TCP_IP.png

  • 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)
  1. client sends list of algorithms it supports, along with client nonce

  2. server chooses algorithms from list; sends back: choice + certificate + server nonce

  3. client verifies certificate, extracts server’s public key, generates pre_master_secret, encrypts with server’s public key, sends to server

  4. client and server independently compute encryption and MAC keys from pre_master_secret and nonces

  5. client sends a MAC of all the handshake messages

  6. 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

SSL_record_protocol.png

  • 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:

SSL_record_format.png

  • data and MAC encrypted (symmetric algorithm)

Real SSL connection

SSL_real_connection.png

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

VPNs.png

IPsec services

  • data integrity
  • origin authentication
  • replay attack(重放攻击) prevention
  • confidentiality

  • two protocols providing different service models:

    • AH
    • ESP

IPsec transport mode

IPsec.png

  • IPsec datagram emitted and received by end-system
  • protects upper level protocols

IPsec – tunneling mode

IPsec_tunneling_mode.png

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:

IPsec_combination.png

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?

SAfromR1toR2.png

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

IPsec_datagram.png

  • 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:
1
2
3
4
5
6
7
8
9
Example SA
SPI: 12345
Source IP: 200.168.1.100
Dest IP: 193.68.2.23
Protocol: ESP
Encryption algorithm: 3DES-cbc
HMAC algorithm: MD5
Encryption key: 0x7aeaca…
HMAC key:0xc0291f…
  • 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:

symmetric_stream_ciphers.png

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:

stream_cipher_packet_independence.png

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_encryption.png

WEP_encryption2.png

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

WEP_authentication.png

  • 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

802.11i.png

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)

EAP.png

Operational security: firewalls and IDS

Firewalls

  • firewall : isolates organization’s internal net from larger Internet, allowing some packets to pass, blocking others

firewall.png

  • 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.

firewall_stateless_packet_filtering_eg.png

Access Control Lists

  • ACL: table of rules, applied top to bottom to incoming packets: (action, condition) pairs: looks like OpenFlow forwarding (Ch. 4)!

ACL.png

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

firewall_stateful_packet_filtering_eg.png

Application gateways

application_gateways.png

  • filter packets on application data as well as on IP/TCP/UDP fields.
    • example: allow select internal users to telnet outside
  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.

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

IDS.png