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
29 Apache users 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 of the assumptions made on the part of the
61 Apache Group and this document.</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 Group for consideration.</p>
88 <p>Fourth, and last, it has been the decision of
89 the Apache Group to <strong>NOT</strong> make suEXEC part of
90 the default installation of Apache. 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 the Apache Group hopes 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 web 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 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 web 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 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 Presently, 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 Apache
263 If the request is for a regular portion of the server, is
264 the requested directory within suEXEC's document root? If
265 the request is for a <code class="directive"><a href="./mod/mod_userdir.html#userdir">UserDir</a></code>, is the requested directory
266 within the directory configured as suEXEC's userdir (see
267 <a href="#install">suEXEC's configuration options</a>)?
272 <strong>Is the directory <em>NOT</em> writable by anyone
276 We don't want to open up the directory to others; only
277 the owner user may be able to alter this directories
283 <strong>Does the target CGI/SSI program exist?</strong>
286 If it doesn't exists, it can't very well be executed.
291 <strong>Is the target CGI/SSI program <em>NOT</em> writable
292 by anyone else?</strong>
295 We don't want to give anyone other than the owner the
296 ability to change the CGI/SSI program.
301 <strong>Is the target CGI/SSI program <em>NOT</em> setuid or
305 We do not want to execute programs that will then change
311 <strong>Is the target user/group the same as the program's
315 Is the user the owner of the file?
320 <strong>Can we successfully clean the process environment
321 to ensure safe operations?</strong>
324 suEXEC cleans the process' environment by establishing a
325 safe execution PATH (defined during configuration), as
326 well as only passing through those variables whose names
327 are listed in the safe environment list (also created
328 during configuration).
333 <strong>Can we successfully become the target CGI/SSI program
334 and execute?</strong>
337 Here is where suEXEC ends and the target CGI/SSI program begins.
342 <p>This is the standard operation of the
343 suEXEC wrapper's security model. It is somewhat stringent and
344 can impose new limitations and guidelines for CGI/SSI design,
345 but it was developed carefully step-by-step with security in
348 <p>For more information as to how this security
349 model can limit your possibilities in regards to server
350 configuration, as well as what security risks can be avoided
351 with a proper suEXEC setup, see the <a href="#jabberwock">"Beware the Jabberwock"</a> section of this
353 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
354 <div class="section">
355 <h2><a name="install" id="install">Configuring & Installing
358 <p>Here's where we begin the fun.</p>
360 <p><strong>suEXEC configuration
361 options</strong><br />
365 <dt><code>--enable-suexec</code></dt>
367 <dd>This option enables the suEXEC feature which is never
368 installed or activated by default. At least one
369 <code>--with-suexec-xxxxx</code> option has to be provided
370 together with the <code>--enable-suexec</code> option to let
371 APACI accept your request for using the suEXEC feature.</dd>
373 <dt><code>--with-suexec-bin=<em>PATH</em></code></dt>
375 <dd>The path to the <code>suexec</code> binary must be hard-coded
376 in the server for security reasons. Use this option to override
377 the default path. <em>e.g.</em>
378 <code>--with-suexec-bin=/usr/sbin/suexec</code></dd>
380 <dt><code>--with-suexec-caller=<em>UID</em></code></dt>
382 <dd>The <a href="mod/mpm_common.html#user">username</a> under which
383 Apache normally runs. This is the only user allowed to
384 execute this program.</dd>
386 <dt><code>--with-suexec-userdir=<em>DIR</em></code></dt>
388 <dd>Define to be the subdirectory under users' home
389 directories where suEXEC access should be allowed. All
390 executables under this directory will be executable by suEXEC
391 as the user so they should be "safe" programs. If you are
392 using a "simple" <code class="directive"><a href="./mod/mod_userdir.html#userdir">UserDir</a></code>
393 directive (ie. one without a "*" in it) this should be set to the same
394 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
395 a location that is not the same as the user's home directory
396 as referenced in the <code>passwd</code> file. Default value is
397 "<code>public_html</code>".<br />
398 If you have virtual hosts with a different <code class="directive"><a href="./mod/mod_userdir.html#userdir">UserDir</a></code> for each,
399 you will need to define them to all reside in one parent
400 directory; then name that parent directory here. <strong>If
401 this is not defined properly, "~userdir" cgi requests will
402 not work!</strong></dd>
404 <dt><code>--with-suexec-docroot=<em>DIR</em></code></dt>
406 <dd>Define as the DocumentRoot set for Apache. This will be
407 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
408 default directory is the <code>--datadir</code> value with the suffix
409 "<code>/htdocs</code>", <em>e.g.</em> if you configure with
410 "<code>--datadir=/home/apache</code>" the directory
411 "<code>/home/apache/htdocs</code>" is used as document root for the
414 <dt><code>--with-suexec-uidmin=<em>UID</em></code></dt>
416 <dd>Define this as the lowest UID allowed to be a target user
417 for suEXEC. For most systems, 500 or 100 is common. Default
420 <dt><code>--with-suexec-gidmin=<em>GID</em></code></dt>
422 <dd>Define this as the lowest GID allowed to be a target
423 group for suEXEC. For most systems, 100 is common and
424 therefore used as default value.</dd>
426 <dt><code>--with-suexec-logfile=<em>FILE</em></code></dt>
428 <dd>This defines the filename to which all suEXEC
429 transactions and errors are logged (useful for auditing and
430 debugging purposes). By default the logfile is named
431 "<code>suexec_log</code>" and located in your standard logfile
432 directory (<code>--logfiledir</code>).</dd>
434 <dt><code>--with-suexec-safepath=<em>PATH</em></code></dt>
436 <dd>Define a safe PATH environment to pass to CGI
437 executables. Default value is
438 "<code>/usr/local/bin:/usr/bin:/bin</code>".</dd>
441 <h3>Compiling and installing the suEXEC wrapper</h3>
444 <p>If you have enabled the suEXEC feature with the
445 <code>--enable-suexec</code> option the <code>suexec</code> binary
446 (together with Apache itself) is automatically built if you execute
447 the <code>make</code> command.</p>
449 <p>After all components have been built you can execute the
450 command <code>make install</code> to install them. The binary image
451 <code>suexec</code> is installed in the directory defined by the
452 <code>--sbindir</code> option. The default location is
453 "/usr/local/apache2/bin/suexec".</p>
455 <p>Please note that you need <strong><em>root
456 privileges</em></strong> for the installation step. In order
457 for the wrapper to set the user ID, it must be installed as
458 owner <code><em>root</em></code> and must have the setuserid
459 execution bit set for file modes.</p>
462 <h3>Setting paranoid permissions</h3>
465 <p>Although the suEXEC wrapper will check to ensure that its
466 caller is the correct user as specified with the
467 <code>--with-suexec-caller</code> <code class="program"><a href="./programs/configure.html">configure</a></code>
469 always the possibility that a system or library call suEXEC uses
470 before this check may be exploitable on your system. To counter
471 this, and because it is best-practise in general, you should use
472 filesystem permissions to ensure that only the group Apache
473 runs as may execute suEXEC.</p>
475 <p>If for example, your web server is configured to run as:</p>
477 <div class="example"><p><code>
482 <p>and <code class="program"><a href="./programs/suexec.html">suexec</a></code> is installed at
483 "/usr/local/apache2/bin/suexec", you should run:</p>
485 <div class="example"><p><code>
486 chgrp webgroup /usr/local/apache2/bin/suexec<br />
487 chmod 4750 /usr/local/apache2/bin/suexec<br />
490 <p>This will ensure that only the group Apache runs as can even
491 execute the suEXEC wrapper.</p>
493 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
494 <div class="section">
495 <h2><a name="enable" id="enable">Enabling & Disabling
498 <p>Upon startup of Apache, it looks for the file
499 <code class="program"><a href="./programs/suexec.html">suexec</a></code> in the directory defined by the
500 <code>--sbindir</code> option (default is
501 "/usr/local/apache/sbin/suexec"). If Apache finds a properly
502 configured suEXEC wrapper, it will print the following message
503 to the error log:</p>
505 <div class="example"><p><code>
506 [notice] suEXEC mechanism enabled (wrapper: <var>/path/to/suexec</var>)
509 <p>If you don't see this message at server startup, the server is
510 most likely not finding the wrapper program where it expects
511 it, or the executable is not installed <em>setuid root</em>.</p>
513 <p>If you want to enable the suEXEC mechanism for the first time
514 and an Apache server is already running you must kill and
515 restart Apache. Restarting it with a simple HUP or USR1 signal
516 will not be enough. </p>
517 <p>If you want to disable suEXEC you should kill and restart
518 Apache after you have removed the <code class="program"><a href="./programs/suexec.html">suexec</a></code> file.</p>
519 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
520 <div class="section">
521 <h2><a name="usage" id="usage">Using suEXEC</a></h2>
523 <p>Requests for CGI programs will call the suEXEC wrapper only if
524 they are for a virtual host containing a <code class="directive"><a href="./mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code> directive or if
525 they are processed by <code class="module"><a href="./mod/mod_userdir.html">mod_userdir</a></code>.</p>
527 <p><strong>Virtual Hosts:</strong><br /> One way to use the suEXEC
528 wrapper is through the <code class="directive"><a href="./mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code> directive in
529 <code class="directive"><a href="./mod/core.html#virtualhost">VirtualHost</a></code> definitions. By
530 setting this directive to values different from the main server
531 user ID, all requests for CGI resources will be executed as the
532 <em>User</em> and <em>Group</em> defined for that <code class="directive"><a href="./mod/core.html#virtualhost"><VirtualHost></a></code>. If this
533 directive is not specified for a <code class="directive"><a href="./mod/core.html#virtualhost"><VirtualHost></a></code> then the main server userid
536 <p><strong>User directories:</strong><br /> Requests that are
537 processed by <code class="module"><a href="./mod/mod_userdir.html">mod_userdir</a></code> will call the suEXEC
538 wrapper to execute CGI programs under the userid of the requested
539 user directory. The only requirement needed for this feature to
540 work is for CGI execution to be enabled for the user and that the
541 script must meet the scrutiny of the <a href="#model">security
542 checks</a> above. See also the
543 <code>--with-suexec-userdir</code> <a href="#install">compile
544 time option</a>.</p> </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
545 <div class="section">
546 <h2><a name="debug" id="debug">Debugging suEXEC</a></h2>
548 <p>The suEXEC wrapper will write log information
549 to the file defined with the <code>--with-suexec-logfile</code>
550 option as indicated above. If you feel you have configured and
551 installed the wrapper properly, have a look at this log and the
552 error_log for the server to see where you may have gone astray.</p>
554 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
555 <div class="section">
556 <h2><a name="jabberwock" id="jabberwock">Beware the Jabberwock:
557 Warnings & Examples</a></h2>
559 <p><strong>NOTE!</strong> This section may not be
560 complete. For the latest revision of this section of the
561 documentation, see the Apache Group's <a href="http://httpd.apache.org/docs/trunk/suexec.html">Online
562 Documentation</a> version.</p>
564 <p>There are a few points of interest regarding
565 the wrapper that can cause limitations on server setup. Please
566 review these before submitting any "bugs" regarding suEXEC.</p>
569 <li><strong>suEXEC Points Of Interest</strong></li>
572 Hierarchy limitations
575 For security and efficiency reasons, all suEXEC requests
576 must remain within either a top-level document root for
577 virtual host requests, or one top-level personal document
578 root for userdir requests. For example, if you have four
579 VirtualHosts configured, you would need to structure all
580 of your VHosts' document roots off of one main Apache
581 document hierarchy to take advantage of suEXEC for
582 VirtualHosts. (Example forthcoming.)
587 suEXEC's PATH environment variable
590 This can be a dangerous thing to change. Make certain
591 every path you include in this define is a
592 <strong>trusted</strong> directory. You don't want to
593 open people up to having someone from across the world
594 running a trojan horse on them.
599 Altering the suEXEC code
602 Again, this can cause <strong>Big Trouble</strong> if you
603 try this without knowing what you are doing. Stay away
604 from it if at all possible.
610 <div class="bottomlang">
611 <p><span>Available Languages: </span><a href="./en/suexec.html" title="English"> en </a> |
612 <a href="./fr/suexec.html" hreflang="fr" rel="alternate" title="Français"> fr </a> |
613 <a href="./ja/suexec.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
614 <a href="./ko/suexec.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
615 <a href="./tr/suexec.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
616 </div><div id="footer">
617 <p class="apache">Copyright 2008 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>
618 <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>