I have not seen any important TCP/IP server not use SO_REUSEADDR :
Is there any use case for not using SO_REUSEADDR on TCP/IP servers ?
I mean, would making the OS always use SO_REUSEADDR break any server that does not use it?
Do you know a TCP/IP server that not uses SO_REUSEADDR for a reason?
(of course you may not want to use it on MSWindows as it allows to run two servers on the same port)
The SO_REUSEADDR socket option has four different functions: (1) SO_REUSEADDR allows you to start a listening server and bundle well-known ports, even though previously established ports still exist as their local ports. This condition is usually met as follows: A) Start a listening server;
All TCP servers should specify this socket option to allow the server to be restarted in this case. (2) SO_REUSEADDR allows multiple instances of the same server to be started on the same port as long as each instance is bundled with a different local IP address.
If your answer to that is that the remote stack should do something like TIME_WAIT on its side to disallow ephemeral TCP port reuse, that solution assumes that the remote host is benign. A malicious actor is free to reuse that remote port.
As long as SO_REUSEADDR socket option can be used to potentially hijack a port in a server application, the application must be considered to be not secure. All server applications must set SO_EXCLUSIVEADDRUSE for a strong level of socket security.
Well, UNP (Stevens 2004) says:
SO_REUSEADDR allows a listening server to start and bind its well-known port, even if previously established connections exist that use this port as their local port.
All TCP servers should specify this socket option to allow the server to be restarted
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With