Summary:
- If IDS turns off the validation on TCP checksum, packet evasion is possible.
- First, establish the 3 way-handshake.
- Then, fool the IDS by sending a RST packet with bad TCP checksum.
- Then continue sending the EVIL packets.
In a nutshell, TCP timestamps can be included as a TCP option to specify the sending host's timestamp and echo the most recently received timestamp from the other side of the connection. The notion of time or timestamp is not the typical one since it denotes, for most operating systems except OpenBSD, a representation of the uptime of the host since the last reboot.
sysctl -a | grep net.ipv4.tcp_syncookies
net.ipv4.tcp_syncookies = 1
I will start off by covering the relevant parts of syncookies. There are many types of Denial of service attack, but the most powerful are low rate DoS attacks; attacks that need very little of the attackers resources, but cause major disruption to the attacked host or network.
One such attack was the SYN flood attack. The attacker would spoof thousands of packets from fake hosts. Since the destination would half-open a connection for each of these, its resources would soon be overwhelmed with these faked connections, and it would then stop acting as it should (either by rejecting new connections, or dropping old ones, or even crashing outright).
Some clever folks devised TCP Syncookies to combat this problem. Whenever a SYN was received, the connection was not opened by the destination. Instead, it SYN-ACK’d using a ‘magic’ sequence number that it calculated. The calculation involved the IP Source, Destination, TCP Source port and Destination port, along with an unknown random bit of data that only the server would know. No entry was added to the servers table, so its resources would stay free. When the client would ACK, it would increase the sequence number by one. The server would see this ack, and would do the same math it did before to create its magic sequence number, and subtract one from the received number.
Since the number is only based on the IP, Port, and random number, the numbers should be identical, even though it would not remember the original connection. If the two matched, it would open the connection. Since the magic number was effectively unguessable to the client, this would make it impossible for an attacker to flood the server with a low rate SYN flood attack.
If you ever see a packet flying by on your network that has a SYN flag set and does not have a TCP options Maximum Segment Size (MSS) – you can be fairly certain that it was crafted. And, if it was crafted – it probably is for some nefarious purposes. There are other TCP options too that can be included, but most current well-known TCP/IP stacks list the MSS as the first of the TCP options in the TCP header. However, Solaris stacks do not follow this convention and may present some false positives if you include this check.
Another unusual condition that may be a reflection of a crafted packet or a poorly written TCP/IP stack is where a client SYN packet has a non-zero acknowledgement value. After all, the client has received nothing to acknowledge.To filter (SYN and !MSS) with tcpdump:
tcp[13] & 2 != 0 and ((tcp[12]/16 == 5) or (tcp[12]/16 > 5 and tcp[20] != 02))
!(tcp.options.mss) && (tcp.flags.syn == 1)
tcp.flags.syn == 0 && (tcp.options.mss || tcp.options.wscale || tcp.options.sack)
tcp[13] = 2 and tcp[8:4] > 0To filter (SYN and non-zero ACK ) with tcpdump:
tcp.flags.syn == 1 && tcp.flags.ack == 0 && tcp[8:4] > 0