Unix Technical Forum

Verify whether PF is stateful inspection.

This is a discussion on Verify whether PF is stateful inspection. within the comp.unix.bsd.openbsd.misc forums, part of the OpenBSD category; --> Dear all, As our client need to make sure the PF in OpenBSD is a stateful firewall, I need ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > comp.unix.bsd.openbsd.misc

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-16-2008, 04:29 AM
Sam
 
Posts: n/a
Default Verify whether PF is stateful inspection.

Dear all,

As our client need to make sure the PF in OpenBSD is a stateful
firewall, I need to conduct a little test against the PF from the
internet. Is there any tool I can issue an unstateful connection to the
OpenBSD PF firewall and the result should indicate it is stateful?

Thanks
Sam

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-16-2008, 04:29 AM
Sam
 
Posts: n/a
Default Re: Verify whether PF is stateful inspection.



Sam wrote:
> Dear all,
>
> As our client need to make sure the PF in OpenBSD is a stateful
> firewall, I need to conduct a little test against the PF from the
> internet. Is there any tool I can issue an unstateful connection to the
> OpenBSD PF firewall and the result should indicate it is stateful?
>
> Thanks
> Sam
>


I just found something with nmap. Is half open, option -sS with nmap
actually try to generate an unstateful connection? What other example I
can use?

Thanks
sam

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-16-2008, 04:29 AM
Daniel Hartmeier
 
Posts: n/a
Default Re: Verify whether PF is stateful inspection.

On Tue, 19 Aug 2003 16:02:01 +0800, Sam wrote:

> As our client need to make sure the PF in OpenBSD is a stateful
> firewall, I need to conduct a little test against the PF from the
> internet. Is there any tool I can issue an unstateful connection to the
> OpenBSD PF firewall and the result should indicate it is stateful?


With a stateless firewall, you have to allow certain incoming packets
to allow replies for outgoing connections. For instance, if you want
to allow replies to outgoing http connections, you usually need
something like

pass out from any port > 1024 to any port 80
pass in from any port 80 to any port > 1024

The problem is that you're allowing in any packets from source
port 80, even if they're not part of an outgoing connection.
Set up a listener on port 1234 on the local host, then connect
to it from an external host (using source port 80, use nc as
root on OpenBSD). If you can connect, the firewall is stateless.

If the firewall is stateful, you'd use instead

pass out from any to any port 80 keep state
block in from any to any

which would still allow in replies to outgoing connections. Now
repeat the test by trying to connect from the external host port
80 to the local host port 1234. You won't succeed.

You can use dnet from ports/net/libdnet to send arbitrary TCP
packets from the external host. Establish a TCP connection from/to
the firewall'ed host, then use dnet on the external host to try to
deliver arbitrary TCP packets (with the same source/destination
address/port), but random TCP sequence numbers. A stateful
firewall will compare the sequence numbers, and only pass those
packets with sequence numbers within a narrow window, defined
by the established connection.

For added fun, you can fragment the manually generated TCP
packets, make the fragments overlap, overlap the TCP header,
send different data for overlaps (including different TCP
port numbers), etc.

Another way to show that pf is stateful is explaining what
'modulate state' does, and demonstrate that it works (using
a host with weak ISN generation, for optimum effect). There
is no way to implement this feature in a stateless firewall
(supporting multiple concurrent connections, using different
random modulators for each connection).

Daniel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-16-2008, 04:30 AM
Sam
 
Posts: n/a
Default Re: Verify whether PF is stateful inspection.



Daniel Hartmeier wrote:
> On Tue, 19 Aug 2003 16:02:01 +0800, Sam wrote:
>
>
>>As our client need to make sure the PF in OpenBSD is a stateful
>>firewall, I need to conduct a little test against the PF from the
>>internet. Is there any tool I can issue an unstateful connection to the
>>OpenBSD PF firewall and the result should indicate it is stateful?

>
>
> With a stateless firewall, you have to allow certain incoming packets
> to allow replies for outgoing connections. For instance, if you want
> to allow replies to outgoing http connections, you usually need
> something like
>
> pass out from any port > 1024 to any port 80
> pass in from any port 80 to any port > 1024
>
> The problem is that you're allowing in any packets from source
> port 80, even if they're not part of an outgoing connection.
> Set up a listener on port 1234 on the local host, then connect
> to it from an external host (using source port 80, use nc as
> root on OpenBSD). If you can connect, the firewall is stateless.
>
> If the firewall is stateful, you'd use instead
>
> pass out from any to any port 80 keep state
> block in from any to any
>
> which would still allow in replies to outgoing connections. Now
> repeat the test by trying to connect from the external host port
> 80 to the local host port 1234. You won't succeed.
>
> You can use dnet from ports/net/libdnet to send arbitrary TCP
> packets from the external host. Establish a TCP connection from/to
> the firewall'ed host, then use dnet on the external host to try to
> deliver arbitrary TCP packets (with the same source/destination
> address/port), but random TCP sequence numbers. A stateful
> firewall will compare the sequence numbers, and only pass those
> packets with sequence numbers within a narrow window, defined
> by the established connection.
>
> For added fun, you can fragment the manually generated TCP
> packets, make the fragments overlap, overlap the TCP header,
> send different data for overlaps (including different TCP
> port numbers), etc.
>
> Another way to show that pf is stateful is explaining what
> 'modulate state' does, and demonstrate that it works (using
> a host with weak ISN generation, for optimum effect). There
> is no way to implement this feature in a stateless firewall
> (supporting multiple concurrent connections, using different
> random modulators for each connection).
>
> Daniel


Thanks Daniel. How about using the following simpler way to verify it:

Block and Lock everything, allow outgoing connection from your browser
and see if the fw locks the returning data. If the page gets displayed,
the fw is a statefull firewall. Otherwise, I will have to add a rule like

"allow from any 80 to myself any"


Is this make sense?

Thanks
sam

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:07 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com