From: Willy Tarreau <willy@w.ods.org>
To: Mark Rosenstand <mark@borkware.net>
Cc: Bernd Petrovitsch <bernd@firmix.at>, linux-kernel@vger.kernel.org
Subject: Re: Executable shell scripts
Date: Sat, 13 May 2006 14:58:48 +0200 [thread overview]
Message-ID: <20060513125848.GK11191@w.ods.org> (raw)
In-Reply-To: <20060513122330.CAA54146AF@hunin.borkware.net>
On Sat, May 13, 2006 at 02:23:30PM +0200, Mark Rosenstand wrote:
> (Cutting Arjan off the CC list, he's been bugged enough for his attempt
> to help.)
>
> Bernd Petrovitsch <bernd@firmix.at> wrote:
> > On Sat, 2006-05-13 at 13:45 +0200, Mark Rosenstand wrote:
> > > Bernd Petrovitsch <bernd@firmix.at> wrote:
> > > > On Sat, 2006-05-13 at 13:03 +0200, Mark Rosenstand wrote:
> > > > [...]
> > > > > A more useful case is when you setuid the script (and no, this doesn't
> > > > > need to be running as root and/or executable by all.)
> > > >
> > > > Apart from the permission bug: This has been purposely disabled since it
> > > > is way to easy to write exploitable shell or other scripts.
> > > > Use a real programming languages, sudo or a trivial wrapper in C ....
> > s/languages/language/
> >
> > And I forgot to mention that a kernel patch is another possibility.
>
> I'm too stupid to provide such myself, but I'd sure enable the Kconfig
> option if it was there :)
>
> > > It isn't a bug on systems that support executable shell scripts.
> >
> > I never wrote that (or anything which implies that directly).
>
> I was commenting on the "Apart from the permission bug" part.
>
> > > Doing security policy based on programming language seems weird at
> > > best, especially when the only user able to make those decisions is the
> > > superuser.
> >
> > It boils down to "how easy is it for root to shoot in the foot"?
> > And the workarounds are somewhere between trivial and simple.
>
> Or "dare we handle root a gun, it's a powerful weapon but can be used
> to shoot at feet." It's obvious what the answer have been for that in
> other operating systems, and probably one of the reasons we're here.
Well, at first I thought you did not understand how permissions work. I
apologize for this, but your question was not clear at all. I've checked
on OpenBSD and can confirm that it works. However, it does not exactly
work, it passes /dev/fd/3 to the shell as Neil suggested it. Moreover,
argv[0] gets changed to /dev/fd/3 when the script is not readable, not
very useful :
$ cat > foo
#!/bin/sh
echo \$0=$0 \$1=$1 ...
$ chmod 755 foo
$ ./foo bar
$0=./foo $1=bar ...
$ chmod 111 foo
$ ./foo bar
$0=/dev/fd/3 $1=bar ...
So the very common dirname or ${0%/*} tricks used to get the execution
directory from the running script will not work. Worse, behaviour will
have to be validated both with AND without read permissions since it
works differently in both cases.
At least, feeding the script to stdin and renaming argv[0] to point to
it would have been better.
Regards,
Willy
next prev parent reply other threads:[~2006-05-13 12:59 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-13 10:38 Executable shell scripts 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
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 [this message]
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=20060513125848.GK11191@w.ods.org \
--to=willy@w.ods.org \
--cc=bernd@firmix.at \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@borkware.net \
/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.