Bug 2132922

Summary: system cronjobs can query sssd through but sssd cannot reply
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.6CC: lvrabec, mmalik, nknazeko
Target Milestone: rcKeywords: AutoVerified, Triaged
Target Release: 8.8Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.14.3-111.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-16 09:04:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2022-10-07 07:56:27 UTC
Description of problem:

We have a customer executing some sssd client command in a system cronjob (hence running as *system_cronjob_t*). We can see sssd cannot answer to the query due to a USER_AVC:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
type=USER_AVC ... subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc:  denied  { send_msg } for msgtype=method_return dest=:1.103521 ... scontext=system_u:system_r:sssd_t:s0 tcontext=system_u:system_r:system_cronjob_t:s0-s0:c0.c1023 tclass=dbus permissive=0  exe="/usr/bin/dbus-daemon" sauid=81 hostname=? addr=? terminal=?'UID="dbus" AUID="unset" SAUID="dbus"
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

The root cause for this is there is a rule to allow sending messages for all types in attribute *dbusd_unconfined*, but not the opposite rule:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# sesearch -A -s dbusd_unconfined -t sssd_t -c dbus
...
allow dbusd_unconfined sssd_t:dbus send_msg;
...

# sesearch -A -s sssd_t -t dbusd_unconfined -c dbus
... nothing related to "system_cronjob_t" ...
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Version-Release number of selected component (if applicable):

selinux-policy-targeted-3.14.3-95.el8_6.4.noarch

How reproducible:

Always on customer system

Steps to Reproduce:

1. Have a SSSD client system

2. Create a system cronjob executing "sssctl"

    ~~~
    # cat /etc/cron.d/check-sssd
    * * * * * root /usr/sbin/sssctl domain-status -o <DOMAIN>
    ~~~

Actual results:

USER_AVC above

Expected results:

No USER_AVC and result

Comment 1 Milos Malik 2022-10-11 12:39:53 UTC
Caught in enforcing mode:
----
type=USER_AVC msg=audit(10/11/2022 14:36:01.711:447) : pid=973 uid=dbus auid=unset ses=unset subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc:  denied  { send_msg } for msgtype=method_return dest=:1.1467 spid=5736 tpid=7278 scontext=system_u:system_r:sssd_t:s0 tcontext=system_u:system_r:system_cronjob_t:s0-s0:c0.c1023 tclass=dbus permissive=0  exe=/usr/bin/dbus-daemon sauid=dbus hostname=? addr=? terminal=?' 
----

Caught in permissive mode:
----
type=USER_AVC msg=audit(10/11/2022 14:37:01.735:450) : pid=973 uid=dbus auid=unset ses=unset subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc:  denied  { send_msg } for msgtype=method_return dest=:1.1475 spid=5736 tpid=7559 scontext=system_u:system_r:sssd_t:s0 tcontext=system_u:system_r:system_cronjob_t:s0-s0:c0.c1023 tclass=dbus permissive=1  exe=/usr/bin/dbus-daemon sauid=dbus hostname=? addr=? terminal=?' 
----

# sssctl domain-list
implicit_files
# cat /etc/cron.d/check-sssd 
* * * * * root /usr/sbin/sssctl domain-status -o implicit_files

# rpm -qa selinux\* sssd\* cron\* | sort
cronie-1.5.2-8.el8.x86_64
cronie-anacron-1.5.2-8.el8.x86_64
crontabs-1.11-17.20190603git.el8.noarch
selinux-policy-3.14.3-108.el8.noarch
selinux-policy-devel-3.14.3-108.el8.noarch
selinux-policy-doc-3.14.3-108.el8.noarch
selinux-policy-minimum-3.14.3-108.el8.noarch
selinux-policy-mls-3.14.3-108.el8.noarch
selinux-policy-sandbox-3.14.3-108.el8.noarch
selinux-policy-targeted-3.14.3-108.el8.noarch
sssd-2.7.3-4.el8.x86_64
sssd-ad-2.7.3-4.el8.x86_64
sssd-client-2.7.3-4.el8.x86_64
sssd-common-2.7.3-4.el8.x86_64
sssd-common-pac-2.7.3-4.el8.x86_64
sssd-dbus-2.7.3-4.el8.x86_64
sssd-ipa-2.7.3-4.el8.x86_64
sssd-kcm-2.7.3-4.el8.x86_64
sssd-krb5-2.7.3-4.el8.x86_64
sssd-krb5-common-2.7.3-4.el8.x86_64
sssd-ldap-2.7.3-4.el8.x86_64
sssd-nfs-idmap-2.7.3-4.el8.x86_64
sssd-polkit-rules-2.7.3-4.el8.x86_64
sssd-proxy-2.7.3-4.el8.x86_64
sssd-tools-2.7.3-4.el8.x86_64
sssd-winbind-idmap-2.7.3-4.el8.x86_64
#

Comment 21 errata-xmlrpc 2023-05-16 09:04:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (selinux-policy bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2965