Bug 1919122

Summary: Permission denied+AVC seen when executing "sudo authconfig" as a confined user (staff_u or sysadm_u)
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED ERRATA QA Contact: Amith <apeetham>
Severity: medium Docs Contact:
Priority: high    
Version: 8.3CC: lvrabec, miturria, mmalik, plautrba, ssekidde
Target Milestone: rcKeywords: Triaged
Target Release: 8.6   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.14.3-86.el8 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 15:14:56 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:    
Bug Blocks: 1778780    

Description Renaud Métrich 2021-01-22 08:11:45 UTC
Description of problem:

Executing "sudo authconfig" as a confined user ends up having a Permission denied  + AVC:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
$ sudo authconfig --test
[sudo] password for staff: 
sudo: unable to execute /sbin/authconfig: Permission denied
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

AVC:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
time->Fri Jan 22 09:03:35 2021
type=PROCTITLE msg=audit(1611302615.729:148): proctitle=7375646F0061757468636F6E666967002D2D74657374
type=SYSCALL msg=audit(1611302615.729:148): arch=c000003e syscall=59 success=no exit=-13 a0=559e79623e78 a1=559e7961de78 a2=559e79673930 a3=1 items=0 ppid=1963 pid=1987 auid=1001 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts1 ses=4 comm="sudo" exe="/usr/bin/sudo" subj=staff_u:staff_r:staff_sudo_t:s0-s0:c0.c1023 key=(null)
type=AVC msg=audit(1611302615.729:148): avc:  denied  { execute_no_trans } for  pid=1987 comm="sudo" path="/usr/lib/python3.6/site-packages/authselect/authcompat.py" dev="dm-0" ino=18148211 scontext=staff_u:staff_r:staff_sudo_t:s0-s0:c0.c1023 tcontext=system_u:object_r:lib_t:s0 tclass=file permissive=0
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

The reason for this is having /sbin/authconfig be a symlink to /usr/lib/python3.6/site-packages/authselect/authcompat.py which is labeled with lib_t, preventing the execution by staff_sudo_t.
Same happens when being sysadm_sudo_t.

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

authselect-compat-1.2.1-2.el8.x86_64


How reproducible:

Always

Steps to Reproduce:
1. Create a confined user that can sudo

  # useradd -Z staff_u -G wheel staff
  # echo "pass" | passwd --stdin staff

2. Switch to the user

  # ssh staff@localhost
  staff@localhost's password: pass
  $ id -Z
  staff_u:staff_r:staff_t:s0-s0:c0.c1023

3. Execute authconfig through sudo

  $ sudo authconfig --test
  [sudo] password for staff: pass
  sudo: unable to execute /sbin/authconfig: Permission denied


Actual results:

  sudo: unable to execute /sbin/authconfig: Permission denied
  + AVC

Expected results:

  works fine

Comment 1 Pavel Březina 2021-02-01 12:12:56 UTC
Thank you. Switching to selinux-policy.

Comment 4 Markus Iturriaga 2021-06-14 13:23:41 UTC
Interestingly, if the sysadm_u user can change to root via sudo -i, they *can* run the authconfig command while running a root shell:

> sudo authconfig --test
[sudo] password for user:
sudo: unable to execute /sbin/authconfig: Permission denied

> sudo -i

> whoami
root

> id -Z
sysadm_u:sysadm_r:sysadm_t:s0

> authconfig --test
Running authconfig compatibility tool.
[...]

Why would that be the case?

Comment 6 Zdenek Pytela 2021-12-22 12:41:52 UTC
Will be resolved by labeling
/usr/lib/python3.6/site-packages/authselect/authcompat.py

but in RHEL 8 only as there is no authselect-compat in current releases.

Comment 20 errata-xmlrpc 2022-05-10 15:14:56 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-2022:1995