Commit 22ddcd1 made libstd drops ancillary groups when uid == 0:
|
if libc::getuid() == 0 && self.get_groups().is_none() { |
|
cvt(libc::setgroups(0, ptr::null()))?; |
|
} |
Before that it unconditionally dropped group membership.
The new logic is wrong on Linux: it doesn't account for processes whose uid != 0 but have the CAP_SETGID capability.
Such processes can and should drop ancillary groups, otherwise child processes inherit permissions they otherwise wouldn't have.
Suggested change:
if self.get_groups().is_none() {
let _ = libc::setgroups(0, ptr::null()); // or return unless EPERM
}
Commit 22ddcd1 made libstd drops ancillary groups when uid == 0:
rust/library/std/src/sys/unix/process/process_unix.rs
Lines 312 to 314 in 385f8e2
Before that it unconditionally dropped group membership.
The new logic is wrong on Linux: it doesn't account for processes whose uid != 0 but have the CAP_SETGID capability.
Such processes can and should drop ancillary groups, otherwise child processes inherit permissions they otherwise wouldn't have.
Suggested change: