Closed robryk closed 1 year ago
Ah, a better way of checking whether any escalation occurred (if not, we can simply exec the underlying binary without much care) is to check whether AT_SECURE
is set in the auxiliary vector (see getauxval(3)
).
I just got surprised by this while trying out bubblewrap for the first time. To confirm, it dies on the same assertion:
$ bwrap --dev-bind / / sudo echo foo
sudo: /nix/store/v6l2sacryfr88yqq0pq7sia8wfgm9q31-wrapper.c:203: main: Assertion `!(st.st_mode & S_ISUID) || (st.st_uid == geteuid())' failed.
I marked this as stale due to inactivity. → More info
The issue in my previous comment is still reproducible on nixpkgs master.
Describe the bug Wrappers for S[UG]ID binaries crash if they are executed in a way that doesn't cause escalation to happen (i.e. leaves effective UID unchanged), even though the binary has the S[UG]ID bit set.
To Reproduce Steps to reproduce the behavior:
Expected behavior I expect SUID wrapper to simply run the underlying binary if something (
NO_NEW_PRIVS
,nosuid
mountpoint, etc.) prevented the effective UID from changing.Additional context I have initially encountered this issue while using bubblewrap (which sets
NO_NEW_PRIVS
on all the processes it starts in user namespaces), so it's not completely academic.I think the correct way to detect if escalation happened is to check whether UID and EUID are equal -- if they are we can be sure that we weren't escalated using the S[UD]ID mechanism. Some more care might be required due to capabilities, though.
Notify maintainers @ixmatus -- the code of the dying wrappers is in nixos/modules/security/wrappers, and @ixmatus seems to have made most recent meaningful contributions there
Metadata
Maintainer information: