🐛 users: skip /etc/passwd entries with unparseable uid/gid#8659
Open
tas50 wants to merge 1 commit into
Open
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
4a86843 to
0b05778
Compare
ParseEtcPasswd logged a uid/gid parse error but fell through and appended the user anyway with the zero value, surfacing a malformed line as a phantom uid 0 / gid 0 (root) account — the worst possible sentinel for an inventory/security tool. Skip the entry on a parse error instead. Adds a regression test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015U1ocAxfcBhVYi3f9JnyZZ
0b05778 to
5614f7d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
ParseEtcPasswdinusers/etcpasswd.go:The error is logged but not acted on: on a parse failure
uid/gidkeep their zero value and the user is still appended. A malformed/etc/passwdline therefore surfaces as a uid 0 / gid 0 (root) account — the worst possible sentinel for an inventory/security tool (the siblingshadow.goparser correctly returns an error in the same situation).Fix
Skip the entry (with a warning log) when uid or gid can't be parsed, so a corrupt line is dropped rather than fabricating root. Added a regression test with malformed uid and gid lines.
🤖 Generated with Claude Code
https://claude.ai/code/session_015U1ocAxfcBhVYi3f9JnyZZ
Generated by Claude Code