Bug#913020: [Pkg-clamav-devel] Bug#913020: clamd: apparmor denials: cap net_admin, openssl.conf

2018-11-11 Thread Christian Boltz
Hello,

I wouldn't be surprised if capability net_admin is triggered by 
https://bugzilla.opensuse.org/show_bug.cgi?id=991901 (which turned out 
to be an upstream systemd bug) and fixed by 
https://github.com/systemd/systemd/pull/10085

I'd recommend to ask the systemd maintainers to apply/backport that 
patch - it will help to avoid "capability net_admin" requests in several 
daemons (bassically all that use libsystemd sd_notifyf() etc.)


Regards,

Christian Boltz
-- 
 can you please add a safety check to make sure this doesn't
 happen again?
 (for example: the file must have at least 100 lines)
 cboltz: that check was in place
 error page was long enough
[from #opensuse-admin]


signature.asc
Description: This is a digitally signed message part.


Bug#913020: [Pkg-clamav-devel] Bug#913020: clamd: apparmor denials: cap net_admin, openssl.conf

2018-11-11 Thread intrigeri
Hi,

Sebastian Andrzej Siewior:
> intrigeri, I added you on Cc since you were a help the last time
> apparmor came around.

Thanks! Sure, happy to give a hand. I've usertagged this bug so it's
on the AppArmor team's radar (and not just on mine). See the
corresponding documentation:
https://wiki.debian.org/AppArmor/Reportbug#Usertags :)

> On 2018-11-06 10:45:15 [+0800], Paul Wise wrote:
>> AVC apparmor="DENIED" operation="capable" profile="/usr/sbin/clamd" 
>> pid=13277 comm="clamd" capability=12  capname="net_admin"
>> AVC apparmor="DENIED" operation="open" profile="/usr/sbin/clamd" 
>> name="/etc/ssl/openssl.cnf" pid=13277 comm="clamd" requested_mask="r" 
>> denied_mask="r" fsuid=111 ouid=0

> I have no idea what the first one is one about. If this is related to
> #903834 then I think I know what I have to do.

I doubt this is related to #903834 because this time, the requested
capability is missing in the usr.sbin.clamd profile. But in any case,
fixing the racy postinst would be good and who knows, it might fix
this bug too.

The net_admin capability is about modifying the network state, such as
creating network devices, changing sysctls such as net.core.somaxconn,
using RAW or PACKET sockets, binding to any address, modifying routing
tables, some setsockopt() options, this sort of things.

If clamd needs to do this sort of things in order to do its job,
then the AppArmor profile needs:

  capability net_admin,

If it does not need to do this and works fine with the capability
being denied, then you can silence this denial with:

  deny capability net_admin,

Making this judgement call is not always trivial though. For example,
while allowing clamd to use the net_admin capability increases the
attack surface, it might be that clamd would use this capability to
make things safer overall. For this kind of things, upstream
developers are often the best placed to tell what's the impact of
denying a specific permission their piece of software happens
to request.

> The second one should be required by every application using libssl. Is
> there a general rule where it could be allowed for every application to
> just read the openssl.cnf file or is the clamd profile too restrictive
> and not allowing it by default?

I've noticed that other software recently started reading
/etc/ssl/openssl.cnf (no idea why, would be interesting to investigate
but not a blocker), e.g. we fixed that same issue in tor (#909364).
I guess that's due to a change in OpenSSL or some library clamd is
using. I recommend applying the same fix as what we did in src:tor:

  #include 

Cheers,
-- 
intrigeri



Bug#913020: [Pkg-clamav-devel] Bug#913020: clamd: apparmor denials: cap net_admin, openssl.conf

2018-11-08 Thread Sebastian Andrzej Siewior
intrigeri, I added you on Cc since you were a help the last time
apparmor came around.

On 2018-11-06 10:45:15 [+0800], Paul Wise wrote:
> Package: clamav-daemon
> Version: 0.100.2+dfsg-1
> Severity: normal
> File: /etc/apparmor.d/usr.sbin.clamd
> Usertags: apparmor
> 
> When I restart clamav-daemon I get two apparmor denials in syslog:
> 
> AVC apparmor="DENIED" operation="capable" profile="/usr/sbin/clamd" pid=13277 
> comm="clamd" capability=12  capname="net_admin"
> AVC apparmor="DENIED" operation="open" profile="/usr/sbin/clamd" 
> name="/etc/ssl/openssl.cnf" pid=13277 comm="clamd" requested_mask="r" 
> denied_mask="r" fsuid=111 ouid=0

I have no idea what the first one is one about. If this is related to
#903834 then I think I know what I have to do.
The second one should be required by every application using libssl. Is
there a general rule where it could be allowed for every application to
just read the openssl.cnf file or is the clamd profile too restrictive
and not allowing it by default?

Sebastian