All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cedric Blancher <blancher@cartel-securite.fr>
To: Nick Drage <nickd@funkyjesus.org>
Cc: netfilter mailing list <netfilter@lists.netfilter.org>
Subject: Re: what filtering to do on the OUTPUT chain?
Date: 23 Oct 2002 08:51:53 +0200	[thread overview]
Message-ID: <1035355913.20496.19.camel@elendil> (raw)
In-Reply-To: <20021023003146.D8681@funkyjesus.org>

Le mer 23/10/2002 à 01:31, Nick Drage a écrit :
> "--cmd-owner" is your friend, your close, personal, bestest friend.

--cmd-owner is, imho, not usable on its own for filtering purposes, such
as application based filtering.

I'll try to show why :

root@elendil:~# iptables -A OUTPUT -m owner --cmd-owner "nc" -j REJECT

So I should not be able to execute a netcat. I use a REJECT rule to give
a simple example.

cbr@elendil:~$ nc 192.168.1.10 22
(UNKNOWN) [192.168.1.10] 22 (ssh) : Connection refused

Fine. That's what I wanted.

cbr@elendil:~$ ln -s /bin/nc toto
cbr@elendil:~$ ./toto 192.168.1.10 22
SSH-2.0-Feydreiva SSH daemon

Well, a bit tricky... If you investigate a bit more and set a DROP
policy up with only allowed application, you'll discover you just can't
specify a command path, only a command name. That means if you allow
"ping" command, any command named ping will do the trick, would it be a
symlink named "ping" to another command or a binary named "ping". So, if
you want to do it well, you have to restrict your filesystem, forbiding
users to write in order to prevent them to create another "ping".

So --cmd-owner becomes useful when used with other matches, to restrict
ping command to ICMP echo requests as an exemple :

iptables -A OUTPUT -m owner --cmd-owner "ping" -m state --state NEW \
	-p icmp --icmp-type echo-request -j ACCEPT

Solution would be to match commands not on name, but on the exact binary
location (inode number, device number), but it is far out of my skills
to implement this. Moreover, it could affect performance (but you can
reduce it well using state match and only filter NEW packets using this
stuff).

By the way, owner match is very useful to me, especially --uid-owner and
--gid-owner.

-- 
Cédric Blancher  <blancher@cartel-securite.fr>
IT systems and networks security expert  - Cartel Sécurité
Phone : +33 (0)1 44 06 97 87 - Fax: +33 (0)1 44 06 97 99
PGP KeyID:157E98EE  FingerPrint:FA62226DA9E72FA8AECAA240008B480E157E98EE


      reply	other threads:[~2002-10-23  6:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-22 18:57 what filtering to do on the OUTPUT chain? Robert P. J. Day
2002-10-22 20:03 ` Antony Stone
2002-10-22 23:26   ` Nick Drage
2002-10-22 20:09 ` Cedric Blancher
2002-10-22 20:10   ` Robert P. J. Day
2002-10-22 23:21     ` Cedric Blancher
2002-10-23  9:43       ` Antony Stone
2002-10-23 10:24         ` Cedric Blancher
2002-10-24 21:31         ` Nick Drage
2002-10-24 23:06           ` Antony Stone
2002-10-22 23:31     ` Nick Drage
2002-10-23  6:51       ` Cedric Blancher [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1035355913.20496.19.camel@elendil \
    --to=blancher@cartel-securite.fr \
    --cc=netfilter@lists.netfilter.org \
    --cc=nickd@funkyjesus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.