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 2172541 - pam_cap fails due to missing rule
Summary: pam_cap fails due to missing rule
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.7
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: 8.9
Assignee: Zdenek Pytela
QA Contact: Milos Malik
Jan Fiala
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-02-22 13:31 UTC by Renaud Métrich
Modified: 2023-11-14 17:57 UTC (History)
4 users (show)

Fixed In Version: selinux-policy-3.14.3-118.el8
Doc Type: Bug Fix
Doc Text:
.Settings from `pam_cap` are correctly applied on SELinux-enabled systems Previously, the SELinux policy did not contain rules for using the `pam_cap` module. As a consequence, granting login capabilities controlled by `pam_cap` to users in the `/etc/security/capability.conf` configuration file did not work when the users logged in by using `ssh` or the console. This update adds a new rule to the policy. As a result, granting capabilities in `/etc/security/capability.conf` now works, and user capabilities configured with `pam_cap` are taken into account when logging in.
Clone Of:
: 2174331 (view as bug list)
Environment:
Last Closed: 2023-11-14 15:47:42 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github fedora-selinux selinux-policy pull 1620 0 None Merged Allow login_pgm setcap permission 2023-04-13 09:58:45 UTC
Red Hat Bugzilla 2172541 0 low CLOSED pam_cap fails due to missing rule 2023-11-14 17:58:54 UTC
Red Hat Issue Tracker RHELPLAN-149668 0 None None None 2023-02-22 13:46:44 UTC
Red Hat Product Errata RHBA-2023:7091 0 None None None 2023-11-14 15:48:02 UTC

Internal Links: 2172541

Description Renaud Métrich 2023-02-22 13:31:40 UTC
Description of problem:

pam_cap PAM module is used to limit capabilities to certain users, for example we can add capability "cap_dac_read_search" to /usr/bin/find so that the command can be used by any user to search anywhere, but still want to only let user "testuser" use the functionality.
For this to happen, the following customization can be set in place:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# setcap cap_dac_read_search+ie /usr/bin/find
# echo "cap_dac_read_search testuser" > /etc/security/capability.conf 
# echo "auth        required      pam_cap.so" >> /etc/pam.d/postlogin
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

When using such snippet, we can see that "testuser" login in using ssh or on console cannot get the expected capability, due to the following AVC:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
type=PROCTITLE msg=audit(02/22/2023 13:45:07.997:283) : proctitle=sshd: testuser [priv] 
type=SYSCALL msg=audit(02/22/2023 13:45:07.997:283) : arch=x86_64 syscall=capset success=no exit=EACCES(Permission denied) a0=0x555c63d541d4 a1=0x555c63d541dc a2=0x555c63d541dc a3=0x1 items=0 ppid=901 pid=26970 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=sshd exe=/usr/sbin/sshd subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 key=(null) 
type=AVC msg=audit(02/22/2023 13:45:07.997:283) : avc:  denied  { setcap } for  pid=26970 comm=sshd scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tclass=process permissive=0 
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This AVC happens while the session handler still executes as "sshd_t" because we are still in PAM.

We need to allow this through adding the following rule:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# echo "(allow login_pgm self (process (setcap)))" > allow_pam_cap.cil
# semodule -i allow_pam_cap.cil
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

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

selinux-policy-3.14.3-108.el8_7.1.noarch

How reproducible:

Always

Steps to Reproduce: see above

Actual results:

AVC

Expected results:

No AVC

Comment 3 Zdenek Pytela 2023-03-03 16:22:37 UTC
Commit to backport:

704e79751 (HEAD -> rawhide, upstream/rawhide) Allow login_pgm setcap permission

Comment 21 errata-xmlrpc 2023-11-14 15:47:42 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:7091


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