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

Allow root uid/gid (0) in sandbox userns when allowNewPrivileges #2525

Closed
wants to merge 1 commit into from

Conversation

lukego
Copy link

@lukego lukego commented Nov 8, 2018

If Nix is run with the --allow-new-privileges option then it should be possible to run setuid binaries to gain root access. However, this did not work in practice because the root user/group did not exist in the sandbox due to exclusion from the kernel user-namespace. The uid would always be nixbld (1000) even when executing a setuid-root binary.

This change adds uid/gid 0 to the sandbox userns only when --allow-new-privileges is enabled and makes setuid work as expected.

Note: This makes it effective to run setuid executables but it does not make it possible to create them. This means that in practice to gain root in the sandbox you must both provide --allow-new-privileges and also add a suitable binary to the Nix sandbox path.

Resolves #2522.

If Nix is run with the --allow-new-privileges option then it should be
possible to run setuid binaries to gain root access. However, this did
not work in practice because the root user/group did not exist in the
sandbox due to exclusion from the kernel user-namespace. The uid would
always be nixbld (1000) even when executing a setuid-root binary.

This change adds uid/gid 0 to the sandbox userns only when
--allow-new-privileges is enabled and makes setuid work as expected.

Note: This makes it effective to *run* setuid executables but it does
not make it possible to create them. This means that in practice to
gain root in the sandbox you must both provide --allow-new-privileges
and also add a suitable binary to the Nix sandbox path.

Resolves NixOS#2522.
@edolstra
Copy link
Member

edolstra commented Nov 8, 2018

Maybe there should also be an entry added to /etc/passwd for uid 1? Something like host-root.

@stale
Copy link

stale bot commented Feb 13, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 13, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

I closed this issue due to inactivity. → More info

@stale stale bot closed this Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setuid root does not work in sandbox
2 participants