]> granicus.if.org Git - apache/blob - docs/manual/suexec.html.en
update transformation - en
[apache] / docs / manual / suexec.html.en
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
7       -->
8 <title>suEXEC Support - Apache HTTP Server</title>
9 <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="./images/favicon.ico" rel="shortcut icon" /></head>
13 <body id="manual-page"><div id="page-header">
14 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
15 <p class="apache">Apache HTTP Server Version 2.1</p>
16 <img alt="" src="./images/feather.gif" /></div>
17 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
18 <div id="path">
19 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs-project/">Documentation</a> &gt; <a href="./">Version 2.1</a></div><div id="page-content"><div id="preamble"><h1>suEXEC Support</h1>
20 <div class="toplang">
21 <p><span>Available Languages: </span><a href="./en/suexec.html" hreflang="en" title="English">&nbsp;en&nbsp;</a> | <a href="./ja/suexec.html" hreflang="ja" title="Japanese">&nbsp;ja&nbsp;</a> | <a href="./ko/suexec.html" hreflang="ko" title="Korean">&nbsp;ko&nbsp;</a></p>
22 </div>
23
24     <p>The <strong>suEXEC</strong> feature provides
25     Apache users the ability
26     to run <strong>CGI</strong> and <strong>SSI</strong> programs
27     under user IDs different from the user ID of the calling
28     web-server. Normally, when a CGI or SSI program executes, it
29     runs as the same user who is running the web server.</p>
30
31     <p>Used properly, this feature can reduce
32     considerably the security risks involved with allowing users to
33     develop and run private CGI or SSI programs. However, if suEXEC
34     is improperly configured, it can cause any number of problems
35     and possibly create new holes in your computer's security. If
36     you aren't familiar with managing setuid root programs and the
37     security issues they present, we highly recommend that you not
38     consider using suEXEC.</p>
39   </div>
40 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#before">Before we begin</a></li>
41 <li><img alt="" src="./images/down.gif" /> <a href="#model">suEXEC Security Model</a></li>
42 <li><img alt="" src="./images/down.gif" /> <a href="#install">Configuring &amp; Installing
43     suEXEC</a></li>
44 <li><img alt="" src="./images/down.gif" /> <a href="#enable">Enabling &amp; Disabling
45     suEXEC</a></li>
46 <li><img alt="" src="./images/down.gif" /> <a href="#usage">Using suEXEC</a></li>
47 <li><img alt="" src="./images/down.gif" /> <a href="#debug">Debugging suEXEC</a></li>
48 <li><img alt="" src="./images/down.gif" /> <a href="#jabberwock">Beware the Jabberwock:
49     Warnings &amp; Examples</a></li>
50 </ul></div>
51 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
52 <div class="section">
53 <h2><a name="before" id="before">Before we begin</a></h2>
54
55     <p>Before jumping head-first into this document,
56     you should be aware of the assumptions made on the part of the
57     Apache Group and this document.</p>
58
59     <p>First, it is assumed that you are using a UNIX
60     derivative operating system that is capable of
61     <strong>setuid</strong> and <strong>setgid</strong> operations.
62     All command examples are given in this regard. Other platforms,
63     if they are capable of supporting suEXEC, may differ in their
64     configuration.</p>
65
66     <p>Second, it is assumed you are familiar with
67     some basic concepts of your computer's security and its
68     administration. This involves an understanding of
69     <strong>setuid/setgid</strong> operations and the various
70     effects they may have on your system and its level of
71     security.</p>
72
73     <p>Third, it is assumed that you are using an
74     <strong>unmodified</strong> version of suEXEC code. All code
75     for suEXEC has been carefully scrutinized and tested by the
76     developers as well as numerous beta testers. Every precaution
77     has been taken to ensure a simple yet solidly safe base of
78     code. Altering this code can cause unexpected problems and new
79     security risks. It is <strong>highly</strong> recommended you
80     not alter the suEXEC code unless you are well versed in the
81     particulars of security programming and are willing to share
82     your work with the Apache Group for consideration.</p>
83
84     <p>Fourth, and last, it has been the decision of
85     the Apache Group to <strong>NOT</strong> make suEXEC part of
86     the default installation of Apache. To this end, suEXEC
87     configuration requires of the administrator careful attention
88     to details. After due consideration has been given to the
89     various settings for suEXEC, the administrator may install
90     suEXEC through normal installation methods. The values for
91     these settings need to be carefully determined and specified by
92     the administrator to properly maintain system security during
93     the use of suEXEC functionality. It is through this detailed
94     process that the Apache Group hopes to limit suEXEC
95     installation only to those who are careful and determined
96     enough to use it.</p>
97
98     <p>Still with us? Yes? Good. Let's move on!</p>
99 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
100 <div class="section">
101 <h2><a name="model" id="model">suEXEC Security Model</a></h2>
102
103     <p>Before we begin configuring and installing
104     suEXEC, we will first discuss the security model you are about
105     to implement. By doing so, you may better understand what
106     exactly is going on inside suEXEC and what precautions are
107     taken to ensure your system's security.</p>
108
109     <p><strong>suEXEC</strong> is based on a setuid
110     "wrapper" program that is called by the main Apache web server.
111     This wrapper is called when an HTTP request is made for a CGI
112     or SSI program that the administrator has designated to run as
113     a userid other than that of the main server. When such a
114     request is made, Apache provides the suEXEC wrapper with the
115     program's name and the user and group IDs under which the
116     program is to execute.</p>
117
118     <p>The wrapper then employs the following process
119     to determine success or failure -- if any one of these
120     conditions fail, the program logs the failure and exits with an
121     error, otherwise it will continue:</p>
122
123     <ol>
124       <li>
125         <strong>Was the wrapper called with the proper number of
126         arguments?</strong> 
127
128         <p class="indent">
129           The wrapper will only execute if it is given the proper
130           number of arguments. The proper argument format is known
131           to the Apache web server. If the wrapper is not receiving
132           the proper number of arguments, it is either being
133           hacked, or there is something wrong with the suEXEC
134           portion of your Apache binary.
135         </p>
136       </li>
137
138       <li>
139         <strong>Is the user executing this wrapper a valid user of
140         this system?</strong> 
141
142         <p class="indent">
143           This is to ensure that the user executing the wrapper is
144           truly a user of the system.
145         </p>
146       </li>
147
148       <li>
149         <strong>Is this valid user allowed to run the
150         wrapper?</strong> 
151
152         <p class="indent">
153           Is this user the user allowed to run this wrapper? Only
154           one user (the Apache user) is allowed to execute this
155           program.
156         </p>
157       </li>
158
159       <li>
160         <strong>Does the target program have an unsafe hierarchical
161         reference?</strong> 
162
163         <p class="indent">
164           Does the target program contain a leading '/' or have a
165           '..' backreference? These are not allowed; the target
166           program must reside within the Apache webspace.
167         </p>
168       </li>
169
170       <li>
171         <strong>Is the target user name valid?</strong> 
172
173         <p class="indent">
174           Does the target user exist?
175         </p>
176       </li>
177
178       <li>
179         <strong>Is the target group name valid?</strong> 
180
181         <p class="indent">
182           Does the target group exist?
183         </p>
184       </li>
185
186       <li>
187         <strong>Is the target user <em>NOT</em> superuser?</strong>
188         
189
190         <p class="indent">
191           Presently, suEXEC does not allow 'root' to execute
192           CGI/SSI programs.
193         </p>
194       </li>
195
196       <li>
197         <strong>Is the target userid <em>ABOVE</em> the minimum ID
198         number?</strong> 
199
200         <p class="indent">
201           The minimum user ID number is specified during
202           configuration. This allows you to set the lowest possible
203           userid that will be allowed to execute CGI/SSI programs.
204           This is useful to block out "system" accounts.
205         </p>
206       </li>
207
208       <li>
209         <strong>Is the target group <em>NOT</em> the superuser
210         group?</strong> 
211
212         <p class="indent">
213           Presently, suEXEC does not allow the 'root' group to
214           execute CGI/SSI programs.
215         </p>
216       </li>
217
218       <li>
219         <strong>Is the target groupid <em>ABOVE</em> the minimum ID
220         number?</strong> 
221
222         <p class="indent">
223           The minimum group ID number is specified during
224           configuration. This allows you to set the lowest possible
225           groupid that will be allowed to execute CGI/SSI programs.
226           This is useful to block out "system" groups.
227         </p>
228       </li>
229
230       <li>
231         <strong>Can the wrapper successfully become the target user
232         and group?</strong> 
233
234         <p class="indent">
235           Here is where the program becomes the target user and
236           group via setuid and setgid calls. The group access list
237           is also initialized with all of the groups of which the
238           user is a member.
239         </p>
240       </li>
241
242       <li>
243         <strong>Does the directory in which the program resides
244         exist?</strong> 
245
246         <p class="indent">
247           If it doesn't exist, it can't very well contain files.
248         </p>
249       </li>
250
251       <li>
252         <strong>Is the directory within the Apache
253         webspace?</strong> 
254
255         <p class="indent">
256           If the request is for a regular portion of the server, is
257           the requested directory within the server's document
258           root? If the request is for a UserDir, is the requested
259           directory within the user's document root?
260         </p>
261       </li>
262
263       <li>
264         <strong>Is the directory <em>NOT</em> writable by anyone
265         else?</strong> 
266
267         <p class="indent">
268           We don't want to open up the directory to others; only
269           the owner user may be able to alter this directories
270           contents.
271         </p>
272       </li>
273
274       <li>
275         <strong>Does the target program exist?</strong> 
276
277         <p class="indent">
278           If it doesn't exists, it can't very well be executed.
279         </p>
280       </li>
281
282       <li>
283         <strong>Is the target program <em>NOT</em> writable by
284         anyone else?</strong> 
285
286         <p class="indent">
287           We don't want to give anyone other than the owner the
288           ability to change the program.
289         </p>
290       </li>
291
292       <li>
293         <strong>Is the target program <em>NOT</em> setuid or
294         setgid?</strong> 
295
296         <p class="indent">
297           We do not want to execute programs that will then change
298           our UID/GID again.
299         </p>
300       </li>
301
302       <li>
303         <strong>Is the target user/group the same as the program's
304         user/group?</strong> 
305
306         <p class="indent">
307           Is the user the owner of the file?
308         </p>
309       </li>
310
311       <li>
312         <strong>Can we successfully clean the process environment
313         to ensure safe operations?</strong> 
314
315         <p class="indent">
316           suEXEC cleans the process' environment by establishing a
317           safe execution PATH (defined during configuration), as
318           well as only passing through those variables whose names
319           are listed in the safe environment list (also created
320           during configuration).
321         </p>
322       </li>
323
324       <li>
325         <strong>Can we successfully become the target program and
326         execute?</strong> 
327
328         <p class="indent">
329           Here is where suEXEC ends and the target program begins.
330         </p>
331       </li>
332     </ol>
333
334     <p>This is the standard operation of the
335     suEXEC wrapper's security model. It is somewhat stringent and
336     can impose new limitations and guidelines for CGI/SSI design,
337     but it was developed carefully step-by-step with security in
338     mind.</p>
339
340     <p>For more information as to how this security
341     model can limit your possibilities in regards to server
342     configuration, as well as what security risks can be avoided
343     with a proper suEXEC setup, see the <a href="#jabberwock">"Beware the Jabberwock"</a> section of this
344     document.</p>
345 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
346 <div class="section">
347 <h2><a name="install" id="install">Configuring &amp; Installing
348     suEXEC</a></h2>
349
350     <p>Here's where we begin the fun.</p>
351
352     <p><strong>suEXEC configuration
353     options</strong><br />
354     </p>
355
356     <dl>
357       <dt><code>--enable-suexec</code></dt>
358
359       <dd>This option enables the suEXEC feature which is never
360       installed or activated by default. At least one
361       --with-suexec-xxxxx option has to be provided together with the
362       --enable-suexec option to let APACI accept your request for
363       using the suEXEC feature.</dd>
364
365       <dt><code>--with-suexec-bin=<em>PATH</em></code></dt>
366
367       <dd>The path to the suexec binary must be hard-coded in
368       the server for security reasons. Use this option to override
369       the default path. <em>e.g.</em>
370       <code>--with-suexec-bin=/usr/sbin/suexec</code></dd>
371
372       <dt><code>--with-suexec-caller=<em>UID</em></code></dt>
373
374       <dd>The <a href="mod/mpm_common.html#user">username</a> under which
375       Apache normally runs. This is the only user allowed to
376       execute this program.</dd>
377
378       <dt><code>--with-suexec-userdir=<em>DIR</em></code></dt>
379
380       <dd>Define to be the subdirectory under users' home
381       directories where suEXEC access should be allowed. All
382       executables under this directory will be executable by suEXEC
383       as the user so they should be "safe" programs. If you are
384       using a "simple" UserDir directive (ie. one without a "*" in
385       it) this should be set to the same value. suEXEC will not
386       work properly in cases where the UserDir directive points to
387       a location that is not the same as the user's home directory
388       as referenced in the passwd file. Default value is
389       "public_html".<br />
390        If you have virtual hosts with a different UserDir for each,
391       you will need to define them to all reside in one parent
392       directory; then name that parent directory here. <strong>If
393       this is not defined properly, "~userdir" cgi requests will
394       not work!</strong></dd>
395
396       <dt><code>--with-suexec-docroot=<em>DIR</em></code></dt>
397
398       <dd>Define as the DocumentRoot set for Apache. This will be
399       the only hierarchy (aside from UserDirs) that can be used for
400       suEXEC behavior. The default directory is the --datadir value
401       with the suffix "/htdocs", <em>e.g.</em> if you configure
402       with "<code>--datadir=/home/apache</code>" the directory
403       "/home/apache/htdocs" is used as document root for the suEXEC
404       wrapper.</dd>
405
406       <dt><code>--with-suexec-uidmin=<em>UID</em></code></dt>
407
408       <dd>Define this as the lowest UID allowed to be a target user
409       for suEXEC. For most systems, 500 or 100 is common. Default
410       value is 100.</dd>
411
412       <dt><code>--with-suexec-gidmin=<em>GID</em></code></dt>
413
414       <dd>Define this as the lowest GID allowed to be a target
415       group for suEXEC. For most systems, 100 is common and
416       therefore used as default value.</dd>
417
418       <dt><code>--with-suexec-logfile=<em>FILE</em></code></dt>
419
420       <dd>This defines the filename to which all suEXEC
421       transactions and errors are logged (useful for auditing and
422       debugging purposes). By default the logfile is named
423       "suexec_log" and located in your standard logfile directory
424       (--logfiledir).</dd>
425
426       <dt><code>--with-suexec-safepath=<em>PATH</em></code></dt>
427
428       <dd>Define a safe PATH environment to pass to CGI
429       executables. Default value is
430       "/usr/local/bin:/usr/bin:/bin".</dd>
431     </dl>
432
433     <p><strong>Checking your suEXEC
434     setup</strong><br />
435      Before you compile and install the suEXEC wrapper you can
436     check the configuration with the --layout option.<br />
437      Example output:</p>
438
439 <div class="example"><p><code>
440     suEXEC setup:<br />
441             suexec binary: /usr/local/apache/sbin/suexec<br />
442             document root: /usr/local/apache/share/htdocs<br />
443            userdir suffix: public_html<br />
444                   logfile: /usr/local/apache/var/log/suexec_log<br />
445                 safe path: /usr/local/bin:/usr/bin:/bin<br />
446                 caller ID: www<br />
447           minimum user ID: 100<br />
448          minimum group ID: 100<br />
449 </code></p></div>
450
451     <p><strong>Compiling and installing the suEXEC
452     wrapper</strong><br />
453      If you have enabled the suEXEC feature with the
454     --enable-suexec option the suexec binary (together with Apache
455     itself) is automatically built if you execute the command
456     "make".<br />
457      After all components have been built you can execute the
458     command "make install" to install them. The binary image
459     "suexec" is installed in the directory defined by the --sbindir
460     option. Default location is
461     "/usr/local/apache/sbin/suexec".<br />
462      Please note that you need <strong><em>root
463     privileges</em></strong> for the installation step. In order
464     for the wrapper to set the user ID, it must be installed as
465     owner <code><em>root</em></code> and must have the setuserid
466     execution bit set for file modes.</p>
467
468 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
469 <div class="section">
470 <h2><a name="enable" id="enable">Enabling &amp; Disabling
471     suEXEC</a></h2>
472
473     <p>Upon startup of Apache, it looks for the file
474     "suexec" in the "sbin" directory (default is
475     "/usr/local/apache/sbin/suexec"). If Apache finds a properly
476     configured suEXEC wrapper, it will print the following message
477     to the error log:</p>
478 <div class="example"><p><code>
479     [notice] suEXEC mechanism enabled (wrapper: <em>/path/to/suexec</em>)
480 </code></p></div>
481     <p>If you don't see this message at server startup, the server is
482     most likely not finding the wrapper program where it expects
483     it, or the executable is not installed <em>setuid root</em>.</p>
484
485      <p>If you want to enable the suEXEC mechanism for the first time
486     and an Apache server is already running you must kill and
487     restart Apache. Restarting it with a simple HUP or USR1 signal
488     will not be enough. </p>
489      <p>If you want to disable suEXEC you should kill and restart
490     Apache after you have removed the "suexec" file. </p>
491 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
492 <div class="section">
493 <h2><a name="usage" id="usage">Using suEXEC</a></h2>
494
495     <p><strong>Virtual Hosts:</strong><br /> One way to use the suEXEC
496     wrapper is through the <code class="directive"><a href="./mod/mod_suexec.html#suexecusergroup">SuexecUserGroup</a></code> directive in
497     <code class="directive"><a href="./mod/core.html#virtualhost">VirtualHost</a></code> definitions.  By
498     setting this directive to values different from the main server
499     user ID, all requests for CGI resources will be executed as the
500     <em>User</em> and <em>Group</em> defined for that <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>. If this
501     directive is not specified for a <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> then the main server userid
502     is assumed.</p>
503
504     <p><strong>User directories:</strong><br />
505      The suEXEC wrapper can also be used to execute CGI programs as
506     the user to which the request is being directed. This is
507     accomplished by using the "<strong><code>~</code></strong>"
508     character prefixing the user ID for whom execution is desired.
509     The only requirement needed for this feature to work is for CGI
510     execution to be enabled for the user and that the script must
511     meet the scrutiny of the <a href="#model">security checks</a>
512     above.</p>
513 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
514 <div class="section">
515 <h2><a name="debug" id="debug">Debugging suEXEC</a></h2>
516
517     <p>The suEXEC wrapper will write log information
518     to the file defined with the --with-suexec-logfile option as
519     indicated above. If you feel you have configured and installed
520     the wrapper properly, have a look at this log and the error_log
521     for the server to see where you may have gone astray.</p>
522
523 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
524 <div class="section">
525 <h2><a name="jabberwock" id="jabberwock">Beware the Jabberwock:
526     Warnings &amp; Examples</a></h2>
527
528     <p><strong>NOTE!</strong> This section may not be
529     complete. For the latest revision of this section of the
530     documentation, see the Apache Group's <a href="http://httpd.apache.org/docs-2.1/suexec.html">Online
531     Documentation</a> version.</p>
532
533     <p>There are a few points of interest regarding
534     the wrapper that can cause limitations on server setup. Please
535     review these before submitting any "bugs" regarding suEXEC.</p>
536
537     <ul>
538       <li><strong>suEXEC Points Of Interest</strong></li>
539
540       <li>
541         Hierarchy limitations 
542
543         <p class="indent">
544           For security and efficiency reasons, all suexec requests
545           must remain within either a top-level document root for
546           virtual host requests, or one top-level personal document
547           root for userdir requests. For example, if you have four
548           VirtualHosts configured, you would need to structure all
549           of your VHosts' document roots off of one main Apache
550           document hierarchy to take advantage of suEXEC for
551           VirtualHosts. (Example forthcoming.)
552         </p>
553       </li>
554
555       <li>
556         suEXEC's PATH environment variable 
557
558         <p class="indent">
559           This can be a dangerous thing to change. Make certain
560           every path you include in this define is a
561           <strong>trusted</strong> directory. You don't want to
562           open people up to having someone from across the world
563           running a trojan horse on them.
564         </p>
565       </li>
566
567       <li>
568         Altering the suEXEC code 
569
570         <p class="indent">
571           Again, this can cause <strong>Big Trouble</strong> if you
572           try this without knowing what you are doing. Stay away
573           from it if at all possible.
574         </p>
575       </li>
576     </ul>
577
578 </div></div>
579 <div class="bottomlang">
580 <p><span>Available Languages: </span><a href="./en/suexec.html" hreflang="en" title="English">&nbsp;en&nbsp;</a> | <a href="./ja/suexec.html" hreflang="ja" title="Japanese">&nbsp;ja&nbsp;</a> | <a href="./ko/suexec.html" hreflang="ko" title="Korean">&nbsp;ko&nbsp;</a></p>
581 </div><div id="footer">
582 <p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
583 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div>
584 </body></html>