Allow root uid/gid (0) in sandbox userns when allowNewPrivileges #2525
+2
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.