Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1699391

Summary: pam_tty_audit fails to execute when user sudoing is confined (staff_u, sysadm_u, ...)
Product: Red Hat Enterprise Linux 7 Reporter: Renaud Métrich <rmetrich>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.6CC: lvrabec, mmalik, plautrba, ssekidde, vmojzis, zpytela
Target Milestone: rcKeywords: AutoVerified
Target Release: 7.8   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.13.1-253.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1700667 (view as bug list) Environment:
Last Closed: 2020-03-31 19:10:44 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: 1711916    

Description Renaud Métrich 2019-04-12 15:03:44 UTC
Description of problem:

When hardening the system for STIG, the following /etc/pam.d/sudo line is added:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
session required pam_tty_audit.so disable=* enable=root open_only
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

With confined users sudoing, this leads to an error seen in /var/log/secure (hence audit not being updated):

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
pam_tty_audit(sudo:session): error setting current audit status: Permission denied
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

It appears that members of the sudodomain attribute cannot perform the "nlmsg_tty_audit" call, whereas unconfined users can, this is missing from the policy:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# sesearch -A -s sudodomain -c netlink_audit_socket -p nlmsg_tty_audit

# sesearch -A -s unconfined_domain_type -c netlink_audit_socket -p nlmsg_tty_audit
Found 1 semantic av rules:
   allow unconfined_domain_type domain : netlink_audit_socket { ioctl read write create getattr setattr lock relabelfrom relabelto append map bind connect listen accept getopt setopt shutdown recvfrom sendto recv_msg send_msg name_bind nlmsg_read nlmsg_write nlmsg_relay nlmsg_readpriv nlmsg_tty_audit } ;
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


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

selinux-policy-3.13.1-229.el7_6.9.noarch


How reproducible:

Always


Steps to Reproduce:
1. Amend /etc/pam.d/sudo as shown below:

- add "session required pam_tty_audit.so disable=* enable=root open_only"

# cat /etc/pam.d/sudo
#%PAM-1.0
auth       include      system-auth
account    include      system-auth
password   include      system-auth
session    optional     pam_keyinit.so revoke
session    required     pam_limits.so
session required pam_tty_audit.so disable=* enable=root open_only
session    include      system-auth

2. Setup a confined user being able to sudo

# useradd -Z staff_u -G wheel staff

3. Login as staff and execute sudo

$ id -Z
staff_u:staff_r:staff_t:s0-s0:c0.c1023

$ sudo -r sysadm_r bash -i
# tail /var/log/secure | grep pam_tty_audit

Actual results:

[...] sudo: pam_tty_audit(sudo:session): error setting current audit status: Permission denied

Expected results:

[...] sudo: pam_tty_audit(sudo:session): changed status from 0 to 1

Comment 2 Renaud Métrich 2019-04-12 15:04:24 UTC
Proposed fix:

# cat sudodomain-nlmsg_tty_audit.te 

module sudodomain-nlmsg_tty_audit 1.0;

require {
	attribute sudodomain;
	class netlink_audit_socket nlmsg_tty_audit;
}

#============= staff_sudo_t ==============
allow sudodomain self:netlink_audit_socket nlmsg_tty_audit;

Comment 24 errata-xmlrpc 2020-03-31 19:10:44 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-2020:1007