Skip to contentSkip to conversation

accessing files under Linux and SELinux

DISCUSSION Mario Olimpio de Menezes 3 participants 3 messages Feb 27, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi,

When accessing files under Linux, several checks will be done by syscall ensuring the user has the rights to do.

When accessing files under SELinux, additional checks (security context) will be done.

Can I think of this as: "the minimum set will prevail".

For example, I add a user with uid=gid=1000 to a system and then assign this user a system_r role. If I try to access /etc/shadow I'll be denied by the Linux checks and not SELinux checks.

Is this correct? Am I getting the wrong picture here?

Thanks,

Signature · 9 lines
Mario O.de Menezes, Ph.D.    "Many are the plans in a man's heart, but
    IPEN-CNEN/SP                is the Lord's purpose that prevails"
http://www.ipen.br/~mario                  Prov. 19.21
    

--
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 1 line · Mario Olimpio de Menezes

Can I think of this as: "the minimum set will prevail".

If I understand you correctly, then yes, i.e. both the Linux access control logic and the SELinux logic must approve each operation. However, longer term, we'd like to replace the native uid 0 / capability checks entirely using the TE policy.
http://www.securecomputing.com/pdf/secureos.pdf has a comparison of POSIX.1e capabilities vs. TE as a mechanism for privileges.

Quoted 3 lines

For example, I add a user with uid=gid=1000 to a system and then assign this user a system_r role. If I try to access /etc/shadow I'll be denied by the Linux checks and not SELinux checks.

Very few domains have direct access to /etc/shadow in the current policy; not even sysadm_t has direct rw access to shadow_t. But sysadm_t can transition to useradd_t via useradd, and useradd_t can write to /etc/shadow. But with regard to your general point, yes, if the Linux uid lacked permissions to the file based on its ownership and mode but the SELinux domain has permissions to the file type, the access would still be denied. This makes SELinux conservative, i.e. we won't weaken the system's security posture, but isn't ideal for long term support for a decomposed root. It is true that uid 0 is no longer all powerful, but you still need uid 0 to do a lot of things (plus the corresponding SELinux domain).

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.
#2 lore raw
Quoted 8 lines · Stephen Smalley
Quoted 3 lines

For example, I add a user with uid=gid=1000 to a system and then assign this user a system_r role. If I try to access /etc/shadow I'll be denied by the Linux checks and not SELinux checks.

Very few domains have direct access to /etc/shadow in the current policy; not even sysadm_t has direct rw access to shadow_t. But sysadm_t can transition to useradd_t via useradd, and useradd_t can write to /etc/shadow.

Also sysadm_t can run "vipw".

For most domains removing access to /etc/shadow was a deliberate policy change to protect this critical file. For sysadm_t the removal of access was to avoid accidentally relabeling it. If sysadm_t is granted access to replace /etc/shadow then by running "vi /etc/shadow" instead of "vipw -s" the administrator could accidentally remove the protection by giving the shadow file a label of etc_t!

Now I could have granted sysadm_t read access to shadow_t for a similar result (with the added benefit of allowing the administrator to grep it). However in that case the administrator may discover that they can't write the file after loading it in their editor, this causes confusion, and may cause a copy of the data to be dropped in /etc/shadow.tmp or something similar.

The only problem domain at the moment in regard to shadow_t is radius_t. Most (all?) Unix RADIUS servers by default will read /etc/shadow directly to authenticate local users. All Unix RADIUS servers can be configured to use other sources of password data, but having a default policy that doesn't support the default operation of the server isn't going to work. I would like to see RADIUS servers re-written such that on PAM systems they will use unix_chkpwd and unix_verify for all password access. A RADIUS server that supports PAM will get this by default, but I don't think that PAM is designed to be thread-safe so threaded servers won't necessarily work this way. Although undocumented the unix_chkpwd interface is easy to use and the RADIUS servers could be adjusted to use it (and the interface can be documented).

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.