Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

An iptables rule on my database server is:

-A INPUT -p tcp --dport 6432 -s -j ACCEPT

I have other rules (loopback, etc.), but I'm wondering if that specific rule can be "hacked". Can somebody just "spoof" the IP address (even though it's a private network address - also, would it be different if it was a public address)? Something different?

share|improve this question
Related… – Zoredache Jun 2 '13 at 18:46
up vote 5 down vote accepted

Iain's answer is generally correct, but needs a little expanding to explain why the attack would be difficult to execute.

TCP uses a combination of bit-based flags and 32-bit counters, called sequence and acknowledgement numbers, to drive the state machine that tracks the progress of a TCP connection throughout its life. Understanding how these two 32-bit counters play into the three-way handshake that precedes transfer of payload data in every TCP connection will make the impracticality of attacks using spoofed source IP addresses clear.

When a client initiates a TCP connection to a remote server it sends a TCP segment with the SYN bit set and a randomly-chosen initial sequence number. The remote server responds with a TCP segment with both the SYN and ACK bits set, a randomly-chosen initial sequence number, and an acknowledgement number equal to the client's initial sequence number plus 1. Finally, the client responds with a TCP segment with the ACK bit set, a sequence number equal to the initial sequence number it send plus 1, and an acknowledgement number equal to the remote server's initial sequence number plus 1.

When an attacker is forging IP datagrams from another host's source IP address it is typically the case that the attacker doesn't receive the responses to any packets they might send. In such a scenario the attacker has, effectively, a one-way communication channel to the remote server. Looking at the packet flow in the TCP handshake, it would be necessary for the attacker to predict the initial sequence number that the remote server is going to generate in its SYN/ACK response in order to respond with the appropriate acknowledgement number in the ACK response to complete the three-way handshake. The attacker needs to guess a 32-bit number correctly in order for the attack to work.

Today this type of attack is complete impractical. In the past, though, some high-profile attacks used this very method. This was possible because, in the past, some operating systems had very predictable initial sequence numbers. (You might find Michal Zalewski's paper Strange Attractors and TCP/IP Sequence Number Analysis - One Year Later an interesting read, in terms of describing the predictability of initial sequence numbers of various operating systems.)

share|improve this answer
Excellent explanation, thanks Evan. – orokusaki Jun 2 '13 at 21:33

Not under normal circumstances.

The TCP protocol has a 3 way handshake to set up a connection

Host A sends a SYN packet to Host B
Host B sends a SYN ACK packet to host A
Host A sends an ACK packet to host B 

and the connection is establishd

Now if we introduce a Host C which spoofs Host A's Address

Host C sends a spoofed SYN packet to Host B
Host B sends a SYN ACK packet to Host A 

Host A isn't expecting a SYN ACK so it just ignores it.

share|improve this answer
Ah, makes perfect sense now. Thanks! – orokusaki Jun 2 '13 at 21:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.