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 1949137 - pam_usertype has flawed logic for system accounts.
Summary: pam_usertype has flawed logic for system accounts.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: pam
Version: 8.3
Hardware: Unspecified
OS: Unspecified
medium
low
Target Milestone: beta
: ---
Assignee: Iker Pedrosa
QA Contact: Anuj Borah
URL:
Whiteboard: sync-to-jira review
Depends On:
Blocks: 2078421
TreeView+ depends on / blocked
 
Reported: 2021-04-13 14:08 UTC by Martin Poole
Modified: 2022-11-08 12:33 UTC (History)
4 users (show)

Fixed In Version: pam-1.3.1-21.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2078421 (view as bug list)
Environment:
Last Closed: 2022-11-08 10:48:39 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github RedHatQE pam pull 33 0 None open Tests: pam_usertype has flawed logic for system accounts 2022-02-24 05:15:18 UTC
Red Hat Issue Tracker SSSD-3538 0 None None None 2021-12-08 12:30:29 UTC
Red Hat Product Errata RHBA-2022:7723 0 None None None 2022-11-08 10:49:01 UTC

Description Martin Poole 2021-04-13 14:08:41 UTC
Description of problem:

pam_usertype has flawed assumptions in determining what constitutes a system account.

The code has a hard-coded check for UID < 100 and then checks the uid is between  SYS_UID_MIN and SYS_UID_MAX from /etc/login.defs

The problem is that this range is not the range of systems accounts. It is the available range to allocate new system accounts after deployment. RHEL-8 default values for these are 

    SYS_UID_MIN               201
    SYS_UID_MAX               999

The range 100-200 is also for system accounts, but the range is specifically excluded from the login.defs range to provide a pool for explicit allocations for certain packages that rely on a fixed id.


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

pam-1.3.1-11.el8

Additional info:

The least worst fix for now is probably just to test uid <= SYS_UID_MAX


There is no lookup I can think of that will give a definitive answer. /etc/login.defs is a config file, available for tweaking as the customer wishes and might make the two ranges anything.

Comment 1 Ding-Yi Chen 2021-04-14 00:10:05 UTC
Related code

static int
pam_usertype_is_system(pam_handle_t *pamh, uid_t uid)
{
    uid_t uid_min;
    uid_t sys_min;
    uid_t sys_max;

    if (uid == (uid_t)-1) {
        pam_syslog(pamh, LOG_WARNING, "invalid uid");
        return PAM_USER_UNKNOWN;
    }

    if (uid <= 99) {
        /* Reserved. */
        return PAM_SUCCESS;
    }

    if (uid == PAM_USERTYPE_OVERFLOW_UID) {
        /* nobody */
        return PAM_SUCCESS;
    }

    uid_min = pam_usertype_get_id(pamh, "UID_MIN", PAM_USERTYPE_UIDMIN);
    sys_min = pam_usertype_get_id(pamh, "SYS_UID_MIN", PAM_USERTYPE_SYSUIDMIN);
    sys_max = pam_usertype_get_id(pamh, "SYS_UID_MAX", uid_min - 1);

    return uid >= sys_min && uid <= sys_max ? PAM_SUCCESS : PAM_AUTH_ERR;
}

static int
pam_usertype_is_regular(pam_handle_t *pamh, uid_t uid)
{
    int ret;

    ret = pam_usertype_is_system(pamh, uid);
    switch (ret) {
    case PAM_SUCCESS:
        return PAM_AUTH_ERR;
    case PAM_USER_UNKNOWN:
        return PAM_USER_UNKNOWN;
    default:
        return PAM_SUCCESS;
    }
}


===================================================================

So according to the code, the followings UID are system users:
  * UID<=99
  * UID is between SYS_UID_MIN and SYS_UID_MAX
  * Kernel overflow uid: default is 65534

And for regular users:
  UID not in the system users except (uid_t)-1)

Comment 5 Tomáš Mráz 2021-06-03 11:04:26 UTC
I agree with Martin here. All the UIDs <= SYS_UID_MAX should be treated as system. I'd simply drop the check of SYS_UID_MIN.

Comment 6 Tomáš Mráz 2021-06-03 11:09:26 UTC
Although maybe there should be also some more sanity checking logic to verify that the uid is < UID_MIN.

I.e., uid <= SYS_UID_MAX && uid < UID_MIN

Comment 9 Iker Pedrosa 2022-02-21 15:39:50 UTC
master:
    pam_usertype: only use SYS_UID_MAX for system users - 370064ef6f99581b08d473a42bb3417d5dda3e4e

Comment 14 errata-xmlrpc 2022-11-08 10:48:39 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 (pam 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:7723


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