Skip to content

user: skip passwd entries with invalid IDs - #267

Closed
sairex53 wants to merge 1 commit into
moby:mainfrom
sairex53:codex/user-id-parse-errors
Closed

sairex53 wants to merge 1 commit into
moby:mainfrom
sairex53:codex/user-id-parse-errors

Conversation

@sairex53

Copy link
Copy Markdown

ParsePasswdFilter and ParseGroupFilter currently discard integer conversion errors, turning malformed IDs into zero. On 32-bit systems, some overflow values can also saturate to the maximum int and appear valid.

Return errors from the internal numeric parser, reject IDs outside the supported range, and skip malformed passwd/group entries while continuing to parse valid rows. Add regression tests for nonnumeric, negative, and overflowing UID/GID values.

Tested on Fedora 44 ARM64:

  • cd user && go test ./...
  • cd user && go vet ./...

Fixes #248.

The passwd and group parsers discard integer conversion errors, which turns malformed UID and GID fields into zero. On 32-bit systems, overflowing values can also saturate to the maximum valid ID.

Reject invalid and out-of-range UID/GID fields, skipping those passwd/group entries while continuing to parse valid entries. Add regression coverage for malformed, negative, and overflowing IDs.

Fixes: moby#248
Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>
@kolyshkin

Copy link
Copy Markdown
Collaborator

@thaJeztah is working on that in #230, so closing this one.

@kolyshkin kolyshkin closed this Oct 19, 2026
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.

user: parseLine silently ignores uid/gid conversion errors, malformed ids parse as 0

2 participants