suexec.html revision f6376d36c4c6d0a91049081f275202a34e10faf6
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
96e54b22ad432d658ba790f3800ee8ea2657449fChristian Maeder BGCOLOR="#FFFFFF"
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder TEXT="#000000"
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder LINK="#0000FF"
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder VLINK="#000080"
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder ALINK="#FF0000"
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder<!--#include virtual="header.html" -->
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder<H1 ALIGN="CENTER">Apache suEXEC Support</H1>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LH><BIG><STRONG>CONTENTS</STRONG></BIG></LH>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><A HREF="#what">What is suEXEC?</A></LI>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><A HREF="#before">Before we begin.</A></LI>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><A HREF="#model">suEXEC Security Model.</A></LI>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><A HREF="#install">Configuring & Installing suEXEC</A></LI>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><A HREF="#enable">Enabling & Disabling suEXEC</A></LI>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><A HREF="#debug">Debugging suEXEC</A></LI>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><A HREF="#jabberwock">Beware the Jabberwock: Warnings &
b82427a46050fa32553e722daedf6a364a14f217Christian MaederThe <STRONG>suEXEC</STRONG> feature -- introduced in Apache 1.2 -- provides
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederApache users the ability to run <STRONG>CGI</STRONG> and <STRONG>SSI</STRONG>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederprograms under user IDs different from the user ID of the calling web-server.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederNormally, when a CGI or SSI program executes, it runs as the same user who is
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederrunning the web server.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederUsed properly, this feature can reduce considerably the security risks involved
b82427a46050fa32553e722daedf6a364a14f217Christian Maederwith allowing users to develop and run private CGI or SSI programs. However,
b82427a46050fa32553e722daedf6a364a14f217Christian Maederif suEXEC is improperly configured, it can cause any number of problems and
b82427a46050fa32553e722daedf6a364a14f217Christian Maederpossibly create new holes in your computer's security. If you aren't familiar
b82427a46050fa32553e722daedf6a364a14f217Christian Maederwith managing setuid root programs and the security issues they present, we
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederhighly recommend that you not consider using suEXEC.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder<STRONG><A HREF="suexec.html">BACK TO CONTENTS</A></STRONG>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder<H3><A NAME="before">Before we begin.</A></H3>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederBefore jumping head-first into this document, you should be aware of the
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederassumptions made on the part of the Apache Group and this document.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederFirst, it is assumed that you are using a UNIX derivate operating system that
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederis capable of <STRONG>setuid</STRONG> and <STRONG>setgid</STRONG> operations.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederAll command examples are given in this regard. Other platforms, if they are
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maedercapable of supporting suEXEC, may differ in their configuration.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederSecond, it is assumed you are familiar with some basic concepts of your
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maedercomputer's security and its administration. This involves an understanding
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederof <STRONG>setuid/setgid</STRONG> operations and the various effects they
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maedermay have on your system and its level of security.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederThird, it is assumed that you are using an <STRONG>unmodified</STRONG>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederversion of suEXEC code. All code for suEXEC has been carefully scrutinized and
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maedertested by the developers as well as numerous beta testers. Every precaution has
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederbeen taken to ensure a simple yet solidly safe base of code. Altering this
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maedercode can cause unexpected problems and new security risks. It is
96e54b22ad432d658ba790f3800ee8ea2657449fChristian Maeder<STRONG>highly</STRONG> recommended you not alter the suEXEC code unless you
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederare well versed in the particulars of security programming and are willing to
96e54b22ad432d658ba790f3800ee8ea2657449fChristian Maedershare your work with the Apache Group for consideration.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederFourth, and last, it has been the decision of the Apache Group to
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder<STRONG>NOT</STRONG> make suEXEC part of the default installation of Apache.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederTo this end, suEXEC configuration is a manual process requiring of the
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederadministrator careful attention to details. It is through this process
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederthat the Apache Group hopes to limit suEXEC installation only to those
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederwho are determined to use it.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederStill with us? Yes? Good. Let's move on!
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder<STRONG><A HREF="suexec.html">BACK TO CONTENTS</A></STRONG>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder<H3><A NAME="model">suEXEC Security Model</A></H3>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian MaederBefore we begin configuring and installing suEXEC, we will first discuss
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederthe security model you are about to implement. By doing so, you may
b82427a46050fa32553e722daedf6a364a14f217Christian Maederbetter understand what exactly is going on inside suEXEC and what precautions
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maederare taken to ensure your system's security.
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder<STRONG>suEXEC</STRONG> is based on a setuid "wrapper" program that is
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maedercalled by the main Apache web server. This wrapper is called when an HTTP
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederrequest is made for a CGI or SSI program that the administrator has designated
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maederto run as a userid other than that of the main server. When such a request
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederis made, Apache provides the suEXEC wrapper with the program's name and the
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederuser and group IDs under which the program is to execute.
b82427a46050fa32553e722daedf6a364a14f217Christian MaederThe wrapper then employs the following process to determine success or
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederfailure -- if any one of these conditions fail, the program logs the failure
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maederand exits with an error, otherwise it will continue:
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><STRONG>Was the wrapper called with the proper number of arguments?</STRONG>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder The wrapper will only execute if it is given the proper number of arguments.
b82427a46050fa32553e722daedf6a364a14f217Christian Maeder The proper argument format is known to the Apache web server. If the wrapper
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder is not receiving the proper number of arguments, it is either being hacked, or
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder there is something wrong with the suEXEC portion of your Apache binary.
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder </BLOCKQUOTE>
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder <LI><STRONG>Is the user executing this wrapper a valid user of this system?</STRONG>
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder This is to ensure that the user executing the wrapper is truly a user of the system.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder </BLOCKQUOTE>
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder <LI><STRONG>Is this valid user allowed to run the wrapper?</STRONG>
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder Is this user the user allowed to run this wrapper? Only one user (the Apache
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder user) is allowed to execute this program.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder </BLOCKQUOTE>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><STRONG>Does the target program have an unsafe hierarchical reference?</STRONG>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder Does the target program contain a leading '/' or have a '..' backreference? These
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder are not allowed; the target program must reside within the Apache webspace.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder </BLOCKQUOTE>
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder <LI><STRONG>Is the target user name valid?</STRONG>
b82427a46050fa32553e722daedf6a364a14f217Christian Maeder Does the target user exist?
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder </BLOCKQUOTE>
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder <LI><STRONG>Is the target group name valid?</STRONG>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder Does the target group exist?
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder </BLOCKQUOTE>
b82427a46050fa32553e722daedf6a364a14f217Christian Maeder <LI><STRONG>Is the target user <EM>NOT</EM> superuser?</STRONG>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder Presently, suEXEC does not allow 'root' to execute CGI/SSI programs.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder </BLOCKQUOTE>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><STRONG>Is the target userid <EM>ABOVE</EM> the minimum ID number?</STRONG>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder The minimum user ID number is specified during configuration. This allows you
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder to set the lowest possible userid that will be allowed to execute CGI/SSI programs.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder This is useful to block out "system" accounts.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder </BLOCKQUOTE>
b82427a46050fa32553e722daedf6a364a14f217Christian Maeder <LI><STRONG>Is the target group <EM>NOT</EM> the superuser group?</STRONG>
b82427a46050fa32553e722daedf6a364a14f217Christian Maeder Presently, suEXEC does not allow the 'root' group to execute CGI/SSI programs.
b82427a46050fa32553e722daedf6a364a14f217Christian Maeder </BLOCKQUOTE>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><STRONG>Is the target groupid <EM>ABOVE</EM> the minimum ID number?</STRONG>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder The minimum group ID number is specified during configuration. This allows you
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder to set the lowest possible groupid that will be allowed to execute CGI/SSI programs.
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder This is useful to block out "system" groups.
b82427a46050fa32553e722daedf6a364a14f217Christian Maeder </BLOCKQUOTE>
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder <LI><STRONG>Can the wrapper successfully become the target user and group?</STRONG>
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder Here is where the program becomes the target user and group via setuid and setgid
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder calls. The group access list is also initialized with all of the groups of which
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder the user is a member.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder </BLOCKQUOTE>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><STRONG>Does the directory in which the program resides exist?</STRONG>
bc8dfa8d893d6ba015300cba3960c061ff7a8760Christian Maeder If it doesn't exist, it can't very well contain files.
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder </BLOCKQUOTE>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><STRONG>Is the directory within the Apache webspace?</STRONG>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder If the request is for a regular portion of the server, is the requested directory
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder within the server's document root? If the request is for a UserDir, is the requested
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder directory within the user's document root?
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder </BLOCKQUOTE>
6596e6462e9356ac01f15a6dcada971e1f346b63Christian Maeder <LI><STRONG>Is the directory <EM>NOT</EM> writable by anyone else?</STRONG>
<!--#include virtual="footer.html" -->