Skip to contentSkip to conversation

iptables icmp protocol match bug.

DISCUSSION Peteris Krumins 4 participants 7 messages Jul 31, 2003 – Aug 4, 2003 netfilter

lore
Share & tools
lore
#0 lore raw

Hello,

A quick bug report:

iptables -A INPUT -p icmp --icmp-type 255 -i lo -j REJECT

this rule also denies icmp ping and i think anything else of icmp.

Works for me at least on 2.4.22-pre6 and patch-o-matic-20030714 havent tried w/ newer versions.

Does not work on base 2.4.20 and iptables 1.2.7a

proof:
--

z@xor:/[1032]# iptables -A INPUT -p icmp --icmp-type 255 -i lo -j REJECT
z@xor:/[1033]# ping localhost -c 5
PING localhost (127.0.0.1): 56 octets data

--- localhost ping statistics ---
5 packets transmitted, 0 packets received, 100% packet loss

z@xor:/[1034]# iptables -D INPUT -p icmp --icmp-type 255 -i lo -j REJECT
z@xor:/[1035]# ping localhost -c 5
PING localhost (127.0.0.1): 56 octets data
64 octets from 127.0.0.1: icmp_seq=0 ttl=128 time=0.3 ms
64 octets from 127.0.0.1: icmp_seq=1 ttl=128 time=0.3 ms
^C

P.Krumins

[email protected]

#1 lore raw
Quoted 6 lines · Peteris Krumins

Hello,

A quick bug report:

iptables -A INPUT -p icmp --icmp-type 255 -i lo -j REJECT

This is deliberate. There is no valid icmp-type 255, it is used as a wildcard to match every possible type. See icmp_type_code_match() in ip_tables.c. Perhaps the userspace tool should warn about invalid types ?

Patrick

Quoted 36 lines

this rule also denies icmp ping and i think anything else of icmp.

Works for me at least on 2.4.22-pre6 and patch-o-matic-20030714 havent tried w/ newer versions.

Does not work on base 2.4.20 and iptables 1.2.7a

proof:
--

z@xor:/[1032]# iptables -A INPUT -p icmp --icmp-type 255 -i lo -j REJECT
z@xor:/[1033]# ping localhost -c 5
PING localhost (127.0.0.1): 56 octets data

--- localhost ping statistics ---
5 packets transmitted, 0 packets received, 100% packet loss

z@xor:/[1034]# iptables -D INPUT -p icmp --icmp-type 255 -i lo -j REJECT
z@xor:/[1035]# ping localhost -c 5
PING localhost (127.0.0.1): 56 octets data
64 octets from 127.0.0.1: icmp_seq=0 ttl=128 time=0.3 ms
64 octets from 127.0.0.1: icmp_seq=1 ttl=128 time=0.3 ms
^C

P.Krumins

[email protected]

#2 lore raw

Friday, August 1, 2003, 12:52:00 AM, you wrote:

Quoted 6 lines · PM> Peteris Krumins wrote:
Quoted 6 lines

Hello,

A quick bug report:

iptables -A INPUT -p icmp --icmp-type 255 -i lo -j REJECT

PM> This is deliberate. There is no valid icmp-type 255, it is used as a PM> wildcard to match every possible type. See icmp_type_code_match() PM> in ip_tables.c. Perhaps the userspace tool should warn about invalid PM> types ?

Why there is no valid icmp-type 255? Maybe it is not defined by rfc or (IANA?), but it could still be used, couldnt it? (Tho i block all but those really needed).

Why is it defined to be used as a wildcard worldwide? If not, I think this is wrong - because if it is not defined to be used for this purpose, then it is still valid and could be used (by some application which constructs packets itself and has chosen 0xff for communications, for example).

P.Krumins

#3 lore raw
Quoted 10 lines · Peteris Krumins

PM> This is deliberate. There is no valid icmp-type 255, it is used as a

PM> wildcard to match every possible type. See icmp_type_code_match() PM> in ip_tables.c. Perhaps the userspace tool should warn about invalid PM> types ?

Why there is no valid icmp-type 255? Maybe it is not defined by rfc or (IANA?), but it could still be used, couldnt it? (Tho i block all but those really needed).

It is not defined. The highest defined type is ICMP_ADDRESSREPLY (18). Of course some application could construct _invalid_ icmp packets, but who cares ?

Quoted 7 lines

Why is it defined to be used as a wildcard worldwide? If not, I think this is wrong - because if it is not defined to be used for this purpose, then it is still valid and could be used (by some application which constructs packets itself and has chosen 0xff for communications, for example).

Ok i see your point, "icmp-type 255 equals wildcard" was introduced as a workaround for "-m icmp" not matching all (or none, i can't remember exactly) types. I suppose if you submit a patch with a better solution, everyone will be fine with it, but it doesn't sound as if you would need it yourself. IIRC one of the reason this way was chosen was backwards-compatibility, if you introduce a new flag you break the ABI.

Bye
Patrick

Quoted 4 lines

P.Krumins

#4 lore raw
Quoted 3 lines · Patrick McHardy

It is not defined. The highest defined type is ICMP_ADDRESSREPLY (18). Of course some application could construct _invalid_ icmp packets, but who cares ?

Anyone who wants to block such invalid ICMP packets.. but given the low ratio of valid ICMP codes it is easier to build a list of what one accepts than what not.

Regards
Henrik

#5 lore raw
In reply to Patrick McHardy
Quoted 4 lines · Patrick McHardy

This is deliberate. There is no valid icmp-type 255, it is used as a wildcard to match every possible type. See icmp_type_code_match() in ip_tables.c. Perhaps the userspace tool should warn about invalid types ?

yes, please make this a bugzilla entry so we don't forget about that.

Quoted 1 line

Patrick

Signature · 5 lines
- Harald Welte <[email protected]>             http://www.netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#6 lore raw
Quoted 4 lines · Harald Welte

On Thu, Jul 31, 2003 at 11:52:00PM +0200, Patrick McHardy wrote:

Quoted 10 lines
Quoted 6 lines

This is deliberate. There is no valid icmp-type 255, it is used as a wildcard to match every possible type. See icmp_type_code_match() in ip_tables.c. Perhaps the userspace tool should warn about invalid types ?

yes, please make this a bugzilla entry so we don't forget about that.

I'll do that later or just send a patch.

Bye
Patrick