All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Johansen <john.johansen-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
To: Jacek <wampir990-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: apparmor-nLRlyDuq1AZFpShjVBNYrg@public.gmane.org
Subject: Re: Apparmor netfiter support?
Date: Mon, 7 Jan 2019 08:51:19 -0800	[thread overview]
Message-ID: <2689a780-1330-15a7-5dc5-b2b31696a4e3@canonical.com> (raw)
In-Reply-To: <91b5b9f7-bb9a-29d9-bc72-b0077b885726-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On 1/7/19 2:16 AM, Jacek wrote:
> Hi
> 
> Apparmor hasn't a Netfilter firewall support module.
> 
> Network rules is a good choice for applications that have AA-profiles,
> but it does not protect unconfined processes for forbidden network
> outgoing connections.
> 
> I mean the function of the Security netfiter tables for SElinux, but the
> easy way similar to xt_gradm, part of the Grsecurity project:
> https://grsecurity.net/stable/grsecurity-2.2.0-iptables.patch
> 
there is work in progress to support secmark (the same mechanism used
by selinux) to apparmor. The base of this work landed in 4.20 and it
is possible to play with it today but it has some limitations.

Currently their is no integration with apparmor policy which means
the label set with the secmark is limited to the label of the task
that created the socket. This works for a lot of applications but
is insufficient for others.

It will also have issues when policy stacking is used in conjunction
with network namespaces (lxd style containers). There are also
problems with LSM stacking which is still in development.

In addition integration into iptables, nftables etc will need some
work.

Long term the goal is to support both secmark and policy based
networking rules. The policy based rules are necessary to be able
to provide customized labels and also to support certain features
not possible through the secmark.


> Proposed solution (userspace):
> NFtables (next Linux firewall):
> 
> nft insert rule ip filter output meta apparmor aapolicy unconfined drop
> nft insert rule ip filter output meta apparmor aapolicy enforce accept
> nft insert rule ip filter output meta apparmor aapolicy complain log accept
> 
> Iptables (current/old Linux firewall):
> iptables -I OUTPUT ! -o lo -m apparmor --aapolicy unconfined -j DROP
> iptables -A OUTPUT ! -o lo -m apparmor --aapolicy enforce  -j ACCEPT
> iptables -A OUTPUT ! -o lo -m apparmor --aapolicy complain  -j LOG
> --log-prefix "$PROFILE_NAME - complain: $APP_NAME"
> iptables -A OUTPUT ! -o lo -m apparmor --aapolicy complain  -j ACCEPT
> 
> 
> 
> Example log from LSM Integrity IMA (Apparmor Variables - enforce)
> 
> /audit: type=1800 audit(1546855115.951:3766): pid=12211 uid=0 auid=1001 ses=4 subj==/bin/kmod (enforce) op=appraise_data cause=IMA-signature-required comm="modprobe" name="/lib64/modules/4.19.13-gt5/kernel/net/sched/sch_codel.ko" dev="sdb1" ino=1334797 res=0/
> 
> /where:/
> 
> Apparmor Profile name & policy:/   //subj==/bin/kmod (enforce) /
> Real aplication name:  /comm="modprobe" /
> 
> AA-variables - unconfined:
> 
> [ 1703.396288] audit: type=1800 audit(1546855383.896:3777): pid=12347 uid=0 auid=1001 ses=4 subj==unconfined op=appraise_data cause=IMA-signature-required comm="modprobe" name="/lib64/modules/4.19.13-gt5/kernel/net/sched/sch_codel.ko" dev="sdb1" ino=1334797 res=0
> 
> where:
> 
> AA-policy: subj==unconfined
> 
> aplication name:    comm="modprobe"
> 
> AA-variables - complain:
> 
> audit: type=1800 audit(1546855552.256:3785): pid=12402 uid=0 auid=1001 ses=4 subj==/bin/kmod (complain) op=appraise_data cause=IMA-signature-required comm="insmod"  name="/lib64/modules/4.19.13-gt5/kernel/net/sched/sch_codel.ko" dev="sdb1" ino=1334797 res=0
> 
> where:
> 
> AA - profile & policy:  subj==/bin/kmod (complain)
> 
> App name: comm="insmod"
> 
> I'm not a programmer, is there any chance of adding a similar module in
> Apparmor?
> 

Currently it is not a module, its a build time configuration so that if the kernel being built supports it and if it is enabled in apparmor's config it is built in to the kernel as part of apparmor.

-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor

      parent reply	other threads:[~2019-01-07 16:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-07 10:16 Apparmor netfiter support? Jacek
     [not found] ` <91b5b9f7-bb9a-29d9-bc72-b0077b885726-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-01-07 16:51   ` John Johansen [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=2689a780-1330-15a7-5dc5-b2b31696a4e3@canonical.com \
    --to=john.johansen-z7wlfzj8ewms+fvcfc7uqw@public.gmane.org \
    --cc=apparmor-nLRlyDuq1AZFpShjVBNYrg@public.gmane.org \
    --cc=netfilter-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=wampir990-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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.