netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: RFC: Mandatory Access Control for sockets aka "personal   firewalls"
@ 2009-01-21  9:32 Rob Meijer
  2009-01-21 23:28 ` Peter Dolding
  0 siblings, 1 reply; 28+ messages in thread
From: Rob Meijer @ 2009-01-21  9:32 UTC (permalink / raw)
  To: Peter Dolding
  Cc: rmeijer, Casey Schaufler, Samir Bellabes, imipak,
	linux-security-module, Stephan Peijnik, netdev, netfilter-devel

On Wed, January 21, 2009 09:15, Peter Dolding wrote:

> Netfilter can already reject or approve out going packets from
> applications on the base of user id process id and so on.  This is
> before packets enter the Netfilter processing stack.   Cost of looking
> up if applicaiton is approved or not appoved is out weight be the cost
> of rejected packets going trough netfilter.
>
> Sorry netfilter is already sorting out how sockets can be used.   What
> you are basically talking about is two layors doing exactly the same
> thing.   Half of what tuxguardian does can be done in a iptables
> module.  Ie filtering out going traffic based on application.
>
> Please explain why expanding netfilter is not a option.   Expanding
> netfilter avoids conflicts with LSM's.
>

Agreed patches to Netfilter might get you a long way. Along the lines of
--owner-uid you may extend it with something like --owner-exe and possibly
--owner-callchainid. That could take care of:

* connection-full-protocol like TCP
* outgoing connection-less-protocol packets like UDP or ICMP

The one thing that would remain would be incoming connection-less-protocol
packets. If Netfilter could be patched in such a way that incoming packets
could be filtered based on receiving process meta, that would be a great
way to go. If not, maybe LSM would need to just mediate 'bind'.

A second issue comes with user level administration. If Netfilter would be
patched to allow a user to administrate her 'private' table, that could
get called from the system wide Netfilter rules, some MAC framework would
still be needed to make sure the user has a way to change the rules in her
private table, but her browser, pdf reader, mail client etc have not.

That is, you could define some system wide ruleset like:

System wide:
  * deny any packet from executables under '/home/*'
  * deny any packet from user 'localuser'
  * for any packet from an executable under /usr/bin/networkingtools/ jump
    to the users USERPRIVATE table.
  * deny all other trafic.

User alice USERPRIVATE:
  * allow all packets from /usr/bin/webbrowser to anything on tcp port 80.

User bob USERPRIVATE:
  * allow all packets from /usr/bin/webbrowser to the socks port of the
    socks server.

Would a solution like that be feasible?

You would want alice or bob to be able to change their USERPRIVATE table,
but you wouldn't want /usr/bin/webbrowser or any other program to do so
independently. At least for that you would need close cooperation with
for example SeLinux or AppArmor.

Further it seems that 'bind' for connection less sockets will still be
important a candidate for mediation by LSM IMHO.

Rob.


^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: RFC: Mandatory Access Control for sockets aka "personal firewalls"
@ 2009-01-21  7:25 Rob Meijer
  2009-01-21  8:15 ` Peter Dolding
  0 siblings, 1 reply; 28+ messages in thread
From: Rob Meijer @ 2009-01-21  7:25 UTC (permalink / raw)
  To: Casey Schaufler
  Cc: Samir Bellabes, imipak, linux-security-module, Stephan Peijnik,
	netdev, netfilter-devel

On Wed, January 21, 2009 02:18, Casey Schaufler wrote:
>
>> we don't need this at all, as we are in process context, syscall can
>> sleep.
>> Trust me, it's strange to have it's web browser freezing waiting for a
>> timeout if the userspace part doesn't reply, but if it's replying, it's
>> transparent.
>
> I hate to be the one to say this, but it looks to me as if the
> easiest way to solve the problems that you have outlined would
> be to create a new LSM based on SELinux with two important
> changes. The first would be to have a separate policy for each
> user (or process tree) and the second would be to make the policy
> specification discretionary. SELinux has all the mechanism you're
> talking about, but you want the policy being enforced to reflect
> a set of "personal firewall" rules rather than "domain type" rules.
>  From the lobby at LCA in Hobart these rule sets are pretty hard to
> tell apart. And let's not have the "SELinux isn't designed to do
> that" row. Of course it isn't. Nonetheless, the personal firewall
> sure sounds a lot like SELinux if you ignore the MAC/DAC difference.

I think this is a perfect example of where using MAC 'and' DAC or rather
centrally 'and' user managed profiles would be very fruitful. If you can
create a purely permissive centrally managed per user profile, in fact
delegating a permission set and allow each user to decompose and
discretionary delegate parts of this profile to programs run by this same
user, but with MAC restrictions when delegating to a process run by a
different user, you would IMHO have a very powerful combination of MAC and
DAC.

I'm not sure however a label based MAC system would be best suited for
combining MAC and DAC in such a way.



Rob


^ permalink raw reply	[flat|nested] 28+ messages in thread
* RFC: Mandatory Access Control for sockets aka "personal firewalls"
@ 2009-01-20 17:48 Stephan Peijnik
  2009-01-20 18:24 ` Jan Engelhardt
                   ` (3 more replies)
  0 siblings, 4 replies; 28+ messages in thread
From: Stephan Peijnik @ 2009-01-20 17:48 UTC (permalink / raw)
  To: linux-security-module; +Cc: netdev, netfilter-devel

Hello all of you,

I am sending this email as a discussion about this topic has been going
on at linux-security-module@vger.kernel.org for some time now and I
believe that all parties affected or somehow related to this should be
involved in the discussion. We would like to hear your opinion on this
matter and would be glad if we could work together on finding a possible
solution. I have CC'ed linux-security-module, netfilter-devel and
netdev, but if you believe that I missed someone, feel free to forward
this email to the respective list.

Firstly, I would like to elaborate on what we more or less agreed on a
personal firewall should be able to do and what such a piece of software
is intended for.

A personal firewall should implement per-application mandatory access
control for sockets. In short this means that such a program decides
every time a call to either socket(), accept(), bind(), connect() or
listen() is made whether the invoking program is allowed to do so or
not. No per-packet filtering can be done and neither is connection
intercepting of any interest.

As personal firewalls are targeted at single-user, desktop systems the
decision on whether a call is allowed or not is usually made by the user
of that system (for example using a popup asking the user what to do).
This means personal firewalls should not enforce system security policy,
but rather a per-user security policy.
The implementations can then add caching of decisions made (ie.
"remember this decision") and thus not ask every time a call is made.
Also, the only protocols to be supported are IPv4 and IPv6. Adding
support for AF_UNIX and/or AF_NETLINK doesn't make much sense, as this
is not network-related and would only increase the amount of work a
personal firewall implementation has to do.

All proposed implementations of personal firewalls until now have made
it rather clear that the decision-making logic should be placed in
userspace, whilst only a small piece of code communicating with a
userspace daemon should be placed in the kernel itself.


Okay, enough of the (not so) brief description on what people want to do
and on to a summary of what has been discussed so far.

Most implementations started out using the LSM framework for creating a
personal firewall, that's also the reason the whole discussion started
out on the LSM mailing list.
Even though this looks like a good solution there is one main problem
with the LSM framework right now: only a single LSM module can be loaded
and enabled at a time. However, this was done intentionally as stacking
multiple LSMs proved to be complex and not entirely sane.
This means that if one decides to enable a personal firewall LSM at boot
time one will not be able to use a generic-purpose LSM, like SELinux or
AppArmor simultaneously. Additionally LSMs can only be enabled at boot
time and cannot be LKMs, they have to be linked statically into the
kernel. 

Another approach that has been suggested is using the netfilter
framework for this purpose. Even though this again sounds like a good
idea in the first place it also has its flaws.
netfilter was designed to work on the network level and, at least from
my understanding, is not process-context aware. Doing lookups to get the
process context on each and every connection/packet passing netfilter
could be done, but might have a negative effect on the overall system
performance.

And yet another approach was suggested: hooking socket-related calls
directly in net/socket.c. This would mean that the personal firewall
code is called directly from net/socket.c and can this way work in
process-context, without using the LSM framework.
On the other hand this would add, besides the LSM calls that are in
place in net/socket.c a few extra calls which might not be what we want.
One should also keep in mind that calls can (and may, this is
intentional) be blocked by the personal firewall system. This could be
seen as an advantage or disadvantage, but would allow waiting for user
input until proceeding with the execution of the caller.

What has not been agreed on yet is whether only a way of hooking these
calls should be made available to implementations or whether the whole
in-kernel part should be developed together and allow implementations of
personal firewalls in userspace only, for example using a netlink socket
to communicate with the shared in-kernel code.

Implementations using the LSM approach are TuxGuardian [0] and snet [1].
Code implementing the last mentioned approach can be found in git over
at [2] in the sactl-direct branch.
Please don't forget that these implementations are probably in either a
defunct state or are up to discussion themselves.

As a final note I would like to add that I believe that all lists this
mail has been sent to are somehow affected by the topic we are
discussing and I (or better said we) would love to hear your opinions.
Also, I hope I didn't miss anything that was discussed, but if I did
feel free to correct me.

-- Stephan

[0] http://tuxguardian.sourceforge.net/
[1] http://www.synack.fr/project/snet/snet.html
[2] http://repo.or.cz/w/linux-2.6/sactl.git


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

end of thread, other threads:[~2009-01-22 17:08 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-21  9:32 RFC: Mandatory Access Control for sockets aka "personal firewalls" Rob Meijer
2009-01-21 23:28 ` Peter Dolding
2009-01-22  0:50   ` Jonathan Day
2009-01-22  0:59     ` Casey Schaufler
2009-01-22  6:29       ` Jonathan Day
2009-01-22 13:46     ` Peter Dolding
2009-01-22 17:08       ` Jonathan Day
  -- strict thread matches above, loose matches on Subject: below --
2009-01-21  7:25 Rob Meijer
2009-01-21  8:15 ` Peter Dolding
2009-01-21  8:35   ` Jan Engelhardt
2009-01-20 17:48 Stephan Peijnik
2009-01-20 18:24 ` Jan Engelhardt
2009-01-20 18:56   ` Stephan Peijnik
2009-01-20 20:15     ` Samir Bellabes
2009-01-20 20:31       ` Jan Engelhardt
2009-01-20 20:53         ` Paul Moore
2009-01-20 21:42           ` Samir Bellabes
2009-01-20 21:51             ` Paul Moore
2009-01-20 19:46 ` Jonathan Day
2009-01-20 21:01   ` Paul Moore
2009-01-21  0:54   ` Samir Bellabes
2009-01-21  1:18     ` Casey Schaufler
2009-01-21  3:14       ` Samir Bellabes
2009-01-20 20:47 ` Paul Moore
2009-01-20 23:48   ` Stephan Peijnik
2009-01-21  8:18     ` Samir Bellabes
2009-01-21 14:49     ` Paul Moore
2009-01-21  0:40 ` Samir Bellabes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).