Information
When tcp_syncookies is set, the kernel will handle TCP SYN packets normally until the half-open connection queue is full, at which time, the SYN cookie functionality kicks in. SYN cookies work by not using the SYN queue at all. Instead, the kernel simply replies to the SYN with a SYN/ACK, but will include a specially crafted TCP sequence number that encodes the source and destination IP address and port number and the time the packet was sent. A legitimate connection would send the ACK packet of the three way handshake with the specially crafted sequence number. This allows the system to verify that it has received a valid response to a SYN cookie and allow the connection, even though there is no corresponding SYN in the queue.
More information about the kernel parameter configuration files, their location, and load preference is available in the "Configure Network Kernel Parameters" section overview.
Attackers use SYN flood attacks to perform a denial of service attacked on a system by sending many SYN packets without completing the three way handshake. This will quickly use up slots in the kernel's half-open connection queue and prevent legitimate connections from succeeding. Setting net.ipv4.tcp_syncookies to 1 enables SYN cookies, allowing the system to keep accepting valid connections, even if under a denial of service attack.
Solution
- Run the following command to comment out net.ipv4.tcp_syncookies lines returned by the audit procedure that are not net.ipv4.tcp_syncookies = 1 :
# sed -ri '^\s*net.ipv4.tcp_syncookies\s*=\s*0/s/^/#/g' "path/to/file/in/audit/filename"
Example:
# sed -ri '/^\s*net.ipv4.tcp_syncookies\s*=\s*0/s/^/#/g' /etc/sysctl.d/99-sysctl.conf
- Create or edit a file in the /etc/sysctl.d/ directory ending in .conf and edit or add the following line:
net.ipv4.tcp_syncookies = 1
Example:
# [ ! -d "/etc/sysctl.d/" ] && mkdir -p /etc/sysctl.d/
# printf '%s\n' "" "net.ipv4.tcp_syncookies = 1" >> /etc/sysctl.d/60-ipv4_sysctl.conf
- Run the following command to load all sysctl configuration files:
# sysctl --system
Item Details
Category: SYSTEM AND COMMUNICATIONS PROTECTION
References: 800-53|SC-5, 800-53|SC-5(2), CCI|CCI-001095, CCI|CCI-002385, CSCv7|9.2, Rule-ID|SV-234829r958528_rule, Rule-ID|SV-257957r1045009_rule, Rule-ID|SV-260522r1069097_rule, Rule-ID|SV-269435r1050318_rule, Rule-ID|SV-270753r1066748_rule, Rule-ID|SV-271884r1092364_rule
Control ID: 3c8e225f4919f47ca0de71cdcc1d8211848a538f1c4f119d5c440ede6426b97c