This section describes the mechanisms of SYN flood attack and defense.
SYN flood attacks are launched based on the TCP protocol stack. The TCP connection setup procedure is the prerequisite to understanding the mechanisms of SYN flood attack and defense.
TCP provides a reliable connection-oriented service. A connection channel must be set up between two parties before one party sends data to the other party. This is called TCP three-way handshake, as shown in Figure 1.
If the server cannot receive an ACK message from the client after the server sending the SYN-ACK message, the server resends an SYN-ACK message to the client. If the server still cannot receive an ACK message from the client within the specified period of time, the incomplete connection is removed.
An attacker can take advantage of the TCP three-way handshake mechanism to launch SYN flood attacks. As shown in Figure 2, an attacker sends a large number of SYN messages to the server. After receiving these packets, the server replies with SYN-ACK messages but the attacker does not return ACK messages. As a result, the server maintains a large number of half-open connections until they age out. These half-open connections exhaust server resources. Therefore, the server fails to respond to normal requests.
The FW defends against SYN flood attacks in TCP proxy or TCP source authentication mode.
As a TCP proxy, the FW is deployed between the client and server to establish a three-way handshake with the client on behalf of the server and relay the TCP connection to the server if the three-way handshake is complete. TCP proxy applies only to scenarios in which the forward and return paths are the same.
The TCP proxy procedure is transparent to both the client and server.
During the TCP proxy procedure, the FW proxies and responds to each SYN message received and maintains half-open connections. Therefore, if a large number of SYN messages are sent to the FW, the FW must have high performance to handle them.
TCP proxy applies only to scenarios in which the forward and return paths are the same.
TCP source authentication enables the FW can defend against SYN flood attacks when forward and return paths are different. Therefore, compared with TCP proxy, TCP source authentication is more widely used.
In TCP source authentication, the source client is whitelisted once the client passes the authentication, and authentication is not performed on subsequent SYN messages sent by this source. This implementation greatly improves the defense efficiency and performance and minimizes the resource consumption.
If there are devices that discard source detection packets, the source detection function cannot be used.
Some attacks continuously change source IP addresses or source ports. Such attack packets are different. If the source authentication mode is used for defense, each attack packet is replied. When the attack traffic is heavy, the replying amount is also large, which consumes a lot of performance and causes link congestion.
The combination of the first packet discarding and source authentication can effectively defend against heavy traffic attacks by changing source IP addresses or source port numbers.
Normally, TCP packets are retransmitted upon timeout. If packets are discarded during the interaction, the packets are retransmitted. The first-packet discarding function uses the packet retransmission mechanism. The first packet received is discarded, and subsequent retransmitted packets are directly permitted. When the rate of retransmitted packets reaches the alarm threshold, the packets enter the source authentication process to reduce the number of reply packets.
If a packet does not match any 3-tuple, the FW considers the packet as the first packet, discards it, and records the 3-tuple information and time.
If a packet matches a 3-tuple, the FW checks the interval between this packet and the preceding packet matching the same 3-tuple.
If the interval is smaller than the specified lower limit or greater than the specified upper limit, the FW considers the packet as the first packet and discards it. If the interval is between the specified lower limit and upper limit, the FW considers the packet as a subsequent retransmitted packet and directly permits it. When the rate of retransmitted SYN packets to the same destination IP address reaches the source authentication alarm threshold, the packets enter the source authentication process.
Currently, the first-packet discarding function applies only to SYN packets.
First packet discarding applies to IPv4 packets, not IPv6 packets.