All of lore.kernel.org
 help / color / mirror / Atom feed
* Security flaw in Stateful filtering ??????
@ 2002-06-07  9:42 Mikkel Christiansen
  2002-06-08  7:44 ` Harald Welte
  0 siblings, 1 reply; 55+ messages in thread
From: Mikkel Christiansen @ 2002-06-07  9:42 UTC (permalink / raw)
  To: netfilter-devel

Hi 

I'm still not sure I quite understand what actions an 
ACK packet from an unregistered connection causes when 
running in connection-pickup mode. Mainly, I'm interested
in knowing whether it causes a new connection to be 
registered in the connnection table or not?
 
Thanks for all the feedback - atleast to us - this is 
a quite interesting discussion.

-Mikkel

^ permalink raw reply	[flat|nested] 55+ messages in thread
[parent not found: <20020606220914.A14542@groar.org>]
* Re: Security flaw in Stateful filtering ??????
@ 2002-06-06 22:15 Andy Whitcroft
  0 siblings, 0 replies; 55+ messages in thread
From: Andy Whitcroft @ 2002-06-06 22:15 UTC (permalink / raw)
  To: Emmanuel Fleury
  Cc: Torben Vinther Schmidt, Mikkel Christiansen,
	Mikkel Refsgaard Bech, netfilter-devel, netfilter-devel-admin,
	Carsten Stiborg

If I understand correctly what is being said is that if
an ACK only packet passes the firewall for a connection
which is otherwise unknown a lost connection is assumed
and the connection will be reaquired, ie become valid
and allow reply packets to be treated as ESTABLISHED from
a contrack point of view.

Whilst this sounds dangerous, the key statement here is
that the ACK only packet is treated as NEW.  If you are
accepting state NEW you are allowing new connections
to pass the firewall in that direction anyhow, so the
firewall is 'open' in that direction.  So almost any
kind of port scan is likely to work in that direction.

Taking your example, this will occur because the packet
matches the NEW state match and is acceptable, note it
is not matching the ESTABLISHED state.

iptables -A FORWARD -p tcp -m state --state ESTABLISHED -j ACCEPT
iptables -A FORWARD -p tcp -m state --state NEW -j ACCEPT
iptables -A FORWARD -p tcp -j DROP

A more typical example would be something like below.
Here we only accept NEW packets from the LAN interface
(a safe and secure internal network).  In the case of
a loss of the connection (from a firewall reboot) we
will be getting ACK packets from both ends of the
connection.  However, the packets from the dangerous
end of the connection will not be compared to the
NEW state and so be dropped as expected.  The first
ACK from the secure internal network will reopen
the connection in the firewall and then the external
ACK's will start to be accepted as ESTABLISHED.

iptables -A FORWARD -i $WAN -o $LAN -p tcp \
      -m state --state ESTABLISHED -j ACCEPT
iptables -A FORWARD -i $LAN -o $WAN -p tcp \
      -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A FORWARD -p tcp -j DROP

Assuming I understand this correctly this seems safe
as connection reaquire can only occur in the directions
through the firewall that we have already said
attempting to open connections is valid.

Cheers.

-apw

^ permalink raw reply	[flat|nested] 55+ messages in thread
* RE: Security flaw in Stateful filtering ??????
@ 2002-06-06 19:29 Sneppe Filip
  0 siblings, 0 replies; 55+ messages in thread
From: Sneppe Filip @ 2002-06-06 19:29 UTC (permalink / raw)
  To: Emmanuel Fleury, netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]

Yes, it's that time of the month again :-) 

Emmanuel Fleury [mailto:fleury@cs.auc.dk] wrote:
>
>Patrick Schaaf wrote:
>
>> The behaviour is intentional. The reason is "connection pickup". Imagine
>> a situation where the firewall reboots. All active conntracking information
>> will be lost. With the observed behaviour, connections are "relearned"
>> on the fly as they create new traffic.
>
>I simply disagree with you on this point (sorry :-/).
>
>I wouldn't accept to have such a flaw in my firewall just because of
>an hypothetic reboot of one of my gateway !!!!
>
>Of course, I could be wrong, but in this case this 'feature' should be
>highly documented and be disabled as default. IMHO.

Hi Emmanuel,

Please note that connection tracking doesn't just pick up connections
based on ACK packets willy-nilly after hypothetical reboots. So there
really is no security problem whatsoever.

It's all a matter of the policy set by the admin. If you have rules
that say to accept ESTABLISHED packets, and to accept tcp connections
to port 25 of your mailserver's IP address, and if your firewall reboots,
it's not like all of a sudden other ports to the mailserver will open 
automagically!

If the mailserver sends a packet with sourceip=it's IP, source port=25,
destip=remote IP, destport= > 1023, it will get dropped, and if 
the other end sends a non-SYN packet to port 25, it goes through and the 
connection picks up, just like you specified in the rules. 

It's a feature I want, and I assume a lot of people want it, since
Checkpoint has been behaving exactly like this for many years.

If you're worried about weird scans, just specify tighter rules
and combine the ESTABLISHED and NEW states with additional checking
of TCP flags.

iptables offers flexibility, not a policy, and one should tailor 
netfilter/iptables to one's needs/policy.

Regards,
Filip





[-- Attachment #2: Type: text/html, Size: 2627 bytes --]

^ permalink raw reply	[flat|nested] 55+ messages in thread
* Security flaw in Stateful filtering ??????
@ 2002-06-06 17:21 Emmanuel Fleury
  2002-06-06 17:48 ` Martin Josefsson
                   ` (2 more replies)
  0 siblings, 3 replies; 55+ messages in thread
From: Emmanuel Fleury @ 2002-06-06 17:21 UTC (permalink / raw)
  To: netfilter-devel
  Cc: Mikkel Christiansen, Mikkel Refsgaard Bech,
	Torben Vinther Schmidt, Carsten Stiborg

Hi,

I am co-supervising students in Aalborg university on a project
about firewalls (and more precisely about stateful firewalling)
in collaboration with Mikkel Christiansen.

Recently, they were testing some of their ideas to improve the
connection tracking module of Netfilter in the university lab
and they discovered some weird things in the behaviour of
Netfilter.

I am just quoting their mail here:

=====
....

The Setup:
----------
A classical client-filter-server setup (two different networks on each
end with a filter/gateway in between). The filter/gateway is configured
to route between the two nets and has the following rules in IP Tables
as suggested by the documentation (see:
http://netfilter.samba.org/documentation/HOWTO/packet-filtering-HOWTO-5.html):

iptables -A FORWARD -p tcp -m state --state ESTABLISHED -j ACCEPT
iptables -A FORWARD -p tcp -m state --state NEW -j ACCEPT
iptables -A FORWARD -p tcp -j DROP

These rules should indicate that we allow packets that create new
connections and packets that are a part of an established connection.
We then drop everything else. These are not good rules for a filter but
they illustrate the point.


The Problem:
------------
When sending an ACK packet, the packet is allowed through the filter.
Due to the second rule. This means that ACK packets are accepted as
being in the state NEW and does not create an entry in the state table.
So if any rule state that we allow NEW connections, this rule can be
used for port scanning.

The ACK packet and the corresponding RST packet were observed on every
machine, i.e. client, server and filter. And, actually, we were able to 
perform a complete ACK scan of the whole network through the filter by
using "nmap -sA".


A Solution:
-----------
As a temporary hack the following rule can be added as the second rule:

iptables -A FORWARD -p tcp --tcp-flags ACK ACK -j DROP

However, this is not a solid solution and the code should be modified,
as we see it, not to recognize ACK packets as being in the state NEW.

We were wondering if this is intentional due to some reason that we
cannot see or if it is a flaw as suggested ?

We have found something about it in the Iptables tutorial (1.1.8),
page 54 (Appendix B, "State NEW packets but no SYN bit set").
But, this is not really convincing.

Any idea ????

Regards,
Mikkel Refsgaard Bech
Torben Vinther Schmidt
Carsten Stiborg
=====

For short:
- ACK packets are classified as NEW (without opening a connection),
- Therefore, allowing NEW packets allow all the ACK packets to go
   through,
- And consequently, in this setting, you can perform ACK scanning
   if you just trust the documentation...

Actually, I don't know what to answer to them. Has somebody any clue to
explain this ?

Regards
-- 
Emmanuel

Maybe somebody should tell gcc maintainers about programmers
that know more than the compiler again.
   -- Linus Torvalds

^ permalink raw reply	[flat|nested] 55+ messages in thread

end of thread, other threads:[~2002-06-12  9:23 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-07  9:42 Security flaw in Stateful filtering ?????? Mikkel Christiansen
2002-06-08  7:44 ` Harald Welte
     [not found] <20020606220914.A14542@groar.org>
2002-06-06 23:31 ` Rusty Russell
2002-06-06 23:52   ` Joerg Mayer
2002-06-07  2:10     ` Rusty Russell
2002-06-07  2:53       ` Joerg Mayer
2002-06-07 12:45         ` Marcus Sundberg
2002-06-07 14:36       ` Henrik Nordstrom
2002-06-07 21:48     ` Ben Reser
2002-06-07  8:15   ` Emmanuel Fleury
2002-06-07  8:50     ` Oskar Andreasson
2002-06-07 12:27       ` Jozsef Kadlecsik
2002-06-10  8:04         ` Oskar Andreasson
2002-06-10  8:26           ` Emmanuel Fleury
2002-06-12  9:23           ` Jozsef Kadlecsik
2002-06-07  9:05     ` Henrik Nordstrom
2002-06-07  9:31       ` Emmanuel Fleury
2002-06-07  9:41         ` Oskar Andreasson
2002-06-07  9:43         ` Guillaume Morin
2002-06-07  9:57           ` Emmanuel Fleury
2002-06-07 10:17             ` Guillaume Morin
2002-06-07 11:30               ` Emmanuel Fleury
2002-06-07 13:33                 ` Guillaume Morin
2002-06-07 15:13                   ` Emmanuel Fleury
2002-06-07 18:36                     ` Guillaume Morin
2002-06-07 19:00                       ` Patrick Schaaf
2002-06-08  2:06                         ` Emmanuel Fleury
2002-06-08  8:21                           ` Patrick Schaaf
2002-06-08 12:02                             ` Henrik Nordstrom
2002-06-09  7:03                               ` Emmanuel Fleury
2002-06-09  8:29                                 ` Patrick Schaaf
2002-06-08  1:42                       ` Emmanuel Fleury
2002-06-07 10:17             ` Henrik Nordstrom
2002-06-07 10:11         ` Henrik Nordstrom
2002-06-07 22:02     ` Ben Reser
2002-06-08  2:13       ` Emmanuel Fleury
2002-06-08  8:23         ` Patrick Schaaf
2002-06-08 16:41         ` Ben Reser
  -- strict thread matches above, loose matches on Subject: below --
2002-06-06 22:15 Andy Whitcroft
2002-06-06 19:29 Sneppe Filip
2002-06-06 17:21 Emmanuel Fleury
2002-06-06 17:48 ` Martin Josefsson
2002-06-06 17:54 ` Maciej Soltysiak
2002-06-06 18:52   ` Emmanuel Fleury
2002-06-06 19:11     ` Maciej Soltysiak
2002-06-06 19:30     ` Guillaume Morin
2002-06-06 19:53       ` Patrick Schaaf
2002-06-06 19:43     ` Henrik Nordstrom
2002-06-06 17:57 ` Patrick Schaaf
2002-06-06 18:34   ` Emmanuel Fleury
2002-06-06 19:12     ` Patrick Schaaf
2002-06-06 19:28       ` Emmanuel Fleury
2002-06-06 19:27     ` Henrik Nordstrom
2002-06-06 20:50       ` Emmanuel Fleury
2002-06-06 21:26         ` Henrik Nordstrom

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.