Skip to contentSkip to conversation

Proposed policy feature: $1_domain attribute

DISCUSSION Ivan Gyurdiev 5 participants 19 messages Mar 1, 2005 – Apr 20, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

I'd like to mark all role-dependent domains with a new attribute $1_domain (analogous to $1_file_type), and then do the following in base_user_macros.te:

can_ps($1, $1_domain)
can_ptrace($1, $1_domain)

Objections?

Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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 8 lines · Ivan Gyurdiev

I'd like to mark all role-dependent domains with a new attribute $1_domain (analogous to $1_file_type), and then do the following in base_user_macros.te:

can_ps($1, $1_domain)
can_ptrace($1, $1_domain)

Objections?

can_ptrace? You could easily end up allowing unintended permissions directly to the user domain that were previously limited to a specific program.

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 5 lines · Stephen Smalley
Quoted 4 lines · Ivan Gyurdiev

I'd like to mark all role-dependent domains with a new attribute $1_domain (analogous to $1_file_type), and then do the following in base_user_macros.te:

Quoted 8 lines
Quoted 4 lines

can_ps($1, $1_domain)
can_ptrace($1, $1_domain)

Objections?

can_ptrace? You could easily end up allowing unintended permissions directly to the user domain that were previously limited to a specific program.

Even can_ps() is suspect here, e.g. allowing the user domain to inspect the state of the program, which may be running with elevated permissions. You can't apply this in general to all derived program domains; it has to be done on a case-by-case basis depending on whether the program domain is more privileged than the user 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.
#3 lore raw
Quoted 15 lines · Stephen Smalley
Quoted 5 lines · Stephen Smalley
Quoted 4 lines · Ivan Gyurdiev

I'd like to mark all role-dependent domains with a new attribute $1_domain (analogous to $1_file_type), and then do the following in base_user_macros.te:

Quoted 8 lines
Quoted 4 lines

can_ps($1, $1_domain)
can_ptrace($1, $1_domain)

Objections?

can_ptrace? You could easily end up allowing unintended permissions directly to the user domain that were previously limited to a specific program.

Quoted 5 lines

Even can_ps() is suspect here, e.g. allowing the user domain to inspect the state of the program, which may be running with elevated permissions. You can't apply this in general to all derived program domains; it has to be done on a case-by-case basis depending on whether the program domain is more privileged than the user domain.

Okay I see what you mean - if you're able to trace syscalls that's dangerous as the program could have higher privileges...

Never mind then - let me think about this some more.

Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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 Stephen Smalley
Quoted 5 lines · Stephen Smalley
Quoted 4 lines · Ivan Gyurdiev

I'd like to mark all role-dependent domains with a new attribute $1_domain (analogous to $1_file_type), and then do the following in base_user_macros.te:

Quoted 8 lines
Quoted 4 lines

can_ps($1, $1_domain)
can_ptrace($1, $1_domain)

Objections?

can_ptrace? You could easily end up allowing unintended permissions directly to the user domain that were previously limited to a specific program.

Can you elaborate? I thought can_ptrace was needed for the proper operation of the strace command.

Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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.
#5 lore raw
Quoted 6 lines · Ivan Gyurdiev
Quoted 3 lines

can_ptrace? You could easily end up allowing unintended permissions directly to the user domain that were previously limited to a specific program.

Can you elaborate? I thought can_ptrace was needed for the proper operation of the strace command.

If the program domain has enhanced permissions for its function beyond what the user domain is directly allowed, and you allow the user domain to ptrace the program domain, then you allow it to completely control the program and thus indirectly gain those permissions. No different than ptracing setuid root programs.

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.
#6 lore raw
In reply to Ivan Gyurdiev
Quoted 8 lines · Ivan Gyurdiev

I'd like to mark all role-dependent domains with a new attribute $1_domain (analogous to $1_file_type), and then do the following in base_user_macros.te:

can_ps($1, $1_domain)
can_ptrace($1, $1_domain)

Objections?

Yes. can_ps() might be OK, but can_ptrace() is too much. With ptrace, users have complete control over derived domains. I do not think we want that. An example: I'd like to have a version of gpg without --export-secret-keys. Together with SELinux it then becomes very hard to steal the secret key, even from a compromised program in user_t. Your change would compromise this.
I'd be more OK with
can_ps($1_t, $1_domain)
allow $1_t $1_domain:process signal;
because the signal permission is very inconsistently used right now and is sometimes needed to kill misbehaving programs.

Thomas

Signature · 2 lines
http://www.cip.ifi.lmu.de/~bleher/selinux/ - my SELinux pages
GPG-Fingerprint: BC4F BB16 30D6 F253 E3EA  D09E C562 2BAE B2F4 ABE7
#7 lore raw
Quoted 5 lines · Thomas Bleher

I'd be more OK with
can_ps($1_t, $1_domain)
allow $1_t $1_domain:process signal;
because the signal permission is very inconsistently used right now and is sometimes needed to kill misbehaving programs.

Even can_ps() is risky, as it exposes much of the /proc/pid state to reading; to do that safely, we'd need to introduce finer-grained typing of /proc/pid files (e.g. a derived type for different files within /proc/pid). And allowing the caller to kill the program at any arbitrary point is potentially dangerous, e.g. leading to file corruption or holding of a lock indefinitely. Admittedly, signal permission does not convey the ability to send SIGKILL or SIGSTOP, but other signals may be sufficient to do harm (if the program isn't explicitly handling them).

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

And allowing the caller to kill the program at any arbitrary point is potentially dangerous, e.g. leading to file corruption or holding of a lock indefinitely.

As opposed to not being able to kill misbehaving programs? Shouldn't that be the user's decision? I've been wondering why under strict SElinux I always have so much trouble killing my broken scripts...

-
Ivan Gyurdiev <[email protected]>
Cornell University

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

#9 lore raw
Quoted 8 lines · Ivan Gyurdiev
Quoted 3 lines

And allowing the caller to kill the program at any arbitrary point is potentially dangerous, e.g. leading to file corruption or holding of a lock indefinitely.

As opposed to not being able to kill misbehaving programs? Shouldn't that be the user's decision? I've been wondering why under strict SElinux I always have so much trouble killing my broken scripts...

Depends on whether the program operates with more or less permissions than the user. Again, think about the parallel for setuid programs. Some domain-changing programs should be killable by the user; others should not.

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

And allowing the caller to kill the program at any arbitrary point is potentially dangerous, e.g. leading to file corruption or holding of a lock indefinitely.

As opposed to not being able to kill misbehaving programs? Shouldn't that be the user's decision? I've been wondering why under strict SElinux I always have so much trouble killing my broken scripts...

Quoted 4 lines

Depends on whether the program operates with more or less permissions than the user. Again, think about the parallel for setuid programs. Some domain-changing programs should be killable by the user; others should not.

Well, in that case, how about an attribute to marks all of the programs that have less permissions than the user. You said Tresys has done inheritance work that can verify this stuff automatically.

How about a: $1_constrained attribute.

Then we can do:
can_ps($1, $1_constrained)
can_ptrace($1, $1_constrained)
allow $1 $1_constrained:process signal;

Quoted 1 line
Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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.
#11 lore raw
Quoted 3 lines · Ivan Gyurdiev

Well, in that case, how about an attribute to marks all of the programs that have less permissions than the user. You said Tresys has done inheritance work that can verify this stuff automatically.

Not sure that their notion of inheritance will apply here, as it is:
1) name-based, i.e. type A.B.C is bounded by the permissions allowed to type A.B and type A.B is bounded by the permissions allowed to type A,
2) strict, i.e. type A.B.C cannot any permissions to type D unless type A has those permissions, whereas program domains have often some additional permissions even if we consider them to be less privileged for their own private objects,
3) likely to cut across domains differently than you envision, as it is intended to allow delegation of management of portions of the policy, e.g. the entire apache policy, without being able to alter properties of the base policy (as bounded by the overall "apache" type).

Quoted 6 lines

How about a: $1_constrained attribute.

Then we can do:
can_ps($1, $1_constrained)
can_ptrace($1, $1_constrained)
allow $1 $1_constrained:process signal;

I think I'd prefer a macro that can be selectively included by program domains that have been identified as being suitable for complete control by the user (but if you are allowing ptrace, then you might as well allow all signals, including sigkill and sigstop).

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.
#12 lore raw
Quoted 5 lines · Stephen Smalley
Quoted 3 lines · Ivan Gyurdiev

Well, in that case, how about an attribute to marks all of the programs that have less permissions than the user. You said Tresys has done inheritance work that can verify this stuff automatically.

Quoted 11 lines

Not sure that their notion of inheritance will apply here, as it is:
1) name-based, i.e. type A.B.C is bounded by the permissions allowed to type A.B and type A.B is bounded by the permissions allowed to type A,
2) strict, i.e. type A.B.C cannot any permissions to type D unless type A has those permissions, whereas program domains have often some additional permissions even if we consider them to be less privileged for their own private objects,
3) likely to cut across domains differently than you envision, as it is intended to allow delegation of management of portions of the policy, e.g. the entire apache policy, without being able to alter properties of the base policy (as bounded by the overall "apache" type).

I'm tempted to try and put the policy in a database and write SQL queries against that. :) There's too many rules - hard to keep track of them all.

Quoted 11 lines
Quoted 6 lines

How about a: $1_constrained attribute.

Then we can do:
can_ps($1, $1_constrained)
can_ptrace($1, $1_constrained)
allow $1 $1_constrained:process signal;

I think I'd prefer a macro that can be selectively included by program domains that have been identified as being suitable for complete control by the user (but if you are allowing ptrace, then you might as well allow all signals, including sigkill and sigstop).

Okay then - now I just have to find out which types are 'safe'.

Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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.
#13 lore raw
Quoted 6 lines · Ivan Gyurdiev
Quoted 5 lines · Stephen Smalley
Quoted 3 lines · Ivan Gyurdiev

Well, in that case, how about an attribute to marks all of the programs that have less permissions than the user. You said Tresys has done inheritance work that can verify this stuff automatically.

Quoted 11 lines
Quoted 11 lines

Not sure that their notion of inheritance will apply here, as it is:
1) name-based, i.e. type A.B.C is bounded by the permissions allowed to type A.B and type A.B is bounded by the permissions allowed to type A,
2) strict, i.e. type A.B.C cannot any permissions to type D unless type A has those permissions, whereas program domains have often some additional permissions even if we consider them to be less privileged for their own private objects,
3) likely to cut across domains differently than you envision, as it is intended to allow delegation of management of portions of the policy, e.g. the entire apache policy, without being able to alter properties of the base policy (as bounded by the overall "apache" type).

It would be an interesting exercise to try to represent SElinux as a graph, and use standard graph algorithms to determine domain interactions... but in the meantime I'll just do this the normal way - looking at the policy rules by hand :)

Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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.
#14 lore raw
Quoted 35 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ivan Gyurdiev
Sent: Tuesday, March 01, 2005 5:07 PM
To: Stephen Smalley
Cc: Thomas Bleher; [email protected]
Subject: Re: Proposed policy feature: $1_domain attribute

Quoted 4 lines · Ivan Gyurdiev
Quoted 3 lines · Stephen Smalley
Quoted 2 lines · Ivan Gyurdiev

Well, in that case, how about an attribute to marks all of the programs that have less permissions than the user. You

said Tresys

Quoted 1 line
Quoted 1 line
Quoted 1 line

has done inheritance work that can verify this stuff

automatically.

Quoted 3 lines
Quoted 3 lines

Not sure that their notion of inheritance will apply here, as it is:
1) name-based, i.e. type A.B.C is bounded by the

permissions allowed

Quoted 1 line
Quoted 1 line

to type A.B and type A.B is bounded by the permissions

allowed to type

Quoted 3 lines
Quoted 3 lines

A,
2) strict, i.e. type A.B.C cannot any permissions to type D unless type A has those permissions, whereas program domains have

often some

Quoted 1 line
Quoted 1 line

additional permissions even if we consider them to be less

privileged

Quoted 2 lines
Quoted 2 lines

for their own private objects,
3) likely to cut across domains differently than you

envision, as it

Quoted 3 lines
Quoted 3 lines

is intended to allow delegation of management of portions of the policy, e.g. the entire apache policy, without being able to alter properties of the base policy (as bounded by the overall

Quoted 7 lines

"apache" type).

It would be an interesting exercise to try to represent SElinux as a graph, and use standard graph algorithms to determine domain interactions... but in the meantime I'll just do this the normal way - looking at the policy rules by hand :)

My information flow work for Setools does just that - represents the policy as a set of nodes with edges representing information flow. You can search the list for some discussions of this with Mitre and, of course, look at the libapol source.

Karl

---
Karl MacMillan
Tresys Technology
http://www.tresys.com
(410) 290-1411 ext 134

Quoted 5 lines

--
Ivan Gyurdiev <[email protected]>
Cornell University

Quoted 7 lines

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

#15 lore raw
In reply to Ivan Gyurdiev
Quoted 29 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ivan Gyurdiev
Sent: Tuesday, March 01, 2005 1:08 PM
To: Stephen Smalley
Cc: Thomas Bleher; [email protected]
Subject: Re: Proposed policy feature: $1_domain attribute

Quoted 7 lines · Stephen Smalley
Quoted 3 lines · Ivan Gyurdiev

Well, in that case, how about an attribute to marks all of the programs that have less permissions than the user. You said Tresys has done inheritance work that can verify this stuff automatically.

Not sure that their notion of inheritance will apply here, as it is:
1) name-based, i.e. type A.B.C is bounded by the permissions

allowed to

Quoted 1 line

type A.B and type A.B is bounded by the permissions allowed

to type A,

Quoted 1 line

2) strict, i.e. type A.B.C cannot any permissions to type D

unless type

Quoted 2 lines

A has those permissions, whereas program domains have often some additional permissions even if we consider them to be less

privileged

Quoted 2 lines

for their own private objects,
3) likely to cut across domains differently than you

envision, as it is

Quoted 1 line

intended to allow delegation of management of portions of

Quoted 9 lines

the policy,

Quoted 1 line

e.g. the entire apache policy, without being able to alter

properties

Quoted 1 line

of the base policy (as bounded by the overall "apache" type).

I'm tempted to try and put the policy in a database and write SQL queries against that. :) There's too many rules - hard to keep track of them all.

I doubt that you really want to do that - it is likely to be both painful, slow, and not actually answer a lot of your questions (e.g., how would you handle attributes efficiently). I encourage you to look at Apol and libapol. Apol provides searching and analysis features in a gui. If that doesn't meet your needs you can write analysis programs against libapol. We have spent several years creating this analysis infrastructure and have had to tackle some difficult problems along the way. It is a good starting point for anyone trying to analyze or understand a policy.

Karl

---
Karl MacMillan
Tresys Technology
http://www.tresys.com
(410) 290-1411 ext 134

Quoted 5 lines

--
Ivan Gyurdiev <[email protected]>
Cornell University

Quoted 7 lines

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

#16 lore raw
In reply to Stephen Smalley
Quoted 8 lines
Quoted 7 lines

How about a: $1_constrained attribute.

Then we can do:
can_ps($1, $1_constrained)
can_ptrace($1, $1_constrained)
allow $1 $1_constrained:process signal;

Quoted 4 lines

I think I'd prefer a macro that can be selectively included by program domains that have been identified as being suitable for complete control by the user (but if you are allowing ptrace, then you might as well allow all signals, including sigkill and sigstop).

I am starting to give up on this idea - it's not going to work. Programs have too many private things that should not be exposed to user_t for no good reason. I thought there were going to be lots of user-restricted domains, but that's not so - most of them do something special that user can't currently do. Seems better to just make the current permissions more consistent throughout the policy without additional macros.

Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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.
#17 lore raw
In reply to Stephen Smalley
Quoted 15 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stephen Smalley
Sent: Tuesday, March 01, 2005 12:31 PM
To: Ivan Gyurdiev
Cc: Thomas Bleher; [email protected]
Subject: Re: Proposed policy feature: $1_domain attribute

Quoted 2 lines · Ivan Gyurdiev

Well, in that case, how about an attribute to marks all of the programs that have less permissions than the user. You said

Tresys has

Quoted 1 line

done inheritance work that can verify this stuff automatically.

Quoted 14 lines

Not sure that their notion of inheritance will apply here, as it is:
1) name-based, i.e. type A.B.C is bounded by the permissions allowed to type A.B and type A.B is bounded by the permissions allowed to type A,
2) strict, i.e. type A.B.C cannot any permissions to type D unless type A has those permissions, whereas program domains have often some additional permissions even if we consider them to be less privileged for their own private objects,
3) likely to cut across domains differently than you envision, as it is intended to allow delegation of management of portions of the policy, e.g. the entire apache policy, without being able to alter properties of the base policy (as bounded by the overall "apache" type).

One further note - there is no inheritance of permissions in this model, only of constraints. A newly declared subtype has no access until it appears in rules.

Karl

---
Karl MacMillan
Tresys Technology
http://www.tresys.com
(410) 290-1411 ext 134

Quoted 6 lines

--
Stephen Smalley <[email protected]>
National Security Agency

Quoted 7 lines

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

#18 lore raw
In reply to Ivan Gyurdiev
Quoted 8 lines · Ivan Gyurdiev

I'd like to mark all role-dependent domains with a new attribute $1_domain (analogous to $1_file_type), and then do the following in base_user_macros.te:

can_ps($1, $1_domain)
can_ptrace($1, $1_domain)

Objections?

I'm catching up on email.

I object to the policy you suggest above for the same reasons as everyone else.

However I believe that there is one significant point which has been overlooked.

If I want to allow a domain (such as staff_t) to be able to manage the role user_r then there is currently no complete way of doing it. Policy such as the following is commonly used to allow staff_t to kill user processes that are doing undesired things:
can_ps(staff_t, user_t)
allow staff_t user_t:process signal;

This of course doesn't permit staff_t to see or kill user_gpg_t etc.

Something like the following might be useful:
can_ps(staff_t, user_domain)
allow staff_t user_domain:process signal;

If I was running a university shell server I would probably give some trusted postgrad students access to UID 0 and have policy such as the following:
can_ps(postgrad_t, user_domain)
allow postgrad_t user_domain:process signal;

That would keep the under-graduate students in line...

So I think that having an attribute for user domains makes sense. Having an attribute named user_domain as well as an attribute userdomain is a bad idea. The name $1_domain seems appropriate, so maybe we should rename the current userdomain attribute to user_login_domain (which is a better name anyway) before implementing this.

We could then have assertions to prevent the obvious mistakes such as allowing ptrace of a more privileged process in the policy macros for gpg etc.

Signature · 9 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.