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 1691351 - Cannot execute "sudo su" when user is confined to staff_u or sysadm_u
Summary: Cannot execute "sudo su" when user is confined to staff_u or sysadm_u
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.1
Assignee: Lukas Vrabec
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On: 1673107
Blocks: 1778780
TreeView+ depends on / blocked
 
Reported: 2019-03-21 13:12 UTC by Milos Malik
Modified: 2021-10-07 11:44 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1688887
Environment:
Last Closed: 2019-11-05 22:11:10 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:3547 0 None None None 2019-11-05 22:11:18 UTC

Description Milos Malik 2019-03-21 13:12:08 UTC
+++ This bug was initially created as a clone of Bug #1688887 +++

Description of problem:

When user is confined to "staff_u" or "sysadm_u", executing "sudo su" fails in error:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
$ sudo su
su: avc.c:74: avc_context_to_sid_raw: Assertion `avc_running' failed.
Aborted
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


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

selinux-policy-3.14.1-61.el8.noarch
selinux-policy-devel-3.14.1-61.el8.noarch
selinux-policy-targeted-3.14.1-61.el8.noarch
sudo-1.8.25p1-4.el8.x86_64

How reproducible:

Always


Steps to Reproduce:

1. Update system to latest 8.0

  # yum -y update

2. Create confined administrators with sudo capabilities

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

  # useradd -Z sysadm_u -G wheel sysadm
  # echo "sysadm" | passwd --stdin sysadm
  # semanage boolean -m --on ssh_sysadm_login

3. Log as "staff" and try to "sudo su". Do the same with "sysadm"

  # ssh staff@localhost
  $ id -Z
  staff_u:staff_r:staff_t:s0-s0:c0.c1023
  $ sudo su
  su: avc.c:74: avc_context_to_sid_raw: Assertion `avc_running' failed.
  Aborted
  $ exit

  # ssh sysadm@localhost
  $ id -Z
  sysadm_u:sysadm_r:sysadm_t:s0-s0:c0.c1023
  $ sudo su
  su: avc.c:74: avc_context_to_sid_raw: Assertion `avc_running' failed.
  Aborted
  $


Additional info:

The following module fixes the issue:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
module staff_sysadm_sudo_su 1.0;

require {
	type security_t;
	type staff_sudo_t;
	type sysadm_sudo_t;
	type lastlog_t;
	class passwd passwd;
	class netlink_selinux_socket { bind create };
	class file { open read write };
	class security compute_av;
}

allow staff_sudo_t lastlog_t:file { open read write };
allow staff_sudo_t security_t:security compute_av;
allow sysadm_sudo_t lastlog_t:file { open read write };
allow sysadm_sudo_t security_t:security compute_av;

allow staff_sudo_t self:netlink_selinux_socket { bind create };
allow staff_sudo_t self:passwd passwd;
allow sysadm_sudo_t self:netlink_selinux_socket { bind create };
allow sysadm_sudo_t self:passwd passwd;
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Comment 1 Milos Malik 2019-03-21 13:59:03 UTC
When I run the reproducer in permissive mode, it generates a lot of SELinux denials. When these denials are processed by audit2allow, the output is:

#============= staff_sudo_t ==============
allow staff_sudo_t lastlog_t:file { open read write };
allow staff_sudo_t security_t:security compute_av;
allow staff_sudo_t self:netlink_selinux_socket { bind create };
allow staff_sudo_t self:passwd rootok;

#============= sysadm_sudo_t ==============
allow sysadm_sudo_t lastlog_t:file { open read write };
allow sysadm_sudo_t security_t:security compute_av;
allow sysadm_sudo_t self:netlink_selinux_socket { bind create };
allow sysadm_sudo_t self:passwd rootok;

I have never seen an AVC with 'rootok' permission.

Comment 13 errata-xmlrpc 2019-11-05 22:11:10 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, 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-2019:3547


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