Skip to content

Commit

Permalink
[NETFILTER]: Fix ip6_tables protocol bypass bug
Browse files Browse the repository at this point in the history
As reported by Mark Dowd <Mark_Dowd@McAfee.com>, ip6_tables is susceptible
to a fragmentation attack causing false negatives on protocol matches.

When the protocol header doesn't follow the fragment header immediately,
the fragment header contains the protocol number of the next extension
header. When the extension header and the protocol header are sent in
a second fragment a rule like "ip6tables .. -p udp -j DROP" will never
match.

Drop fragments that are at offset 0 and don't contain the final protocol
header regardless of the ruleset, since this should not happen normally.

With help from Yasuyuki KOZAKAI <yasuyuki.kozakai@toshiba.co.jp>.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Oct 24, 2006
1 parent 2fab22f commit 51d8b1a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/ipv6/netfilter/ip6_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ ip6_packet_match(const struct sk_buff *skb,
const char *outdev,
const struct ip6t_ip6 *ip6info,
unsigned int *protoff,
int *fragoff)
int *fragoff, int *hotdrop)
{
size_t i;
unsigned long ret;
Expand Down Expand Up @@ -169,9 +169,11 @@ ip6_packet_match(const struct sk_buff *skb,
unsigned short _frag_off;

protohdr = ipv6_find_hdr(skb, protoff, -1, &_frag_off);
if (protohdr < 0)
if (protohdr < 0) {
if (_frag_off == 0)
*hotdrop = 1;
return 0;

}
*fragoff = _frag_off;

dprintf("Packet protocol %hi ?= %s%hi.\n",
Expand Down Expand Up @@ -290,7 +292,7 @@ ip6t_do_table(struct sk_buff **pskb,
IP_NF_ASSERT(e);
IP_NF_ASSERT(back);
if (ip6_packet_match(*pskb, indev, outdev, &e->ipv6,
&protoff, &offset)) {
&protoff, &offset, &hotdrop)) {
struct ip6t_entry_target *t;

if (IP6T_MATCH_ITERATE(e, do_match,
Expand Down

0 comments on commit 51d8b1a

Please sign in to comment.