Skip to content

user: limit reads when parsing passwd and group files - #286

Merged
vvoland merged 6 commits into
moby:mainfrom
thaJeztah:passwd_userfile
Nov 23, 2026
Merged

vvoland merged 6 commits into
moby:mainfrom
thaJeztah:passwd_userfile

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

user: limit reads when parsing passwd files

Use the existing openUserFile helper in ParsePasswdFileFilter to limit reads
to 10 MiB and reject non-regular files. This extends the protection introduced
in bba2f13 for group files to passwd files, which may also originate
from untrusted container images.

See: bba2f13

user: limit reads when looking up additional groups

Use the existing openUserFile helper in GetAdditionalGroupsPath to limit reads
to 10 MiB and reject non-regular files. This extends the protection introduced
in bba2f13 to additional group lookups, which may also read group files
from untrusted container images.

Preserve the existing behavior for missing group files, but propagate other
errors instead of silently ignoring them.

See: bba2f13

user: limit reads when parsing subordinate ID files

Use the existing openUserFile helper in ParseSubIDFileFilter to limit reads
to 10 MiB and reject non-regular files. This extends the protection introduced
in bba2f13 to subordinate UID/GID files, which may also originate
from untrusted sources.

See: bba2f13

user: limit reads when looking up users and groups

Use ParsePasswdFileFilter and ParseGroupFileFilter for user and group lookups
instead of opening and parsing the files directly. This reuses the existing
10 MiB read limit and regular-file checks introduced in bba2f13 and
extended to passwd files.

See: bba2f13

user: document unrestricted passwd and group readers

Add GoDoc comments to GetPasswdPath, GetGroupPath, GetPasswd, and GetGroup.

Clarify that GetPasswd and GetGroup return unrestricted readers without
validating the file type or limiting reads, unlike the file-based parsing
functions. Callers are responsible for closing the returned readers and
handling potentially unbounded input.

This comment was marked as outdated.

This comment was marked as outdated.

Use the existing openUserFile helper in ParsePasswdFileFilter to limit reads
to 10 MiB and reject non-regular files. This extends the protection introduced
in bba2f13 for group files to passwd files, which may also originate
from untrusted container images.

See: moby@bba2f13

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Use the existing openUserFile helper in GetAdditionalGroupsPath to limit reads
to 10 MiB and reject non-regular files. This extends the protection introduced
in bba2f13 to additional group lookups, which may also read group files
from untrusted container images.

Preserve the existing behavior for missing group files, but propagate other
errors instead of silently ignoring them.

See: moby@bba2f13

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Use the existing openUserFile helper in ParseSubIDFileFilter to limit reads
to 10 MiB and reject non-regular files. This extends the protection introduced
in bba2f13 to subordinate UID/GID files, which may also originate
from untrusted sources.

See: moby@bba2f13

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Use ParsePasswdFileFilter and ParseGroupFileFilter for user and group lookups
instead of opening and parsing the files directly. This reuses the existing
10 MiB read limit and regular-file checks introduced in bba2f13 and
extended to passwd files.

See: moby@bba2f13

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Add GoDoc comments to GetPasswdPath, GetGroupPath, GetPasswd, and GetGroup.

Clarify that GetPasswd and GetGroup return unrestricted readers without
validating the file type or limiting reads, unlike the file-based parsing
functions. Callers are responsible for closing the returned readers and
handling potentially unbounded input.

Signed-off-by: Sebastiaan van Stijn <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are identified for the changes extending file-reading protections to user and group parsing.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@thaJeztah
thaJeztah marked this pull request as ready for review November 23, 2026 15:57
@thaJeztah
thaJeztah requested a review from vvoland November 23, 2026 15:57
@thaJeztah

Copy link
Copy Markdown
Member Author

@vvoland ptal

@vvoland
vvoland merged commit 8b59ddf into moby:main Nov 23, 2026
25 checks passed
@thaJeztah
thaJeztah deleted the passwd_userfile branch November 24, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants