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

drop_privileges does not drop enough #133

Closed
jengelh opened this issue Jan 5, 2023 · 0 comments
Closed

drop_privileges does not drop enough #133

jengelh opened this issue Jan 5, 2023 · 0 comments

Comments

@jengelh
Copy link

jengelh commented Jan 5, 2023

rpmlint has found an issue with postsrsd 2.0.1:

[    5s] postsrsd.x86_64: E: missing-call-to-setgroups-before-setuid /usr/sbin/postsrsd
[    5s] This executable is calling setuid and setgid without setgroups or initgroups.
[    5s] This means it didn't relinquish all groups, and this would be a potential
[    5s] security issue.

Supplementary groups are kept across setgid and setuid calls, so drop_privileges may not be completely dropping all privileges provided suitable starting conditions. Consider:

### ls -al /etc/at.deny 
-rw-r----- 1 root root 62 Aug 31 14:16 /etc/at.deny
### cat x.cpp
#include <unistd.h>
#include <stdio.h>
int main()
{
        setgid(65534);
        setuid(65534);
        if (access("/etc/at.deny", R_OK) == 0)
                printf("Can still read\n");
}
### ./a.out 
Can still read
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

No branches or pull requests

1 participant