summaryrefslogtreecommitdiffstats
path: root/docs/xml/security.xml
blob: a1f2f57705850c19d6500984692c34353db4c9b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
<?xml version="1.0"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
                      "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
    <!ENTITY % myents SYSTEM "bugzilla.ent">
    %myents;
]>

<chapter id="security">
<title>Bugzilla Security</title>

  <para>While some of the items in this chapter are related to the operating
  system Bugzilla is running on or some of the support software required to
  run Bugzilla, it is all related to protecting your data. This is not
  intended to be a comprehensive guide to securing Linux, Apache, MySQL, or
  any other piece of software mentioned. There is no substitute for active
  administration and monitoring of a machine. The key to good security is
  actually right in the middle of the word: <emphasis>U R It</emphasis>.
  </para>
  
  <para>While programmers in general always strive to write secure code,
  accidents can and do happen. The best approach to security is to always
  assume that the program you are working with isn't 100% secure and restrict
  its access to other parts of your machine as much as possible.
  </para>
 
  <section id="security-os">
  <title>Operating System</title>
  
    <section id="security-os-ports">
    <title>TCP/IP Ports</title>
    
      <!-- TODO: Get exact number of ports -->
      <para>The TCP/IP standard defines more than 65,000 ports for sending
      and receiving traffic. Of those, Bugzilla needs exactly one to operate
      (different configurations and options may require up to 3). You should
      audit your server and make sure that you aren't listening on any ports
      you don't need to be. It's also highly recommended that the server
      Bugzilla resides on, along with any other machines you administer, be
      placed behind some kind of firewall.
      </para>
    
    </section>
    
    <section id="security-os-accounts">
    <title>System User Accounts</title>
    
      <para>Many <glossterm linkend="gloss-daemon">daemons</glossterm>, such
      as Apache's <filename>httpd</filename> or MySQL's
      <filename>mysqld</filename>, run as either <quote>root</quote> or
      <quote>nobody</quote>. This is even worse on Windows machines where the
      majority of <glossterm linkend="gloss-service">services</glossterm>
      run as <quote>SYSTEM</quote>. While running as <quote>root</quote> or
      <quote>SYSTEM</quote> introduces obvious security concerns, the
      problems introduced by running everything as <quote>nobody</quote> may
      not be so obvious. Basically, if you run every daemon as
      <quote>nobody</quote> and one of them gets comprimised it can
      comprimise every other daemon running as <quote>nobody</quote> on your
      machine. For this reason, it is recommended that you create a user
      account for each daemon.
      </para>
    
      <note>
        <para>You will need to set the <option>webservergroup</option> option
        in <filename>localconfig</filename> to the group your webserver runs
        as. This will allow <filename>./checksetup.pl</filename> to set file
        permissions on Unix systems so that nothing is world-writable.
        </para>
      </note>
    
    </section>
    
    <section id="security-os-chroot">
    <title>The <filename>chroot</filename> Jail</title>
    
      <para>
        If your system supports it, you may wish to consider running
        Bugzilla inside of a <filename>chroot</filename> jail. This option
        provides unprecedented security by restricting anything running
        inside the jail from accessing any information outside of it. If you
        wish to use this option, please consult the documentation that came
        with your system.
      </para>
      
    </section>
  
  </section>
  
  
  
  <section id="security-mysql">
  <title>MySQL</title>
  
    <section id="security-mysql-account">
    <title>The MySQL System Account</title>
    
      <para>As mentioned in <xref linkend="security-os-accounts"/>, the MySQL
      daemon should run as a non-privleged, unique user. Be sure to consult
      the MySQL documentation or the documentation that came with your system
      for instructions.
      </para>
    </section>
    
    <section id="security-mysql-root">
    <title>The MySQL <quote>root</quote> and <quote>anonymous</quote> Users</title>
    
      <para>By default, MySQL comes with a <quote>root</quote> user with a
      blank password and an <quote>anonymous</quote> user, also with a blank
      password. In order to protect your data, the <quote>root</quote> user
      should be given a password and the anonymous user should be disabled.
      </para>
      
      <example id="security-mysql-account-root">
      <title>Assigning the MySQL <quote>root</quote> User a Password</title>
      
        <screen>
<prompt>bash$</prompt> mysql mysql
<prompt>mysql&gt;</prompt> UPDATE user SET password = password('<replaceable>new_password</replaceable>') WHERE user = 'root';
<prompt>mysql&gt;</prompt> FLUSH PRIVILEGES;
        </screen>
      </example>
      
      <example id="security-mysql-account-anonymous">
      <title>Disabling the MySQL <quote>anonymous</quote> User</title>
        <screen>
<prompt>bash$</prompt> mysql -u root -p mysql           <co id="security-mysql-account-anonymous-mysql"/>
<prompt>Enter Password:</prompt> <replaceable>new_password</replaceable>
<prompt>mysql&gt;</prompt> DELETE FROM user WHERE user = '';
<prompt>mysql&gt;</prompt> FLUSH PRIVILEGES;
        </screen>
        <calloutlist>
          <callout arearefs="security-mysql-account-anonymous-mysql">
            <para>This command assumes that you have already completed
            <xref linkend="security-mysql-account-root"/>.
            </para>
          </callout>
        </calloutlist>
      </example>
          
    </section>
    
    <section id="security-mysql-network">
    <title>Network Access</title>
    
      <para>If MySQL and your webserver both run on the same machine and you
      have no other reason to access MySQL remotely, then you should disable
      the network access. This, along with the suggestion in
      <xref linkend="security-os-ports"/>, will help protect your system from
      any remote vulnerabilites in MySQL.
      </para>
      
      <example id="security-mysql-network-ex">
      <title>Disabling Networking in MySQL</title>
      
        <para>Simply enter the following in <filename>/etc/my.conf</filename>:
        <screen>
[myslqd]
# Prevent network access to MySQL.
skip-networking
        </screen>
        </para>
      </example>
      
    </section>


<!-- For possible addition in the future: How to better control the bugs user
    <section id="security-mysql-bugs">
    <title>The bugs User</title>
    
    </section>
-->
  
  </section>
  
  
  
  <section id="security-webserver">
  <title>Webserver</title>

    <section id="security-webserver-access">
    <title>Disabling Remote Access to Bugzilla Configuration Files</title>
    
      <para>There are many files that are placed in the Bugzilla directory
      area that should not be accessable from the web. Because of the way
      Bugzilla is currently layed out, the list of what should and should not
      be accessible is rather complicated. A new installation method is
      currently in the works which should solve this by allowing files that
      shouldn't be accessible from the web to be placed in a directory outside
      the webroot. See 
      <ulink url="http://bugzilla.mozilla.org/show_bug.cgi?id=44659">bug 44659</ulink>
      for more information.
      </para>
      
      <tip>
        <para>Bugzilla ships with the ability to create
        <glossterm linkend="gloss-htaccess"><filename>.htaccess</filename></glossterm>
        files that enforce these rules. Instructions for enabling these
        directives in Apache can be found in <xref linkend="http-apache"/>
        </para>
      </tip>
        
      <itemizedlist spacing="compact">
        <listitem>
          <para>In the main Bugzilla directory, you should:</para>
          <itemizedlist spacing="compact">
            <listitem>
              <para>Block:
              <simplelist type="inline">
                <member><filename>*.pl</filename></member>
                <member><filename>*localconfig*</filename></member>
              </simplelist>
              </para>
            </listitem>
          </itemizedlist>
        </listitem>

        <listitem>
          <para>In <filename class="directory">data</filename>:</para>
          <itemizedlist spacing="compact">
            <listitem>
              <para>Block everything</para>
            </listitem>
            <listitem>
              <para>But allow:
              <simplelist type="inline">
                <member><filename>duplicates.rdf</filename></member>
              </simplelist>
              </para>
            </listitem>
          </itemizedlist>
        </listitem>

        <listitem>
          <para>In <filename class="directory">data/webdot</filename>:</para>
          <itemizedlist spacing="compact">
            <listitem>
              <para>If you use a remote webdot server:</para>
              <itemizedlist spacing="compact">
                <listitem>
                  <para>Block everything</para>
                </listitem>
                <listitem>
                  <para>But allow
                  <simplelist type="inline">
                    <member><filename>*.dot</filename></member>
                  </simplelist>
                  only for the remote webdot server</para>
                </listitem>
              </itemizedlist>
            </listitem>
            <listitem>
              <para>Otherwise, if you use a local GraphViz:</para>
              <itemizedlist spacing="compact">
                <listitem>
                  <para>Block everything</para>
                </listitem>
                <listitem>
                  <para>But allow:
                  <simplelist type="inline">
                    <member><filename>*.png</filename></member>
                    <member><filename>*.gif</filename></member>
                    <member><filename>*.jpg</filename></member>
                    <member><filename>*.map</filename></member>
                  </simplelist>
                  </para>
                </listitem>
              </itemizedlist>
            </listitem>
            <listitem>
              <para>And if you don't use any dot:</para>
              <itemizedlist spacing="compact">
                <listitem>
                  <para>Block everything</para>
                </listitem>
              </itemizedlist>
            </listitem>
          </itemizedlist>
        </listitem>

        <listitem>
          <para>In <filename class="directory">Bugzilla</filename>:</para>
          <itemizedlist spacing="compact">
            <listitem>
              <para>Block everything</para>
            </listitem>
          </itemizedlist>
        </listitem>

        <listitem>
          <para>In <filename class="directory">template</filename>:</para>
          <itemizedlist spacing="compact">
            <listitem>
              <para>Block everything</para>
            </listitem>
          </itemizedlist>
        </listitem>
      </itemizedlist>

      <para>Be sure to test that data that should not be accessed remotely is
      properly blocked. Of particular intrest is the localconfig file which
      contains your database password. Also, be aware that many editors
      create temporary and backup files in the working directory and that
      those should also not be accessable. For more information, see 
      <ulink url="http://bugzilla.mozilla.org/show_bug.cgi?id=186383">bug 186383</ulink>
      or
      <ulink url="http://online.securityfocus.com/bid/6501">Bugtraq ID 6501</ulink>.
      To test, simply point your web browser at the file; for example, to
      test mozilla.org's installation, we'd try to access
      <ulink url="http://bugzilla.mozilla.org/localconfig"/>. You should get
      a <quote><errorcode>403</errorcode> <errorname>Forbidden</errorname></quote>
      error.
      </para>
      
      <tip>
        <para>Be sure to check <xref linkend="http"/> for instructions
        specific to the webserver you use.
        </para>
      </tip>
    
    </section>


    <section id="security-webserver-mod-throttle">
      <title>Using <filename>mod_throttle</filename> to Prevent a DOS</title>

      <note>
        <para>This section only applies to people who have chosen the Apache
        webserver. It may be possible to do similar things with other
        webservers. Consult the documentation that came with your webserver
        to find out.
        </para>
      </note>

      <para>It is possible for a user, by mistake or on purpose, to access
      the database many times in a row which can result in very slow access
      speeds for other users (effectively, a
      <glossterm linkend="gloss-dos">DOS</glossterm> attack). If your
      Bugzilla installation is experiencing this problem, you may install
      the Apache module <filename>mod_throttle</filename> which can limit
      connections by IP address. You may download this module at 
      <ulink url="http://www.snert.com/Software/mod_throttle/"/>.
      Follow the instructions to install into your Apache install. 
      The command you need is 
      <command>ThrottleClientIP</command>. See the 
      <ulink url="http://www.snert.com/Software/mod_throttle/">documentation</ulink>
      for more information.</para>
    </section>

      
  </section>
  
  
  <section id="security-bugzilla">
  <title>Bugzilla</title>

    <section id="security-bugzilla-charset">
    <title>Prevent users injecting malicious Javascript</title>

      <para>If you installed Bugzilla version 2.22 or later from scratch,
      then the <emphasis>utf8</emphasis> parameter is switched on by default.
      This makes Bugzilla explicitly set the character encoding, following
      <ulink
      url="http://www.cert.org/tech_tips/malicious_code_mitigation.html#3">a
      CERT advisory</ulink> recommending exactly this.
      The following therefore does not apply to you; just keep
      <emphasis>utf8</emphasis> turned on.
      </para>

      <para>If you've upgraded from an older version, then it may be possible
      for a Bugzilla user to take advantage of character set encoding
      ambiguities to inject HTML into Bugzilla comments.
      This could include malicious scripts. 
      This is because due to internationalization concerns, we are unable to
      turn the <emphasis>utf8</emphasis> parameter on by default for upgraded
      installations.
      Turning it on manually will prevent this problem.
      </para>
    </section>    
    
  </section>

</chapter> 

<!-- Keep this comment at the end of the file 
Local variables: 
mode: sgml 
sgml-always-quote-attributes:t
sgml-auto-insert-required-elements:t
sgml-balanced-tag-edit:t
sgml-exposed-tags:nil
sgml-general-insert-case:lower
sgml-indent-data:t 
sgml-indent-step:2 
sgml-local-catalogs:nil
sgml-local-ecat-files:nil 
sgml-minimize-attributes:nil
sgml-namecase-general:t 
sgml-omittag:t
sgml-parent-document:("Bugzilla-Guide.xml" "book" "chapter")
sgml-shorttag:t 
sgml-tag-region-if-active:t 
End: -->