RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2127902 - Insights compliance service is run from cron instead of systemd which have different SELinux context and leads to AVCs
Summary: Insights compliance service is run from cron instead of systemd which have di...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.6
Hardware: Unspecified
OS: Linux
high
medium
Target Milestone: rc
: 8.8
Assignee: Zdenek Pytela
QA Contact: Milos Malik
Mirek Jahoda
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-09-19 10:33 UTC by Riya Banerjee
Modified: 2023-05-16 11:02 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-16 09:04:16 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-134298 0 None None None 2022-09-19 10:53:04 UTC
Red Hat Product Errata RHBA-2023:2965 0 None None None 2023-05-16 09:04:37 UTC

Description Riya Banerjee 2022-09-19 10:33:47 UTC
Description of problem:
As follow-up on the SELinux challenges for the insights collection rules, the regular run is now from systemd timer started with insights_client_t as context.

However, the Compliance run is documented to be from the cron (Refer KB - https://access.redhat.com/solutions/6707871) which creates things like pid files with a different context like cron_var_run_t. 
Leading to AVCs like
~~~
allow insights_client_t cron_var_run_t:file unlink;
~~~


Both runs were on the same time, compliance scheduled at 1:30am, but it looks like the insgihts-client timer can also use that timeframe.

~~~
[cb/LI] hoiroot@li-lc-2105:~$ cat /etc/cron.d/hoi-insights-scap
30 1 * * * root /opt/hoi/bin/hoi-cron-wrapper '/usr/bin/insights-client --compliance 2>&1'

[cb/LI] hoiroot@li-lc-2105:~$ sudo ausearch -i -m avc,user_avc -ts today
----
type=PROCTITLE msg=audit(09/16/2022 01:31:32.702:218383) : proctitle=/usr/libexec/platform-python /usr/bin/insights-client --retry 3
type=PATH msg=audit(09/16/2022 01:31:32.702:218383) : item=1 name=/var/run/insights-client.pid inode=33134529 dev=00:18 mode=file,644 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:cron_var_run_t:s0 nametype=DELETE cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0
type=PATH msg=audit(09/16/2022 01:31:32.702:218383) : item=0 name=/var/run/ inode=12425 dev=00:18 mode=dir,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:var_run_t:s0 nametype=PARENT cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0
type=CWD msg=audit(09/16/2022 01:31:32.702:218383) : cwd=/
type=SYSCALL msg=audit(09/16/2022 01:31:32.702:218383) : arch=x86_64 syscall=unlink success=no exit=EACCES(Permission denied) a0=0x7f9342157990 a1=0x0 a2=0x0 a3=0x1 items=2 ppid=1 pid=1261648 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=insights-client exe=/usr/libexec/platform-python3.6 subj=system_u:system_r:insights_client_t:s0 key=(null)
type=AVC msg=audit(09/16/2022 01:31:32.702:218383) : avc:  denied  { unlink } for  pid=1261648 comm=insights-client name=insights-client.pid dev="tmpfs" ino=33134529 scontext=system_u:system_r:insights_client_t:s0 tcontext=system_u:object_r:cron_var_run_t:s0 tclass=file permissiv
~~~

Queries:
- Conflict in how insights-client runs are supposed to the started taking the new SELinux rules into account
- Concurrent runs of compliance/malwre and insights collection. How is this supposed to go together without conflicts?  This is undocumented in KB (https://access.redhat.com/solutions/6707871) on the timeframes used by each

Comment 1 Zdenek Pytela 2022-09-19 10:40:35 UTC
> [cb/LI] hoiroot@li-lc-2105:~$ cat /etc/cron.d/hoi-insights-scap
> 30 1 * * * root /opt/hoi/bin/hoi-cron-wrapper '/usr/bin/insights-client --compliance 2>&1'

Where do these files come from, are they a part of a customer's setup?

Comment 3 Zdenek Pytela 2022-10-07 14:33:04 UTC
I've checked both system and user cronjobs executing insights-client directly do not trigger any issue with the latest selinux-policy package in place.
Using a custom wrapper is not considered as a supported scenario.

Comment 8 Peter Vreman 2023-03-08 20:11:32 UTC
No compliance issues seen anymore with the latest selinux-policy-3.14.3-95.el8_6.6
For me the BZ can be closed

Comment 9 Zdenek Pytela 2023-03-09 07:59:43 UTC
Peter,

Thank you for conforming. This bz will follow the internal process and will be closed with RHEL 8.8 GA.

Comment 12 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


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