1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>suEXEC Support - Apache HTTP Server</title>
9 <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="./images/favicon.ico" rel="shortcut icon" /></head>
13 <body id="manual-page"><div id="page-header">
14 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
15 <p class="apache">Apache HTTP Server Version 2.1</p>
16 <img alt="" src="./images/feather.gif" /></div>
17 <div class="up"><a href="./"><img title="<-" alt="<-" src="./images/left.gif" /></a></div>
19 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="./">Version 2.1</a></div><div id="page-content"><div id="preamble"><h1>suEXEC Support</h1>
21 <p><span>Available Languages: </span><a href="./en/suexec.html" hreflang="en" title="English"> en </a> | <a href="./ja/suexec.html" hreflang="ja" title="Japanese"> ja </a> | <a href="./ko/suexec.html" hreflang="ko" title="Korean"> ko </a></p>
24 <p>The <strong>suEXEC</strong> feature provides
25 Apache users the ability
26 to run <strong>CGI</strong> and <strong>SSI</strong> programs
27 under user IDs different from the user ID of the calling
28 web-server. Normally, when a CGI or SSI program executes, it
29 runs as the same user who is running the web server.</p>
31 <p>Used properly, this feature can reduce
32 considerably the security risks involved with allowing users to
33 develop and run private CGI or SSI programs. However, if suEXEC
34 is improperly configured, it can cause any number of problems
35 and possibly create new holes in your computer's security. If
36 you aren't familiar with managing setuid root programs and the
37 security issues they present, we highly recommend that you not
38 consider using suEXEC.</p>
40 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#before">Before we begin</a></li>
41 <li><img alt="" src="./images/down.gif" /> <a href="#model">suEXEC Security Model</a></li>
42 <li><img alt="" src="./images/down.gif" /> <a href="#install">Configuring & Installing
44 <li><img alt="" src="./images/down.gif" /> <a href="#enable">Enabling & Disabling
46 <li><img alt="" src="./images/down.gif" /> <a href="#usage">Using suEXEC</a></li>
47 <li><img alt="" src="./images/down.gif" /> <a href="#debug">Debugging suEXEC</a></li>
48 <li><img alt="" src="./images/down.gif" /> <a href="#jabberwock">Beware the Jabberwock:
49 Warnings & Examples</a></li>
51 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
53 <h2><a name="before" id="before">Before we begin</a></h2>
55 <p>Before jumping head-first into this document,
56 you should be aware of the assumptions made on the part of the
57 Apache Group and this document.</p>
59 <p>First, it is assumed that you are using a UNIX
60 derivative operating system that is capable of
61 <strong>setuid</strong> and <strong>setgid</strong> operations.
62 All command examples are given in this regard. Other platforms,
63 if they are capable of supporting suEXEC, may differ in their
66 <p>Second, it is assumed you are familiar with
67 some basic concepts of your computer's security and its
68 administration. This involves an understanding of
69 <strong>setuid/setgid</strong> operations and the various
70 effects they may have on your system and its level of
73 <p>Third, it is assumed that you are using an
74 <strong>unmodified</strong> version of suEXEC code. All code
75 for suEXEC has been carefully scrutinized and tested by the
76 developers as well as numerous beta testers. Every precaution
77 has been taken to ensure a simple yet solidly safe base of
78 code. Altering this code can cause unexpected problems and new
79 security risks. It is <strong>highly</strong> recommended you
80 not alter the suEXEC code unless you are well versed in the
81 particulars of security programming and are willing to share
82 your work with the Apache Group for consideration.</p>
84 <p>Fourth, and last, it has been the decision of
85 the Apache Group to <strong>NOT</strong> make suEXEC part of
86 the default installation of Apache. To this end, suEXEC
87 configuration requires of the administrator careful attention
88 to details. After due consideration has been given to the
89 various settings for suEXEC, the administrator may install
90 suEXEC through normal installation methods. The values for
91 these settings need to be carefully determined and specified by
92 the administrator to properly maintain system security during
93 the use of suEXEC functionality. It is through this detailed
94 process that the Apache Group hopes to limit suEXEC
95 installation only to those who are careful and determined
98 <p>Still with us? Yes? Good. Let's move on!</p>
99 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
100 <div class="section">
101 <h2><a name="model" id="model">suEXEC Security Model</a></h2>
103 <p>Before we begin configuring and installing
104 suEXEC, we will first discuss the security model you are about
105 to implement. By doing so, you may better understand what
106 exactly is going on inside suEXEC and what precautions are
107 taken to ensure your system's security.</p>
109 <p><strong>suEXEC</strong> is based on a setuid
110 "wrapper" program that is called by the main Apache web server.
111 This wrapper is called when an HTTP request is made for a CGI
112 or SSI program that the administrator has designated to run as
113 a userid other than that of the main server. When such a
114 request is made, Apache provides the suEXEC wrapper with the
115 program's name and the user and group IDs under which the
116 program is to execute.</p>
118 <p>The wrapper then employs the following process
119 to determine success or failure -- if any one of these
120 conditions fail, the program logs the failure and exits with an
121 error, otherwise it will continue:</p>
125 <strong>Was the wrapper called with the proper number of
129 The wrapper will only execute if it is given the proper
130 number of arguments. The proper argument format is known
131 to the Apache web server. If the wrapper is not receiving
132 the proper number of arguments, it is either being
133 hacked, or there is something wrong with the suEXEC
134 portion of your Apache binary.
139 <strong>Is the user executing this wrapper a valid user of
140 this system?</strong>
143 This is to ensure that the user executing the wrapper is
144 truly a user of the system.
149 <strong>Is this valid user allowed to run the
153 Is this user the user allowed to run this wrapper? Only
154 one user (the Apache user) is allowed to execute this
160 <strong>Does the target program have an unsafe hierarchical
164 Does the target program contain a leading '/' or have a
165 '..' backreference? These are not allowed; the target
166 program must reside within the Apache webspace.
171 <strong>Is the target user name valid?</strong>
174 Does the target user exist?
179 <strong>Is the target group name valid?</strong>
182 Does the target group exist?
187 <strong>Is the target user <em>NOT</em> superuser?</strong>
191 Presently, suEXEC does not allow 'root' to execute
197 <strong>Is the target userid <em>ABOVE</em> the minimum ID
201 The minimum user ID number is specified during
202 configuration. This allows you to set the lowest possible
203 userid that will be allowed to execute CGI/SSI programs.
204 This is useful to block out "system" accounts.
209 <strong>Is the target group <em>NOT</em> the superuser
213 Presently, suEXEC does not allow the 'root' group to
214 execute CGI/SSI programs.
219 <strong>Is the target groupid <em>ABOVE</em> the minimum ID
223 The minimum group ID number is specified during
224 configuration. This allows you to set the lowest possible
225 groupid that will be allowed to execute CGI/SSI programs.
226 This is useful to block out "system" groups.
231 <strong>Can the wrapper successfully become the target user
235 Here is where the program becomes the target user and
236 group via setuid and setgid calls. The group access list
237 is also initialized with all of the groups of which the
243 <strong>Does the directory in which the program resides
247 If it doesn't exist, it can't very well contain files.
252 <strong>Is the directory within the Apache
256 If the request is for a regular portion of the server, is
257 the requested directory within the server's document
258 root? If the request is for a UserDir, is the requested
259 directory within the user's document root?
264 <strong>Is the directory <em>NOT</em> writable by anyone
268 We don't want to open up the directory to others; only
269 the owner user may be able to alter this directories
275 <strong>Does the target program exist?</strong>
278 If it doesn't exists, it can't very well be executed.
283 <strong>Is the target program <em>NOT</em> writable by
284 anyone else?</strong>
287 We don't want to give anyone other than the owner the
288 ability to change the program.
293 <strong>Is the target program <em>NOT</em> setuid or
297 We do not want to execute programs that will then change
303 <strong>Is the target user/group the same as the program's
307 Is the user the owner of the file?
312 <strong>Can we successfully clean the process environment
313 to ensure safe operations?</strong>
316 suEXEC cleans the process' environment by establishing a
317 safe execution PATH (defined during configuration), as
318 well as only passing through those variables whose names
319 are listed in the safe environment list (also created
320 during configuration).
325 <strong>Can we successfully become the target program and
329 Here is where suEXEC ends and the target program begins.
334 <p>This is the standard operation of the
335 suEXEC wrapper's security model. It is somewhat stringent and
336 can impose new limitations and guidelines for CGI/SSI design,
337 but it was developed carefully step-by-step with security in
340 <p>For more information as to how this security
341 model can limit your possibilities in regards to server
342 configuration, as well as what security risks can be avoided
343 with a proper suEXEC setup, see the <a href="#jabberwock">"Beware the Jabberwock"</a> section of this
345 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
346 <div class="section">
347 <h2><a name="install" id="install">Configuring & Installing
350 <p>Here's where we begin the fun.</p>
352 <p><strong>suEXEC configuration
353 options</strong><br />
357 <dt><code>--enable-suexec</code></dt>
359 <dd>This option enables the suEXEC feature which is never
360 installed or activated by default. At least one
361 --with-suexec-xxxxx option has to be provided together with the
362 --enable-suexec option to let APACI accept your request for
363 using the suEXEC feature.</dd>
365 <dt><code>--with-suexec-bin=<em>PATH</em></code></dt>
367 <dd>The path to the suexec binary must be hard-coded in
368 the server for security reasons. Use this option to override
369 the default path. <em>e.g.</em>
370 <code>--with-suexec-bin=/usr/sbin/suexec</code></dd>
372 <dt><code>--with-suexec-caller=<em>UID</em></code></dt>
374 <dd>The <a href="mod/mpm_common.html#user">username</a> under which
375 Apache normally runs. This is the only user allowed to
376 execute this program.</dd>
378 <dt><code>--with-suexec-userdir=<em>DIR</em></code></dt>
380 <dd>Define to be the subdirectory under users' home
381 directories where suEXEC access should be allowed. All
382 executables under this directory will be executable by suEXEC
383 as the user so they should be "safe" programs. If you are
384 using a "simple" UserDir directive (ie. one without a "*" in
385 it) this should be set to the same value. suEXEC will not
386 work properly in cases where the UserDir directive points to
387 a location that is not the same as the user's home directory
388 as referenced in the passwd file. Default value is
390 If you have virtual hosts with a different UserDir for each,
391 you will need to define them to all reside in one parent
392 directory; then name that parent directory here. <strong>If
393 this is not defined properly, "~userdir" cgi requests will
394 not work!</strong></dd>
396 <dt><code>--with-suexec-docroot=<em>DIR</em></code></dt>
398 <dd>Define as the DocumentRoot set for Apache. This will be
399 the only hierarchy (aside from UserDirs) that can be used for
400 suEXEC behavior. The default directory is the --datadir value
401 with the suffix "/htdocs", <em>e.g.</em> if you configure
402 with "<code>--datadir=/home/apache</code>" the directory
403 "/home/apache/htdocs" is used as document root for the suEXEC
406 <dt><code>--with-suexec-uidmin=<em>UID</em></code></dt>
408 <dd>Define this as the lowest UID allowed to be a target user
409 for suEXEC. For most systems, 500 or 100 is common. Default
412 <dt><code>--with-suexec-gidmin=<em>GID</em></code></dt>
414 <dd>Define this as the lowest GID allowed to be a target
415 group for suEXEC. For most systems, 100 is common and
416 therefore used as default value.</dd>
418 <dt><code>--with-suexec-logfile=<em>FILE</em></code></dt>
420 <dd>This defines the filename to which all suEXEC
421 transactions and errors are logged (useful for auditing and
422 debugging purposes). By default the logfile is named
423 "suexec_log" and located in your standard logfile directory
426 <dt><code>--with-suexec-safepath=<em>PATH</em></code></dt>
428 <dd>Define a safe PATH environment to pass to CGI
429 executables. Default value is
430 "/usr/local/bin:/usr/bin:/bin".</dd>
433 <p><strong>Checking your suEXEC
435 Before you compile and install the suEXEC wrapper you can
436 check the configuration with the --layout option.<br />
439 <div class="example"><p><code>
441 suexec binary: /usr/local/apache/sbin/suexec<br />
442 document root: /usr/local/apache/share/htdocs<br />
443 userdir suffix: public_html<br />
444 logfile: /usr/local/apache/var/log/suexec_log<br />
445 safe path: /usr/local/bin:/usr/bin:/bin<br />
447 minimum user ID: 100<br />
448 minimum group ID: 100<br />
451 <p><strong>Compiling and installing the suEXEC
452 wrapper</strong><br />
453 If you have enabled the suEXEC feature with the
454 --enable-suexec option the suexec binary (together with Apache
455 itself) is automatically built if you execute the command
457 After all components have been built you can execute the
458 command "make install" to install them. The binary image
459 "suexec" is installed in the directory defined by the --sbindir
460 option. Default location is
461 "/usr/local/apache/sbin/suexec".<br />
462 Please note that you need <strong><em>root
463 privileges</em></strong> for the installation step. In order
464 for the wrapper to set the user ID, it must be installed as
465 owner <code><em>root</em></code> and must have the setuserid
466 execution bit set for file modes.</p>
468 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
469 <div class="section">
470 <h2><a name="enable" id="enable">Enabling & Disabling
473 <p>Upon startup of Apache, it looks for the file
474 "suexec" in the "sbin" directory (default is
475 "/usr/local/apache/sbin/suexec"). If Apache finds a properly
476 configured suEXEC wrapper, it will print the following message
477 to the error log:</p>
478 <div class="example"><p><code>
479 [notice] suEXEC mechanism enabled (wrapper: <em>/path/to/suexec</em>)
481 <p>If you don't see this message at server startup, the server is
482 most likely not finding the wrapper program where it expects
483 it, or the executable is not installed <em>setuid root</em>.</p>
485 <p>If you want to enable the suEXEC mechanism for the first time
486 and an Apache server is already running you must kill and
487 restart Apache. Restarting it with a simple HUP or USR1 signal
488 will not be enough. </p>
489 <p>If you want to disable suEXEC you should kill and restart
490 Apache after you have removed the "suexec" file. </p>
491 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
492 <div class="section">
493 <h2><a name="usage" id="usage">Using suEXEC</a></h2>
495 <p><strong>Virtual Hosts:</strong><br /> One way to use the suEXEC
496 wrapper is through the <code class="directive"><a href="./mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code> directive in
497 <code class="directive"><a href="./mod/core.html#virtualhost">VirtualHost</a></code> definitions. By
498 setting this directive to values different from the main server
499 user ID, all requests for CGI resources will be executed as the
500 <em>User</em> and <em>Group</em> defined for that <code class="directive"><a href="./mod/core.html#virtualhost"><VirtualHost></a></code>. If this
501 directive is not specified for a <code class="directive"><a href="./mod/core.html#virtualhost"><VirtualHost></a></code> then the main server userid
504 <p><strong>User directories:</strong><br />
505 The suEXEC wrapper can also be used to execute CGI programs as
506 the user to which the request is being directed. This is
507 accomplished by using the "<strong><code>~</code></strong>"
508 character prefixing the user ID for whom execution is desired.
509 The only requirement needed for this feature to work is for CGI
510 execution to be enabled for the user and that the script must
511 meet the scrutiny of the <a href="#model">security checks</a>
513 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
514 <div class="section">
515 <h2><a name="debug" id="debug">Debugging suEXEC</a></h2>
517 <p>The suEXEC wrapper will write log information
518 to the file defined with the --with-suexec-logfile option as
519 indicated above. If you feel you have configured and installed
520 the wrapper properly, have a look at this log and the error_log
521 for the server to see where you may have gone astray.</p>
523 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
524 <div class="section">
525 <h2><a name="jabberwock" id="jabberwock">Beware the Jabberwock:
526 Warnings & Examples</a></h2>
528 <p><strong>NOTE!</strong> This section may not be
529 complete. For the latest revision of this section of the
530 documentation, see the Apache Group's <a href="http://httpd.apache.org/docs-2.1/suexec.html">Online
531 Documentation</a> version.</p>
533 <p>There are a few points of interest regarding
534 the wrapper that can cause limitations on server setup. Please
535 review these before submitting any "bugs" regarding suEXEC.</p>
538 <li><strong>suEXEC Points Of Interest</strong></li>
541 Hierarchy limitations
544 For security and efficiency reasons, all suexec requests
545 must remain within either a top-level document root for
546 virtual host requests, or one top-level personal document
547 root for userdir requests. For example, if you have four
548 VirtualHosts configured, you would need to structure all
549 of your VHosts' document roots off of one main Apache
550 document hierarchy to take advantage of suEXEC for
551 VirtualHosts. (Example forthcoming.)
556 suEXEC's PATH environment variable
559 This can be a dangerous thing to change. Make certain
560 every path you include in this define is a
561 <strong>trusted</strong> directory. You don't want to
562 open people up to having someone from across the world
563 running a trojan horse on them.
568 Altering the suEXEC code
571 Again, this can cause <strong>Big Trouble</strong> if you
572 try this without knowing what you are doing. Stay away
573 from it if at all possible.
579 <div class="bottomlang">
580 <p><span>Available Languages: </span><a href="./en/suexec.html" hreflang="en" title="English"> en </a> | <a href="./ja/suexec.html" hreflang="ja" title="Japanese"> ja </a> | <a href="./ko/suexec.html" hreflang="ko" title="Korean"> ko </a></p>
581 </div><div id="footer">
582 <p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
583 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div>