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.0</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/">Documentation</a> > <a href="./">Version 2.0</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> |
24 <a href="./tr/suexec.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
27 <p>The <strong>suEXEC</strong> feature provides
28 Apache users the ability
29 to run <strong>CGI</strong> and <strong>SSI</strong> programs
30 under user IDs different from the user ID of the calling
31 web server. Normally, when a CGI or SSI program executes, it
32 runs as the same user who is running the web server.</p>
34 <p>Used properly, this feature can reduce
35 considerably the security risks involved with allowing users to
36 develop and run private CGI or SSI programs. However, if suEXEC
37 is improperly configured, it can cause any number of problems
38 and possibly create new holes in your computer's security. If
39 you aren't familiar with managing <em>setuid root</em> programs
40 and the security issues they present, we highly recommend that
41 you not consider using suEXEC.</p>
43 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#before">Before we begin</a></li>
44 <li><img alt="" src="./images/down.gif" /> <a href="#model">suEXEC Security Model</a></li>
45 <li><img alt="" src="./images/down.gif" /> <a href="#install">Configuring & Installing
47 <li><img alt="" src="./images/down.gif" /> <a href="#enable">Enabling & Disabling
49 <li><img alt="" src="./images/down.gif" /> <a href="#usage">Using suEXEC</a></li>
50 <li><img alt="" src="./images/down.gif" /> <a href="#debug">Debugging suEXEC</a></li>
51 <li><img alt="" src="./images/down.gif" /> <a href="#jabberwock">Beware the Jabberwock:
52 Warnings & Examples</a></li>
54 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
56 <h2><a name="before" id="before">Before we begin</a></h2>
58 <p>Before jumping head-first into this document,
59 you should be aware of the assumptions made on the part of the
60 Apache Group and this document.</p>
62 <p>First, it is assumed that you are using a UNIX
63 derivative operating system that is capable of
64 <strong>setuid</strong> and <strong>setgid</strong> operations.
65 All command examples are given in this regard. Other platforms,
66 if they are capable of supporting suEXEC, may differ in their
69 <p>Second, it is assumed you are familiar with
70 some basic concepts of your computer's security and its
71 administration. This involves an understanding of
72 <strong>setuid/setgid</strong> operations and the various
73 effects they may have on your system and its level of
76 <p>Third, it is assumed that you are using an
77 <strong>unmodified</strong> version of suEXEC code. All code
78 for suEXEC has been carefully scrutinized and tested by the
79 developers as well as numerous beta testers. Every precaution
80 has been taken to ensure a simple yet solidly safe base of
81 code. Altering this code can cause unexpected problems and new
82 security risks. It is <strong>highly</strong> recommended you
83 not alter the suEXEC code unless you are well versed in the
84 particulars of security programming and are willing to share
85 your work with the Apache Group for consideration.</p>
87 <p>Fourth, and last, it has been the decision of
88 the Apache Group to <strong>NOT</strong> make suEXEC part of
89 the default installation of Apache. To this end, suEXEC
90 configuration requires of the administrator careful attention
91 to details. After due consideration has been given to the
92 various settings for suEXEC, the administrator may install
93 suEXEC through normal installation methods. The values for
94 these settings need to be carefully determined and specified by
95 the administrator to properly maintain system security during
96 the use of suEXEC functionality. It is through this detailed
97 process that the Apache Group hopes to limit suEXEC
98 installation only to those who are careful and determined
101 <p>Still with us? Yes? Good. Let's move on!</p>
102 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
103 <div class="section">
104 <h2><a name="model" id="model">suEXEC Security Model</a></h2>
106 <p>Before we begin configuring and installing
107 suEXEC, we will first discuss the security model you are about
108 to implement. By doing so, you may better understand what
109 exactly is going on inside suEXEC and what precautions are
110 taken to ensure your system's security.</p>
112 <p><strong>suEXEC</strong> is based on a setuid
113 "wrapper" program that is called by the main Apache web server.
114 This wrapper is called when an HTTP request is made for a CGI
115 or SSI program that the administrator has designated to run as
116 a userid other than that of the main server. When such a
117 request is made, Apache provides the suEXEC wrapper with the
118 program's name and the user and group IDs under which the
119 program is to execute.</p>
121 <p>The wrapper then employs the following process
122 to determine success or failure -- if any one of these
123 conditions fail, the program logs the failure and exits with an
124 error, otherwise it will continue:</p>
128 <strong>Is the user executing this wrapper a valid user of
129 this system?</strong>
132 This is to ensure that the user executing the wrapper is
133 truly a user of the system.
138 <strong>Was the wrapper called with the proper number of
142 The wrapper will only execute if it is given the proper
143 number of arguments. The proper argument format is known
144 to the Apache web server. If the wrapper is not receiving
145 the proper number of arguments, it is either being
146 hacked, or there is something wrong with the suEXEC
147 portion of your Apache binary.
152 <strong>Is this valid user allowed to run the
156 Is this user the user allowed to run this wrapper? Only
157 one user (the Apache user) is allowed to execute this
163 <strong>Does the target CGI or SSI program have an unsafe
164 hierarchical reference?</strong>
167 Does the target CGI or SSI program's path contain a leading
168 '/' or have a '..' backreference? These are not allowed; the
169 target CGI/SSI program must reside within suEXEC's document
170 root (see <code>--with-suexec-docroot=<em>DIR</em></code>
176 <strong>Is the target user name valid?</strong>
179 Does the target user exist?
184 <strong>Is the target group name valid?</strong>
187 Does the target group exist?
192 <strong>Is the target user <em>NOT</em> superuser?</strong>
196 Presently, suEXEC does not allow <code><em>root</em></code>
197 to execute CGI/SSI programs.
202 <strong>Is the target userid <em>ABOVE</em> the minimum ID
206 The minimum user ID number is specified during
207 configuration. This allows you to set the lowest possible
208 userid that will be allowed to execute CGI/SSI programs.
209 This is useful to block out "system" accounts.
214 <strong>Is the target group <em>NOT</em> the superuser
218 Presently, suEXEC does not allow the <code><em>root</em></code>
219 group to execute CGI/SSI programs.
224 <strong>Is the target groupid <em>ABOVE</em> the minimum ID
228 The minimum group ID number is specified during
229 configuration. This allows you to set the lowest possible
230 groupid that will be allowed to execute CGI/SSI programs.
231 This is useful to block out "system" groups.
236 <strong>Can the wrapper successfully become the target user
240 Here is where the program becomes the target user and
241 group via setuid and setgid calls. The group access list
242 is also initialized with all of the groups of which the
248 <strong>Can we change directory to the one in which the target
249 CGI/SSI program resides?</strong>
252 If it doesn't exist, it can't very well contain files. If we
253 can't change directory to it, it might aswell not exist.
258 <strong>Is the directory within the Apache
262 If the request is for a regular portion of the server, is
263 the requested directory within suEXEC's document root? If
264 the request is for a <code class="directive"><a href="./mod/mod_userdir.html#userdir">UserDir</a></code>, is the requested directory
265 within the directory configured as suEXEC's userdir (see
266 <a href="#install">suEXEC's configuration options</a>)?
271 <strong>Is the directory <em>NOT</em> writable by anyone
275 We don't want to open up the directory to others; only
276 the owner user may be able to alter this directories
282 <strong>Does the target CGI/SSI program exist?</strong>
285 If it doesn't exists, it can't very well be executed.
290 <strong>Is the target CGI/SSI program <em>NOT</em> writable
291 by anyone else?</strong>
294 We don't want to give anyone other than the owner the
295 ability to change the CGI/SSI program.
300 <strong>Is the target CGI/SSI program <em>NOT</em> setuid or
304 We do not want to execute programs that will then change
310 <strong>Is the target user/group the same as the program's
314 Is the user the owner of the file?
319 <strong>Can we successfully clean the process environment
320 to ensure safe operations?</strong>
323 suEXEC cleans the process' environment by establishing a
324 safe execution PATH (defined during configuration), as
325 well as only passing through those variables whose names
326 are listed in the safe environment list (also created
327 during configuration).
332 <strong>Can we successfully become the target CGI/SSI program
333 and execute?</strong>
336 Here is where suEXEC ends and the target CGI/SSI program begins.
341 <p>This is the standard operation of the
342 suEXEC wrapper's security model. It is somewhat stringent and
343 can impose new limitations and guidelines for CGI/SSI design,
344 but it was developed carefully step-by-step with security in
347 <p>For more information as to how this security
348 model can limit your possibilities in regards to server
349 configuration, as well as what security risks can be avoided
350 with a proper suEXEC setup, see the <a href="#jabberwock">"Beware the Jabberwock"</a> section of this
352 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
353 <div class="section">
354 <h2><a name="install" id="install">Configuring & Installing
357 <p>Here's where we begin the fun.</p>
359 <p><strong>suEXEC configuration
360 options</strong><br />
364 <dt><code>--enable-suexec</code></dt>
366 <dd>This option enables the suEXEC feature which is never
367 installed or activated by default. At least one
368 <code>--with-suexec-xxxxx</code> option has to be provided
369 together with the <code>--enable-suexec</code> option to let
370 APACI accept your request for using the suEXEC feature.</dd>
372 <dt><code>--with-suexec-bin=<em>PATH</em></code></dt>
374 <dd>The path to the <code>suexec</code> binary must be hard-coded
375 in the server for security reasons. Use this option to override
376 the default path. <em>e.g.</em>
377 <code>--with-suexec-bin=/usr/bin/suexec</code></dd>
379 <dt><code>--with-suexec-caller=<em>UID</em></code></dt>
381 <dd>The <a href="mod/mpm_common.html#user">username</a> under which
382 Apache normally runs. This is the only user allowed to
383 execute this program.</dd>
385 <dt><code>--with-suexec-userdir=<em>DIR</em></code></dt>
387 <dd>Define to be the subdirectory under users' home
388 directories where suEXEC access should be allowed. All
389 executables under this directory will be executable by suEXEC
390 as the user so they should be "safe" programs. If you are
391 using a "simple" <code class="directive"><a href="./mod/mod_userdir.html#userdir">UserDir</a></code>
392 directive (ie. one without a "*" in it) this should be set to the same
393 value. suEXEC will not work properly in cases where the <code class="directive"><a href="./mod/mod_userdir.html#userdir">UserDir</a></code> directive points to
394 a location that is not the same as the user's home directory
395 as referenced in the <code>passwd</code> file. Default value is
396 "<code>public_html</code>".<br />
397 If you have virtual hosts with a different <code class="directive"><a href="./mod/mod_userdir.html#userdir">UserDir</a></code> for each,
398 you will need to define them to all reside in one parent
399 directory; then name that parent directory here. <strong>If
400 this is not defined properly, "~userdir" cgi requests will
401 not work!</strong></dd>
403 <dt><code>--with-suexec-docroot=<em>DIR</em></code></dt>
405 <dd>Define as the DocumentRoot set for Apache. This will be
406 the only hierarchy (aside from <code class="directive"><a href="./mod/mod_userdir.html#userdir">UserDir</a></code>s) that can be used for suEXEC behavior. The
407 default directory is the <code>--datadir</code> value with the suffix
408 "<code>/htdocs</code>", <em>e.g.</em> if you configure with
409 "<code>--datadir=/home/apache</code>" the directory
410 "<code>/home/apache/htdocs</code>" is used as document root for the
413 <dt><code>--with-suexec-uidmin=<em>UID</em></code></dt>
415 <dd>Define this as the lowest UID allowed to be a target user
416 for suEXEC. For most systems, 500 or 100 is common. Default
419 <dt><code>--with-suexec-gidmin=<em>GID</em></code></dt>
421 <dd>Define this as the lowest GID allowed to be a target
422 group for suEXEC. For most systems, 100 is common and
423 therefore used as default value.</dd>
425 <dt><code>--with-suexec-logfile=<em>FILE</em></code></dt>
427 <dd>This defines the filename to which all suEXEC
428 transactions and errors are logged (useful for auditing and
429 debugging purposes). By default the logfile is named
430 "<code>suexec_log</code>" and located in your standard logfile
431 directory (<code>--logfiledir</code>).</dd>
433 <dt><code>--with-suexec-safepath=<em>PATH</em></code></dt>
435 <dd>Define a safe PATH environment to pass to CGI
436 executables. Default value is
437 "<code>/usr/local/bin:/usr/bin:/bin</code>".</dd>
440 <h3>Compiling and installing the suEXEC wrapper</h3>
443 <p>If you have enabled the suEXEC feature with the
444 <code>--enable-suexec</code> option the <code>suexec</code> binary
445 (together with Apache itself) is automatically built if you execute
446 the <code>make</code> command.</p>
448 <p>After all components have been built you can execute the
449 command <code>make install</code> to install them. The binary image
450 <code>suexec</code> is installed in the directory defined by the
451 <code>--sbindir</code> option. The default location is
452 "/usr/local/apache2/bin/suexec".</p>
454 <p>Please note that you need <strong><em>root
455 privileges</em></strong> for the installation step. In order
456 for the wrapper to set the user ID, it must be installed as
457 owner <code><em>root</em></code> and must have the setuserid
458 execution bit set for file modes.</p>
461 <h3>Setting paranoid permissions</h3>
464 <p>Although the suEXEC wrapper will check to ensure that its
465 caller is the correct user as specified with the
466 <code>--with-suexec-caller</code> <code class="program"><a href="./programs/configure.html">configure</a></code>
468 always the possibility that a system or library call suEXEC uses
469 before this check may be exploitable on your system. To counter
470 this, and because it is best-practise in general, you should use
471 filesystem permissions to ensure that only the group Apache
472 runs as may execute suEXEC.</p>
474 <p>If for example, your web server is configured to run as:</p>
476 <div class="example"><p><code>
481 <p>and <code class="program"><a href="./programs/suexec.html">suexec</a></code> is installed at
482 "/usr/local/apache2/bin/suexec", you should run:</p>
484 <div class="example"><p><code>
485 chgrp webgroup /usr/local/apache2/bin/suexec<br />
486 chmod 4750 /usr/local/apache2/bin/suexec<br />
489 <p>This will ensure that only the group Apache runs as can even
490 execute the suEXEC wrapper.</p>
492 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
493 <div class="section">
494 <h2><a name="enable" id="enable">Enabling & Disabling
497 <p>Upon startup of Apache, it looks for the file
498 <code class="program"><a href="./programs/suexec.html">suexec</a></code> in the directory defined by the
499 <code>--sbindir</code> option (default is
500 "/usr/local/apache/bin/suexec"). If Apache finds a properly
501 configured suEXEC wrapper, it will print the following message
502 to the error log:</p>
504 <div class="example"><p><code>
505 [notice] suEXEC mechanism enabled (wrapper: <var>/path/to/suexec</var>)
508 <p>If you don't see this message at server startup, the server is
509 most likely not finding the wrapper program where it expects
510 it, or the executable is not installed <em>setuid root</em>.</p>
512 <p>If you want to enable the suEXEC mechanism for the first time
513 and an Apache server is already running you must kill and
514 restart Apache. Restarting it with a simple HUP or USR1 signal
515 will not be enough. </p>
516 <p>If you want to disable suEXEC you should kill and restart
517 Apache after you have removed the <code class="program"><a href="./programs/suexec.html">suexec</a></code> file.</p>
518 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
519 <div class="section">
520 <h2><a name="usage" id="usage">Using suEXEC</a></h2>
522 <p>Requests for CGI programs will call the suEXEC wrapper only if
523 they are for a virtual host containing a <code class="directive"><a href="./mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code> directive or if
524 they are processed by <code class="module"><a href="./mod/mod_userdir.html">mod_userdir</a></code>.</p>
526 <p><strong>Virtual Hosts:</strong><br /> One way to use the suEXEC
527 wrapper is through the <code class="directive"><a href="./mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code> directive in
528 <code class="directive"><a href="./mod/core.html#virtualhost">VirtualHost</a></code> definitions. By
529 setting this directive to values different from the main server
530 user ID, all requests for CGI resources will be executed as the
531 <em>User</em> and <em>Group</em> defined for that <code class="directive"><a href="./mod/core.html#virtualhost"><VirtualHost></a></code>. If this
532 directive is not specified for a <code class="directive"><a href="./mod/core.html#virtualhost"><VirtualHost></a></code> then the main server userid
535 <p><strong>User directories:</strong><br /> Requests that are
536 processed by <code class="module"><a href="./mod/mod_userdir.html">mod_userdir</a></code> will call the suEXEC
537 wrapper to execute CGI programs under the userid of the requested
538 user directory. The only requirement needed for this feature to
539 work is for CGI execution to be enabled for the user and that the
540 script must meet the scrutiny of the <a href="#model">security
541 checks</a> above. See also the
542 <code>--with-suexec-userdir</code> <a href="#install">compile
543 time option</a>.</p> </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
544 <div class="section">
545 <h2><a name="debug" id="debug">Debugging suEXEC</a></h2>
547 <p>The suEXEC wrapper will write log information
548 to the file defined with the <code>--with-suexec-logfile</code>
549 option as indicated above. If you feel you have configured and
550 installed the wrapper properly, have a look at this log and the
551 error_log for the server to see where you may have gone astray.</p>
553 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
554 <div class="section">
555 <h2><a name="jabberwock" id="jabberwock">Beware the Jabberwock:
556 Warnings & Examples</a></h2>
558 <p><strong>NOTE!</strong> This section may not be
559 complete. For the latest revision of this section of the
560 documentation, see the Apache Group's <a href="http://httpd.apache.org/docs/2.0/suexec.html">Online
561 Documentation</a> version.</p>
563 <p>There are a few points of interest regarding
564 the wrapper that can cause limitations on server setup. Please
565 review these before submitting any "bugs" regarding suEXEC.</p>
568 <li><strong>suEXEC Points Of Interest</strong></li>
571 Hierarchy limitations
574 For security and efficiency reasons, all suEXEC requests
575 must remain within either a top-level document root for
576 virtual host requests, or one top-level personal document
577 root for userdir requests. For example, if you have four
578 VirtualHosts configured, you would need to structure all
579 of your VHosts' document roots off of one main Apache
580 document hierarchy to take advantage of suEXEC for
581 VirtualHosts. (Example forthcoming.)
586 suEXEC's PATH environment variable
589 This can be a dangerous thing to change. Make certain
590 every path you include in this define is a
591 <strong>trusted</strong> directory. You don't want to
592 open people up to having someone from across the world
593 running a trojan horse on them.
598 Altering the suEXEC code
601 Again, this can cause <strong>Big Trouble</strong> if you
602 try this without knowing what you are doing. Stay away
603 from it if at all possible.
609 <div class="bottomlang">
610 <p><span>Available Languages: </span><a href="./en/suexec.html" title="English"> en </a> |
611 <a href="./ja/suexec.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
612 <a href="./ko/suexec.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
613 <a href="./tr/suexec.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
614 </div><div id="footer">
615 <p class="apache">Copyright 2009 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
616 <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>