Skip to contentSkip to conversation

Question regarding no_new_privs for pid 1 and SELinux

DISCUSSION Cathy Hu 2 participants 3 messages Nov 21, 2025 – Dec 10, 2025 SELinux security module

lore
Share & tools
lore

Cathy Hu

author
#0 lore raw

Hi all,

I have some questions regarding the "nnp_transition".
We are seeing efforts currently to disable most setuid/gid binaries by using no_new_privs in pid 1 [0]:

https://www.thkukuk.de/blog/no_new_privs/

For context, we are using the fedora policy as upstream with some modifications and the regular userspace toolchain.

The problem that we have atm is that setting no_new_privs for pid 1 (systemd)
means that the subsequent domain transitions where execve is used would need to have nnp_transition allowed.

I am currently unsure about:

1) [Question for kernel people] ... the impact that would have, as I don't really fully understand the exact vector that was described in the kernel commit [0] by Stephen and Paul:

"Allowing nnp_transition between two contexts opens up the potential for the old context to subvert the new context by installing seccomp filters before the execve. Allowing nosuid_transition between two contexts opens up the potential for a context transition to occur on a file from an untrusted filesystem (e.g. removable media or remote filesystem). Use with care."

Would it be possible to have a more in-depth explanation (and maybe recommendation for the policy)? Thanks :D

2) [Question for fedora and userspace people] ... how this could be implemented in the policy, such that this would be either accepted by the fedora policy or we would not diverge too much.

The problem here is, that because of 1), we likely would want to have it not as default and maybe behind a boolean (?)

I tried adding a tunable_policy to "domain_transition_pattern" [1], which does not work, as the m4 generates nested if() when the domain transition is behind a different boolean already, which is not accepted by the parser. That seems to be not easily workaroundable.

So the only idea left that I have is to create a pattern and add it to every domain transition manually. I am not sure if that big change would be acceptable or if there are any other ways/ideas to accomplish that?

Thanks a lot and please let me know if I am totally on the wrong track here :)

Kind regards,

Cathy

[0]
https://www.thkukuk.de/blog/no_new_privs/
https://github.com/thkukuk/account-utils
https://build.opensuse.org/projects/home:kukuk:no_new_privs/packages/disable-setuid/files/10-disable-setuid.conf?expand=1
[1] https://www.paul-moore.com/blog/d/2017/11/linux_v414.html
[2] https://github.com/fedora-selinux/selinux-policy/blob/rawhide/policy/support/misc_patterns.spt#L4

Signature · 9 lines
Cathy Hu <[email protected]>
SELinux Security Engineer
GPG: 5873 CFD1 8C0E A6D4 9CBB F6C4 062A 1016 1505 A08A

SUSE Software Solutions Germany GmbH
Frankenstrasse 146
90461 Nürnberg

Geschäftsführer: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
maintainer
#1 lore raw
Quoted 30 lines · Cathy Hu

Hi all,

I have some questions regarding the "nnp_transition".
We are seeing efforts currently to disable most setuid/gid binaries by using no_new_privs in pid 1 [0]:

https://www.thkukuk.de/blog/no_new_privs/

For context, we are using the fedora policy as upstream with some modifications and the regular userspace toolchain.

The problem that we have atm is that setting no_new_privs for pid 1 (systemd)
means that the subsequent domain transitions where execve is used would need to have nnp_transition allowed.

I am currently unsure about:

1) [Question for kernel people] ... the impact that would have, as I don't really fully understand the exact vector that was described in the kernel commit [0] by Stephen and Paul:

"Allowing nnp_transition between two contexts opens up the potential for the old context to subvert the new context by installing seccomp filters before the execve. Allowing nosuid_transition between two contexts opens up the potential for a context transition to occur on a file from an untrusted filesystem (e.g. removable media or remote filesystem). Use with care."

Quoted 2 lines

Would it be possible to have a more in-depth explanation (and maybe recommendation for the policy)? Thanks :D

The general principle is that it should be safe to allow nnp_transition when the calling/old domain is more trusted than the called/new domain.
So for transitions from init/systemd, I wouldn't be concerned about allowing nnp_transition permission. Ditto for transitions from any unconfined domain.
Otherwise, I would be cautious with allowing it from any confined domain, although again if you trust the calling domain to set up other aspects of the state of the called domain, it may be fine. If you already allow "noatsecure" permission between the two domains, then you've already allowed the caller to exert substantial influence over the callee and hence allowing nnp_transition should be (no less) safe.

Quoted 3 lines

2) [Question for fedora and userspace people] ... how this could be implemented in the policy, such that this would be either accepted by the fedora policy or we would not diverge too much.

I'll defer this one to the policy folks. Added Chris P to the cc for the upstream refpolicy view.

Quoted 41 lines

The problem here is, that because of 1), we likely would want to have it not as default and maybe behind a boolean (?)

I tried adding a tunable_policy to "domain_transition_pattern" [1], which does not work, as the m4 generates nested if()
when the domain transition is behind a different boolean already, which is not accepted by the parser. That seems to be not easily workaroundable.

So the only idea left that I have is to create a pattern and add it to every domain transition manually. I am not sure if that big change would be acceptable or if there are any other ways/ideas to accomplish that?

Thanks a lot and please let me know if I am totally on the wrong track here :)

Kind regards,

Cathy

[0]
https://www.thkukuk.de/blog/no_new_privs/
https://github.com/thkukuk/account-utils
https://build.opensuse.org/projects/home:kukuk:no_new_privs/packages/disable-setuid/files/10-disable-setuid.conf?expand=1
[1] https://www.paul-moore.com/blog/d/2017/11/linux_v414.html
[2]
https://github.com/fedora-selinux/selinux-policy/blob/rawhide/policy/support/misc_patterns.spt#L4

--
Cathy Hu <[email protected]>
SELinux Security Engineer
GPG: 5873 CFD1 8C0E A6D4 9CBB F6C4 062A 1016 1505 A08A

SUSE Software Solutions Germany GmbH
Frankenstrasse 146
90461 Nürnberg

Geschäftsführer: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)

author
#2 lore raw
Quoted 14 lines · Stephen Smalley

The general principle is that it should be safe to allow nnp_transition when the calling/old domain is more trusted than the called/new domain.
So for transitions from init/systemd, I wouldn't be concerned about allowing nnp_transition permission. Ditto for transitions from any unconfined domain.
Otherwise, I would be cautious with allowing it from any confined domain, although again if you trust the calling domain to set up other aspects of the state of the called domain, it may be fine. If you already allow "noatsecure" permission between the two domains, then you've already allowed the caller to exert substantial influence over the callee and hence allowing nnp_transition should be (no less) safe.

Thanks a lot for the explanation!

Quoted 7 lines
Quoted 3 lines

2) [Question for fedora and userspace people] ... how this could be implemented in the policy, such that this would be either accepted by the fedora policy or we would not diverge too much.

I'll defer this one to the policy folks. Added Chris P to the cc for the upstream refpolicy view.

FYI, I started testing out different implementations and hitting walls, not sure if someone would have a more clever way or ideas :)
https://github.com/fedora-selinux/selinux-policy/pull/2993