Skip to contentSkip to conversation

conntrack and ICMP errors

DISCUSSION Don Cohen 2 participants 3 messages Apr 15, 2003 – Apr 16, 2003 1 message not in the archive netfilter

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20030411101702.14701.14873.Mailman@kashyyyk

Don Cohen

author
#1 lore raw

[continuing a topic from 4/11]

The real job of conntrack is to track the states of the two machines communicating through the firewall. This is, in general, not really possible for several reasons.

The one pointed out in this exchange is that we don't really know how the endpoints will react to the packets they receive. I think the biggest problem is that we don't know when an endpoint discards a connection, and we don't want to fill up the conntrack table with connections that the endpoints have discarded.

As far as I can tell UDP is essentially hopeless since it doesn't even support the concept of connection. I can't see anything better than relatively short timeouts. Perhaps it depends on what you hope to do with the connection data. (Any answers other than NAT?)

For the case of TCP, however, I do have a proposal.
If you keep the last ack# that you've sent in each direction you can do a weak sort of check of whether a participant still thinks the connection is alive by (re)sending that last ack (with no other payload) and hoping to get back a reset if the participant thinks the connection was closed. I suggest that this technique be used either when you have some reason to suspect the connection is closed (such as the ICMP messages in the discussion), or when you've not heard any packets for a long time (it's reasonably likely that one side or the other has rebooted in the mean while), or for that matter, when you find the conntrack table filling up and want to reclaim some space.

It might be better to send some packet that ought to generate a response in the still-open case, but it would still be dangerous to interpret no response as an indication that the connection should be closed. On the other hand, if this connection is preventing other possibly useful connections from being created, it might make sense to interpret several non-responses as reason to reset the connection. This sort of thing should clearly be controlled by policy set by the firewall administrator.

I've been hoping to try this but have not managed to get there yet. I'm hoping that by mentioning it here either
- someone will point out why it's a bad idea or
- someone else will implement it and try it

One more point: if you do get back a reset, you should not only use it locally but also forward it to the other participant.

#2 lore raw

Hi Don & list,

Quoted 11 lines

For the case of TCP, however, I do have a proposal.
If you keep the last ack# that you've sent in each direction you can do a weak sort of check of whether a participant still thinks the connection is alive by (re)sending that last ack (with no other payload) and hoping to get back a reset if the participant thinks the connection was closed. I suggest that this technique be used either when you have some reason to suspect the connection is closed (such as the ICMP messages in the discussion), or when you've not heard any packets for a long time (it's reasonably likely that one side or the other has rebooted in the mean while), or for that matter, when you find the conntrack table filling up and want to reclaim some space.

There are basically two questions to worry about:

1) for any such probing method, what could go wrong in the real world? As I work for a dialup service provider, the extreme case that I have to consider is both sides of a tracked connection having been reassigned to different customers. Now your probe comes. What will happen? How many calls will support get about attack attemts? (not many, but also not none)

2) there's the question of when to probe. My crystall ball displays "halting problem", but it is occasionally flakey. Any kind of probing violates the unwritten "never send more than you receive" rule of intermediate protocol stacks, so one has to be careful.

Both questions turn my brain into fog mode, so I always refrained from publicizing such heretical thoughts. But deep in my heart, I feel that it is a worthy path to explore. Without need, though, it's something I'll do when I'm old.

It may well be that all this has been researched to death, before. I wouldn't know. I'm a lazy ignorant.

best regards
Patrick

author
#3 lore raw

Patrick Schaaf writes:
...

Quoted 3 lines

There are basically two questions to worry about:

1) for any such probing method, what could go wrong in the real world?

That question can only be answered by trying it. Or hearing from someone else who has already tried it, or something similar. Which is why I want to hear from anyone who has tried it or knows why it won't work, or failing that, try it.

The best we can do otherwise is read the specs.

Quoted 5 lines

As I work for a dialup service provider, the extreme case that I have to consider is both sides of a tracked connection having been reassigned to different customers. Now your probe comes. What will happen? How many calls will support get about attack attemts? (not many, but also not none)

If I understand the question, you imagine that one or both sides close the connection without any explicit agreement to do so (as in RST or FIN packets that the firewall would see). Now the firewall sends a packet to the old connection. The design of tcp is that this should, with extremely high probability, be detected as a packet to a nonexistent connection, which should cause a RST, which is just what we want.

If such packets result in calls to support about attacks then so would the legitimate packets that we simulate. As an example of that, I telnet (I mean, ssh) to a server, interact for a while, then go off to eat supper. Now my machine goes down, and in your case my IP is reassigned, say to your machine. Later on the server decides to tell me that mail has arrived and sends a packet to me which is very similar to the one I propose the firewall send. You get it and say "what's this?" and send a RST.
If that happens at a high rate then you're justified in calling it an attack. If it happens about as frequently as connections are lost because machines crash then this is just TCP working as intended. I guess if you were really unlucky you'd be assigned the IP of a machine that had recently crashed with a huge number of open connections. (I think that's a good reason not to reassign an IP immediately after it becomes unused.)

Quoted 4 lines

2) there's the question of when to probe. My crystall ball displays "halting problem", but it is occasionally flakey. Any kind of probing violates the unwritten "never send more than you receive" rule of intermediate protocol stacks, so one has to be careful.

I'm not quite sure what either of these is supposed to mean. Halting means that this is not a real decision procedure? That's true, but (1) it may still be useful, (2) if we can send a packet that ought to cause a response, then the lack of response can reasonably be interpreted as evidence.
"Never send more than you receive" seems a good rule in some ways, but is certainly not normally followed. For instance, a packet of size 40 bytes can easily result in an ICMP packet that contains the entire original packet inside it. In this case I'm proposing to send extra packets at a very low rate. And this is, after all, meant as a way to prevent or at least mitigate another problem - the connection table filling up.

Quoted 2 lines

It may well be that all this has been researched to death, before. I wouldn't know. I'm a lazy ignorant.

If it has been then whoever knows about it should please speak up!