Bug 1738246

Summary: SELinux prevents rhsmcertd-worker from opening the /var/log/hawkey.log file
Product: Red Hat Enterprise Linux 8 Reporter: John Sefler <jsefler>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: low Docs Contact:
Priority: medium    
Version: 8.1CC: csnyder, lvrabec, mmalik, plautrba, ssekidde, zpytela
Target Milestone: rcKeywords: Triaged
Target Release: 8.0   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-09-15 09:11:52 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:
Bug Depends On: 1716971    
Bug Blocks:    

Description John Sefler 2019-08-06 15:20:44 UTC
Description of problem:
The rhsmcertd-worker is causing the following AVC denial...

type=AVC msg=audit(1565104291.260:4936): avc:  denied  { open } for  pid=41389 comm="rhsmcertd-worke" path="/var/log/hawkey.log" dev="dm-0" ino=101246874 scontext=system_u:system_r:rhsmcertd_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=file permissive=0


Version-Release number of selected component (if applicable):
[root@qualcomm-amberwing-rep-20 ~]# rpm -q subscription-manager
subscription-manager-1.25.13-1.el8.aarch64
[root@qualcomm-amberwing-rep-20 ~]# rpm -q selinux-policy
selinux-policy-3.14.3-13.el8.noarch


How reproducible:


Steps to Reproduce:
[root@qualcomm-amberwing-rep-20 ~]# systemctl stop rhsmcertd.service
[root@qualcomm-amberwing-rep-20 ~]# 
[root@qualcomm-amberwing-rep-20 ~]# subscription-manager config --rhsmcertd.splay=0 --logging=DEBUG
[root@qualcomm-amberwing-rep-20 ~]# 

FOLLOWING INSTRUCTIONS FROM https://wiki.test.redhat.com/BaseOs/Security/SelinuxTestOnlyBugs#SELinuxHowToTestInstructions

[root@qualcomm-amberwing-rep-20 ~]# service auditd restart
Stopping logging:                                          [  OK  ]
Redirecting start to /bin/systemctl start auditd.service
[root@qualcomm-amberwing-rep-20 ~]# 
[root@qualcomm-amberwing-rep-20 ~]# setenforce 1
[root@qualcomm-amberwing-rep-20 ~]# 
[root@qualcomm-amberwing-rep-20 ~]# restorecon -Rv /etc /run /var
Relabeled /etc/dnf/modules.d/satellite-5-client.module from system_u:object_r:root_t:s0 to system_u:object_r:etc_t:s0
Relabeled /run/fsck/sda.lock from system_u:object_r:fsadm_var_run_t:s0 to system_u:object_r:var_run_t:s0
[root@qualcomm-amberwing-rep-20 ~]# 
[root@qualcomm-amberwing-rep-20 ~]# START_DATE_TIME=`date "+%m/%d/%Y %T"`
[root@qualcomm-amberwing-rep-20 ~]# 
[root@qualcomm-amberwing-rep-20 ~]# 
[root@qualcomm-amberwing-rep-20 ~]# subscription-manager register --serverurl=subscription.rhsm.stage.redhat.com --username=stage_auto_testuser --servicelevel=Production --auto-attach
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Password: 
The system has been registered with ID: 474bdaa2-406d-4268-a1f2-5c08f451d53f
The registered system name is: qualcomm-amberwing-rep-20.khw3.lab.eng.bos.redhat.com
Service level set to: Production
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for ARM 64 High Touch Beta
Status:       Subscribed

[root@qualcomm-amberwing-rep-20 ~]# systemctl start rhsmcertd.service
[root@qualcomm-amberwing-rep-20 ~]# 
[root@qualcomm-amberwing-rep-20 ~]# sleep 120
[root@qualcomm-amberwing-rep-20 ~]# 
[root@qualcomm-amberwing-rep-20 ~]# ausearch -m AVC -m USER_AVC -m SELINUX_ERR -i -ts ${START_DATE_TIME}
----
type=PROCTITLE msg=audit(08/06/2019 11:11:31.260:4936) : proctitle=/usr/libexec/platform-python /usr/libexec/rhsmcertd-worker 
type=SYSCALL msg=audit(08/06/2019 11:11:31.260:4936) : arch=aarch64 syscall=openat success=no exit=EACCES(Permission denied) a0=0xffffffffffffff9c a1=0xaaaae39c5a00 a2=O_WRONLY|O_CREAT|O_APPEND a3=0x1b6 items=0 ppid=41336 pid=41389 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=rhsmcertd-worke exe=/usr/libexec/platform-python3.6 subj=system_u:system_r:rhsmcertd_t:s0 key=(null) 
type=AVC msg=audit(08/06/2019 11:11:31.260:4936) : avc:  denied  { open } for  pid=41389 comm=rhsmcertd-worke path=/var/log/hawkey.log dev="dm-0" ino=101246874 scontext=system_u:system_r:rhsmcertd_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=file permissive=0 
[root@qualcomm-amberwing-rep-20 ~]# 


Actual results:
  shown above
  Once the rhsmcertd.service triggers the rhsmcertd-worker to run, AVC denials are logged to /var/log/audit/audit.log

Expected results:
  no AVC denials from "rhsmcertd-worke"r

Additional info:

[root@qualcomm-amberwing-rep-20 ~]# tail -f /var/log/audit/audit.log | grep denied
type=AVC msg=audit(1565104291.260:4936): avc:  denied  { open } for  pid=41389 comm="rhsmcertd-worke" path="/var/log/hawkey.log" dev="dm-0" ino=101246874 scontext=system_u:system_r:rhsmcertd_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=file permissive=0

Comment 2 Milos Malik 2019-08-07 05:55:43 UTC
This issue is already mentioned in following bugs:
 * https://bugzilla.redhat.com/show_bug.cgi?id=1716971
 * https://bugzilla.redhat.com/show_bug.cgi?id=1720639

I believe the issue can be fixed by adding an appropriate file context pattern which matches /var/log/hawkey.log. Important question: Is rhsmcertd-worker supposed to only read the file? Or is the append / write access also needed?

Comment 6 Lukas Vrabec 2019-09-15 09:11:52 UTC

*** This bug has been marked as a duplicate of bug 1720639 ***