From: Karl MacMillan <kmacmillan@mentalrootkit.com>
To: Klaus Weidner <klaus@atsec.com>
Cc: Joshua Brindle <method@manicmethod.com>,
Joshua Brindle <method@gentoo.org>,
russell@coker.com.au, selinux@tycho.nsa.gov,
Stephan Mueller <smueller@atsec.com>
Subject: Re: type transitioning script race condition?
Date: Thu, 31 Aug 2006 12:39:10 -0400 [thread overview]
Message-ID: <1157042350.14623.25.camel@localhost.localdomain> (raw)
In-Reply-To: <20060831160222.GD12307@w-m-p.com>
On Thu, 2006-08-31 at 11:02 -0500, Klaus Weidner wrote:
> On Thu, Aug 31, 2006 at 11:29:24AM -0400, Karl MacMillan wrote:
> > Sorry - started one message and sent another. If you embed the script
> > (as a string) and interpreter in the C wrapper you can avoid the race.
>
> Yes, the important thing is to ensure that raising the privileges and
> picking the thing to execute is a single operation.
>
> > In practice - for the scripts we are discussing - if you have sufficient
> > privilege to modify the script or the environment to take advantage of
> > the race condition you likely have a more direct attack vector. So the
> > environment cleansing seems more important to me.
>
> You don't need to modify the script or have special privileges to exploit
> the race condition. A possible example looks like this:
>
> - create link to executable (the link can be one of the path components),
> for example:
>
> ln -s /usr/sbin /tmp/hack
>
In a strict environment the creation of the symlinks to privileged
applications should be controlled.
> - execute /tmp/hack/semanage
>
> - kernel looks at label of /tmp/hack/semanage, gets the label of
> /usr/sbin/semanage
>
> - kernel decides to do a domain transition, suid, whatever
>
> - kernel executes: /usr/bin/python /tmp/hack/semanage
>
> - attacker redirects /tmp/hack to /tmp/malicious/ which contains a
> different semanage script
>
> - python opens /tmp/hack/semanage which now resolves to
> /tmp/malicious/semanage
>
Good point. Seems like a less invasive option than opening the file
descriptor is to pass in the target of the symlink instead of the
symlink, but this has several other problems.
> (As an aside, I think in this specific case the AppArmor approach of
> making the security decisions based on the path name is actually safer
> than using the file label. Time for a flame war about "label based
> security considered harmful"? ;-) But the real solution is to avoid the
> race in the first place.)
>
Well, this is more a problem that the privilege escalation is not
properly tied to the entrypoint object, which is why this is a problem
for both suid and selinux - in which both _correctly_ associate security
attributes with the object :).
This should be fixed for semanage. Actually, things are even worse since
semanage has "#! /usr/bin/env python" - no need to try to exploit a race
condition when you can just execute whatever you want with privileges as
long as it is called python.
Karl
--
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.
next prev parent reply other threads:[~2006-08-31 16:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1157042350.14623.25.camel@localhost.localdomain \
--to=kmacmillan@mentalrootkit.com \
--cc=klaus@atsec.com \
--cc=method@gentoo.org \
--cc=method@manicmethod.com \
--cc=russell@coker.com.au \
--cc=selinux@tycho.nsa.gov \
--cc=smueller@atsec.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.