Description of problem: When logged as a confined user (user_u or staff_u), it is possible to run 'pkexec bash' to become root (knowing the root password of course). Here some outputs: $ id uid=1002(test) gid=1002(test) groups=1002(test) context=user_u:user_r:user_t:s0 $ pkexec bash ==== AUTHENTICATING FOR org.freedesktop.policykit.exec === Authentication is needed to run `/usr/bin/bash' as the super user Authenticating as: root Password: ==== AUTHENTICATION COMPLETE === bash: /root/.bashrc: Permission denied bash-4.3# id uid=0(root) gid=0(root) groups=0(root) context=user_u:user_r:user_t:s0 bash-4.3# pwd /root This should not be possible, 'pkexec' should obey the same rules as 'su'. Policy version: 3.13.1-105.6.fc21
That is expected. You need to use sudo for this or pkexec needs to learn to change the SELinux label. This is not a bug in policy. You also cannot run su.
> You need to use sudo for this Huh? For what? > You also cannot run su. Yes, I know. We need to switch to the sysadm_r role to run su, and I expected it would be the same to run pkexec. I thought user_u had no way to try to become root, but he can use 'pkexec bash' for that. He does not really gain power since he is still in the user_r role and user_t domain, but I want to avoid that.
Not sure what you mean you want to avoid that. If you don't know the root password you will not be allowed pkexec or su. If you know the root password then confined users are probably not going to stop you from ssh root@localhost. We do not block executing su and pkexec from the confined users, currently.
> We do not block executing su and pkexec from the confined users, currently. If you are not in the sysadm_r role, su will fail even with the good root password, so you cannot try to guess it. With pkexec, the authentication will success so you can try to guess the password & become root. > If you know the root password then confined users are probably not going to > stop you from ssh root@localhost. The machine is built so that the only root access possible is using ssh, with an authentication by certificates. I do not know what pkexec is used for, but it looks like an admin tool, so it should be restricted to the sysadm_r role. I have written a dumb policy to forbid its use by the users, without any complaints nor avc for the moment.
This is a problem with su against pkexec. You are not allowed to reach another user using "su" because we don't allow setuid and other capabilities for some confined users. But this is not required by pkexec which is a reason why you can log in if you know root passwd.
How does the policy look?
> You are not allowed to reach another user using "su" because we don't allow > setuid and other capabilities for some confined users. I don't understand, pkexec is also setuid root. > How does the policy look? As I wrote above, the policy is not finished. It was created by sepolgen, and modified by looking at the su policy. It forbids the use of pkexec by users who are not using the sysadm_r role (which is what I want). The only test tried for the sysadm_r role is to run 'pkexec bash', and it fails. I have not investigated this any further since I don't use it; I'm waiting for complaints/avc to fix it. Anyway, I'm joining the files.
Created attachment 1010664 [details] pkexec.te
Created attachment 1010665 [details] pkexec.if
Created attachment 1010667 [details] pkexec.fc
Well this is a problem with kexec. The point is we don't allow "setuid" capability for user_t, staff_t. But pkexec does not fail on it.
This message is a reminder that Fedora 21 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 21. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '21'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 21 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
This message is a reminder that Fedora 23 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 23. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '23'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 23 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
This message is a reminder that Fedora 25 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 25. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '25'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 25 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
This message is a reminder that Fedora 27 is nearing its end of life. On 2018-Nov-30 Fedora will stop maintaining and issuing updates for Fedora 27. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '27'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 27 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
Fedora 27 changed to end-of-life (EOL) status on 2018-11-30. Fedora 27 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.