Skip to contentSkip to conversation

Query about desktop apps.

DISCUSSION Gaurav Poothia 4 participants 6 messages Mar 26, 2006 – Mar 27, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi I am wondering how SELinux intends to handle desktop apps. With daemons I understand SELinux restricts access to parts of the filesystem which the application (almost always running as root) needs to performs its job.

With a desktop app which is an editor (of any type, text/images etc), its not clear how SELinux intends to restrict access to some "safe" part of the filesystem.

Consider this problem: Superuser runs vi and decides to look at the contents of the shadow file versus regular user decides to try his luck and open it using vi.
MAC will allow former and deny latter.
To do this we are gonna need 2 different vi domains one belonging to the role system_r and the other belonging to role user_r each with their own policies.

Q1. Is the there a need for 2 different policies for an app like vi or is there something I am missing?

Additionally it seems to me that we need a way for the regular users vi policy to prevent him from overwriting other user's data (that probably a solvable problem given the constructs,)

Q2. How do you make an app like vi when invoked by a regular user stick to that particualar user's data?

Q3More importantly how do you prevent a malicious vi binary from modifying any of the users own file on the sly (afterall the user can use vi to modify ANY of his files, so no
policy should really stop vi from doing so)

Thanks in advance,
Gaurav

--
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 2 lines · Gaurav Poothia

Q1. Is the there a need for 2 different policies for an app like vi or is there something I am missing?

You're missing something.

Quoted 3 lines

Additionally it seems to me that we need a way for the regular users vi policy to prevent him from overwriting other user's data (that probably a solvable problem given the constructs,)

The sysadmin invokes vi while already in a sysadm_t or similar context that is allowed to poke at the files in question. The user is invoking it in user_t or similar..

And remember - if the *regular* file permissions don't allow it, the SELinux ones won't matter. So as long as userA doesn't chmod 777 the file, userB still can't get at it..

Quoted 2 lines

Q2. How do you make an app like vi when invoked by a regular user stick to that particualar user's data?

File permissions still work.

And if you're *really* paranoid, you can always define separate SELinux identities usera:user_r:user_t and userb:user_r:user_t and add rules that prohibit a usera process from using userb files and vice versa.

Or use the MCS stuff to add categories, and define userA and userB with separate default categories that each other can't read (this doesn't scale well past 256 users, however).

Quoted 4 lines

Q3More importantly how do you prevent a malicious vi binary from modifying any of the users own file on the sly (afterall the user can use vi to modify ANY of his files, so no
policy should really stop vi from doing so)

Fix the system so a malicious vi binary can't be installed in the first place.

If there's a rogue 'vi' on your system, you have *bigger* problems than the fact it can ruin a user's data.

#2 lore raw
Quoted 7 lines · On Sat, 25 Mar 2006 [email protected] wrote:
Quoted 2 lines · Gaurav Poothia

Q1. Is the there a need for 2 different policies for an app like vi or is there something I am missing?

You're missing something.

Quoted 7 lines
Quoted 3 lines

Additionally it seems to me that we need a way for the regular users vi policy to prevent him from overwriting other user's data (that probably a solvable problem given the constructs,)

The sysadmin invokes vi while already in a sysadm_t or similar context that is allowed to poke at the files in question. The user is invoking it in user_t or similar..

I still dont see it. I assume that there is a vi specific domain to which both both sys admin and regular user will have to transition. In which case there should be 2 vi domains one for admin and other for regular users and thus 2 policies. Please remember my question is about ANY desktop app and vi is just an example.

Quoted 5 lines

And remember - if the *regular* file permissions don't allow it, the SELinux ones won't matter. So as long as userA doesn't chmod 777 the file, userB still can't get at it..

Quoted 8 lines
Quoted 2 lines

Q2. How do you make an app like vi when invoked by a regular user stick to that particualar user's data?

File permissions still work.

And if you're *really* paranoid, you can always define separate SELinux identities usera:user_r:user_t and userb:user_r:user_t and add rules that prohibit a usera process from using userb files and vice versa.

Yes I dont want the regular permission model, I wanted MAC. I do agree that solution will work.Although it seems to me that the policy needs to be aware of the users. Thats not very scalable.

Quoted 10 lines

Or use the MCS stuff to add categories, and define userA and userB with separate default categories that each other can't read (this doesn't scale well past 256 users, however).

Quoted 4 lines

Q3More importantly how do you prevent a malicious vi binary from modifying any of the users own file on the sly (afterall the user can use vi to modify ANY of his files, so no
policy should really stop vi from doing so)

Fix the system so a malicious vi binary can't be installed in the first place.

Again (and this is the crux) please consider ANY desktop app. How can we enforce MAC on any app?

I am trying to solve the general problem of WHAT IS the Mandatory policy for desktop apps. Any comments will be appreciated.Thanks! -Gaurav

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

The default "targeted" policy only provides specific MAC restrictions for a defined set of daemons which usually run with root privilege and for which it is desirable to provide greater restriction. The user is not restricted (or only minimally restricted in Fedora Core 5) by the targeted policy and, therefore, any application run by the user is not restricted. This includes desktop applications such as vi, KDE, GNOME, Firefox, etc.

Under the other policies provided in the SELinux reference policy, such as strict and MLS, the intent is to restrict everything unless explicit policy is defined to permit it. This requires users of this policy to define their own policy extensions to meet the requirements of their systems. How you choose to handle desktop applications becomes a local security policy issue. My impression is that generally the intent is not to attempt to define policy related to each individual application run in user space. Instead, roles are defined with desired privileges, users are assigned to these roles and applications run in user space are confined by the roles of the user running the application.

So the answer to your question of "what is the mandatory policy for desktop applications?" is "the mandatory policy which applies to the user of the applications". Under targeted policy, that means minimal policy restrictions.

Disclaimer: the above is just the impression formed by a lurker. I don't claim to be an expert in SELinux. More informed opinions are surely available, e.g.
http://www.fedoraproject.org/wiki/SELinux/Policies.

- Mark.

Quoted 60 lines · Gaurav Poothia
Quoted 7 lines · On Sat, 25 Mar 2006 [email protected] wrote:
Quoted 2 lines · Gaurav Poothia

Q1. Is the there a need for 2 different policies for an app like vi or is there something I am missing?

You're missing something.

Quoted 7 lines
Quoted 3 lines

Additionally it seems to me that we need a way for the regular users vi policy to prevent him from overwriting other user's data (that probably a solvable problem given the constructs,)

The sysadmin invokes vi while already in a sysadm_t or similar context that is allowed to poke at the files in question. The user is invoking it in user_t or similar..

I still dont see it. I assume that there is a vi specific domain to which both both sys admin and regular user will have to transition. In which case there should be 2 vi domains one for admin and other for regular users and thus 2 policies. Please remember my question is about ANY desktop app and vi is just an example.

Quoted 5 lines

And remember - if the *regular* file permissions don't allow it, the SELinux ones won't matter. So as long as userA doesn't chmod 777 the file, userB still can't get at it..

Quoted 8 lines
Quoted 2 lines

Q2. How do you make an app like vi when invoked by a regular user stick to that particualar user's data?

File permissions still work.

And if you're *really* paranoid, you can always define separate SELinux identities usera:user_r:user_t and userb:user_r:user_t and add rules that prohibit a usera process from using userb files and vice versa.

Yes I dont want the regular permission model, I wanted MAC. I do agree that solution will work.Although it seems to me that the policy needs to be aware of the users. Thats not very scalable.

Quoted 10 lines

Or use the MCS stuff to add categories, and define userA and userB with separate default categories that each other can't read (this doesn't scale well past 256 users, however).

Quoted 4 lines

Q3More importantly how do you prevent a malicious vi binary from modifying any of the users own file on the sly (afterall the user can use vi to modify ANY of his files, so no
policy should really stop vi from doing so)

Fix the system so a malicious vi binary can't be installed in the first place.

Again (and this is the crux) please consider ANY desktop app. How can we enforce MAC on any app?

Quoted 9 lines

I am trying to solve the general problem of WHAT IS the Mandatory policy for desktop apps. Any comments will be appreciated.Thanks! -Gaurav

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

#4 lore raw
In reply to Gaurav Poothia
Quoted 2 lines · Gaurav Poothia

I still dont see it. I assume that there is a vi specific domain to which both both sys admin and regular user will have to transition.

No.. the point is that as far as a *security* model goes, what you really care about is:

1) What is the sysadmin allowed to do?
2) What is the regular user allowed to do?

The obvious answer is "put the sysadmin and all programs he runs in a domain that has certain access rights", and "put the user and all his programs in a different domain with different rights".

You see, you don't really need a 'vi' policy, because the policy basically is "vi can read the files the user can read, and write the files the user can write". In other words, no separate policy is needed - unless you *really* feel like wasting your time and creating a vi policy that says the above, and then a policy for /bin/sed that says the same thing, and for cp, and for cat, and for dd, and for perl, and for all the other myriad ways there are to read and/or write a file on a Linux box - all things that are just better off run in the invoking user's domain and not worry. If the user is allowed to do it, the program is, and if the user isn't, the program usually isn't either. So the vast majority of binaries can just be flagged as "this is a bin_t that should be run under the user's access domain". Makes things a *lot* easier..

When it gets interesting is when the invoked binary needs access to something that the calling user *doesn't* already have access to - for instance, if you change your password, the program will at some point need to have access to the /etc/shadow file even though the invoking user *doesn't* have that access. *THIS* is when you need a separate security domain for that program - because the list of what that program should be allowed is *different* than what the invoking user is allowed (in particular, the program to change your password can probably do *without* access to 95% of the things the invoking user *does* have access to...)

#5 lore raw
In reply to Gaurav Poothia
Quoted 5 lines · Gaurav Poothia

I still dont see it. I assume that there is a vi specific domain to which both both sys admin and regular user will have to transition. In which case there should be 2 vi domains one for admin and other for regular users and thus 2 policies. Please remember my question is about ANY desktop app and vi is just an example.

A few quick points:
- SELinux already supports and includes "derived domains", where you instantiate a separate domain for the program per caller domain, e.g. user_mozilla_t vs. staff_mozilla_t, so that you can allow each instance appropriate permissions to e.g. home directory files, tty/pty, etc. of the right type without allowing the ordinary user's browser to interfere with the staff user's browser.
- vi is a bad example here, as it lacks a well-defined purpose (and hence set of permissions) and it ultimately can do everything (e.g. run commands in sub-shells), so it is difficult to write a meaningful policy just for it. Hence, it presently just runs in the caller's domain, as Valdis noted. However, one could create various domains for well-defined purposes, and the user could invoke vi via a suitable wrapper or via runcon -t to force it into an appropriate domain for a given purpose (e.g. editing system config files vs. personal files). There is already precedent for such wrappers in e.g. vipw, vigr.
- Ultimately, we would like to devolve many of the permissions currently granted directly to the base user domain into more specific program
domains. But this will require time and always requires acceptance by
users.

Quoted 3 lines

Yes I dont want the regular permission model, I wanted MAC. I do agree that solution will work.Although it seems to me that the policy needs to be aware of the users. Thats not very scalable.

It needs to be aware of user roles, but not per-Linux user.

Signature · 8 lines
Stephen Smalley
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.