Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
israel-lugo opened this issue Apr 28, 2017 · 0 comments
Open

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

israel-lugo opened this issue Apr 28, 2017 · 0 comments
Assignees

Comments

@israel-lugo
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant