All of lore.kernel.org
 help / color / mirror / Atom feed
* type transitioning script race condition?
@ 2006-08-30 22:39 Klaus Weidner
  2006-08-30 23:18 ` Russell Coker
  0 siblings, 1 reply; 20+ messages in thread
From: Klaus Weidner @ 2006-08-30 22:39 UTC (permalink / raw)
  To: selinux; +Cc: Stephan Mueller

Hello,

in the current refpolicy, quite a few script files have a *_exec_t type
and do a type transition. My understanding is that the transition happens
in the kernel in the execve() call, and then after transitioning the
kernel launches the interpreter (from fs/binfmt_script.c) and passes the
script name to the interpreter.

This sounds as if it suffers from the well known race condition that
makes setuid shell scripts a bad idea - is there any protection in place
to prevent users from exploiting the race condition to run code of their
own choice in the new domain?

The thread "labeling of compilers etc" on this mailing list (Feb this
year) touched on the subject but I didn't see a definite answer how this
is handled.

I've experimented a bit, running /usr/bin/yum as a normal user and using
Ctrl-Z to suspend it, and according to "ps axZ" output the python
process has the staff_u:staff_r:staff_t:SystemLow-SystemHigh context, and
doesn't seem to be transitioning. 

When run as root/sysadm_r, running "yum" appears to try to transition
(which incidentally produces an error and audit records, but that's a
different issue):

 # yum
 bash: /usr/bin/yum: /usr/bin/python: bad interpreter: Permission denied

 type=SELINUX_ERR msg=audit(1156698927.439:529): security_compute_sid: invalid context staff_u:system_r:rpm_t:s0-s15:c0.c255 for scontext=staff_u:sysadm_r:sysadm_t:s0-s15:c0.c255 tcontext=system_u:object_r:rpm_exec_t:s0 tclass=process
 type=SYSCALL msg=audit(1156698927.439:529): arch=40000003 syscall=11 success=no exit=-13 a0=83a6020 a1=83a9990 a2=83aabd8 a3=83a9a10 items=0 ppid=1754 pid=2080 auid=500 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 comm="bash" exe="/bin/bash" subj=staff_u:sysadm_r:sysadm_t:s0-s15:c0.c255 key=(null)

-Klaus

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2006-09-01 13:13 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-30 22:39 type transitioning script race condition? Klaus Weidner
2006-08-30 23:18 ` Russell Coker
2006-08-31  3:12   ` Joshua Brindle
2006-08-31 13:23     ` Karl MacMillan
2006-08-31 13:53       ` Joshua Brindle
2006-08-31 15:29         ` Karl MacMillan
2006-08-31 15:41           ` Joshua Brindle
2006-08-31 16:02           ` Klaus Weidner
2006-08-31 16:39             ` Karl MacMillan
2006-08-31 17:19               ` Klaus Weidner
2006-08-31 20:02                 ` Karl MacMillan
2006-08-31 15:46         ` Klaus Weidner
2006-08-31 16:13           ` Joshua Brindle
2006-08-31 16:40             ` Klaus Weidner
2006-09-01 11:37           ` Stephen Smalley
2006-09-01 12:48         ` Russell Coker
2006-09-01 13:13           ` Joshua Brindle
2006-08-31 14:43     ` Stephen Smalley
2006-08-31 14:49       ` Joshua Brindle
2006-08-31 15:09         ` Stephen Smalley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.