I know this question looks very silly, but, it has been bothering me for a while and I am unable to come up with an answer by myself. So, here it goes..
Packets in the TLS protocol consist of a 5 byte header followed by data which is encrypted once the handshake is done. The 5 byte header is always transmitted in the clear and it also contains a 2 byte length field.
Now, the MiTM attacker can just modify the length field alone in the header, such, that receiving party ends up waiting for a large amount of data, even after receiving the actual amount of bytes originally sent by the peer side. For Ex: Let's say peer side has sent a packet of 20 bytes, and the MiTM attacker just modifies length field of the header to make it 65535 bytes. Now, if no other data is sent by the peer, then the receiving side will wait indefinitely to receive the 65515 bytes (65535 - 20) which was never sent in the first place.
The TLS includes the header in MAC calculation, so any tampering with the header will result in a failure and effective connection closure. But, how is the case of blocking on socket to receive data resolved?
The receiver can avoid it by using a non-blocking sockets with select(again select should have a timeout) or using timeout with sockets. But, how about the case of blocking sockets? Is there anyway at all in which we can avoid the receiving side blocking on the socket?