Bug 1610541 - systemd-sysusers creates system users without honoring login.defs limits
Summary: systemd-sysusers creates system users without honoring login.defs limits
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: 28
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2018-07-31 21:28 UTC by Scott Shambarger
Modified: 2019-05-28 18:57 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2019-05-28 18:57:02 UTC
Type: Bug

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Github systemd systemd issues 9769 0 None closed sysusers creates system users without honoring login.defs limits 2020-08-31 12:01:39 UTC

Description Scott Shambarger 2018-07-31 21:28:52 UTC
Description of problem:
system-sysusers is creating system users with UIDs in regular user range.  This allows those users to potentially bypass PAM restrictions and other limits based on UID range.

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

How reproducible:
Anytime systemd-sysuser is used to create users, for example during systemd upgrade (systemd-coredump user) or install of dnsmasq (dnsmasq user)

Steps to Reproduce:
1. Edit login.defs so that UID_MIN is != 1000, eg "UID_MIN 500" (as was the default in earlier Fedora releases)... you could also update SYS_UID_MAX if that's defined.

2. Create sysuser conf file /run/sysusers.d/test-sysusers.conf containing

u test-sysusers - "Test sysusers"

3. Run: systemd-sysusers /run/sysusers.d/test-sysusers.conf

Actual results:

Creating group test-sysusers with gid 998.
Creating user test-sysusers (Test sysusers) with uid 998 and gid 998.

Expected results:

System user created with UID < 500, as useradd -r does and almost all RPM packages that create system users.

Additional info:

From looking at the systemd source, it appears to be setting a build config option SYSTEM_UID_MAX from the build machines /etc/login.defs SYS_UID_MAX value (with default 999 if missing) -- so the max is being set at compile time.

Even this is incorrect, as SYS_UID_MAX defaults to UID_MIN-1, not 999...

src/sysusers/sysusers.c should be modified to use the logic documented in login.defs(5): SYS_UID_MAX, or UID_MIN-1, or 999, in that order... and probably also honoring SYS_UID_MIN etc...

Comment 1 Scott Shambarger 2018-08-01 09:10:33 UTC
Submitted upstream: https://github.com/systemd/systemd/issues/9769

Comment 2 Scott Shambarger 2018-08-01 19:48:02 UTC
Lennart closed the upstream bug referring to https://github.com/systemd/systemd/blob/f4ea7552c109942b49cc1a3c37e959716fb8c453/doc/UIDS-GIDS.md - it states that systemd systems have their SYS_UID_MAX fixed at compile time (distro chooses it), and are not user configurable.

This pretty much makes systemd-sysusers incompatible with Fedora since Fedora systems do have configurable SYS_UID_MAX, and has changed it over the years (100, later 500, now 1000) - and so there are many, many upgraded systems that cannot easily re-number all their existing users...

So it appears that there are two options here:

a) create a patch for Fedora that make systemd-sysusers reference login.defs knowing the patch will not be accepted upstream

b) fix all rpm.spec files that currently user sysusers to pre-create system users using useradd -r so that any installed sysusers.d/*.conf files will be a no-op.

Of course, there's always c) do nothing, and break security on older systems.

Personally, I'd suggest (b) since it's simple, and doesn't involve patching systemd, and is therefore easier to maintain... but does involve patching a number of spec files (and hence creating a number of new bugs :P)

Comment 3 Ben Cotton 2019-05-02 21:13:12 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 4 Ben Cotton 2019-05-28 18:57:02 UTC
Fedora 28 changed to end-of-life (EOL) status on 2019-05-28. Fedora 28 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this

Thank you for reporting this bug and we are sorry it could not be fixed.

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