Bug 1475528 - SELinux denial prevents FreeIPA certificate renewal working correctly
Summary: SELinux denial prevents FreeIPA certificate renewal working correctly
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 25
Hardware: x86_64
OS: Linux
unspecified
urgent
Target Milestone: ---
Assignee: Lukas Vrabec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-26 20:45 UTC by Adam Williamson
Modified: 2017-12-12 10:19 UTC (History)
15 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-12-12 10:19:48 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Adam Williamson 2017-07-26 20:45:08 UTC
Rob Critenden just helped me diagnose and fix a major bug on my FreeIPA server. It seems that an SELinux denial prevents FreeIPA's certificate renewal script from working correctly. Here are the relevant log messages:

Jul 09 18:37:28 id.happyassassin.net dogtag-ipa-ca-renew-agent-submit[3832]: Forwarding request to dogtag-ipa-renew-agent
Jul 09 18:37:28 id.happyassassin.net dogtag-ipa-ca-renew-agent-submit[3832]: dogtag-ipa-renew-agent returned 5
Jul 09 18:37:29 id.happyassassin.net stop_pkicad[3866]: Stopping pki_tomcatd
Jul 09 18:37:29 id.happyassassin.net audit[1]: USER_AVC pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc:  denied  { stop } for auid=n/a uid=0 gid=0 path="/usr/lib/systemd/system/pki-tomcatd@.service" cmdline="/bin/systemctl stop pki-tomcatd" scontext=system_u:system_r:certmonger_t:s0 tcontext=system_u:object_r:pki_tomcat_unit_file_t:s0 tclass=service
                                                exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
Jul 09 18:37:29 id.happyassassin.net stop_pkicad[3866]: Cannot stop pki_tomcatd: Command '/bin/systemctl stop pki-tomcatd' returned non-zero exit status 4
Jul 09 18:37:31 id.happyassassin.net renew_ca_cert[3883]: Stopping pki_tomcatd
Jul 09 18:37:31 id.happyassassin.net audit[1]: USER_AVC pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc:  denied  { stop } for auid=n/a uid=0 gid=0 path="/usr/lib/systemd/system/pki-tomcatd@.service" cmdline="/bin/systemctl stop pki-tomcatd" scontext=system_u:system_r:certmonger_t:s0 tcontext=system_u:object_r:pki_tomcat_unit_file_t:s0 tclass=service
                                                exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
Jul 09 18:37:31 id.happyassassin.net renew_ca_cert[3883]: Cannot stop pki_tomcatd: Command '/bin/systemctl stop pki-tomcatd' returned non-zero exit status 4

It seems that certmonger(?) scripts 'stop_pkicad' and 'renew_ca_cert' both try to stop pki-tomcatd and are rejected by SELinux. This subsequently causes renew_ca_cert to crash, which probably led to my broken FreeIPA.

Note, the denial doesn't seem to show up in ausearch output, which is odd...

Comment 1 Adam Williamson 2017-07-26 20:48:12 UTC
CC'ing a few FreeIPA folks for any necessary info from them. The relevant scripts are part of the freeipa-server package:

[root@id etc]# rpm -qf /usr/libexec/ipa/certmonger/stop_pkicad /usr/libexec/ipa/certmonger/renew_ca_cert
freeipa-server-4.4.4-4.fc26.x86_64
freeipa-server-4.4.4-4.fc26.x86_64

but I believe ultimately get run as part of the 'certmonger' service (note the scontext is certmonger_t).

Comment 2 Adam Williamson 2017-07-26 20:50:46 UTC
Note, I believe this is quite urgent: the same problem will likely affect *all* FreeIPA server deployments when their internal certificates expire and come up for auto-renewal, and the result is quite nasty (bits of FreeIPA just refuse to work properly and it is not at all easy to work out why, I wouldn't have been able to work it out without Rob's help). Fixing it is also rather icky (involves some complex LDAP admin work).

Comment 3 Petr Lautrbach 2017-07-27 10:48:04 UTC
(In reply to Adam Williamson from comment #0)

> Jul 09 18:37:29 id.happyassassin.net audit[1]: USER_AVC pid=1 uid=0
> auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc: 
> denied  { stop } for auid=n/a uid=0 gid=0
> path="/usr/lib/systemd/system/pki-tomcatd@.service" cmdline="/bin/systemctl
> stop pki-tomcatd"
> scontext=system_u:system_r:certmonger_t:s0
> tcontext=system_u:object_r:pki_tomcat_unit_file_t:s0 tclass=service
> exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
...
> Jul 09 18:37:31 id.happyassassin.net audit[1]: USER_AVC pid=1 uid=0
> auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc: 
> denied  { stop } for auid=n/a uid=0 gid=0
> path="/usr/lib/systemd/system/pki-tomcatd@.service" cmdline="/bin/systemctl
> stop pki-tomcatd"
> scontext=system_u:system_r:certmonger_t:s0
> tcontext=system_u:object_r:pki_tomcat_unit_file_t:s0 tclass=service
> exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
...
> Note, the denial doesn't seem to show up in ausearch output, which is odd...

Did you use -m AVC,USER_AVC to cover USER_AVCs generated by SELinux managers (systemd, dbus, ...)?

Comment 4 Adam Williamson 2017-07-27 16:09:58 UTC
ah, no, I didn't realize that was needed. Thanks. Here's the ausearch output for one of the denials, then, in case it helps:

time->Sun Jul  9 18:38:13 2017
type=USER_AVC msg=audit(1499650693.377:2936): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc:  denied  { stop } for auid=n/a uid=0 gid=0 path="/usr/lib/systemd/system/pki-tomcatd@.service" cmdline="/bin/systemctl stop pki-tomcatd" scontext=system_u:system_r:certmonger_t:s0 tcontext=system_u:object_r:pki_tomcat_unit_file_t:s0 tclass=service  exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'

Comment 5 Vit Mojzis 2017-07-28 17:39:00 UTC
Thank you for reporting the issue.
Could you please try if the following build of selinux-policy-targeted fixes the issue? If not, please try to reproduce the issue with SELinux in permissive mode and report any new AVC messages.

https://vmojzis.fedorapeople.org/selinux-policy/selinux-policy-targeted-3.13.1-225.19.fc25.noarch.rpm

Comment 6 Rob Foehl 2017-08-28 15:39:45 UTC
I just ran into the same issue on a test Fedora 25 VM with selinux-policy-targeted-3.13.1-225.20.fc25.noarch installed from current updates.  AVC is the same:

time->Sun Aug 27 22:49:17 2017
type=USER_AVC msg=audit(1503888557.853:236): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc:  denied  { stop } for auid=n/a uid=0 gid=0 path="/lib/systemd/system/pki-tomcatd@.service" cmdline="/bin/systemctl stop pki-tomcatd" scontext=system_u:system_r:certmonger_t:s0 tcontext=system_u:object_r:pki_tomcat_unit_file_t:s0 tclass=service  exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'

Running through this again after switching to permissive mode only results in one additional AVC, for the (re)start of the same service.

I don't see anything relevant in the change logs for either the .19 or .20 RPMs -- what was expected to make a difference here?

Comment 7 Fedora End Of Life 2017-11-16 19:31:48 UTC
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 8 Fedora End Of Life 2017-12-12 10:19:48 UTC
Fedora 25 changed to end-of-life (EOL) status on 2017-12-12. Fedora 25 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.