dynamic context transitions
i hope people don't mind me pointing out what may appear to be obvious:
q: how do you stop an attacker circumventing a program with this seteuid-like dynamic context transition capability, such that the attacker can make the program transition anywhere anytime to an arbitrarily chosen domain?
answer: by restricting the domains to which the transition may occur.
q: how would you do that?
answer: by providing something similar to domain_auto_trans() which is instead adding a level of indirection. so, instead of the newly proposed function (let's call it selinux_change_domain) specifying the new domain as its argument, you instead specify an intermediate handle.
so you'd have in the policy:
dynamic_handle "samba_as_root" samba_root_tdynamic_handle "samba_as_user" samba_user_t
dynamic_auto_trans(samba_t, "samba_as_root")dynamic_auto_trans(samba_root_t, "samba_as_user")
then, inside smbd, you call, at the appropriate point:
selinux_change_domain("samba_as_user")
then, the job of the selinux_change_domain() function is to not only check that you have permission to make dynamic transitions, but also that you are in the samba_root_t domain - and to do a lookup onto the dynamic_handle to find out what domain to transition to.
otherwise, you run the risk of a circumvented program being able to transition to unconfined_t - or anything that they damn well choose.
i trust that this has been considered in the design of the new dynamic transition function?
l.
--
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.
Quoted 34 lines · Luke Kenneth Casson Leighton
i hope people don't mind me pointing out what may appear to be obvious:
q: how do you stop an attacker circumventing a program with this seteuid-like dynamic context transition capability, such that the attacker can make the program transition anywhere anytime to an arbitrarily chosen domain?
answer: by restricting the domains to which the transition may occur.
q: how would you do that?
answer: by providing something similar to
domain_auto_trans()which is instead adding a level of indirection. so, instead of the newly proposed function (let's call itselinux_change_domain) specifying the new domain as its argument, you instead specify an intermediate handle.so you'd have in the policy:
dynamic_handle"samba_as_root"samba_root_tdynamic_handle"samba_as_user"samba_user_t
dynamic_auto_trans(samba_t, "samba_as_root")dynamic_auto_trans(samba_root_t, "samba_as_user")then, inside smbd, you call, at the appropriate point:
selinux_change_domain("samba_as_user")then, the job of the
selinux_change_domain()function is to not only check that you have permission to make dynamic transitions, but also that you are in thesamba_root_tdomain - and to do a lookup onto thedynamic_handleto find out what domain to transition to.
Quoted 5 lines
otherwise, you run the risk of a circumvented program being able to transition to
unconfined_t- or anything that they damn well choose.i trust that this has been considered in the design of the new dynamic transition function?
Luke,
As proposed, there are two permission checks applied upon a dynamic domain transition operation from A to B:
1) In order to write to /proc/pid/attr/current at all, A must have setcurrent permission to itself, i.e. allow A self:process setcurrent; This parallels the setexec and setfscreate checks performed for setting other attributes under /proc/pid/attr.
2) In order to dynamically transition from A to B, A must have dyntransition permission to B, i.e. allow A B:process dyntransition; This parallels the transition permission check applied upon exec-based transitions, but is distinct so that we can control them separately.
domain_auto_trans() is merely a macro that expands to a set of allow rules typically needed for an exec-based transition and a type_transition rule to define the default type transition for a given (calling domain, executable) pair. In the case of dynamic transitions, there is no such thing as a default transition; the application is always explicitly requesting a transition, and can specify the desired new context, just as some security-aware applications presently do for exec-based transitions using setexeccon(). But there is no need for any new policy construct to control this operation; you just need the new permissions to be defined, and then you can control the reachability of domains via dynamic transitions using allow rules.
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.
Quoted 10 lines · Stephen Smalley
As proposed, there are two permission checks applied upon a dynamic domain transition operation from A to B:
1) In order to write to/proc/pid/attr/currentat all, A must have setcurrent permission to itself, i.e. allow A self:process setcurrent; This parallels the setexec and setfscreate checks performed for setting other attributes under/proc/pid/attr.
2) In order to dynamically transition from A to B, A must have dyntransition permission to B, i.e. allow A B:process dyntransition; This parallels the transition permission check applied upon exec-based transitions, but is distinct so that we can control them separately.
okay - different language / words that i didn't quite understand at the time.
thanks for clarifying.
it was that allow A B:process dyntransition bit that i wasn't understanding.
just to make absolutely sure: my fears about A being able to transition to anydomainatall would be true if someone [explicitly] did this:
allow A domain:process dyntransition;
is that correct?
l.
Signature · 8 lines
-- <a href="http://lkcl.net">http://lkcl.net</a> -- -- 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.
Quoted 7 lines · Luke Kenneth Casson Leighton
just to make absolutely sure: my fears about A being able to transition to anydomainatall would be true if someone [explicitly] did this:
allow A domain:process dyntransition;is that correct?
Yes, or even something less direct, e.g.
allow A B:process dyntransition; allow B C:process dyntransition; allow C domain:process dyntransition;
But this specific issue (bounding the set of reachable domains) is not particularly different than the equivalent rule for exec-based transitions, e.g.
allow A domain:process transition;
would be just as bad, given that at least one privileged domain (i.e. sysadm_t) has the shell as its entrypoint. The exec-based transitions can apply entrypoint restrictions in most cases and can apply inheritance controls, but you still want to bound reachability there as well.
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.