I work on a web service which could be the target of a denial-of-service attack. We have in place some mitigations against "SYN flood" style attacks. But there are other "application-level" attacks against our service, where a malicious/broken client could repeatedly instruct the web service to perform expensive tasks.
We can identify these abusive clients at the application layer, i.e. in our server processes. Once our process has identified an abusive client connection, we'd like to reduce our level of service to that client.
A naive method would be to terminate the TCP connection with close(2)
, shutdown(2)
, or similar. But then the the client can immediately reconnect (up to the connections/second limit set to mitigate SYN floods), and this reconnection is expensive for us due to TLS handshakes and other connection setup costs. We're looking for a way to stop the client interacting with our service for a while, but a clean TCP connection termination does not do this.
However, if our process were able to terminate the TCP connection uncleanly, the abusive client would be delayed for some time before it reconnects, thus providing a "cool off" period. By "unclean termination", I mean closing the TCP connection (both halves of the full-duplex) on the server side, without sending any FIN
packet to notify the client of termination, and without sending any further packets referring to that connection. This would delay the client while the client considers the connection still in the ESTABLISHED
state (which is 13-30 minutes on Linux).
However, I can't see any way for a UNIX/Linux process to uncleanly terminate a TCP connection. close(2)
, shutdown(2)
and similar all seem to cleanly terminate the connection, and provide no options for an unclean termination.
Does any option exist in UNIX/Linux for immediate, unclean TCP connection termination, as a mitigation to DOS attacks?