Skip to content

Command is being executed with root's group ID #1

@israel-lugo

Description

@israel-lugo

Problem

We need to squash the group ID and supplementary group list when changing user. Right now, we're running the command with root's groups, unchanged. This is a security bug.

Example:

$ sudo ./nonet -u nobody -- id
uid=65534(nobody) gid=0(root) groups=0(root)
$ ls -l /tmp/secret 
-rw-r----- 1 root root 12 Abr 28 23:29 /tmp/secret
$ sudo ./nonet -u nobody -- cat /tmp/secret 
SECRET DATA

Solution

The logical behavior would be to change the group ID to the the group ID from the user's passwd entry. As for the supplementary group IDs, these could either be blanked, or set to the list of groups that the user belongs to (which is more expectable and user friendly).

The getgrouplist() function can be used for this, but it's not POSIX standard. An alternative would be to use getgrent() to crawl the list of group entries, looking for groups with the desired member.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions