]> granicus.if.org Git - apache/blobdiff - docs/manual/suexec.xml
Help doc writer to spot places where:
[apache] / docs / manual / suexec.xml
index a3f1c9d015614beeaf5996dd2b7247416204d97e..83144fbe58d8e8098214a8f2fc07bc7bb1e2b762 100644 (file)
@@ -1,18 +1,35 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="./style/manual.en.xsl"?>
+<!-- $LastChangedRevision$ -->
 
-<manualpage>
-  <relativepath href="."/>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manualpage metafile="suexec.xml.meta">
 
   <title>suEXEC Support</title>
 
   <summary>
-    <p>The <strong>suEXEC</strong> feature provides
-    Apache users the ability
+    <p>The <strong>suEXEC</strong> feature provides users of the Apache
+    HTTP Server the ability
     to run <strong>CGI</strong> and <strong>SSI</strong> programs
     under user IDs different from the user ID of the calling
-    web-server. Normally, when a CGI or SSI program executes, it
+    web server. Normally, when a CGI or SSI program executes, it
     runs as the same user who is running the web server.</p>
 
     <p>Used properly, this feature can reduce
     develop and run private CGI or SSI programs. However, if suEXEC
     is improperly configured, it can cause any number of problems
     and possibly create new holes in your computer's security. If
-    you aren't familiar with managing setuid root programs and the
-    security issues they present, we highly recommend that you not
-    consider using suEXEC.</p>
+    you aren't familiar with managing <em>setuid root</em> programs
+    and the security issues they present, we highly recommend that
+    you not consider using suEXEC.</p>
   </summary>
 
 <section id="before"><title>Before we begin</title>
 
     <p>Before jumping head-first into this document,
-    you should be aware of the assumptions made on the part of the
-    Apache Group and this document.</p>
+    you should be aware that certain assumptions are made about you and
+    the environment in which you will be using suexec.</p>
 
     <p>First, it is assumed that you are using a UNIX
-    derivate operating system that is capable of
+    derivative operating system that is capable of
     <strong>setuid</strong> and <strong>setgid</strong> operations.
     All command examples are given in this regard. Other platforms,
     if they are capable of supporting suEXEC, may differ in their
     security risks. It is <strong>highly</strong> recommended you
     not alter the suEXEC code unless you are well versed in the
     particulars of security programming and are willing to share
-    your work with the Apache Group for consideration.</p>
+    your work with the Apache HTTP Server development team for consideration.</p>
 
     <p>Fourth, and last, it has been the decision of
-    the Apache Group to <strong>NOT</strong> make suEXEC part of
-    the default installation of Apache. To this end, suEXEC
+    the Apache HTTP Server development team to <strong>NOT</strong> make suEXEC part of
+    the default installation of Apache httpd. To this end, suEXEC
     configuration requires of the administrator careful attention
     to details. After due consideration has been given to the
     various settings for suEXEC, the administrator may install
@@ -66,7 +83,7 @@
     these settings need to be carefully determined and specified by
     the administrator to properly maintain system security during
     the use of suEXEC functionality. It is through this detailed
-    process that the Apache Group hopes to limit suEXEC
+    process that we hope to limit suEXEC
     installation only to those who are careful and determined
     enough to use it.</p>
 
     taken to ensure your system's security.</p>
 
     <p><strong>suEXEC</strong> is based on a setuid
-    "wrapper" program that is called by the main Apache web server.
+    "wrapper" program that is called by the main Apache HTTP Server.
     This wrapper is called when an HTTP request is made for a CGI
     or SSI program that the administrator has designated to run as
     a userid other than that of the main server. When such a
-    request is made, Apache provides the suEXEC wrapper with the
+    request is made, Apache httpd provides the suEXEC wrapper with the
     program's name and the user and group IDs under which the
     program is to execute.</p>
 
 
     <ol>
       <li>
+        <strong>Is the user executing this wrapper a valid user of
+        this system?</strong>
+
+        <p class="indent">
+          This is to ensure that the user executing the wrapper is
+          truly a user of the system.
+        </p>
+     </li>
+
+     <li>
         <strong>Was the wrapper called with the proper number of
-        arguments?</strong> 
+        arguments?</strong>
 
         <p class="indent">
           The wrapper will only execute if it is given the proper
           number of arguments. The proper argument format is known
-          to the Apache web server. If the wrapper is not receiving
+          to the Apache HTTP Server. If the wrapper is not receiving
           the proper number of arguments, it is either being
           hacked, or there is something wrong with the suEXEC
-          portion of your Apache binary.
-        </p>
-      </li>
-
-      <li>
-        <strong>Is the user executing this wrapper a valid user of
-        this system?</strong> 
-
-        <p class="indent">
-          This is to ensure that the user executing the wrapper is
-          truly a user of the system.
+          portion of your Apache httpd binary.
         </p>
       </li>
 
       <li>
         <strong>Is this valid user allowed to run the
-        wrapper?</strong> 
+        wrapper?</strong>
 
         <p class="indent">
           Is this user the user allowed to run this wrapper? Only
       </li>
 
       <li>
-        <strong>Does the target program have an unsafe hierarchical
-        reference?</strong> 
+        <strong>Does the target CGI or SSI program have an unsafe
+        hierarchical reference?</strong>
 
         <p class="indent">
-          Does the target program contain a leading '/' or have a
-          '..' backreference? These are not allowed; the target
-          program must reside within the Apache webspace.
+          Does the target CGI or SSI program's path contain a leading
+          '/' or have a '..' backreference? These are not allowed; the
+          target CGI/SSI program must reside within suEXEC's document
+          root (see <code>--with-suexec-docroot=<em>DIR</em></code>
+          below).
         </p>
       </li>
 
       <li>
-        <strong>Is the target user name valid?</strong> 
+        <strong>Is the target user name valid?</strong>
 
         <p class="indent">
           Does the target user exist?
       </li>
 
       <li>
-        <strong>Is the target group name valid?</strong> 
+        <strong>Is the target group name valid?</strong>
 
         <p class="indent">
           Does the target group exist?
 
       <li>
         <strong>Is the target user <em>NOT</em> superuser?</strong>
-        
+
 
         <p class="indent">
-          Presently, suEXEC does not allow 'root' to execute
-          CGI/SSI programs.
+          suEXEC does not allow <code><em>root</em></code>
+          to execute CGI/SSI programs.
         </p>
       </li>
 
       <li>
         <strong>Is the target userid <em>ABOVE</em> the minimum ID
-        number?</strong> 
+        number?</strong>
 
         <p class="indent">
           The minimum user ID number is specified during
 
       <li>
         <strong>Is the target group <em>NOT</em> the superuser
-        group?</strong> 
+        group?</strong>
 
         <p class="indent">
-          Presently, suEXEC does not allow the 'root' group to
-          execute CGI/SSI programs.
+          Presently, suEXEC does not allow the <code><em>root</em></code>
+          group to execute CGI/SSI programs.
         </p>
       </li>
 
       <li>
         <strong>Is the target groupid <em>ABOVE</em> the minimum ID
-        number?</strong> 
+        number?</strong>
 
         <p class="indent">
           The minimum group ID number is specified during
 
       <li>
         <strong>Can the wrapper successfully become the target user
-        and group?</strong> 
+        and group?</strong>
 
         <p class="indent">
           Here is where the program becomes the target user and
       </li>
 
       <li>
-        <strong>Does the directory in which the program resides
-        exist?</strong> 
+        <strong>Can we change directory to the one in which the target
+        CGI/SSI program resides?</strong>
 
         <p class="indent">
-          If it doesn't exist, it can't very well contain files.
+          If it doesn't exist, it can't very well contain files. If we
+          can't change directory to it, it might as well not exist.
         </p>
       </li>
 
       <li>
-        <strong>Is the directory within the Apache
-        webspace?</strong> 
+        <strong>Is the directory within the httpd webspace?</strong>
 
         <p class="indent">
           If the request is for a regular portion of the server, is
-          the requested directory within the server's document
-          root? If the request is for a UserDir, is the requested
-          directory within the user's document root?
+          the requested directory within suEXEC's document root? If
+          the request is for a <directive module="mod_userdir"
+          >UserDir</directive>, is the requested directory
+          within the directory configured as suEXEC's userdir (see
+          <a href="#install">suEXEC's configuration options</a>)?
         </p>
       </li>
 
       <li>
         <strong>Is the directory <em>NOT</em> writable by anyone
-        else?</strong> 
+        else?</strong>
 
         <p class="indent">
           We don't want to open up the directory to others; only
       </li>
 
       <li>
-        <strong>Does the target program exist?</strong> 
+        <strong>Does the target CGI/SSI program exist?</strong>
 
         <p class="indent">
           If it doesn't exists, it can't very well be executed.
       </li>
 
       <li>
-        <strong>Is the target program <em>NOT</em> writable by
-        anyone else?</strong> 
+        <strong>Is the target CGI/SSI program <em>NOT</em> writable
+        by anyone else?</strong>
 
         <p class="indent">
           We don't want to give anyone other than the owner the
-          ability to change the program.
+          ability to change the CGI/SSI program.
         </p>
       </li>
 
       <li>
-        <strong>Is the target program <em>NOT</em> setuid or
-        setgid?</strong> 
+        <strong>Is the target CGI/SSI program <em>NOT</em> setuid or
+        setgid?</strong>
 
         <p class="indent">
           We do not want to execute programs that will then change
 
       <li>
         <strong>Is the target user/group the same as the program's
-        user/group?</strong> 
+        user/group?</strong>
 
         <p class="indent">
           Is the user the owner of the file?
 
       <li>
         <strong>Can we successfully clean the process environment
-        to ensure safe operations?</strong> 
+        to ensure safe operations?</strong>
 
         <p class="indent">
           suEXEC cleans the process' environment by establishing a
       </li>
 
       <li>
-        <strong>Can we successfully become the target program and
-        execute?</strong> 
+        <strong>Can we successfully become the target CGI/SSI program
+        and execute?</strong>
 
         <p class="indent">
-          Here is where suEXEC ends and the target program begins.
+          Here is where suEXEC ends and the target CGI/SSI program begins.
         </p>
       </li>
     </ol>
 
-    <p>This is the standard operation of the the
+    <p>This is the standard operation of the
     suEXEC wrapper's security model. It is somewhat stringent and
     can impose new limitations and guidelines for CGI/SSI design,
     but it was developed carefully step-by-step with security in
 
       <dd>This option enables the suEXEC feature which is never
       installed or activated by default. At least one
-      --with-suexec-xxxxx option has to be provided together with the
-      --enable-suexec option to let APACI accept your request for
-      using the suEXEC feature.</dd>
+      <code>--with-suexec-xxxxx</code> option has to be provided
+      together with the <code>--enable-suexec</code> option to let
+      APACI accept your request for using the suEXEC feature.</dd>
+
+      <dt><code>--enable-suexec-capabilities</code></dt>
+
+      <dd><strong>Linux specific:</strong> Normally,
+      the <code>suexec</code> binary is installed "setuid/setgid
+      root", which allows it to run with the full privileges of the
+      root user.  If this option is used, the <code>suexec</code>
+      binary will instead be installed with only the setuid/setgid
+      "capability" bits set, which is the subset of full root
+      priviliges required for suexec operation.  Note that
+      the <code>suexec</code> binary may not be able to write to a log
+      file in this mode; it is recommended that the
+      <code>--with-suexec-syslog --without-suexec-logfile</code>
+      options are used in conjunction with this mode, so that syslog
+      logging is used instead.</dd>
 
       <dt><code>--with-suexec-bin=<em>PATH</em></code></dt>
 
-      <dd>The path to the suexec binary must be hard-coded in
-      the server for security reasons. Use this option to override
+      <dd>The path to the <code>suexec</code> binary must be hard-coded
+      in the server for security reasons. Use this option to override
       the default path. <em>e.g.</em>
       <code>--with-suexec-bin=/usr/sbin/suexec</code></dd>
 
       <dt><code>--with-suexec-caller=<em>UID</em></code></dt>
 
       <dd>The <a href="mod/mpm_common.html#user">username</a> under which
-      Apache normally runs. This is the only user allowed to
-      execute this program.</dd>
+      httpd normally runs. This is the only user allowed to
+      execute the suEXEC wrapper.</dd>
 
       <dt><code>--with-suexec-userdir=<em>DIR</em></code></dt>
 
       directories where suEXEC access should be allowed. All
       executables under this directory will be executable by suEXEC
       as the user so they should be "safe" programs. If you are
-      using a "simple" UserDir directive (ie. one without a "*" in
-      it) this should be set to the same value. suEXEC will not
-      work properly in cases where the UserDir directive points to
+      using a "simple" <directive module="mod_userdir">UserDir</directive>
+      directive (ie. one without a "*" in it) this should be set to the same
+      value. suEXEC will not work properly in cases where the <directive
+      module="mod_userdir">UserDir</directive> directive points to
       a location that is not the same as the user's home directory
-      as referenced in the passwd file. Default value is
-      "public_html".<br />
-       If you have virtual hosts with a different UserDir for each,
+      as referenced in the <code>passwd</code> file. Default value is
+      "<code>public_html</code>".<br />
+      If you have virtual hosts with a different <directive
+      module="mod_userdir">UserDir</directive> for each,
       you will need to define them to all reside in one parent
       directory; then name that parent directory here. <strong>If
       this is not defined properly, "~userdir" cgi requests will
 
       <dt><code>--with-suexec-docroot=<em>DIR</em></code></dt>
 
-      <dd>Define as the DocumentRoot set for Apache. This will be
-      the only hierarchy (aside from UserDirs) that can be used for
-      suEXEC behavior. The default directory is the --datadir value
-      with the suffix "/htdocs", <em>e.g.</em> if you configure
-      with "<code>--datadir=/home/apache</code>" the directory
-      "/home/apache/htdocs" is used as document root for the suEXEC
-      wrapper.</dd>
+      <dd>Define as the DocumentRoot set for httpd. This will be
+      the only hierarchy (aside from <directive module="mod_userdir"
+      >UserDir</directive>s) that can be used for suEXEC behavior. The
+      default directory is the <code>--datadir</code> value with the suffix
+      "<code>/htdocs</code>", <em>e.g.</em> if you configure with
+      "<code>--datadir=/home/apache</code>" the directory
+      "<code>/home/apache/htdocs</code>" is used as document root for the
+      suEXEC wrapper.</dd>
 
       <dt><code>--with-suexec-uidmin=<em>UID</em></code></dt>
 
       <dd>This defines the filename to which all suEXEC
       transactions and errors are logged (useful for auditing and
       debugging purposes). By default the logfile is named
-      "suexec_log" and located in your standard logfile directory
-      (--logfiledir).</dd>
+      "<code>suexec_log</code>" and located in your standard logfile
+      directory (<code>--logfiledir</code>).</dd>
+
+      <dt><code>--with-suexec-syslog</code></dt>
+
+      <dd>If defined, suexec will log notices and errors to syslog
+      instead of a logfile.  This option must be combined
+      with <code>--without-suexec-logfile</code>.</dd>
 
       <dt><code>--with-suexec-safepath=<em>PATH</em></code></dt>
 
       <dd>Define a safe PATH environment to pass to CGI
       executables. Default value is
-      "/usr/local/bin:/usr/bin:/bin".</dd>
+      "<code>/usr/local/bin:/usr/bin:/bin</code>".</dd>
     </dl>
 
-    <p><strong>Checking your suEXEC
-    setup</strong><br />
-     Before you compile and install the suEXEC wrapper you can
-    check the configuration with the --layout option.<br />
-     Example output:</p>
-
-<example>
-    suEXEC setup:<br />
-            suexec binary: /usr/local/apache/sbin/suexec<br />
-            document root: /usr/local/apache/share/htdocs<br />
-           userdir suffix: public_html<br />
-                  logfile: /usr/local/apache/var/log/suexec_log<br />
-                safe path: /usr/local/bin:/usr/bin:/bin<br />
-                caller ID: www<br />
-          minimum user ID: 100<br />
-         minimum group ID: 100<br />
-</example>
-
-    <p><strong>Compiling and installing the suEXEC
-    wrapper</strong><br />
-     If you have enabled the suEXEC feature with the
-    --enable-suexec option the suexec binary (together with Apache
-    itself) is automatically built if you execute the command
-    "make".<br />
-     After all components have been built you can execute the
-    command "make install" to install them. The binary image
-    "suexec" is installed in the directory defined by the --sbindir
-    option. Default location is
-    "/usr/local/apache/sbin/suexec".<br />
-     Please note that you need <strong><em>root
-    privileges</em></strong> for the installation step. In order
-    for the wrapper to set the user ID, it must be installed as
-    owner <code><em>root</em></code> and must have the setuserid
-    execution bit set for file modes.</p>
-
+    <section>
+      <title>Compiling and installing the suEXEC wrapper</title>
+
+      <p>If you have enabled the suEXEC feature with the
+      <code>--enable-suexec</code> option the <code>suexec</code> binary
+      (together with httpd itself) is automatically built if you execute
+      the <code>make</code> command.</p>
+
+      <p>After all components have been built you can execute the
+      command <code>make install</code> to install them. The binary image
+      <code>suexec</code> is installed in the directory defined by the
+      <code>--sbindir</code> option. The default location is
+      "/usr/local/apache2/bin/suexec".</p>
+
+      <p>Please note that you need <strong><em>root
+      privileges</em></strong> for the installation step. In order
+      for the wrapper to set the user ID, it must be installed as
+      owner <code><em>root</em></code> and must have the setuserid
+      execution bit set for file modes.</p>
+    </section>
+
+    <section>
+      <title>Setting paranoid permissions</title>
+
+      <p>Although the suEXEC wrapper will check to ensure that its
+      caller is the correct user as specified with the
+      <code>--with-suexec-caller</code> <program>configure</program>
+      option, there is
+      always the possibility that a system or library call suEXEC uses
+      before this check may be exploitable on your system. To counter
+      this, and because it is best-practise in general, you should use
+      filesystem permissions to ensure that only the group httpd
+      runs as may execute suEXEC.</p>
+
+      <p>If for example, your web server is configured to run as:</p>
+
+      <highlight language="config">
+User www
+Group webgroup
+      </highlight>
+
+      <p>and <program>suexec</program> is installed at
+      "/usr/local/apache2/bin/suexec", you should run:</p>
+
+      <example>
+          chgrp webgroup /usr/local/apache2/bin/suexec<br />
+          chmod 4750 /usr/local/apache2/bin/suexec<br />
+      </example>
+
+      <p>This will ensure that only the group httpd runs as can even
+      execute the suEXEC wrapper.</p>
+    </section>
 </section>
 
+
 <section id="enable"><title>Enabling &amp; Disabling
     suEXEC</title>
 
-    <p>Upon startup of Apache, it looks for the file
-    "suexec" in the "sbin" directory (default is
-    "/usr/local/apache/sbin/suexec"). If Apache finds a properly
+    <p>Upon startup of httpd, it looks for the file
+    <program>suexec</program> in the directory defined by the
+    <code>--sbindir</code> option (default is
+    "/usr/local/apache/sbin/suexec"). If httpd finds a properly
     configured suEXEC wrapper, it will print the following message
     to the error log:</p>
+
 <example>
-    [notice] suEXEC mechanism enabled (wrapper: <em>/path/to/suexec</em>)
+    [notice] suEXEC mechanism enabled (wrapper: <var>/path/to/suexec</var>)
 </example>
+
     <p>If you don't see this message at server startup, the server is
     most likely not finding the wrapper program where it expects
     it, or the executable is not installed <em>setuid root</em>.</p>
 
      <p>If you want to enable the suEXEC mechanism for the first time
-    and an Apache server is already running you must kill and
-    restart Apache. Restarting it with a simple HUP or USR1 signal
+    and an Apache HTTP Server is already running you must kill and
+    restart httpd. Restarting it with a simple HUP or USR1 signal
     will not be enough. </p>
      <p>If you want to disable suEXEC you should kill and restart
-    Apache after you have removed the "suexec" file. </p>
+    httpd after you have removed the <program>suexec</program> file.</p>
 </section>
 
 <section id="usage"><title>Using suEXEC</title>
 
+    <p>Requests for CGI programs will call the suEXEC wrapper only if
+    they are for a virtual host containing a <directive
+    module="mod_suexec">SuexecUserGroup</directive> directive or if
+    they are processed by <module>mod_userdir</module>.</p>
+
     <p><strong>Virtual Hosts:</strong><br /> One way to use the suEXEC
     wrapper is through the <directive
     module="mod_suexec">SuexecUserGroup</directive> directive in
     type="section">VirtualHost</directive> then the main server userid
     is assumed.</p>
 
-    <p><strong>User directories:</strong><br />
-     The suEXEC wrapper can also be used to execute CGI programs as
-    the user to which the request is being directed. This is
-    accomplished by using the "<strong><code>~</code></strong>"
-    character prefixing the user ID for whom execution is desired.
-    The only requirement needed for this feature to work is for CGI
-    execution to be enabled for the user and that the script must
-    meet the scrutiny of the <a href="#model">security checks</a>
-    above.</p>
-</section>
+    <p><strong>User directories:</strong><br /> Requests that are
+     processed by <module>mod_userdir</module> will call the suEXEC
+     wrapper to execute CGI programs under the userid of the requested
+     user directory.  The only requirement needed for this feature to
+     work is for CGI execution to be enabled for the user and that the
+     script must meet the scrutiny of the <a href="#model">security
+     checks</a> above.  See also the
+     <code>--with-suexec-userdir</code> <a href="#install">compile
+     time option</a>.</p> </section>
 
 <section id="debug"><title>Debugging suEXEC</title>
 
     <p>The suEXEC wrapper will write log information
-    to the file defined with the --with-suexec-logfile option as
-    indicated above. If you feel you have configured and installed
-    the wrapper properly, have a look at this log and the error_log
-    for the server to see where you may have gone astray.</p>
+    to the file defined with the <code>--with-suexec-logfile</code>
+    option as indicated above, or to syslog if <code>--with-suexec-syslog</code>
+    is used. If you feel you have configured and
+    installed the wrapper properly, have a look at the log and the
+    error_log for the server to see where you may have gone astray.
+    The output of <code>"suexec -V"</code> will show the options
+    used to compile suexec, if using a binary distribution.</p>
 
 </section>
 
 
     <p><strong>NOTE!</strong> This section may not be
     complete. For the latest revision of this section of the
-    documentation, see the Apache Group's <a
-    href="http://httpd.apache.org/docs-2.1/suexec.html">Online
+    documentation, see the <a
+    href="http://httpd.apache.org/docs/&httpd.docs;/suexec.html">Online
     Documentation</a> version.</p>
 
     <p>There are a few points of interest regarding
       <li><strong>suEXEC Points Of Interest</strong></li>
 
       <li>
-        Hierarchy limitations 
+        Hierarchy limitations
 
         <p class="indent">
-          For security and efficiency reasons, all suexec requests
+          For security and efficiency reasons, all suEXEC requests
           must remain within either a top-level document root for
           virtual host requests, or one top-level personal document
           root for userdir requests. For example, if you have four
           VirtualHosts configured, you would need to structure all
-          of your VHosts' document roots off of one main Apache
+          of your VHosts' document roots off of one main httpd
           document hierarchy to take advantage of suEXEC for
           VirtualHosts. (Example forthcoming.)
         </p>
       </li>
 
       <li>
-        suEXEC's PATH environment variable 
+        suEXEC's PATH environment variable
 
         <p class="indent">
           This can be a dangerous thing to change. Make certain
       </li>
 
       <li>
-        Altering the suEXEC code 
+        Altering the suEXEC code
 
         <p class="indent">
           Again, this can cause <strong>Big Trouble</strong> if you
 
 </section>
 
-</manualpage>
\ No newline at end of file
+</manualpage>