Bug 1206069 - confined users (user_u, staff_u) can become root using pkexec
Summary: confined users (user_u, staff_u) can become root using pkexec
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: polkit
Version: 27
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lukas Vrabec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-26 09:25 UTC by Alphonse Steiner
Modified: 2018-11-30 17:32 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-11-30 17:32:47 UTC


Attachments (Terms of Use)
pkexec.te (1.17 KB, text/plain)
2015-04-03 15:56 UTC, Alphonse Steiner
no flags Details
pkexec.if (1.51 KB, text/plain)
2015-04-03 15:58 UTC, Alphonse Steiner
no flags Details
pkexec.fc (68 bytes, text/plain)
2015-04-03 15:58 UTC, Alphonse Steiner
no flags Details

Description Alphonse Steiner 2015-03-26 09:25:57 UTC
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

Comment 1 Daniel Walsh 2015-03-27 13:45:36 UTC
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.

Comment 2 Alphonse Steiner 2015-03-27 16:00:52 UTC
> 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.

Comment 3 Daniel Walsh 2015-03-31 16:50:51 UTC
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.

Comment 4 Alphonse Steiner 2015-03-31 17:30:11 UTC
> 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.

Comment 5 Miroslav Grepl 2015-04-03 15:09:42 UTC
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.

Comment 6 Miroslav Grepl 2015-04-03 15:10:16 UTC
How does the policy look?

Comment 7 Alphonse Steiner 2015-04-03 15:55:39 UTC
> 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.

Comment 8 Alphonse Steiner 2015-04-03 15:56:57 UTC
Created attachment 1010664 [details]
pkexec.te

Comment 9 Alphonse Steiner 2015-04-03 15:58:20 UTC
Created attachment 1010665 [details]
pkexec.if

Comment 10 Alphonse Steiner 2015-04-03 15:58:59 UTC
Created attachment 1010667 [details]
pkexec.fc

Comment 11 Miroslav Grepl 2015-05-11 11:51:34 UTC
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.

Comment 12 Fedora End Of Life 2015-11-04 12:04:00 UTC
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.

Comment 13 Fedora End Of Life 2016-11-24 11:37:34 UTC
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.

Comment 14 Fedora End Of Life 2017-11-16 18:59:53 UTC
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.

Comment 15 Ben Cotton 2018-11-27 18:13:33 UTC
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.

Comment 16 Ben Cotton 2018-11-30 17:32:47 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.