Bug 865759

Summary: Root can ssh when ssh_sysadm_login --> off in MLS
Product: Red Hat Enterprise Linux 6 Reporter: Michal Trunecka <mtruneck>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 6.4CC: degts, dwalsh, ebenes, mmalik, mvadkert, pvrabec, tlavigne
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.7.19-193.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 08:31:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 895654    

Description Michal Trunecka 2012-10-12 11:06:35 UTC
Description of problem:
Root/sysadm_r can ssh even when ssh_sysadm_login is set to OFF in MLS.

Version-Release number of selected component (if applicable):
selinux-policy-doc-3.7.19-169.el6.noarch
selinux-policy-mls-3.7.19-169.el6.noarch
selinux-policy-3.7.19-169.el6.noarch
selinux-policy-minimum-3.7.19-169.el6.noarch
selinux-policy-targeted-3.7.19-169.el6.noarch


How reproducible:
always

Steps to Reproduce:
1. set MLS in /etc/selinux/config
2. setenforce 1
3. setsebool ssh_sysadm_login 0
4. ssh root/sysadm_r@IPADDR
  
Actual results:
$ ssh root/sysadm_r.122.19
root/sysadm_r.122.19's password: 
Last login: Fri Oct 12 12:14:28 2012 from 192.168.122.1
[root@dhcp-25-224 ~]# 

Expected results: (The same as in targeted policy)
$ ssh root/sysadm_r.122.19
root/sysadm_r.122.19's password: 
Last login: Fri Oct 12 13:02:36 2012 from 192.168.122.1
Connection to 192.168.122.19 closed.

Comment 1 Miroslav Grepl 2012-10-12 11:11:05 UTC
What does

# id -Z

Comment 2 Michal Trunecka 2012-10-12 11:19:52 UTC
As root after ssh:

# id -Z
root:sysadm_r:sysadm_t:s0-s15:c0.c1023

Comment 4 Miroslav Grepl 2012-10-15 19:19:53 UTC
Miro,
does we break MLS? Is there a test which contain this boolean?

Comment 6 RHEL Program Management 2012-12-14 08:17:22 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 7 Miroslav Grepl 2012-12-14 10:29:26 UTC
It looks like we will need to remove this boolean because of privsep patch.

Comment 8 David Egts 2013-01-08 19:14:09 UTC
To add, not adding a role, sensitivity, and category fails as desired...

# ssh root@localhost
root@localhost's password: 
Unable to get valid context for root
Last login: Tue Jan  8 14:09:14 2013 from localhost
Connection to localhost closed.

But adding a role like sysadm_r causes it to succeed which isn't the desired behavior...

# ssh root/sysadm_r@localhost
root/sysadm_r@localhost's password: 
Last login: Tue Jan  8 14:09:36 2013 from localhost
[root@rhel6 ~]#

And adding a role and a sensitivity and/or category also causes a succeess which again isn't desired...

# ssh root/sysadm_r/U-TS@localhost
root/sysadm_r/U-TS@localhost's password: 
Last login: Tue Jan  8 14:10:37 2013 from localhost
[root@rhel6 ~]#

Comment 10 David Egts 2013-01-09 14:15:27 UTC
For the sake of completeness, here are the cases w/ssh_sysadm_login disabled (default) and enabled on a RHEL 6 system fully patched with the MLS policy.

Essentially, the results are the same whether ssh_sysadm_login is disabled or enabled.  In other words, the boolean appears to have no effect.  The root login behavior is the same no matter what the boolean setting is.


# ssh_sysadm_login disabled (default) -- sysadm_r may not ssh in
================================================================
# boolean off (default)
[root@rhel6 ~]# getsebool ssh_sysadm_login
ssh_sysadm_login --> off
# root by itself cannot get in (desired result)
[root@rhel6 ~]# ssh root@localhost
root@localhost's password: 
Unable to get valid context for root
Last login: Wed Jan  9 08:57:21 2013 from localhost
Connection to localhost closed.
# root/sysadm_r can get in (not desired result)
[root@rhel6 ~]# ssh root/sysadm_r@localhost
root/sysadm_r@localhost's password: 
Last login: Wed Jan  9 08:59:22 2013 from localhost
[root@rhel6 ~]# logout
Connection to localhost closed.
# root/sysadm_r/U-TS can get in (not desired result)
[root@rhel6 ~]# ssh root/sysadm_r/U-TS@localhost
root/sysadm_r/U-TS@localhost's password: 
Last login: Wed Jan  9 08:59:43 2013 from localhost
[root@rhel6 ~]# logout
Connection to localhost closed.


# ssh_sysadm_login enabled -- sysadm_r may ssh in
=================================================
# boolean on
[root@rhel6 ~]# setsebool -P ssh_sysadm_login on
[root@rhel6 ~]# getsebool ssh_sysadm_login
ssh_sysadm_login --> on
# root by itself cannot get in (not desired result)
[root@rhel6 ~]# ssh root@localhost
root@localhost's password: 
Unable to get valid context for root
Last login: Wed Jan  9 09:00:09 2013 from localhost
Connection to localhost closed.
# root/sysadm_r can get in (desired result)
[root@rhel6 ~]# ssh root/sysadm_r@localhost
root/sysadm_r@localhost's password: 
Last login: Wed Jan  9 09:01:48 2013 from localhost
[root@rhel6 ~]# logout
Connection to localhost closed.
# root/sysadm_r/U-TS can get in (desired result)
[root@rhel6 ~]# ssh root/sysadm_r/U-TS@localhost
root/sysadm_r/U-TS@localhost's password: 
Last login: Wed Jan  9 09:02:09 2013 from localhost
[root@rhel6 ~]# logout
Connection to localhost closed.

Comment 11 Miroslav Grepl 2013-01-09 14:27:29 UTC
> In other words, the boolean appears to have no effect.

Yes, this is caused by privsep patch in openssh. We have been discussing it with Dan and we believe we have a solution. But it needs to be tested. I will do a scratch build.

Comment 12 Miroslav Grepl 2013-01-14 08:56:38 UTC
Ok, it looks fine with our solution. We need to get a fix ASAP for testing.

Comment 16 Miroslav Grepl 2013-01-15 12:35:24 UTC
Fixed in selinux-policy-3.7.19-193.el6

Comment 30 errata-xmlrpc 2013-02-21 08:31:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-0314.html