Search code examples
securityauthenticationtcpspoofing

Is authenticating a TCP connection by source IP safe?


I'm developing an application that accepts connections from clients over the internet. All these clients are on fixed IP addresses and will establish a non-encrypted TCP connection.

The current plan is for the server to check which IP the connections come from and allow only client connections from a list of know IPs?

How safe is that against IP spoofing?

My reasoning is that since this is a TCP connection, an attacker couldn't just fake its sender IP (which is easy), but would have to assure that the packets travel back to him and thus he would have to hack all routers on the path, which seems rather hard.

I know I could use encryption, like SSH, but lets stick with the question of how safe the plain TCP connection would be.


Solution

  • Restricting connections by IP address is generally a good practice when practical, as it greatly reduces the attack surface and makes the complexity of an attack much higher. As stated in other answers, you would now have to do something like IP spoofing, or attacking the network itself (false BGP routes, etc).

    That said, IP address restriction should be used as one layer of a defense-in-depth approach. Could you encrypt the TCP stream without too much rework? Maybe SSL? If you can't modify the program, how about the network? Site ti site IPSEC VPN tunnels are not difficult to establish, as almost any commercial firewall supports them. Even some soho routers can be modified to support IPSEC (with OpenWrt plus OpenSwan, for example).

    Lastly, could you require the client and server to mutually authenticate?