It was discovered that a systemd service that uses DynamicUser property can create a SUID/SGID binary that would be allowed to run as the transient service UID/GID even after the service is terminated. A local attacker may use this flaw to access resources that will be owned by a potentially different service in the future, when the UID/GID will be recycled.
A compromised or malicious service that uses DynamicUser property could leave on the filesystem a SUID/SGID binary that would allow other users to execute programs with the privileges of the transient user/group created by systemd. If the same UID/GID is reused by another service in the future, the SUID/SGID binary can be used to access the new service's resources.
This issue did not affect the versions of systemd as shipped with Red Hat Enterprise Linux 7 as they did not include support for DynamicUser property.
Created systemd tracking bugs for this issue:
Affects: fedora-all [bug 1703356]
https://github.com/systemd/systemd-stable/pull/54 contains a backport for v241-stable.
Name: Jann Horn (Google Project Zero)