Skip to contentSkip to conversation

ssh and fs relabel (new release)

DISCUSSION Timothy Wood 3 participants 4 messages Aug 28, 2002 1 message not in the archive SELinux security module

lore
Share & tools
lore
#0 lore raw

I just preformed a clean install of RH7.2 and the latest lsm from the NSA site and there seem to be a few problems.

When enforcing mode is enabled there are several things that do not work which should. The first of these is sshd. sshd works fine in permissive mode, but when in enforcing mode the following avc messages are logged and no connection can be completed. From the client side authentication passes and then the connection is closed.

avc: denied { relabelto } for pid=1298 exe=/usr/sbin/sshd path=/0 dev=00:06 ino=2 scontext=system_u:system_r:sshd_t tcontext=timothy:object_r:sysadm_devpts_t tclass=chr_file

sshd[1298]: fatal: chsid(/dev/pts/0, 490) failed: Permission denied

sshd[1298]: syslogin_perform_logout: logout() returned an error

Also while in enforcing mode attempting a make relabel from the selinux/policy directory fails with the following avc messages.

avc: denied { read } for pid=1476 exe=/usr/local/selinux/bin/checkpolicy path=/src/selinux/policy/Makefile dev=03:0b ino=1737013 scontext=root:sysadm_r:checkpolicy_t tcontext=system_u:object_r:src_t tclass=file

avc: denied { read } for pid=1477 exe=/usr/local/selinux/bin/setfiles path=/src/selinux/policy/file_contexts/file_contexts dev=03:0b ino=1524031 scontext=root:sysadm_r:setfiles_t tcontext=system_u:object_r:src_t tclass=file

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 9 lines · Timothy Wood

I just preformed a clean install of RH7.2 and the latest lsm from the NSA site and there seem to be a few problems.

When enforcing mode is enabled there are several things that do not work which should. The first of these is sshd. sshd works fine in permissive mode, but when in enforcing mode the following avc messages are logged and no connection can be completed. From the client side authentication passes and then the connection is closed.

Quoted 3 lines

avc: denied { relabelto } for pid=1298 exe=/usr/sbin/sshd path=/0 dev=00:06 ino=2 scontext=system_u:system_r:sshd_t tcontext=timothy:object_r:sysadm_devpts_t tclass=chr_file

In the new policy ssh is totally denied access to the sysadm_t domain (there's no domain transition allowed) and to the pseudo-tty devices (can't access them or transition to/from them). You can change ssh.te, change the following line:
allow sshd_t userpty_type:chr_file { setattr relabelto rw_file_perms }; to:
allow sshd_t { sysadm_devpts_t userpty_type }:chr_file { setattr relabelto rw_file_perms };

Then change the following:
domain_trans($1, shell_exec_t, unpriv_userdomain) to:
domain_trans($1, shell_exec_t, { sysadm_t unpriv_userdomain })

However, be aware that making such changes grants anyone who has port 22 access to your machine full administrative access if (when?) another bug is discovered in sshd...

Quoted 8 lines

Also while in enforcing mode attempting a make relabel from the selinux/policy directory fails with the following avc messages.

avc: denied { read } for pid=1476 exe=/usr/local/selinux/bin/checkpolicy path=/src/selinux/policy/Makefile dev=03:0b ino=1737013 scontext=root:sysadm_r:checkpolicy_t tcontext=system_u:object_r:src_t tclass=file

Quoted 4 lines

avc: denied { read } for pid=1477 exe=/usr/local/selinux/bin/setfiles path=/src/selinux/policy/file_contexts/file_contexts dev=03:0b ino=1524031 scontext=root:sysadm_r:setfiles_t tcontext=system_u:object_r:src_t tclass=file

It's expected that the policy source files have type policy_src_t...

Signature · 3 lines
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

A message that is not in the archive (sent off-list or not yet received): 1030549849.2346.59.camel@phobos

#3 lore raw
Quoted 6 lines · you
Quoted 3 lines

However, be aware that making such changes grants anyone who has port 22 access to your machine full administrative access if (when?) another bug is discovered in sshd...

So then I need to login under someone with user_r:user_t and then newrole and su correct?

It's your call.

If you have port 22 firewalled so that only trusted people can connect to it then allowing an administrative login may make sense.

Quoted 5 lines
Quoted 1 line

It's expected that the policy source files have type policy_src_t...

Is this an error in the file_context policies or do I just have selinux in an abnormal directory (/usr/src/selinux)? This is stock and I haven't changed any of the policies yet.

I'm not sure what the plan is in that regard. I never test the stock install, I concentrate on my Debian packages.

Quoted 7 lines

Also, how broken are the user admin programs? I tried adding a user, which didn't work, and I remember seeing you post some fixes for suseradd. Are they partly functional or broken? The suseradd in the new release appears to work in premissive mode (denied in enforcing). The spasswd program is a different story. It tells me it doesn't take an argument (such as spasswd <username> ) so I don't see how you set an initial password for a new user.

sadminpasswd is for setting a password for a new user. spasswd is for that user to change their own password.

How did suseradd fail?

Signature · 3 lines
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
In reply to Timothy Wood
Quoted 6 lines · Timothy Wood

When enforcing mode is enabled there are several things that do not work which should. The first of these is sshd. sshd works fine in permissive mode, but when in enforcing mode the following avc messages are logged and no connection can be completed. From the client side authentication passes and then the connection is closed.

Quoted 7 lines

avc: denied { relabelto } for pid=1298 exe=/usr/sbin/sshd path=/0 dev=00:06 ino=2 scontext=system_u:system_r:sshd_t tcontext=timothy:object_r:sysadm_devpts_t tclass=chr_file

sshd[1298]: fatal: chsid(/dev/pts/0, 490) failed: Permission denied

sshd[1298]: syslogin_perform_logout: logout() returned an error

This isn't new to this release. We removed direct transitions from sshd_t to sysadm_t in the prior release (2002070313) in response to the sshd vulnerability, requiring people to login as user_r:user_t and then use newrole. This was discussed previously on the selinux list, e.g.
http://marc.theaimsgroup.com/?l=selinux&m=102613964408029&w=2

Quoted 8 lines

Also while in enforcing mode attempting a make relabel from the selinux/policy directory fails with the following avc messages.

avc: denied { read } for pid=1476 exe=/usr/local/selinux/bin/checkpolicy path=/src/selinux/policy/Makefile dev=03:0b ino=1737013 scontext=root:sysadm_r:checkpolicy_t tcontext=system_u:object_r:src_t tclass=file

Quoted 4 lines

avc: denied { read } for pid=1477 exe=/usr/local/selinux/bin/setfiles path=/src/selinux/policy/file_contexts/file_contexts dev=03:0b ino=1524031 scontext=root:sysadm_r:setfiles_t tcontext=system_u:object_r:src_t tclass=file

Several of the policy-related utilities (setfiles, checkpolicy, load_policy) have been placed into their own domains and limited to reading appropriate types. The setfiles_t domain is also not new; it was created by Russell and added prior to the 2002070313 release. The checkpolicy_t domain was added as part of the policy management patch posted on the list by Tresys Technology. In this case, the 'make relabel' is only truly being prevented by the second denial.

Limiting these domains to reading particular types is useful in reducing the risk of including untrustworthy data in the policy or file contexts configuration. At present, setfiles_t is still fairly permissive in this regard (it still permits reading home directory types to permit 'make relabel' from a selinux/policy in the user's home directory), but we are likely to restrict it to reading policy_src_t in the future now that the policy management patch has been merged.

As part of the policy management patch, the policy sources are now installed into /etc/security/selinux/src/policy via 'make install-src', which is run during the SELinux installation procedure. You can then perform subsequent policy loads and relabels from that directory. That directory is labeled with policy_src_t, which can be read by setfiles_t and checkpolicy_t.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.