sys/user: incomplete mitigation of unbounded passwd/group file reads
Description
The fix for GHSA-mjcv-p78q-w5fw / CVE-2026-61801 introduced file type and size checks when parsing user and group files in github.com/moby/sys/user. However, these checks were not applied consistently across all parsing and lookup functions.
Several functions could still process large or unbounded files, potentially causing excessive memory or CPU consumption and resulting in a denial of service.
Details
The following functions are affected:
ParsePasswdFile/ParsePasswdFileFilterGetAdditionalGroupsPathParseSubIDFile/ParseSubIDFileFilterParseIDMapFile/ParseIDMapFileFilterLookupUser/LookupUidLookupGroup/LookupGid
The issue can be triggered when an affected application processes attacker-controlled user or group files, such as /etc/passwd or /etc/group from a container image.
Impact
An attacker who controls the contents of a user or group file processed by an affected application may cause excessive resource consumption, potentially exhausting memory or causing a denial of service.
Exploitation depends on how the consuming application uses the affected functions. For example, some paths require specific build operations or container configuration options.
Remediation
The affected parsing and lookup functions now enforce the 10 MiB read limit introduced by GHSA-mjcv-p78q-w5fw / CVE-2026-61801. Regular-file checks are applied where appropriate. ID mapping files retain support for non-regular procfs files while enforcing the same read limit.