Supplementary groups are cleared instead of initialized from /etc/group when --userspec is used without --groups #3
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
utils/warproot#3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
When
--userspecis provided without--groups, the code clears all supplementary groups instead of initializing them from the target user's actual group memberships:Standard tools like
chroot/sutypically call the equivalent ofinitgroups()in this situation — looking up which groups the target user belongs to in/etc/groupand applying that list. Here, the user silently loses all supplementary group memberships instead.Impact
A process running as the target uid inside the chroot may unexpectedly lose access to files/resources that rely on group membership (e.g. group-readable/writable files), because none of the user's normal secondary groups are applied — and there's no indication to the operator that this happened beyond a debug-level log line.
Steps to reproduce
/etc/passwd//etc/group(inside the new root) who is a member of one or more supplementary groups../warproot --userspec=<user> /path/to/rootwithout--groups.id— supplementary groups are empty instead of matching/etc/group.Expected behavior
When
--groupsis not specified, supplementary groups should be initialized from the target user's memberships in/etc/group(aninitgroups()-style lookup), matching the behavior of standardchroot/suimplementations — or, if clearing groups by default is an intentional security choice, this should be clearly documented in--helpand the README.