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 1917879 - Cannot sudo passwordless from staff_u/sysadm_u when using pam_ssh_agent_auth
Summary: Cannot sudo passwordless from staff_u/sysadm_u when using pam_ssh_agent_auth
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.3
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.6
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks: 1778780
TreeView+ depends on / blocked
 
Reported: 2021-01-19 15:04 UTC by Renaud Métrich
Modified: 2024-03-25 17:53 UTC (History)
7 users (show)

Fixed In Version: selinux-policy-3.14.3-86.el8
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-10 15:14:56 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
SELinux denials gathered during testing of staff_u and sysadm_u users (4.99 KB, text/plain)
2021-01-26 10:03 UTC, Milos Malik
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1910077 1 high CLOSED sudoing as sysadm_r still requires specifying "-r sysadm_r" parameter 2023-10-09 15:18:00 UTC
Red Hat Knowledge Base (Solution) 5717881 0 None None None 2021-01-20 08:45:27 UTC
Red Hat Product Errata RHBA-2022:1995 0 None None None 2022-05-10 15:15:13 UTC

Description Renaud Métrich 2021-01-19 15:04:35 UTC
Description of problem:

After configuring pam_ssh_agent_auth to provide passwordless sudo through ssh agent, AVCs are preventing "sudo" from working:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
allow staff_sudo_t staff_t:unix_stream_socket connectto;
allow staff_sudo_t user_tmp_t:sock_file { getattr write };
allow sysadm_sudo_t sysadm_t:unix_stream_socket connectto;
allow sysadm_sudo_t user_tmp_t:sock_file write;
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

More generally, what is missing are these rules:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
allow staff_sudo_t staff_t:unix_stream_socket connectto;
allow sysadm_sudo_t sysadm_t:unix_stream_socket connectto;
allow auditadm_sudo_t auditadm_t:unix_stream_socket connectto;
allow dbadm_sudo_t dbadm_t:unix_stream_socket connectto;
allow secadm_sudo_t secadm_t:unix_stream_socket connectto;

allow sudodomain user_tmp_t:sock_file { getattr write };
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


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

selinux-policy-3.14.3-54.el8.noarch


How reproducible:

Always


Steps to Reproduce:
1. Install pam_ssh_agent_auth

  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  # yum -y install pam_ssh_agent_auth
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

2. Configure passwordless sudo through ssh agent

  /etc/pam.d/sudo:
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  auth       sufficient   pam_ssh_agent_auth.so file=~/.ssh/authorized_keys
  ...
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

  /etc/sudoers:
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  Defaults    env_keep += "SSH_AUTH_SOCK"
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

3. Create "staff" and "sysadm" users

  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  # useradd -Z staff_u -G wheel staff
  # echo "pass" | passwd --stdin staff
  # useradd -Z sysadm_u -G wheel sysadm
  # echo "pass" | passwd --stdin sysadm
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

4. Generate ssh key and install it

  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  # ssh-keygen
  # ssh-copy-id staff@localhost
  # ssh-copy-id sysadm@localhost
  # semanage boolean -m ssh_sysadm_login --on
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

5. Finally start ssh-agent, ssh and sudo from the account

  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  # ssh-agent; ssh-add
  # ssh -A staff@localhost
  $ sudo -i
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


Actual results:

  [sudo] password for staff: 

Expected results:

  Password-less sudo

Comment 1 Renaud Métrich 2021-01-21 10:08:13 UTC
Additional missing rules:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
allow sudodomain user_tmp_t:sock_file { write getattr append open };
allow sudodomain ssh_agent_tmp_t:sock_file { write getattr append open };
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Comment 2 Milos Malik 2021-01-26 10:03:32 UTC
Created attachment 1750851 [details]
SELinux denials gathered during testing of staff_u and sysadm_u users

Comment 5 Zdenek Pytela 2021-12-22 12:42:12 UTC
I've submitted a Fedora PR to address the issue:
https://github.com/fedora-selinux/selinux-policy/pull/976

Comment 6 Zdenek Pytela 2021-12-23 16:48:44 UTC
To backport:
commit 901ac5314982f5600ef11691969b9af89aeba772
Author: Zdenek Pytela <zpytela>
Date:   Mon Dec 20 14:21:33 2021 +0100

    Allow userdomains use pam_ssh_agent_auth for passwordless sudo

    The pam_ssh_agent_auth module can be used for granting permissions based
    on SSH agent requests. When configured for using in the sudo pam module,
    it requires permissions for sudodomain to use the user socket file and
    stream connect to its corresponding userdomain.

    Resolves: rhbz#1917879

Comment 21 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


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