There are many application-level protocols in networks. There are File Transfer Protocols like ftp, scp, and sftp. There are Mail Protocols like smtp, pop, and imap. There are Web Protocols like http 1.0, 1.1, and 2.0. And there are many more. But they are not that secure.
File Transfer Protocol
In short, it is just FTP, providing a file transfer service. It is implemented upon TCP following the RFC 172 standards. The client sends a connection request to the server that's listening on port 21, and provides username and password as an authentication. Then the client user uses GET and PUT commands to transfer files. During the connection, the data is in fact transferred on a separate TCP connection. There are two modes in this connection. One is active mode such that the connection opens one of client's local ports and opens port 20 on the server. Another is passive mode such that client sends PASV to the server and the server opens a port and tells the client via the previous incoming port adding one on the client. More details are here.
The weakness of TCP
- Username and password provided by the client is sent in the clear across the network
- All session traffic is transferred without any protection
- Vulnerable to sniffing and hijacking
- Vulnerable to FTP Bounce Attack
FTP Bounce Attack
(photo credit to Giovanni)
- Used to execute a TCP port scan
- Used to send data to any ports
The Domain Name System
In short, DNS is a distributed database that maps IP addresses to the corresponding domain names and vice versa. Mostly DNS uses UDP. Sometimes it uses TCP for long queries and zone transfers between servers via port 53 for instance.
Name servers are responsible for mapping names in a zone. There are five types of name servers:
- Primary: authoritative for the domain
- Secondary: backup server, gets its data through zone transfers
- Caching-only: relies on other servers to resolve names but maintains the cached results
- Forwarding: simply forwards queries to other servers
- Recursive: provides full resolution services
Notice that the results are maintained in a local cache for a limited time (minutes to days) only.
The Weakness of DNS
- DNS discloses too much information (HINFO records, exhaustive queries, zone transfers)
- Being based on UDP, vulnerable to spoofing and hijacking
- Clients can be compromised and directed to malicious DNS servers
- DOS attacks from long replies
DNS Spoofing Defense
(photo credit to Giovanni)
Double reverse lookup: given the IP address, obtain resolved domain name. Then use domain name to obtain IP address. Compare the two IP addresses and check if they equal to each other.
DNS Hijacking
Need to race with the server with respect to a client, or with a server with respect to another server.
DNS Cache Poisoning
There may exist some bugs in DNS implementations that allow additional answers poisoning the cache.
(photo credit to Giovanni)
The attacker must try to answer queries that come from the right port and have the right sequence number. If the attacker loses the race, he will have to wait for the TTL to expire.
The Kaminsky Attack
Attack to poison the cache of a recursive DNS server.
Remote DNS cache poisoning assumption: the attack knows/guesses the 16-bit ID value used to match requests to replies as well as the source port used in the request.
Details see here.
DNSSEC
Namely DNS Security Extensions that protects against data spoofing and corruption. It requires re-deployment of the Internet infrastructure but introduces substantial overhead.
Transport Layer Security (TLS)
SSL is deprecated in 2015. SSL was standardized by the IETF and renamed to TLS. The current version is 1.2 and 1.3 will be released at the end of 2015.
- Symmetric encrypted communication
- Two-way authentication using certificates
- Use of Message Authentication Codes to guarantee integrity
TLS Session
TLS is stateful. Client and server maintain a number of configuration parameters that can be reused for many connections. For example, ID, certificates, compression algorithms, cipher specs, and a master secret shared between client and server.
TLS Connection
Each TLS connection includes:
- Two random numbers chosen by client and server
- Keys used to generate MACs
- Keys used to encrypt traffic
- Sequence numbers for sent and received messages
There are two TLS protocols. One is the handshake protocol and another is the record protocol. The prior manages the establishment of the cipher spec of a session; and the later processes data coming from applications by applying encryption and authentication procedures.