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.3</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.3</a></div><div id="page-content"><div id="preamble"><h1>suEXEC Support</h1>
21 <p><span>Available Languages: </span><a href="./en/suexec.html" title="English"> en </a> |
22 <a href="./ja/suexec.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
23 <a href="./ko/suexec.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
26 <p>The <strong>suEXEC</strong> feature provides
27 Apache users the ability
28 to run <strong>CGI</strong> and <strong>SSI</strong> programs
29 under user IDs different from the user ID of the calling
30 web server. Normally, when a CGI or SSI program executes, it
31 runs as the same user who is running the web server.</p>
33 <p>Used properly, this feature can reduce
34 considerably the security risks involved with allowing users to
35 develop and run private CGI or SSI programs. However, if suEXEC
36 is improperly configured, it can cause any number of problems
37 and possibly create new holes in your computer's security. If
38 you aren't familiar with managing <em>setuid root</em> programs
39 and the security issues they present, we highly recommend that
40 you not consider using suEXEC.</p>
42 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#before">Before we begin</a></li>
43 <li><img alt="" src="./images/down.gif" /> <a href="#model">suEXEC Security Model</a></li>
44 <li><img alt="" src="./images/down.gif" /> <a href="#install">Configuring & Installing
46 <li><img alt="" src="./images/down.gif" /> <a href="#enable">Enabling & Disabling
48 <li><img alt="" src="./images/down.gif" /> <a href="#usage">Using suEXEC</a></li>
49 <li><img alt="" src="./images/down.gif" /> <a href="#debug">Debugging suEXEC</a></li>
50 <li><img alt="" src="./images/down.gif" /> <a href="#jabberwock">Beware the Jabberwock:
51 Warnings & Examples</a></li>
53 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
55 <h2><a name="before" id="before">Before we begin</a></h2>
57 <p>Before jumping head-first into this document,
58 you should be aware of the assumptions made on the part of the
59 Apache Group and this document.</p>
61 <p>First, it is assumed that you are using a UNIX
62 derivative operating system that is capable of
63 <strong>setuid</strong> and <strong>setgid</strong> operations.
64 All command examples are given in this regard. Other platforms,
65 if they are capable of supporting suEXEC, may differ in their
68 <p>Second, it is assumed you are familiar with
69 some basic concepts of your computer's security and its
70 administration. This involves an understanding of
71 <strong>setuid/setgid</strong> operations and the various
72 effects they may have on your system and its level of
75 <p>Third, it is assumed that you are using an
76 <strong>unmodified</strong> version of suEXEC code. All code
77 for suEXEC has been carefully scrutinized and tested by the
78 developers as well as numerous beta testers. Every precaution
79 has been taken to ensure a simple yet solidly safe base of
80 code. Altering this code can cause unexpected problems and new
81 security risks. It is <strong>highly</strong> recommended you
82 not alter the suEXEC code unless you are well versed in the
83 particulars of security programming and are willing to share
84 your work with the Apache Group for consideration.</p>
86 <p>Fourth, and last, it has been the decision of
87 the Apache Group to <strong>NOT</strong> make suEXEC part of
88 the default installation of Apache. To this end, suEXEC
89 configuration requires of the administrator careful attention
90 to details. After due consideration has been given to the
91 various settings for suEXEC, the administrator may install
92 suEXEC through normal installation methods. The values for
93 these settings need to be carefully determined and specified by
94 the administrator to properly maintain system security during
95 the use of suEXEC functionality. It is through this detailed
96 process that the Apache Group hopes to limit suEXEC
97 installation only to those who are careful and determined
100 <p>Still with us? Yes? Good. Let's move on!</p>
101 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
102 <div class="section">
103 <h2><a name="model" id="model">suEXEC Security Model</a></h2>
105 <p>Before we begin configuring and installing
106 suEXEC, we will first discuss the security model you are about
107 to implement. By doing so, you may better understand what
108 exactly is going on inside suEXEC and what precautions are
109 taken to ensure your system's security.</p>
111 <p><strong>suEXEC</strong> is based on a setuid
112 "wrapper" program that is called by the main Apache web server.
113 This wrapper is called when an HTTP request is made for a CGI
114 or SSI program that the administrator has designated to run as
115 a userid other than that of the main server. When such a
116 request is made, Apache provides the suEXEC wrapper with the
117 program's name and the user and group IDs under which the
118 program is to execute.</p>
120 <p>The wrapper then employs the following process
121 to determine success or failure -- if any one of these
122 conditions fail, the program logs the failure and exits with an
123 error, otherwise it will continue:</p>
127 <strong>Is the user executing this wrapper a valid user of
128 this system?</strong>
131 This is to ensure that the user executing the wrapper is
132 truly a user of the system.
137 <strong>Was the wrapper called with the proper number of
141 The wrapper will only execute if it is given the proper
142 number of arguments. The proper argument format is known
143 to the Apache web server. If the wrapper is not receiving
144 the proper number of arguments, it is either being
145 hacked, or there is something wrong with the suEXEC
146 portion of your Apache binary.
151 <strong>Is this valid user allowed to run the
155 Is this user the user allowed to run this wrapper? Only
156 one user (the Apache user) is allowed to execute this
162 <strong>Does the target CGI or SSI program have an unsafe
163 hierarchical reference?</strong>
166 Does the target CGI or SSI program's path contain a leading
167 '/' or have a '..' backreference? These are not allowed; the
168 target CGI/SSI program must reside within suEXEC's document
169 root (see <code>--with-suexec-docroot=<em>DIR</em></code>
175 <strong>Is the target user name valid?</strong>
178 Does the target user exist?
183 <strong>Is the target group name valid?</strong>
186 Does the target group exist?
191 <strong>Is the target user <em>NOT</em> superuser?</strong>
195 Presently, suEXEC does not allow <code><em>root</em></code>
196 to execute CGI/SSI programs.
201 <strong>Is the target userid <em>ABOVE</em> the minimum ID
205 The minimum user ID number is specified during
206 configuration. This allows you to set the lowest possible
207 userid that will be allowed to execute CGI/SSI programs.
208 This is useful to block out "system" accounts.
213 <strong>Is the target group <em>NOT</em> the superuser
217 Presently, suEXEC does not allow the <code><em>root</em></code>
218 group to execute CGI/SSI programs.
223 <strong>Is the target groupid <em>ABOVE</em> the minimum ID
227 The minimum group ID number is specified during
228 configuration. This allows you to set the lowest possible
229 groupid that will be allowed to execute CGI/SSI programs.
230 This is useful to block out "system" groups.
235 <strong>Can the wrapper successfully become the target user
239 Here is where the program becomes the target user and
240 group via setuid and setgid calls. The group access list
241 is also initialized with all of the groups of which the
247 <strong>Can we change directory to the one in which the target
248 CGI/SSI program resides?</strong>
251 If it doesn't exist, it can't very well contain files. If we
252 can't change directory to it, it might aswell not exist.
257 <strong>Is the directory within the Apache
261 If the request is for a regular portion of the server, is
262 the requested directory within suEXEC's document root? If
263 the request is for a UserDir, is the requested directory
264 within the directory configured as suEXEC's userdir (see
265 <a href="#install">suEXEC's configuration options</a>)?
270 <strong>Is the directory <em>NOT</em> writable by anyone
274 We don't want to open up the directory to others; only
275 the owner user may be able to alter this directories
281 <strong>Does the target CGI/SSI program exist?</strong>
284 If it doesn't exists, it can't very well be executed.
289 <strong>Is the target CGI/SSI program <em>NOT</em> writable
290 by anyone else?</strong>
293 We don't want to give anyone other than the owner the
294 ability to change the CGI/SSI program.
299 <strong>Is the target CGI/SSI program <em>NOT</em> setuid or
303 We do not want to execute programs that will then change
309 <strong>Is the target user/group the same as the program's
313 Is the user the owner of the file?
318 <strong>Can we successfully clean the process environment
319 to ensure safe operations?</strong>
322 suEXEC cleans the process' environment by establishing a
323 safe execution PATH (defined during configuration), as
324 well as only passing through those variables whose names
325 are listed in the safe environment list (also created
326 during configuration).
331 <strong>Can we successfully become the target CGI/SSI program
332 and execute?</strong>
335 Here is where suEXEC ends and the target CGI/SSI program begins.
340 <p>This is the standard operation of the
341 suEXEC wrapper's security model. It is somewhat stringent and
342 can impose new limitations and guidelines for CGI/SSI design,
343 but it was developed carefully step-by-step with security in
346 <p>For more information as to how this security
347 model can limit your possibilities in regards to server
348 configuration, as well as what security risks can be avoided
349 with a proper suEXEC setup, see the <a href="#jabberwock">"Beware the Jabberwock"</a> section of this
351 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
352 <div class="section">
353 <h2><a name="install" id="install">Configuring & Installing
356 <p>Here's where we begin the fun.</p>
358 <p><strong>suEXEC configuration
359 options</strong><br />
363 <dt><code>--enable-suexec</code></dt>
365 <dd>This option enables the suEXEC feature which is never
366 installed or activated by default. At least one
367 <code>--with-suexec-xxxxx</code> option has to be provided
368 together with the <code>--enable-suexec</code> option to let
369 APACI accept your request for using the suEXEC feature.</dd>
371 <dt><code>--with-suexec-bin=<em>PATH</em></code></dt>
373 <dd>The path to the <code>suexec</code> binary must be hard-coded
374 in the server for security reasons. Use this option to override
375 the default path. <em>e.g.</em>
376 <code>--with-suexec-bin=/usr/sbin/suexec</code></dd>
378 <dt><code>--with-suexec-caller=<em>UID</em></code></dt>
380 <dd>The <a href="mod/mpm_common.html#user">username</a> under which
381 Apache normally runs. This is the only user allowed to
382 execute this program.</dd>
384 <dt><code>--with-suexec-userdir=<em>DIR</em></code></dt>
386 <dd>Define to be the subdirectory under users' home
387 directories where suEXEC access should be allowed. All
388 executables under this directory will be executable by suEXEC
389 as the user so they should be "safe" programs. If you are
390 using a "simple" UserDir directive (ie. one without a "*" in
391 it) this should be set to the same value. suEXEC will not
392 work properly in cases where the UserDir directive points to
393 a location that is not the same as the user's home directory
394 as referenced in the passwd file. Default value is
396 If you have virtual hosts with a different UserDir for each,
397 you will need to define them to all reside in one parent
398 directory; then name that parent directory here. <strong>If
399 this is not defined properly, "~userdir" cgi requests will
400 not work!</strong></dd>
402 <dt><code>--with-suexec-docroot=<em>DIR</em></code></dt>
404 <dd>Define as the DocumentRoot set for Apache. This will be
405 the only hierarchy (aside from UserDirs) that can be used for
406 suEXEC behavior. The default directory is the <code>--datadir</code>
407 value with the suffix "/htdocs", <em>e.g.</em> if you configure
408 with "<code>--datadir=/home/apache</code>" the directory
409 "/home/apache/htdocs" is used as document root for the suEXEC
412 <dt><code>--with-suexec-uidmin=<em>UID</em></code></dt>
414 <dd>Define this as the lowest UID allowed to be a target user
415 for suEXEC. For most systems, 500 or 100 is common. Default
418 <dt><code>--with-suexec-gidmin=<em>GID</em></code></dt>
420 <dd>Define this as the lowest GID allowed to be a target
421 group for suEXEC. For most systems, 100 is common and
422 therefore used as default value.</dd>
424 <dt><code>--with-suexec-logfile=<em>FILE</em></code></dt>
426 <dd>This defines the filename to which all suEXEC
427 transactions and errors are logged (useful for auditing and
428 debugging purposes). By default the logfile is named
429 "suexec_log" and located in your standard logfile directory
430 (<code>--logfiledir</code>).</dd>
432 <dt><code>--with-suexec-safepath=<em>PATH</em></code></dt>
434 <dd>Define a safe PATH environment to pass to CGI
435 executables. Default value is
436 "/usr/local/bin:/usr/bin:/bin".</dd>
439 <p><strong>Compiling and installing the suEXEC
440 wrapper</strong><br />
441 If you have enabled the suEXEC feature with the
442 <code>--enable-suexec</code> option the <code>suexec</code> binary
443 (together with Apache itself) is automatically built if you execute
444 the <code>make</code> command.<br />
445 After all components have been built you can execute the
446 command <code>make install</code> to install them. The binary image
447 <code>suexec</code> is installed in the directory defined by the
448 <code>--sbindir</code> option. The default location is
449 "/usr/local/apache2/sbin/suexec".<br />
450 Please note that you need <strong><em>root
451 privileges</em></strong> for the installation step. In order
452 for the wrapper to set the user ID, it must be installed as
453 owner <code><em>root</em></code> and must have the setuserid
454 execution bit set for file modes.</p>
456 <p><strong>Setting paranoid permissions</strong><br />
457 Although the suEXEC wrapper will check to ensure that its
458 caller is the correct user as specified with the
459 <code>--with-suexec-caller</code> <code class="program"><a href="./programs/configure.html">configure</a></code>
461 always the possibility that a system or library call suEXEC uses
462 before this check may be exploitable on your system. To counter
463 this, and because it is best-practise in general, you should use
464 filesystem permissions to ensure that only the group Apache
465 runs as may execute suEXEC.</p>
467 <p>If for example, your web server is configured to run as:</p>
469 <div class="example"><p><code>
474 <p>and <code class="program"><a href="./programs/suexec.html">suexec</a></code> is installed at
475 "/usr/local/apache2/sbin/suexec", you should run:</p>
477 <div class="example"><p><code>
478 chgrp webgroup /usr/local/apache2/bin/suexec<br />
479 chmod 4750 /usr/local/apache2/bin/suexec<br />
482 <p>This will ensure that only the group Apache runs as can even
483 execute the suEXEC wrapper.</p>
484 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
485 <div class="section">
486 <h2><a name="enable" id="enable">Enabling & Disabling
489 <p>Upon startup of Apache, it looks for the file
490 <code class="program"><a href="./programs/suexec.html">suexec</a></code> in the directory defined by the
491 <code>--sbindir</code> option (default is
492 "/usr/local/apache/sbin/suexec"). If Apache finds a properly
493 configured suEXEC wrapper, it will print the following message
494 to the error log:</p>
496 <div class="example"><p><code>
497 [notice] suEXEC mechanism enabled (wrapper: <var>/path/to/suexec</var>)
500 <p>If you don't see this message at server startup, the server is
501 most likely not finding the wrapper program where it expects
502 it, or the executable is not installed <em>setuid root</em>.</p>
504 <p>If you want to enable the suEXEC mechanism for the first time
505 and an Apache server is already running you must kill and
506 restart Apache. Restarting it with a simple HUP or USR1 signal
507 will not be enough. </p>
508 <p>If you want to disable suEXEC you should kill and restart
509 Apache after you have removed the <code class="program"><a href="./programs/suexec.html">suexec</a></code> file.</p>
510 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
511 <div class="section">
512 <h2><a name="usage" id="usage">Using suEXEC</a></h2>
514 <p>Requests for CGI programs will call the suEXEC wrapper only if
515 they are for a virtual host containing a <code class="directive"><a href="./mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code> directive or if
516 they are processed by <code class="module"><a href="./mod/mod_userdir.html">mod_userdir</a></code>.</p>
518 <p><strong>Virtual Hosts:</strong><br /> One way to use the suEXEC
519 wrapper is through the <code class="directive"><a href="./mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code> directive in
520 <code class="directive"><a href="./mod/core.html#virtualhost">VirtualHost</a></code> definitions. By
521 setting this directive to values different from the main server
522 user ID, all requests for CGI resources will be executed as the
523 <em>User</em> and <em>Group</em> defined for that <code class="directive"><a href="./mod/core.html#virtualhost"><VirtualHost></a></code>. If this
524 directive is not specified for a <code class="directive"><a href="./mod/core.html#virtualhost"><VirtualHost></a></code> then the main server userid
527 <p><strong>User directories:</strong><br /> Requests that are
528 processed by <code class="module"><a href="./mod/mod_userdir.html">mod_userdir</a></code> will call the suEXEC
529 wrapper to execute CGI programs under the userid of the requested
530 user directory. The only requirement needed for this feature to
531 work is for CGI execution to be enabled for the user and that the
532 script must meet the scrutiny of the <a href="#model">security
533 checks</a> above. See also the
534 <code>--with-suexec-userdir</code> <a href="#install">compile
535 time option</a>.</p> </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
536 <div class="section">
537 <h2><a name="debug" id="debug">Debugging suEXEC</a></h2>
539 <p>The suEXEC wrapper will write log information
540 to the file defined with the <code>--with-suexec-logfile</code>
541 option as indicated above. If you feel you have configured and
542 installed the wrapper properly, have a look at this log and the
543 error_log for the server to see where you may have gone astray.</p>
545 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
546 <div class="section">
547 <h2><a name="jabberwock" id="jabberwock">Beware the Jabberwock:
548 Warnings & Examples</a></h2>
550 <p><strong>NOTE!</strong> This section may not be
551 complete. For the latest revision of this section of the
552 documentation, see the Apache Group's <a href="http://httpd.apache.org/docs/trunk/suexec.html">Online
553 Documentation</a> version.</p>
555 <p>There are a few points of interest regarding
556 the wrapper that can cause limitations on server setup. Please
557 review these before submitting any "bugs" regarding suEXEC.</p>
560 <li><strong>suEXEC Points Of Interest</strong></li>
563 Hierarchy limitations
566 For security and efficiency reasons, all suEXEC requests
567 must remain within either a top-level document root for
568 virtual host requests, or one top-level personal document
569 root for userdir requests. For example, if you have four
570 VirtualHosts configured, you would need to structure all
571 of your VHosts' document roots off of one main Apache
572 document hierarchy to take advantage of suEXEC for
573 VirtualHosts. (Example forthcoming.)
578 suEXEC's PATH environment variable
581 This can be a dangerous thing to change. Make certain
582 every path you include in this define is a
583 <strong>trusted</strong> directory. You don't want to
584 open people up to having someone from across the world
585 running a trojan horse on them.
590 Altering the suEXEC code
593 Again, this can cause <strong>Big Trouble</strong> if you
594 try this without knowing what you are doing. Stay away
595 from it if at all possible.
601 <div class="bottomlang">
602 <p><span>Available Languages: </span><a href="./en/suexec.html" title="English"> en </a> |
603 <a href="./ja/suexec.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
604 <a href="./ko/suexec.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
605 </div><div id="footer">
606 <p class="apache">Copyright 1995-2005 The Apache Software Foundation or its licensors, as applicable.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
607 <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>