About Domain Transition
Suppose a process is in domain "CurrDom". Now the process invokes a program with type "Type".
Following is my understanding of whether the execution can succeed, can anyone help me to see if it's correct?
(1) If "CurrDom" does not have "execute" permission on "Type" with security class "file"(or variations), access is denied.
(2) If there is a type_transition rule says that "CurrDom" should transition to "NewDom" after executing type "Type", then
(2.1) If "CurrDom" does not have "transition" permission on "Type" with
security class "file" (or variations), access is denied.
(2.2) If "NewDom" does not have "entrypoint" permission on "Type" with
security class "file" (or variations), access is denied.
(2.3) Access is granted if both (2.1) and (2.2) are passed.
(3) There is no type_transition rules says anything about new domain for "CurrDom" when executing "Type"
Access is granted only when "CurrDom" has "execute_no_trans" permission
on "Type" with security class "file" (or variations).
I am not sure about following questions:
(A) In (2), if multiple type_transition rules specify a new domain for "CurrDom", what'll happen?
(B) In (1), what if CurrDom has permission "execute_no_trans"?
(C) If a process fails to transition to another domain in (2), and if CurrDom has permission "execute_no_trans", can it execute the program and stay in the current domain?
Is there any documentation I can refer to so I can see how the access decision is made? Or where in the kernel source code above logic is implement?
Thanks!
Quoted 6 lines · Hong
Is there any documentation I can refer to so I can see how the access decision is made? Or where in the kernel source code above logic is implement?
Thanks!
Hello and welcome, There is a separate mailing list for (ref)policy. You can subscribe here: http://oss.tresys.com/mailman/listinfo/refpolicy
You can browse policy source code here:
http://oss.tresys.com/projects/refpolicy/browser/trunk
I Think your explanation looks good.
1. cannot execute (access is denied by default)
2. can execute but not transition to new domain (run executable file in the caller domain) for example: if domain_type_6_t tries to execute application_executable_files_type_1_t then run that process in the domain_type_6_t domain
3. can execute and and transition to a predefined domain ( for example:
if domain_type_1_t tries to executes application_executable_files_type_1_t then transition to domain_type_2_t
You can easily test these with policy like can_exec() and domain_auto_trans()
Another good resource for knowledge is the #selinux and #fedora-selinux irc channel on irc.freenode.org.
if domain_type_3_t tries to execute application_executable_files_type_1_t then transition to domain_type_3_t
Signature · 1 line
Dominick Grift <[email protected]>
Thanks Dominick, your comments are very helpful.
I have another question. Suppose there is a rule:type_transition domain1_type app_exec_t: process domain2_type;
but domain1_type only has execute_no_trans over over app_exec_t:
allow domain1_type app_exec_t: file execute_no_trans;
Then what'll happen when a process within domain1_type executes a program with type app_exec_t? Will it stay in domain1_type or the access is denied?
Hong
Quoted 42 lines · Dominick Grift
Quoted 6 lines · Hong
Is there any documentation I can refer to so I can see how the access decision is made? Or where in the kernel source code above logic is implement?
Thanks!
Hello and welcome, There is a separate mailing list for (ref)policy. You can subscribe here: http://oss.tresys.com/mailman/listinfo/refpolicy
You can browse policy source code here:
http://oss.tresys.com/projects/refpolicy/browser/trunkI Think your explanation looks good.
1. cannot execute (access is denied by default)
2. can execute but not transition to new domain (run executable file in the caller domain) for example: if
domain_type_6_ttries to executeapplication_executable_files_type_1_tthen run that process in thedomain_type_6_tdomain3. can execute and and transition to a predefined domain ( for example:
ifdomain_type_1_ttries to executesapplication_executable_files_type_1_tthen transition todomain_type_2_tYou can easily test these with policy like
can_exec()anddomain_auto_trans()Another good resource for knowledge is the #selinux and #fedora-selinux irc channel on irc.freenode.org.
if
domain_type_3_ttries to executeapplication_executable_files_type_1_tthen transition todomain_type_3_t--
Dominick Grift <[email protected]>
Quoted 11 lines · Hong
Thanks Dominick, your comments are very helpful.
I have another question. Suppose there is a rule:
type_transitiondomain1_typeapp_exec_t: processdomain2_type;but
domain1_typeonly hasexecute_no_transover overapp_exec_t:
allowdomain1_typeapp_exec_t: fileexecute_no_trans;Then what'll happen when a process within
domain1_typeexecutes a program with typeapp_exec_t? Will it stay indomain1_typeor the access is denied?
Good question. My bet is that it will be able to execute it but not transition.
These things can be reproduced and referenced easily. Try it :)
define(domain_transition_pattern',
allow $1 $2:file { getattr read execute };
allow $1 $3:process transition;
dontaudit $1 $3:process { noatsecure siginh rlimitinh };type_transition $1 $2:process $3;
')
Signature · 1 line
Dominick Grift <[email protected]>
Quoted 7 lines · Hong
Suppose a process is in domain "CurrDom". Now the process invokes a program with type "Type".
Following is my understanding of whether the execution can succeed, can anyone help me to see if it's correct?(1) If "CurrDom" does not have "execute" permission on "Type" with security class "file"(or variations), access is denied.
Correct.
Quoted 2 lines
(2) If there is a
type_transitionrule says that "CurrDom" should transition to "NewDom" after executing type "Type", then
Or if the process explicitly requests "NewDom" via setexeccon(3) prior to invoking execve().
Quoted 2 lines
(2.1) If "CurrDom" does not have "transition" permission on
"Type" with security class "file" (or variations), access is denied.
No, the transition check is: If "CurrDom" does not have "transition" permission to "NewDom" (class process), access is denied.
Quoted 2 lines
(2.2) If "NewDom" does not have "entrypoint" permission on "Type"
with security class "file" (or variations), access is denied.
Correct.
Quoted 1 line
(2.3) Access is granted if both (2.1) and (2.2) are passed.
Yes, with the modification above.
Quoted 2 lines
(3) There is no
type_transitionrules says anything about new domain for "CurrDom" when executing "Type"
And the process did not explicitly request a new domain via setexeccon(3) prior to invoking execve().
Quoted 2 lines
Access is granted only when "CurrDom" has "
execute_no_trans"
permission on "Type" with security class "file" (or variations).
Correct.
Quoted 3 lines
I am not sure about following questions:
(A) In (2), if multipletype_transitionrules specify a new domain for "CurrDom", what'll happen?
There can only be one type_transition rule per (domain, type, class) tuple. However, the application may explicitly request a particular domain transition via setexeccon(3), and this will override any default transition.
Quoted 1 line
(B) In (1), what if CurrDom has permission "
execute_no_trans"?
Makes no difference.
Quoted 3 lines
(C) If a process fails to transition to another domain in (2), and if CurrDom has permission "
execute_no_trans", can it execute the program and stay in the current domain?
Only if it explicitly asks to stay in the same domain by using setexeccon().
Quoted 3 lines
Is there any documentation I can refer to so I can see how the access decision is made? Or where in the kernel source code above logic is implement?
http://www.nsa.gov/selinux/papers/module/x645.html
http://lxr.linux.no/linux+v2.6.26.3/security/selinux/hooks.c#L1946
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.