From: Neil Brown <neilb@suse.de>
To: Mark Rosenstand <mark@borkware.net>
Cc: Theodore Tso <tytso@mit.edu>,
doug@mcnaught.org, arjan@infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: Executable shell scripts
Date: Sun, 14 May 2006 08:42:21 +1000 [thread overview]
Message-ID: <17510.24781.295255.225387@cse.unsw.edu.au> (raw)
In-Reply-To: message from Mark Rosenstand on Saturday May 13
On Saturday May 13, mark@borkware.net wrote:
>
> Anyhow, I don't really mind the 111 mode, the point was to show shell
> scripts being treated as executables. What I do want this feature for
> is the "more useful case" that somehow got stripped off in the replies,
> namely setuid and setgid scripts.
> -
setXid scripts are trivially exploitable unless the "/dev/fd/X"
approach is used to pass the file to the interpreter.
A classic approach is
ln -s /bin/setuid-script ~/bin/-i
-i
This will run the interpreter with a first argument of
-i
which (if it is the shell) will just run an interactive shell for
you!!!
Now several shells have hacks to try to detect that case and reject it,
but there are other approaches..
Create a symlink to the script, and just at the right time between the
interpreter starting setuid and the interpreter opening the script,
you redirect the symlink somewhere else. You might have to try a few
times to win the race, but it is sure to be possible.
Again, several shells have hacks in place to detect and avoid that
condition.
But it has turned into an arms race - Can you be sure that the
interpreter you are using correctly detects and avoids all possible
subversion attempts? It seems unlikely.
It is much safer to have a compiled program be the setuid bit, and it
does appropriate checks and runs a script in a highly controlled
manner. I have a program called 'priv' which runs scripts out of
/usr/local/priv after doing some access checks listed at the top of
the script. It makes it quite easy and fairly safe (you still need to
check all command line args carefully) to write setuid-root script.
NeilBrown
next prev parent reply other threads:[~2006-05-13 22:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-13 10:38 Mark Rosenstand
2006-05-13 10:56 ` Arjan van de Ven
2006-05-13 11:03 ` Mark Rosenstand
2006-05-13 11:07 ` Arjan van de Ven
2006-05-13 11:17 ` Mark Rosenstand
2006-05-13 11:18 ` Willy Tarreau
2006-05-13 11:19 ` Douglas McNaught
2006-05-13 11:27 ` Mark Rosenstand
2006-05-13 11:37 ` Joel Jaeggli
2006-05-13 12:59 ` Theodore Tso
2006-05-13 13:18 ` Mark Rosenstand
2006-05-13 22:42 ` Neil Brown [this message]
2006-05-13 11:28 ` Stefan Smietanowski
2006-05-13 11:37 ` Neil Brown
2006-05-13 12:45 ` Willy Tarreau
2006-05-13 14:00 ` Arjan van de Ven
2006-05-13 20:52 ` Douglas McNaught
2006-05-13 11:16 ` J.A. Magallón
2006-05-13 11:22 ` Bernd Petrovitsch
2006-05-13 11:45 ` Mark Rosenstand
2006-05-13 11:56 ` Bernd Petrovitsch
2006-05-13 12:23 ` Mark Rosenstand
2006-05-13 12:58 ` Willy Tarreau
2006-05-13 18:55 ` Bernd Petrovitsch
2006-05-13 11:23 ` CaT
2006-05-13 11:00 ` Willy Tarreau
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=17510.24781.295255.225387@cse.unsw.edu.au \
--to=neilb@suse.de \
--cc=arjan@infradead.org \
--cc=doug@mcnaught.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@borkware.net \
--cc=tytso@mit.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®