Closed
Description
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:
if self.get_groups().is_none() {
let _ = libc::setgroups(0, ptr::null()); // or return unless EPERM
}
Metadata
Metadata
Assignees
Labels
Area: `std::process` and `std::env`Category: This is a bug.Operating system: LinuxOperating system: Unix-likeRelevant to the library team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.