You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SUID wrappers (i.e. sudo) do not work in FHSEnvs #69338
0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: architectureRelating to code and API architecture of Nixpkgs
Yeah, that's an implication of us using mount namespaces inside buildFHSUserEnv. Unfortunately I don't think much could be done about it: the security check that the wrapper does avoids a scenario when you craft a malicious namespace where say /etc/passwd is mounted to a file you control, and gain user privileges via sudo.
This is a really major blocker for me because I'm trying to package VMware Workstation 15 for NixOS (nixpkgs) and so far I only see two options:
1.) Use an FHS environment to install VMware in to meaning to need to patch the binaries - blocked by this issue.
2.) Use patchelf to patch the binaries - this then generates a large binary and patchelf complains it cannot patch it due to a max filesize limit so basically I can't win either way!
Any ideas on how I can work around this in a way which can be pushed to nixpkgs? (i.e. not hacking random scripts and things because I obviously can't share that outside of my own system. :))
cc @abbradar - any ideas about how I can address this? Completely blocked at the moment.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
Search for maintainers and people that previously touched the related code and @ mention them in a comment.
Could this be solved by "registering" the FHSUserenvs which are allowed to run SUID wrappers using a mechanism that requires root privileges?
That's how SUID wrappers work outside of chrootenvs, right?
This is important to me too - it's necessary to get fuse working inside a FHS User Env. I'll keep this issue open while I look for alternatives, and report back if I find a workaround.
Just realised that this is, in fact, not a duplicate as the other issue was about dropping privileges when already privileged rather than gaining privileges as is the case here.
Copying my idea from over there here:
I've had a look into how Flatpak solves this issue and it seems like most apps use Polkit to authenticate. SteamVR (the main reason I'm here) uses it too.
AFAIUI, it's an IPC-based privilege escalation mechanism which enables it to work in containers. It needs a privileged daemon on the host of course though.
Perhaps we could build a sudo substitute on top of polkit?
Perhaps we could build a sudo substitute on top of polkit?
This will actually exists soon: Systemd 256 adds support for run0. You should be able to manually create your own "run0" using systemd-run already though if anyone wants to experiment.
Okay, so apparently polkit (via pkexec) still requires SUID and will immediately exit with pkexec must be setuid root if it doesn't have SUID.
But somehow this must be working within flatpak and friends?
Perhaps it's safe to allow SUID in any case on polkit because it does its own internal userns-aware checking using a privileged daemon that cannot be fooled by a malicious userns? Figuring this out feels like the logical next step.
I'm linking this other issue on documenting suid wrappers because it's actually not clear how to proceed when packaging something that needs to access a suid binary, especially when this is inside any kind of jail
FWIW you can use sudobefore entering that shell, and then you'll be root within it. However, you still won't be able to run sudo. Not sure if it helps:
Would be auto-accepted by polkit (I think that should be secure except for the denial of service if you misconfigure AllowedCPUs? maybe needs hardcoded binary paths to /run/current-system/sw/bin?), but systemd-run uses the generic org.freedesktop.systemd1.manage-units policy which just exposes the unit name and verb - start in this case. So there's no way to match on the prefix and validate the specific command being run as far as I can see.
0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: architectureRelating to code and API architecture of Nixpkgs
Activity
matthewbauer commentedon Sep 28, 2019
This looks like any program with the SUID bit fails?
abbradar commentedon Oct 1, 2019
Yeah, that's an implication of us using mount namespaces inside
buildFHSUserEnv. Unfortunately I don't think much could be done about it: the security check that the wrapper does avoids a scenario when you craft a malicious namespace where say /etc/passwd is mounted to a file you control, and gain user privileges via sudo.[-]sudo does not work in buildFHSUserenv.env[/-][+]SUID wrappedrs do not work in buildFHSUserenv.env[/+]JohnAZoidberg commentedon Oct 6, 2019
Yes, you're right. All SUID wrapped programs fail.
cawilliamson commentedon Dec 17, 2019
This is a really major blocker for me because I'm trying to package VMware Workstation 15 for NixOS (nixpkgs) and so far I only see two options:
1.) Use an FHS environment to install VMware in to meaning to need to patch the binaries - blocked by this issue.
2.) Use patchelf to patch the binaries - this then generates a large binary and patchelf complains it cannot patch it due to a max filesize limit so basically I can't win either way!
Any ideas on how I can work around this in a way which can be pushed to nixpkgs? (i.e. not hacking random scripts and things because I obviously can't share that outside of my own system. :))
cc @abbradar - any ideas about how I can address this? Completely blocked at the moment.
[-]SUID wrappedrs do not work in buildFHSUserenv.env[/-][+]SUID wrappers do not work in buildFHSUserenv.env[/+]stale commentedon Jun 30, 2020
Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
Atemu commentedon Jul 10, 2020
Still important to me.
Atemu commentedon Jul 30, 2020
Could this be solved by "registering" the FHSUserenvs which are allowed to run SUID wrappers using a mechanism that requires root privileges?
That's how SUID wrappers work outside of chrootenvs, right?
setupminimal commentedon Aug 1, 2020
This is important to me too - it's necessary to get
fuseworking inside a FHS User Env. I'll keep this issue open while I look for alternatives, and report back if I find a workaround.noonien commentedon Aug 26, 2020
This is also important to me. Some programs don't work without FHS, and, some of those require access to root-only resources.
eglaysher commentedon Sep 15, 2020
This is important to me since it's in the blocking path for Steam VR stuff.
5 remaining items
Atemu commentedon Aug 10, 2023
Just realised that this is, in fact, not a duplicate as the other issue was about dropping privileges when already privileged rather than gaining privileges as is the case here.
Copying my idea from over there here:
I've had a look into how Flatpak solves this issue and it seems like most apps use Polkit to authenticate. SteamVR (the main reason I'm here) uses it too.
AFAIUI, it's an IPC-based privilege escalation mechanism which enables it to work in containers. It needs a privileged daemon on the host of course though.
Perhaps we could build a sudo substitute on top of polkit?
nixos-discourse commentedon Jun 4, 2024
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/sudo-not-working-inside-a-buildfhsuserenv-no-new-privileges-flag/38971/4
Atemu commentedon Jun 4, 2024
This will actually exists soon: Systemd 256 adds support for
run0. You should be able to manually create your own "run0" usingsystemd-runalready though if anyone wants to experiment.nixos-discourse commentedon Jun 4, 2024
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/sudo-not-working-inside-a-buildfhsuserenv-no-new-privileges-flag/38971/5
Atemu commentedon Jun 4, 2024
Okay, so apparently polkit (via
pkexec) still requires SUID and will immediately exit withpkexec must be setuid rootif it doesn't have SUID.But somehow this must be working within flatpak and friends?
Perhaps it's safe to allow SUID in any case on polkit because it does its own internal userns-aware checking using a privileged daemon that cannot be fooled by a malicious userns? Figuring this out feels like the logical next step.
zarelit commentedon Jul 14, 2024
I'm linking this other issue on documenting suid wrappers because it's actually not clear how to proceed when packaging something that needs to access a suid binary, especially when this is inside any kind of jail
yajo commentedon Apr 22, 2025
FWIW you can use
sudobefore entering that shell, and then you'll berootwithin it. However, you still won't be able to runsudo. Not sure if it helps:farnoy commentedon Sep 21, 2025
Has anyone figured out a replacement with systemd-run/run0? I wanted to create a policy so that commands with a prefix:
Would be auto-accepted by polkit (I think that should be secure except for the denial of service if you misconfigure AllowedCPUs? maybe needs hardcoded binary paths to /run/current-system/sw/bin?), but systemd-run uses the generic
org.freedesktop.systemd1.manage-unitspolicy which just exposes the unit name and verb -startin this case. So there's no way to match on the prefix and validate the specific command being run as far as I can see.nixos-discourse commentedon Oct 29, 2025
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/derivation-for-binary-using-fusermount-stuck-on-glibc-hwcaps/71494/1
Atemu commentedon Mar 8, 2026
Tried using run0 in an fhsenv and it threw:
This appears to be related to pam and/or login not being done the way it should? systemd/systemd#37149
Further context I have found:
microsoft/WSL#9213 (cc @K900)
https://gitlab.archlinux.org/archlinux/archlinux-wsl/-/issues/13
[-]SUID wrappers do not work in buildFHSUserenv.env[/-][+]SUID wrappers (i.e. `sudo`) do not work in FHSEnvs[/+]