Is authenticating a TCP connection by source IP safe?

1.1k Views Asked by At

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.

3

There are 3 best solutions below

0
On BEST ANSWER

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?

0
On

First of all, using the IP you are not identifying the client, but just some numbers. Even if the IP is right, there still can be a troyan on user's computer, authenticating in place of the user itself (as I don't know what kind of service you provide, I assume that this might make sense).

Now, if one has access to one of the routers via which the packets between the client and the server go, then he can do almost anything - he can send and receive packets in the name of the client or he can modify them (as the data goes unencrypted). Moreover, the attacker doesn't need to hack all or one of routers - he just needs to have access (including legitimate one) to the channel where the data goes, be it the router itself or the cable (which can be cut and the router can be inserted).

So to summarize, IP can be used as one of the component that hardens spoofing to some extent, but it can't be the main security measure.

0
On

Not safe. BGP gateways are not immune to attack, and with that, false routes can be advertised and IPs can be spoofed.