Computer Science 161 Fall 2016 Popa and Weaver
Network #3: TCP/IP
1
Network #3: TCP/IP 1 Spot the Zero Day: TPLink Miniature - - PowerPoint PPT Presentation
Computer Science 161 Fall 2016 Popa and Weaver Network #3: TCP/IP 1 Spot the Zero Day: TPLink Miniature Wireless Router Computer Science 161 Fall 2016 Popa and Weaver 2 Spot the Zero Day: TPLink Miniature Wireless Router
Computer Science 161 Fall 2016 Popa and Weaver
1
Computer Science 161 Fall 2016 Popa and Weaver
2
Computer Science 161 Fall 2016 Popa and Weaver
3
Computer Science 161 Fall 2016 Popa and Weaver
PLEASE TELL ME
4
Computer Science 161 Fall 2016 Popa and Weaver
(race once vs race-until-win)
5
Computer Science 161 Fall 2016 Popa and Weaver
6
Computer Science 161 Fall 2016 Popa and Weaver
7
4-bit Version 4-bit Header Length 8-bit Type of Service (TOS)
16-bit Total Length (Bytes) 16-bit Identification
3-bit Flags
13-bit Fragment Offset
8-bit Time to Live (TTL)
8-bit Protocol 16-bit Header Checksum 32-bit Source IP Address 32-bit Destination IP Address Options (if any) Payload
Computer Science 161 Fall 2016 Popa and Weaver
8
4-bit Version 4-bit Header Length 8-bit Type of Service (TOS)
16-bit Total Length (Bytes) 16-bit Identification
3-bit Flags
13-bit Fragment Offset
8-bit Time to Live (TTL)
8-bit Protocol 16-bit Header Checksum 32-bit Source IP Address 32-bit Destination IP Address Options (if any) Payload
Specifies the length of the entire IP packet: bytes in this header plus bytes in the Payload
Computer Science 161 Fall 2016 Popa and Weaver
9
4-bit Version 4-bit Header Length 8-bit Type of Service (TOS)
16-bit Total Length (Bytes) 16-bit Identification
3-bit Flags
13-bit Fragment Offset
8-bit Time to Live (TTL)
8-bit Protocol 16-bit Header Checksum 32-bit Source IP Address 32-bit Destination IP Address Options (if any) Payload
Specifies how to interpret the start
header of a Transport Protocol such as TCP or UDP
Computer Science 161 Fall 2016 Popa and Weaver
10
4-bit Version 4-bit Header Length 8-bit Type of Service (TOS)
16-bit Total Length (Bytes) 16-bit Identification
3-bit Flags
13-bit Fragment Offset
8-bit Time to Live (TTL)
8-bit Protocol 16-bit Header Checksum 32-bit Source IP Address 32-bit Destination IP Address Options (if any) Payload
Computer Science 161 Fall 2016 Popa and Weaver
11
4-bit Version 4-bit Header Length 8-bit Type of Service (TOS)
16-bit Total Length (Bytes) 16-bit Identification
3-bit Flags
13-bit Fragment Offset
8-bit Time to Live (TTL)
8-bit Protocol 16-bit Header Checksum 32-bit Source IP Address 32-bit Destination IP Address Options (if any) Payload
Computer Science 161 Fall 2016 Popa and Weaver
12
4-bit Version 4-bit Header Length 8-bit Type of Service (TOS)
16-bit Total Length (Bytes) 16-bit Identification
3-bit Flags
13-bit Fragment Offset
8-bit Time to Live (TTL)
8-bit Protocol 16-bit Header Checksum 32-bit Source IP Address 32-bit Destination IP Address Options (if any) Payload
Computer Science 161 Fall 2016 Popa and Weaver
13
Computer Science 161 Fall 2016 Popa and Weaver
table
14
source destination
IP network
Computer Science 161 Fall 2016 Popa and Weaver
15
Computer Science 161 Fall 2016 Popa and Weaver
16
AS 1 AS 2 AS 3 AS 4 AS 5 AS 4 Sender Recipient
Computer Science 161 Fall 2016 Popa and Weaver
Links can go down and the system will recover
, and
17
Computer Science 161 Fall 2016 Popa and Weaver
18
Computer Science 161 Fall 2016 Popa and Weaver
19
Host A Host B Host E Host D Host C Router 1 Router 2 Router 3 Router 4 Router 5 Router 6 Router 7
Host A communicates with Host D On-path Off-path Off-path
Computer Science 161 Fall 2016 Popa and Weaver
20
AS 1 AS 2 AS 3 AS 4 AS 5 AS 4 Sender Recipient
Computer Science 161 Fall 2016 Popa and Weaver
21
AS 1 AS 2 AS 3 AS 4 AS 5 AS 4 Sender Recipient
Computer Science 161 Fall 2016 Popa and Weaver
22
Application Transport (Inter)Network Link Physical 7 4 3 2 1 Source port Destination port Sequence number Acknowledgment Advertised window HdrLen Flags Checksum Urgent pointer Options (variable)
Data
Computer Science 161 Fall 2016 Popa and Weaver
23
Source port Destination port Sequence number Acknowledgment Advertised window HdrLen Flags Checksum Urgent pointer Options (variable)
Data
These plus IP addresses define a given connection
Computer Science 161 Fall 2016 Popa and Weaver
24
Source port Destination port Sequence number Acknowledgment Advertised window HdrLen Flags Checksum Urgent pointer Options (variable)
Data
Used to order data in the connection: client program receives data in order
Computer Science 161 Fall 2016 Popa and Weaver
25
Source port Destination port Sequence number Acknowledgment Advertised window HdrLen Flags Checksum Urgent pointer Options (variable)
Data
Used to say how much data has been received
Computer Science 161 Fall 2016 Popa and Weaver
26
Source port Destination port Sequence number Acknowledgment Advertised window HdrLen Flags Checksum Urgent pointer Options (variable)
Data
Flags have different meaning: SYN: Synchronize, used to initiate a connection ACK: Acknowledge, used to indicate acknowledgement of data FIN: Finish, used to indicate no more data will be sent (but can still receive and acknowledge data) RST: Reset, used to terminate the connection completely
Computer Science 161 Fall 2016 Popa and Weaver
27
Client (initiator) IP address 1.2.1.2, port 3344 Server IP address 9.8.7.6, port 80
S r c A = 1 . 2 . 1 . 2 , S r c P = 3 3 4 4 , D s t A = 9 . 8 . 7 . 6 , D s t P = 8 , S Y N , S e q = x SrcA=9.8.7.6, SrcP=80, DstA=1.2.1.2, DstP=3344, SYN+ACK, Seq = y, Ack = x+1 S r c A = 1 . 2 . 1 . 2 , S r c P = 3 3 4 4 , D s t A = 9 . 8 . 7 . 6 , D s t P = 8 , A C K , S e q = x + 1 , A c k = y + 1 S r c A = 1 . 2 . 1 . 2 , S r c P = 3 3 4 4 , D s t A = 9 . 8 . 7 . 6 , D s t P = 8 , A C K , S e q = x + 1 , A c k = y + 1 , D a t a = “ G E T / l
i n . h t m l SrcA=9.8.7.6, SrcP=80, DstA=1.2.1.2, DstP=3344, ACK, Seq = y+1, Ack = x+16, Data=“200 OK … <html> …”
Computer Science 161 Fall 2016 Popa and Weaver
any TCP connection
28
S Y N S Y N A C K A C K Data ACK time
A B
Nasty Data Nasty Data2
Computer Science 161 Fall 2016 Popa and Weaver
29
Client (initiator) IP address 1.2.1.2, port 3344 Server IP address 9.8.7.6, port 80
S r c A = 1 . 2 . 1 . 2 , S r c P = 3 3 4 4 , D s t A = 9 . 8 . 7 . 6 , D s t P = 8 , A C K , S e q = x + 1 , A c k = y + 1 , D a t a = “ G E T / l
i n . h t m l
...
Attacker (AirPwn, QUANTUM, etc) IP address 6.6.6.6, port N/A
SrcA=9.8.7.6, SrcP=80, DstA=1.2.1.2, DstP=3344, ACK, Seq = y+1, Ack = x+16 Data=“200 OK … <poison> …”
Client dutifully processes as server’s response
Computer Science 161 Fall 2016 Popa and Weaver
30
Client (initiator) IP address 1.2.1.2, port 3344 Server IP address 9.8.7.6, port 80
S r c A = 1 . 2 . 1 . 2 , S r c P = 3 3 4 4 , D s t A = 9 . 8 . 7 . 6 , D s t P = 8 , A C K , S e q = x + 1 , A c k = y + 1 , D a t a = “ G E T / l
i n . h t m l
...
Attacker IP address 6.6.6.6, port N/A
SrcA=9.8.7.6, SrcP=80, DstA=1.2.1.2, DstP=3344, ACK, Seq = y+1, Ack = x+16 Data=“200 OK … <poison> …”
Client ignores since already processed that part of bytestream: the network can duplicate packets so only pay attention to the first version in sequence
SrcA=9.8.7.6, SrcP=80, DstA=1.2.1.2, DstP=3344, ACK, Seq = y+1, Ack = x+16, Data=“200 OK … <html> …”
Computer Science 161 Fall 2016 Popa and Weaver
31
Computer Science 161 Fall 2016 Popa and Weaver
32
Computer Science 161 Fall 2016 Popa and Weaver
address
connections can’t be traced back to the attacker
33
Computer Science 161 Fall 2016 Popa and Weaver
34
Alleged Client (not actual) IP address 1.2.1.2, port N/A Server IP address 9.8.7.6, port 80 Blind Attacker
SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6, DstP=80, SYN, Seq = z SrcA=9.8.7.6, SrcP=80, DstA=1.2.1.2, DstP=5566, SYN+ACK, Seq = y, Ack = z+1
Attacker’s goal:
SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6, DstP=80, ACK, Seq = z+1, ACK = y+1 SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6, DstP=80, ACK, Seq = z+1, ACK = y+1, Data = “GET /transfer-money.html”
Computer Science 161 Fall 2016 Popa and Weaver
35
Alleged Client (not actual) IP address 1.2.1.2, port NA Server IP address 9.8.7.6, port 80 Blind Attacker
SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6, DstP=80, SYN, Seq = z SrcA=9.8.7.6, SrcP=80, DstA=1.2.1.2, DstP=5566, SYN+ACK, Seq = y, Ack = x+1
Small Note #1: if alleged client receives this, will be confused ⇒ send a RST back to server … … So attacker may need to hurry! But firewalls may inadvertently stop this reply to the alleged client so it never sends the RST 🤕
Computer Science 161 Fall 2016 Popa and Weaver
36
Alleged Client (not actual) IP address 1.2.1.2, port NA Server IP address 9.8.7.6, port 80 Blind Attacker
SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6, DstP=80, SYN, Seq = z SrcA=9.8.7.6, SrcP=80, DstA=1.2.1.2, DstP=5566, SYN+ACK, Seq = y, Ack = z+1
Big Note #2: attacker doesn’t get to see this packet!
Computer Science 161 Fall 2016 Popa and Weaver
37
Alleged Client (not actual) IP address 1.2.1.2, port N/A Server IP address 9.8.7.6, port 80 Blind Attacker
SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6, DstP=80, SYN, Seq = z SrcA=9.8.7.6, SrcP=80, DstA=1.2.1.2, DstP=5566, SYN+ACK, Seq = y, Ack = z+1
So how can the attacker figure out what value of y to use for their ACK?
SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6, DstP=80, ACK, Seq = z+1, ACK = y+1 SrcA=1.2.1.2, SrcP=5566, DstA=9.8.7.6, DstP=80, ACK, Seq = z+1, ACK = y+1, Data = “GET /transfer-money.html”
Computer Science 161 Fall 2016 Popa and Weaver
38
SYN SYN+ACK ACK
A B
D a t a D a t a
Each host tells its Initial Sequence Number (ISN) to the other host.
(Spec says to pick based on local clock)
Hmm, any way for the attacker to know this? Sure – make a non-spoofed connection first, and see what server used for ISN y then! How Do We Fix This? Use a (Pseudo)-Random ISN
Computer Science 161 Fall 2016 Popa and Weaver
numbers (both directions) and TCP ports
39
Computer Science 161 Fall 2016 Popa and Weaver
directions) and TCP ports
connection to the server
when in fact it hasn’t
40
Computer Science 161 Fall 2016 Popa and Weaver
2016
presentation/cao
stream (d'oh)
41
Computer Science 161 Fall 2016 Popa and Weaver
42
Computer Science 161 Fall 2016 Popa and Weaver
43