Skip to contentSkip to conversation

does bin_t vs sbin_t really make sense?

DISCUSSION Russell Coker 2 participants 2 messages Mar 21, 2002 – Mar 25, 2002 SELinux security module

lore
Share & tools
lore
#0 lore raw

I have been thinking about the division of bin_t vs sbin_t.

Does preventing a regular user from running a (non-SUID and non-SGID) program in /sbin actually gain us anything? The only possible advantage I can see is if the user is denied execute access to all directories where they have write access, if the user is denied ptrace() access, and if we suspect that there is a kernel bug allowing one of these programs to do nasty things in spite of SE policy and unix permissions prohibiting it.

Having the two types just requires an additional entry on allow lines for no great benefit as far as I can tell.

What I think would be more useful is to give /usr/bin a different type, then you can either ban sysadm_t from executing it or trigger an automatic type conversion to something safe!

One reason for blocking sysadm_t from executing it is the issue of security holes in those programs which may allow hijacking an active session and causing a command to be run. How many times have you run "man" as superuser? I know I've done it many times, there was at one time a bug in man that allowed non-root users to crash and possibly exploit a root invocation of man. All you need to do is run "avc_toggle ; chmod 666 /etc/shadow" and the machine is open!

One reason for blocking sysadm_t instead of doing a type transition is to enforce safe usage. I once shared root access of a machine with someone who gloried in having the power of root. They used root for many things that they shouldn't have, which was a great concern for me as they didn't have much experience in Unix administration. So I put the following in some of the more commonly used shell scripts:
"if [ "$USER" = "root" ]; then
echo "Can't do this as root"
exit 0
fi

;)

Of course someone that has full root access can easily change such things, if they know how and believe that they can do it without breaking anything. But in this case they didn't.

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux 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 11 lines · Russell Coker

I have been thinking about the division of bin_t vs sbin_t.

Does preventing a regular user from running a (non-SUID and non-SGID) program in /sbin actually gain us anything? The only possible advantage I can see is if the user is denied execute access to all directories where they have write access, if the user is denied ptrace() access, and if we suspect that there is a kernel bug allowing one of these programs to do nasty things in spite of SE policy and unix permissions prohibiting it.

Having the two types just requires an additional entry on allow lines for no great benefit as far as I can tell.

The distinction may have some benefit for the daemon domains, as opposed to the user domains. It doesn't impose much burden to retain the distinction, since can_exec_any covers all of the executable types, and you can also define your own macros and/or type attributes to cover particular sets of executable types.

Quoted 3 lines

What I think would be more useful is to give /usr/bin a different type, then you can either ban sysadm_t from executing it or trigger an automatic type conversion to something safe!

This would be interesting, but I'm not sure what the impact would be on normal operations. I'd be more inclined to transitioning to an unprivileged user domain rather than denying execute access completely.

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

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.