Re: [PATCH] cockpit web admin system

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 4/26/21 4:21 PM, Dominick Grift wrote:
> 
> 
> On 4/26/21 3:34 PM, Dominick Grift wrote:
>>
>>
>> On 4/26/21 3:22 PM, Dominick Grift wrote:
>>>
>>>
>>> On 4/26/21 2:47 PM, Chris PeBenito wrote:
>>>> On 4/20/21 9:49 AM, Dominick Grift wrote:
>>>>> Russell Coker <russell@xxxxxxxxxxxx> writes:
>>>>>
>>>>>> I took this from the rawhide policy and adapted it to work with
>>>>>> refpolicy.
>>>>>>
>>>>>> Probably not ready for merging yet, let me know what should be changed.
>>>>>
>>>>> Its been a while since I played with cockpit
>>>>>
>>>>> Theres one thing that I want to mention though, instead of login the
>>>>> confined users in with their login shell domain consider confining the
>>>>> cockpit-bridge instead and make it log users in with bridge context
>>>>> instead of the login shell context.
>>>>
>>>> Do you have an example of permissions that would be concerning?
>>>
>>> The wide direct dbus access might be concerning.
>>>
>>> cockpit-bridge (at least when I used it) seems to chat directly with
>>> various system services like firewalld,tuned,udisks but also various
>>> systemd components including pid1 (although not sure if the latter are
>>> direct or via systemctl.
>>>
>>> There's a bunch of other access that I can't explain anymore and some of
>>> it does not make sense. Theres network access (connects to vnc and binds
>>> tcp sockets to ephemeral ports)
>>
>> It is not binding sockets to ports but it is connecting. That no big
>> deal since refpolicy already allows that access.
>>
>> It does execute gpg though. if it runs in the shell domain then it has
>> access to gpg data (either via the gpg command or directly) and it seems
>> to not need that (but it still runs gpg probably with a different $GPG_HOME)
>>
>> It does not look too terrible, but things like tcp_socket/udp_socket,
>> dbus, and service access are things i would try not to associate with
>> confined shells (but refpolicy already allows quite a bit of that access
>> anyway)
> 
> I took a little trip down memory lane:
> 
> The issue becomes with users with polkit access. pkexec is a command
> that is much like sudo (its probably setuid) however it is not selinux
> aware and it seems that refpolicy currently does not support it at all.
> 
> Imagine a user with polkit access log in (ie wheel, adm (or whatever
> Debian uses for users with wide polkit access). The bridge for those
> users will in some cases run pkexec (and sudo). Both have issues because
> with sudo you either have a ROLE= in the user /etc/sudoers or you do not
> if you do then sudo will try to go whether its told, if not then it will
> just stick in its domain.
> 
> Since pkexec is not selinux aware you rely on automatic transitions. So
> iif you say staff_t gets polkit access then you might for example say
> automatically transition to sysadm_t when staff_t runs pkexec.
> 
> If you do not differentiate between bridge and login shell then bridge
> will also transition to sysadm_t when it runs pkexec and end up with the
> same permissions that staff_t would get when it runs pkexec.
> 
> It is kind of hard to talk about this topic without having even
> considered how to deal with pkexec.
> 
> There is also a upside to that, because now we can anticipate how pkexec
> might be (ab)used

Thing is though that when all is said and done bridge probably just
needs the same permissions/identifiers as the login user.

I did not realize this only until later because the bridge for my wheel
(staff_t) user would have to be able to run sudo with a transition to
staff_sudo_t, just because it needed to be able to transition to
whatever was specified in /etc/sudoers for that user (ie ROLE=sysadm_r
TYPE=sysadm_t)

So in other words. I image that refpolicy would allow staff_t to run
pkexec with a automatic transition to sysadm_t (anything else probably
wouldnt make sense?). So that then means that the bridge for those users
gets root access. because it runs with the uid of the user that has
access to polkit/pkexec and it can transition to sysadm_t automatically
upon pkexec:

ie: pkexec setenforce 0

> 
>>
>>>
>>> I also allowed it to mapread shadow unconditionally but that does not
>>> make sense as shadow is mode 000 and even if the bridge would be run by
>>> a root login it still seems to not have cap_dac_read_search access ...
>>>
>>> https://git.defensec.nl/?p=dssp2.git;a=blob;f=policy/services/c/cockpit.cil;h=f09d5084ba0c9f1b671b26772b29eb383c40e60a;hb=HEAD#l95
>>>
>>> Things may have changed since then as well. I just wanted to give a
>>> heads-up, it may be nothing to worry about.
>>>
>>>>
>>>>
>>>>> Because otherwise you'll end up extending the login shell domain with
>>>>> permissions needed by the bridge. You can still allow the bridge to open
>>>>> up a shell with a transition back to the login shell domain (but then
>>>>> you will get into domain prefixes
>>>>>
>>>>> ie: staff_bridge_t -> shell_exec_t -> staff_t vs. user_bridge_t ->
>>>>> shell_exec_t -> user_t etc.
>>>>
>>>>
>>>> Otherwise I only see some style cleanup needed.  Also there is an
>>>> optional block in the admin interface for systemd calls.  Systemd is
>>>> required for cockpit, so it shouldn't be optional, right?
>>>>



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux