Running setuid CGI scripts with Apache

This is a discussion on Running setuid CGI scripts with Apache within the Linux Web Servers forums, part of the Web Server and Related Forums category; Hello, I'm not running suexec, nor do I care to. I have a suid script which is owned by ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-13-2004
Sean Hamilton
 
Posts: n/a
Default Running setuid CGI scripts with Apache

Hello,

I'm not running suexec, nor do I care to. I have a suid script which is
owned by a user other than the one Apache is running as. When I run this
from the shell, all is well. When I run it from Apache, it runs as the same
user as Apache. Binaries do not exhibit this problem, only scripts.

My first thought was that Apache was reading the hash-bang line and running
that program with the script as an argument, thereby using the permissions
of that binary instead of the script. I sure hope this isn't the case, as
that would be rather silly. I read through much of the relevant source and
didn't see any indications of this, but the large amount of abstraction
makes the code difficult to follow.

So, without using suidperl, and without using a binary wrapper, what's going
on here, and how do I fix it? I'm running Apache 2.0.48 on FreeBSD
5.1-RELEASE.

--
Sean Hamilton <sh@bel.bc.ca>


  #2 (permalink)  
Old 01-14-2004
David Efflandt
 
Posts: n/a
Default Re: Running setuid CGI scripts with Apache

On Tue, 13 Jan 2004 19:03:37 GMT, Sean Hamilton <sh@bel.bc.ca> wrote:
> Hello,
>
> I'm not running suexec, nor do I care to. I have a suid script which is
> owned by a user other than the one Apache is running as. When I run this
> from the shell, all is well. When I run it from Apache, it runs as the same
> user as Apache. Binaries do not exhibit this problem, only scripts.


When you say in the shell "all is well" are you changing to a different
user and actually confirming that it runs as the suid user (printing the
output of `id` or something)?

> My first thought was that Apache was reading the hash-bang line and running
> that program with the script as an argument, thereby using the permissions
> of that binary instead of the script. I sure hope this isn't the case, as
> that would be rather silly. I read through much of the relevant source and
> didn't see any indications of this, but the large amount of abstraction
> makes the code difficult to follow.
>
> So, without using suidperl, and without using a binary wrapper, what's going
> on here, and how do I fix it? I'm running Apache 2.0.48 on FreeBSD
> 5.1-RELEASE.


Most systems ignore suid for scripts for security reasons. So you have no
choice but to use an suid binary wrapper, or suexec, or suidperl (which
is not suid root by default).

--
David Efflandt - All spam ignored http://www.de-srv.com/
  #3 (permalink)  
Old 01-16-2004
Sean Hamilton
 
Posts: n/a
Default Re: Running setuid CGI scripts with Apache

"David Efflandt" <efflandt@xnet.com> wrote:
| When you say in the shell "all is well" are you
| changing to a different user and actually confirming
| that it runs as the suid user (printing the output of
| `id` or something)?

Yes. Exactly.

| Most systems ignore suid for scripts for security
| reasons. So you have no choice but to use an suid
| binary wrapper, or suexec, or suidperl (which is not
| suid root by default).

FreeBSD does not ignore setuid for scripts. If I run it from a shell running
as the apache user, it works fine. The problem only occurs when Apache runs
the script.

--
Sean Hamilton <sh@bel.bc.ca>


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:27 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0