NetworkSecurity 2
NetworkSecurity 2
Network Security
Chenxiong Qian
[email protected]
COMP3355 Cyber Security (2023 Fall) Network Security
In Last Class
Network Basics (OSI Model and TCP/IP Stack)
Network Layer Security
Transport Layer Security
Application Layer Security
COMP3355 Cyber Security (2023 Fall) Network Security
In This Class
Network Basics (OSI Model and TCP/IP Stack)
Network Layer Security
Transport Layer Security
Application Layer Security
COMP3355 Cyber Security (2023 Fall) Network Security
Recap
TCP Header
Application message - data
Application Message
Network Frame
Interface EH IP TCP data ET
IP Header
Recap IP
Break up segment from transport layer to packets
Message Application
Segment
Transport segment
(TCP, UDP)
Packet Network (IP) packet …… packet
Frame
Network
Interface
COMP3355 Cyber Security (2023 Fall) Network Security
Recap IP
Break up segment from transport layer to packets
Add an IP header
Message Application
Segment
Transport segment
(TCP, UDP)
Packet Network (IP) IP packet …… IP packet
Frame
Network
Interface
COMP3355 Cyber Security (2023 Fall) Network Security
Recap IP
Break up segment from transport layer to packets
Add an IP header
Source/Destination IP address
Message Application
Segment
Transport segment
(TCP, UDP)
Packet Network (IP) IP packet …… IP packet
Frame
Network
Interface
Source Node Destination Node
COMP3355 Cyber Security (2023 Fall) Network Security
Recap IP
Break up segment from transport layer to packets
Add an IP header
Source/Destination IP address
Find a path from the source node to the destination node
Message Application
Segment
Transport segment
(TCP, UDP)
Packet Network (IP) IP packet …… IP packet
Frame
Network
Interface
Source Node Destination Node
COMP3355 Cyber Security (2023 Fall) Network Security
Transport
Alice callsLayer
Bob using Skype
Transport
Alice callsLayer
Bob using Skype
Skype’s data
IP packet
COMP3355 Cyber Security (2023 Fall) Network Security
Transport
Alice callsLayer
Bob using Skype
Skype’s data
IP packet
Transport
Alice callsLayer
Bob using Skype
Skype’s data
IP packet
Transport
Alice callsLayer
Bob using Skype
Skype’s data
IP packet
Source Node Destination Node
COMP3355 Cyber Security (2023 Fall) Network Security
Transport Layer
Establish connections between applications
Transport Layer
Breaks up application data into segments
app data
Message Application
Segment
Transport
segment …… segment
(TCP, UDP)
Packet Network (IP)
Frame
Network
Interface
COMP3355 Cyber Security (2023 Fall) Network Security
Transport Layer
Breaks up application data into segments
Append a TCP/UDP header to each segment
app data
Message Application
Segment
Transport
TCP/UDP segment TCP/UDP segment
……
(TCP, UDP)
Packet Network (IP)
Frame
Network
Interface
COMP3355 Cyber Security (2023 Fall) Network Security
Transport Layer
Breaks up application data into segments
Append a TCP/UDP header to each segment
Source port and Destination port
Distinguish data from/to different applications
app data
Message Application
Segment
Transport
TCP/UDP segment TCP/UDP segment
……
(TCP, UDP)
Packet Network (IP)
Frame
Network
Interface
COMP3355 Cyber Security (2023 Fall) Network Security
Transport
Alice callsLayer
Bob using Skype
Skype’s data
IP Header
TCP/UDP Header
Source Node Destination Node
Message Payload
COMP3355 Cyber Security (2023 Fall) Network Security
Transport Layer is used for routing the data from source node to
The IP header
destination node
Alice’s Host Bob’s Host
Skype’s data
IP Header
TCP/UDP Header
Source Node Destination Node
Message Payload
COMP3355 Cyber Security (2023 Fall) Network Security
Skype’s data
IP Header
TCP/UDP Header
Message Payload
Source Node Destination Node
COMP3355 Cyber Security (2023 Fall) Network Security
UDP
TCP
COMP3355 Cyber Security (2023 Fall) Network Security
TCP Reliability
Reliable connection (Connection-oriented)
Detect and retransmit lost data
All packets are delivered to applications
Rearrange the data in order
Detect modified data with reasonably high probability
COMP3355 Cyber Security (2023 Fall) Network Security
TCP’s View
Process 1 on host 1
byte 0 byte 1 byte 2 byte 3 byte 4 byte 5 byte 6
Process 2 on host 2
COMP3355 Cyber Security (2023 Fall) Network Security
TCP Header
SrcPort and DstPort
Identify the source and destination ports, respectively
(SrcIPAddr::SrcPort, DstIPAddr::DstPort) identifies a TCP connection
COMP3355 Cyber Security (2023 Fall) Network Security
TCP Header
SequenceNum
The sequence number of the first byte in the payload
COMP3355 Cyber Security (2023 Fall) Network Security
TCP Header
Acknowledgment
Next sequence number that the sender of the ACK is expecting
Acknowledges receipt of all prior bytes
COMP3355 Cyber Security (2023 Fall) Network Security
TCP Header
AdvertisedWindow
Specifies the number of bytes that the sender of this segment is currently
willing to receive
COMP3355 Cyber Security (2023 Fall) Network Security
TCP Header
HdrLen (Header Length)
The length of the header, number of 32-bit word (4 bytes); 5~15
20 bytes
COMP3355 Cyber Security (2023 Fall) Network Security
TCP Header
Flags
Relay control information between TCP peers
SYN, FIN, RESET, ACK, PUSH, URG
COMP3355 Cyber Security (2023 Fall) Network Security
TCP Header
Checksum
Used for error-checking for TCP header, the payload and an IP pseudo-header
COMP3355 Cyber Security (2023 Fall) Network Security
TCP Header
Checksum
Used for error-checking for TCP header, the payload and an IP pseudo-header
What is this?
COMP3355 Cyber Security (2023 Fall) Network Security
Connection Establishment
Three-Way Handshake
The client and the server exchange information to establish a connection.
The information fall into two categories
Sync initial sequence number (ISN)
Exchange parameters (e.g., maximum segment size)
COMP3355 Cyber Security (2023 Fall) Network Security
Client Server
SYN
Is set to 1
COMP3355 Cyber Security (2023 Fall) Network Security
Client Server
SYN
SYN+ACK
Is set to 1
COMP3355 Cyber Security (2023 Fall) Network Security
Client Server
SYN
SYN+ACK
ACK
NS CWRECE URG ACK PSH RST SYN FIN
Is set to 1
COMP3355 Cyber Security (2023 Fall) Network Security
The client sends a segment to the server stating the initial sequence
number
Client Server
SYN Seq = X X is a randomly generated number
COMP3355 Cyber Security (2023 Fall) Network Security
SYN+ACK
Y is a randomly generated number
Seq = Y Ack = X+1
COMP3355 Cyber Security (2023 Fall) Network Security
SYN+ACK
Y is a randomly generated number
Seq = Y Ack = X+1
After receiving SYN, the server will create a special data structure
called Transmission Control Block (TCB) and store it in a queue.
Client Server
SYN Seq = X
Connection information
TCB
TCB queue
COMP3355 Cyber Security (2023 Fall) Network Security
Server sends the SYN+ACK segment and waits for an ACK segment
Client Server
SYN Seq = X
SYN+ACK
TCB
Seq = Y Ack = X+1 TCB queue
COMP3355 Cyber Security (2023 Fall) Network Security
After receiving ACK, the server will take TCB out of the queue.
Client Server
SYN Seq = X Removed from the queue
SYN+ACK
TCB
Seq = Y Ack = X+1 TCB queue
After receiving ACK, the server will take TCB out of the queue.
Client Server
SYN Seq = X
SYN+ACK
Seq = Y Ack = X+1 TCB queue
The server will resend SYN+ACK packet if the final ACK packet does
not come.
Client Server
SYN Seq = X
SYN+ACK
TCB
Seq = Y Ack = X+1 TCB queue
SYN+ACK
Seq = Y Ack = X+1
COMP3355 Cyber Security (2023 Fall) Network Security
Client Server
SYN Seq = X Removed from the queue
SYN+ACK
TCB
Seq = Y Ack = X+1 TCB queue
SYN+ACK
Seq = Y Ack = X+1
……
COMP3355 Cyber Security (2023 Fall) Network Security
Countermeasures
Enlarge TCB queue
Reduce timeout for waiting ACK packet
Recycle the oldest half-open TCP
SYN cookies
COMP3355 Cyber Security (2023 Fall) Network Security
SYN Cookies
It is a standard part of Linux and FreeBSD
It is enabled by default
It starts working when the system detects there are too many half-
open connections
COMP3355 Cyber Security (2023 Fall) Network Security
SYN Cookies
The basic idea is to allocate resources only if the server has received
the final ACK packet.
Client Server
SYN Seq = X
SYN+ACK
Seq = Y Ack = X+1
SYN Cookies
The basic idea is to allocate resources only if the server has received
the final ACK packet.
Client Server
SYN Seq = X
Must track the previous SYN segment.
SYN+ACK
Seq = Y Ack = X+1
SYN Cookies
The basic idea is to allocate resources only if the server has received
the final ACK packet.
SYN+ACK
Seq = Y Ack = X+1
SYN Cookies
SYN cookies are particular choices of initial TCP sequence numbers by
TCP servers.
COMP3355 Cyber Security (2023 Fall) Network Security
SYN Cookies
1. After receiving SYN, the server calculates a keyed hash (cookie)
using the packet’s information.
Client Server
SYN Seq = X
Y
COMP3355 Cyber Security (2023 Fall) Network Security
SYN Cookies
2. The server sends the hash in SYN+ACK packet. Also records Y.
Client Server
SYN Seq = X
Y
SYN+ACK
Seq = Y Ack = X+1
COMP3355 Cyber Security (2023 Fall) Network Security
SYN Cookies
3. When the server receives the final ACK packet, it calculates the hash
again to verify.
Client Server
SYN Seq = X
SYN+ACK
Y
Seq = Y Ack = X+1
SYN Cookies
The attacker cannot forge a valid cookie without knowing the secret
key
SYN Seq = X
SYN+ACK
Y
Seq = Y Ack = X+1
SYN Cookies
If the attacker spoofs IP address
Cannot receive the SYN+ACK packet
If the attack does not spoof IP address
Connection is created
COMP3355 Cyber Security (2023 Fall) Network Security
Questions?
COMP3355 Cyber Security (2023 Fall) Network Security
Data Transfer
Sender Receiver
Se q = 0
, 1k d a 2k
ta
COMP3355 Cyber Security (2023 Fall) Network Security
Data Transfer
Sender Receiver
Se q = 0
, 1k d a 2k
ta
Win = 1k
024,
Ack=1
COMP3355 Cyber Security (2023 Fall) Network Security
Data Transfer
Sender Receiver
Se q = 0
, 1k d a 2k
ta
W in = 1k
024,
Ack=1
Se q = 1
024, 1
k data
COMP3355 Cyber Security (2023 Fall) Network Security
Data Transfer
Sender Receiver
Se q = 0
, 1k d a 2k
ta
W in = 1k
024,
Ack=1
Se q = 1
024, 1
k data
COMP3355 Cyber Security (2023 Fall) Network Security
Data Transfer
Sender Receiver
Se q = 0
, 1k d a 2k
ta
W in = 1k
024,
Ack=1
Se q = 1
024, 1
k data
8, Win=0
0 4
Ack=2
COMP3355 Cyber Security (2023 Fall) Network Security
Data Transfer
Sender Receiver
Se q = 0
, 1k d a 2k
ta
W in = 1k
024,
Ack=1
Se q = 1
024, 1
k data
8 , W in=0
0 4
Ack=2
8 , W in=1k
04
Ack=2
Se q = 2
048, 1
k data
COMP3355 Cyber Security (2023 Fall) Network Security
Data Transfer
Retransmission
Timeout
Sender Receiver
Se q # 1
Timeout Se q # 2
Se q # 3
Se q # 1
Se q # 2
COMP3355 Cyber Security (2023 Fall) Network Security
Data Transfer
Retransmission
Error
Sender Receiver
Se q # 1
Se q # 2
Ack#1
Se q # 3
Ack#1
Se q # 2
COMP3355 Cyber Security (2023 Fall) Network Security
Connection Termination
Four-Way Handshake
COMP3355 Cyber Security (2023 Fall) Network Security
Initiator Receiver
FIN Seq = X
Initiator Receiver
FIN Seq = X
Seq = Y FIN
COMP3355 Cyber Security (2023 Fall) Network Security
The initiator acknowledges with an ACK and waits for a timeout before
closing the connection
Initiator Receiver
FIN Seq = X
Seq = Y FIN
Questions?
COMP3355 Cyber Security (2023 Fall) Network Security
Attacks On TCP
SYN Flooding Attack
TCP Reset Attack
TCP Session Hijacking Attack
COMP3355 Cyber Security (2023 Fall) Network Security
Seq = Y FIN
Connection Termination
COMP3355 Cyber Security (2023 Fall) Network Security
Seq = Y FIN
Connection Termination
COMP3355 Cyber Security (2023 Fall) Network Security
Countermeasures
Encrypt the connection using VPN
Service
Client
Server
COMP3355 Cyber Security (2023 Fall) Network Security
Attacks On TCP
SYN Flooding Attack
TCP Reset Attack
TCP Session Hijacking Attack
COMP3355 Cyber Security (2023 Fall) Network Security
Sender Receiver
Se q = 0
, 1k d a 2k
ta
4, Win=1k
02
Ack=1
COMP3355 Cyber Security (2023 Fall) Network Security
Sender Receiver
Se q = 0
, 1k d a 2k
ta
Sniff
4, Win=1k
02
Ack=1
COMP3355 Cyber Security (2023 Fall) Network Security
Sender Receiver
Se q = 0
, 1k d a 2k
ta
Sniff
4, W in=1k
02
Ack=1
Se q = 1
024, 1
k data
COMP3355 Cyber Security (2023 Fall) Network Security
Sender Receiver
Se q = 0
, 1k d a 2k
ta
Sniff
4, W in=1k
02
Ack=1
Se q = 1
024, 1
k data
Se q = 1
024, 1
k data
COMP3355 Cyber Security (2023 Fall) Network Security
Takedown (2000)
COMP3355 Cyber Security (2023 Fall) Network Security
Tsutomu Shimomura
COMP3355 Cyber Security (2023 Fall) Network Security
SYN, seq=x
SYN+ACK, seq=y
……
COMP3355 Cyber Security (2023 Fall) Network Security
i ng
od
Flo
N
SY
COMP3355 Cyber Security (2023 Fall) Network Security
=y
eq
s
K,
AC
N+
SY
SYN, seq=x, spoofed IP
Connected!
Let’s talk!
COMP3355 Cyber Security (2023 Fall) Network Security
Questions?
SYN Flooding Attack
TCP Reset Attack
TCP Session Hijacking Attack