Skip to contentSkip to conversation

changing root to default to sysadm_r

DISCUSSION Nick 4 participants 5 messages Dec 10, 2003 – Dec 17, 2003 1 message not in the archive SELinux security module

lore
Share & tools
lore

Nick

author
#0 lore raw

I thought I could do make root come up in the sysadm_r initially by changing the users.te file

diff users .users
42c42
< user root roles { sysadm_r staff_r };
---

Quoted 1 line

user root roles { staff_r sysadm_r };

and recompiling the policy.

Apparently not, suggestions! and comments why it is not this way already.

Signature · 9 lines
Nick (Nix) Gray
Senior Systems Engineer
Bruzenak Inc.
(512) 331-7998

--
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

Nick

I don't know why you're having problems changing it but I know why it was/is set this way.

If root defaults to sysadm_r, then certain kinds of sshd exploits (kinds that _heve_ been seen before) can get the attacker sysadm_r, game over, not good.

The requirement to authenticate explicitly thru newrole intends to to avoid this.

forrest

On Wed, 10 Dec 2003 16:51:42 -0600 (unchecked - local sync NTPstrat4) Nick <[email protected]> did inscribe thusly:

Quoted 7 lines

I thought I could do make root come up in the sysadm_r initially by changing the users.te file

diff users .users
42c42
< user root roles { sysadm_r staff_r };
---

Quoted 17 lines
Quoted 1 line

user root roles { staff_r sysadm_r };

and recompiling the policy.

Apparently not, suggestions! and comments why it is not this way already.

Signature · 9 lines
Nick (Nix) Gray
Senior Systems Engineer
Bruzenak Inc.
(512) 331-7998

--
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.

--
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.

#2 lore raw
In reply to Nick
Quoted 9 lines · Nick

I thought I could do make root come up in the sysadm_r initially by changing the users.te file

diff users .users
42c42
< user root roles { sysadm_r staff_r };
---

Quoted 1 line

user root roles { staff_r sysadm_r };

As far as I am aware there are no order dependencies at all in the policy (Steve, please correct me if I am wrong).

A quick test on my machine shows that the policy database has the same MD5 checksum regardless of the order of roles in such statements. But even if there was a difference, there is no API for applications to learn about such differences.

The way to solve this is to change the order in /etc/security/default_contexts, change this:
system_r:local_login_t user_r:user_t staff_r:staff_t sysadm_r:sysadm_t to this:
system_r:local_login_t sysadm_r:sysadm_t user_r:user_t staff_r:staff_t

Quoted 3 lines · forrest whitcher

If root defaults to sysadm_r, then certain kinds of sshd exploits (kinds that _heve_ been seen before) can get the attacker sysadm_r, game over, not good.

It's true that we don't want to permit sshd to transition to sysadm_r. However I believe that it's OK to permit this from local_login_t for the following reasons:
1) /bin/login code is simpler than sshd code.
2) /bin/login can only be accessed from system console which prevents entire classes of attack.
3) The standard administration practise is to ssh to servers as non-root and then "su" to perform admin tasks, using newrole is a variation on that theme and corresponds to expectations of users. It is standard practise to login directly as root at the console, because of this users expect to be able to login as sysadm_r at the console.

2 is probably the killer arguement, 1 is important too, 3 is necessary for user acceptance (we could have an arguement about whether it makes sense from a security POV).

Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
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.
#3 lore raw
Quoted 5 lines · Russell Coker

The way to solve this is to change the order in /etc/security/default_contexts, change this:
system_r:local_login_t user_r:user_t staff_r:staff_t sysadm_r:sysadm_t to this:
system_r:local_login_t sysadm_r:sysadm_t user_r:user_t staff_r:staff_t

Alternatively, you should be able to create a /root/.default_contexts file with this entry to override the system defaults, so that only root defaults to logging in as sysadm_r, and other users who are authorized for both staff_r and sysadm_r will still default to staff_r. You'd have to make sure that local_login_t can read the /root/.default_contexts file, either by labeling it with the default_context_t type or by allowing local_login_t to read sysadm_home_t:file.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
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): [email protected]

author
#5 lore raw

Forrest,

Ssh shouldn't be running in the sysadm_r context. I will have to research the exploits and figure out what makes sense. The problem here is that root initially logs into a directory that doesn't match his context. If you cd to / and try to cd back, you cant get in. That is an error.

You have to ask yourself, in a secure system what is the purpose of a root account? for a TOS/CMW it is really for nothing more than development.

Quoted 44 lines · forrest whitcher

Nick

I don't know why you're having problems changing it but I know why it was/is set this way.

If root defaults to sysadm_r, then certain kinds of sshd exploits (kinds that _heve_ been seen before) can get the attacker sysadm_r, game over, not good.

The requirement to authenticate explicitly thru newrole intends to to avoid this.

forrest

On Wed, 10 Dec 2003 16:51:42 -0600 (unchecked - local sync NTPstrat4) Nick <[email protected]> did inscribe thusly:

Quoted 24 lines

I thought I could do make root come up in the sysadm_r initially by changing the users.te file

diff users .users
42c42
< user root roles { sysadm_r staff_r };
---

Quoted 1 line

user root roles { staff_r sysadm_r };

and recompiling the policy.

Apparently not, suggestions! and comments why it is not this way already.

Signature · 9 lines
Nick (Nix) Gray
Senior Systems Engineer
Bruzenak Inc.
(512) 331-7998

--
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.
Signature · 9 lines
Nick (Nix) Gray
Senior Systems Engineer
Bruzenak Inc.
(512) 331-7998

--
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.