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/">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="./fr/suexec.html" hreflang="fr" rel="alternate" title="Français"> fr </a> |
23 <a href="./ja/suexec.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
24 <a href="./ko/suexec.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
25 <a href="./tr/suexec.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
28 <p>The <strong>suEXEC</strong> feature provides users of the Apache
29 HTTP Server the ability
30 to run <strong>CGI</strong> and <strong>SSI</strong> programs
31 under user IDs different from the user ID of the calling
32 web server. Normally, when a CGI or SSI program executes, it
33 runs as the same user who is running the web server.</p>
35 <p>Used properly, this feature can reduce
36 considerably the security risks involved with allowing users to
37 develop and run private CGI or SSI programs. However, if suEXEC
38 is improperly configured, it can cause any number of problems
39 and possibly create new holes in your computer's security. If
40 you aren't familiar with managing <em>setuid root</em> programs
41 and the security issues they present, we highly recommend that
42 you not consider using suEXEC.</p>
44 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#before">Before we begin</a></li>
45 <li><img alt="" src="./images/down.gif" /> <a href="#model">suEXEC Security Model</a></li>
46 <li><img alt="" src="./images/down.gif" /> <a href="#install">Configuring & Installing
48 <li><img alt="" src="./images/down.gif" /> <a href="#enable">Enabling & Disabling
50 <li><img alt="" src="./images/down.gif" /> <a href="#usage">Using suEXEC</a></li>
51 <li><img alt="" src="./images/down.gif" /> <a href="#debug">Debugging suEXEC</a></li>
52 <li><img alt="" src="./images/down.gif" /> <a href="#jabberwock">Beware the Jabberwock:
53 Warnings & Examples</a></li>
55 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
57 <h2><a name="before" id="before">Before we begin</a></h2>
59 <p>Before jumping head-first into this document,
60 you should be aware that certain assumptions are made about you and
61 the environment in which you will be using suexec.</p>
63 <p>First, it is assumed that you are using a UNIX
64 derivative operating system that is capable of
65 <strong>setuid</strong> and <strong>setgid</strong> operations.
66 All command examples are given in this regard. Other platforms,
67 if they are capable of supporting suEXEC, may differ in their
70 <p>Second, it is assumed you are familiar with
71 some basic concepts of your computer's security and its
72 administration. This involves an understanding of
73 <strong>setuid/setgid</strong> operations and the various
74 effects they may have on your system and its level of
77 <p>Third, it is assumed that you are using an
78 <strong>unmodified</strong> version of suEXEC code. All code
79 for suEXEC has been carefully scrutinized and tested by the
80 developers as well as numerous beta testers. Every precaution
81 has been taken to ensure a simple yet solidly safe base of
82 code. Altering this code can cause unexpected problems and new
83 security risks. It is <strong>highly</strong> recommended you
84 not alter the suEXEC code unless you are well versed in the
85 particulars of security programming and are willing to share
86 your work with the Apache HTTP Server development team for consideration.</p>
88 <p>Fourth, and last, it has been the decision of
89 the Apache HTTP Server development team to <strong>NOT</strong> make suEXEC part of
90 the default installation of Apache httpd. To this end, suEXEC
91 configuration requires of the administrator careful attention
92 to details. After due consideration has been given to the
93 various settings for suEXEC, the administrator may install
94 suEXEC through normal installation methods. The values for
95 these settings need to be carefully determined and specified by
96 the administrator to properly maintain system security during
97 the use of suEXEC functionality. It is through this detailed
98 process that we hope to limit suEXEC
99 installation only to those who are careful and determined
100 enough to use it.</p>
102 <p>Still with us? Yes? Good. Let's move on!</p>
103 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
104 <div class="section">
105 <h2><a name="model" id="model">suEXEC Security Model</a></h2>
107 <p>Before we begin configuring and installing
108 suEXEC, we will first discuss the security model you are about
109 to implement. By doing so, you may better understand what
110 exactly is going on inside suEXEC and what precautions are
111 taken to ensure your system's security.</p>
113 <p><strong>suEXEC</strong> is based on a setuid
114 "wrapper" program that is called by the main Apache HTTP Server.
115 This wrapper is called when an HTTP request is made for a CGI
116 or SSI program that the administrator has designated to run as
117 a userid other than that of the main server. When such a
118 request is made, Apache httpd provides the suEXEC wrapper with the
119 program's name and the user and group IDs under which the
120 program is to execute.</p>
122 <p>The wrapper then employs the following process
123 to determine success or failure -- if any one of these
124 conditions fail, the program logs the failure and exits with an
125 error, otherwise it will continue:</p>
129 <strong>Is the user executing this wrapper a valid user of
130 this system?</strong>
133 This is to ensure that the user executing the wrapper is
134 truly a user of the system.
139 <strong>Was the wrapper called with the proper number of
143 The wrapper will only execute if it is given the proper
144 number of arguments. The proper argument format is known
145 to the Apache HTTP Server. If the wrapper is not receiving
146 the proper number of arguments, it is either being
147 hacked, or there is something wrong with the suEXEC
148 portion of your Apache httpd binary.
153 <strong>Is this valid user allowed to run the
157 Is this user the user allowed to run this wrapper? Only
158 one user (the Apache user) is allowed to execute this
164 <strong>Does the target CGI or SSI program have an unsafe
165 hierarchical reference?</strong>
168 Does the target CGI or SSI program's path contain a leading
169 '/' or have a '..' backreference? These are not allowed; the
170 target CGI/SSI program must reside within suEXEC's document
171 root (see <code>--with-suexec-docroot=<em>DIR</em></code>
177 <strong>Is the target user name valid?</strong>
180 Does the target user exist?
185 <strong>Is the target group name valid?</strong>
188 Does the target group exist?
193 <strong>Is the target user <em>NOT</em> superuser?</strong>
197 suEXEC does not allow <code><em>root</em></code>
198 to execute CGI/SSI programs.
203 <strong>Is the target userid <em>ABOVE</em> the minimum ID
207 The minimum user ID number is specified during
208 configuration. This allows you to set the lowest possible
209 userid that will be allowed to execute CGI/SSI programs.
210 This is useful to block out "system" accounts.
215 <strong>Is the target group <em>NOT</em> the superuser
219 Presently, suEXEC does not allow the <code><em>root</em></code>
220 group to execute CGI/SSI programs.
225 <strong>Is the target groupid <em>ABOVE</em> the minimum ID
229 The minimum group ID number is specified during
230 configuration. This allows you to set the lowest possible
231 groupid that will be allowed to execute CGI/SSI programs.
232 This is useful to block out "system" groups.
237 <strong>Can the wrapper successfully become the target user
241 Here is where the program becomes the target user and
242 group via setuid and setgid calls. The group access list
243 is also initialized with all of the groups of which the
249 <strong>Can we change directory to the one in which the target
250 CGI/SSI program resides?</strong>
253 If it doesn't exist, it can't very well contain files. If we
254 can't change directory to it, it might aswell not exist.
259 <strong>Is the directory within the httpd webspace?</strong>
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/sbin/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 httpd normally runs. This is the only user allowed to
383 execute the suEXEC wrapper.</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 httpd. 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 httpd 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 httpd
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 httpd 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 httpd, 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/sbin/suexec"). If httpd 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 HTTP Server is already running you must kill and
514 restart httpd. 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 httpd 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 <a href="http://httpd.apache.org/docs/trunk/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 httpd
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="./fr/suexec.html" hreflang="fr" rel="alternate" title="Français"> fr </a> |
612 <a href="./ja/suexec.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
613 <a href="./ko/suexec.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
614 <a href="./tr/suexec.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
615 </div><div id="footer">
616 <p class="apache">Copyright 2011 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>
617 <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>