Bv9ARM.ch07.html 8.72 KB
Newer Older
Mark Andrews's avatar
regen  
Mark Andrews committed
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 3 4 5 6 7
<HTML
><HEAD
><TITLE
>BIND 9 Security Considerations</TITLE
><META
NAME="GENERATOR"
Mark Andrews's avatar
regen  
Mark Andrews committed
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
9
REL="HOME"
Andreas Gustafsson's avatar
Andreas Gustafsson committed
10
TITLE="BIND 9 Administrator Reference Manual"
11 12 13 14 15 16 17 18
HREF="Bv9ARM.html"><LINK
REL="PREVIOUS"
TITLE="BIND 9 Configuration Reference"
HREF="Bv9ARM.ch06.html"><LINK
REL="NEXT"
TITLE="Troubleshooting"
HREF="Bv9ARM.ch08.html"></HEAD
><BODY
Andreas Gustafsson's avatar
Andreas Gustafsson committed
19
CLASS="chapter"
20 21 22 23 24 25 26 27
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
Mark Andrews's avatar
Mark Andrews committed
28
SUMMARY="Header navigation table"
29 30 31 32 33 34 35 36
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
Andreas Gustafsson's avatar
Andreas Gustafsson committed
37
>BIND 9 Administrator Reference Manual</TH
38 39 40 41 42 43 44 45
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="Bv9ARM.ch06.html"
Mark Andrews's avatar
Mark Andrews committed
46
ACCESSKEY="P"
47 48 49 50 51 52 53 54 55 56 57 58 59
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="Bv9ARM.ch08.html"
Mark Andrews's avatar
Mark Andrews committed
60
ACCESSKEY="N"
61 62 63 64 65 66 67 68 69 70 71 72
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="chapter"
><H1
><A
NAME="ch07"
Mark Andrews's avatar
regen  
Mark Andrews committed
73 74
></A
>Chapter 7. <ACRONYM
75
CLASS="acronym"
Mark Andrews's avatar
regen  
Mark Andrews committed
76 77
>BIND</ACRONYM
> 9 Security Considerations</H1
78 79 80 81 82 83 84 85 86 87 88 89 90 91
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
>7.1. <A
HREF="Bv9ARM.ch07.html#Access_Control_Lists"
>Access Control Lists</A
></DT
><DT
>7.2. <A
Mark Andrews's avatar
regen  
Mark Andrews committed
92
HREF="Bv9ARM.ch07.html#AEN4808"
93 94 95 96 97 98 99 100 101 102 103
><B
CLASS="command"
>chroot</B
> and <B
CLASS="command"
>setuid</B
> (for
UNIX servers)</A
></DT
><DT
>7.3. <A
Andreas Gustafsson's avatar
Andreas Gustafsson committed
104 105
HREF="Bv9ARM.ch07.html#dynamic_update_security"
>Dynamic Update Security</A
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
></DT
></DL
></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="Access_Control_Lists"
>7.1. Access Control Lists</A
></H1
><P
>Access Control Lists (ACLs), are address match lists that
you can set up and nickname for future use in <B
CLASS="command"
Andreas Gustafsson's avatar
Andreas Gustafsson committed
121 122 123 124
>allow-notify</B
>,
<B
CLASS="command"
125 126 127 128
>allow-query</B
>, <B
CLASS="command"
>allow-recursion</B
Andreas Gustafsson's avatar
Andreas Gustafsson committed
129 130
>,
<B
131 132 133 134 135 136 137 138 139
CLASS="command"
>blackhole</B
>, <B
CLASS="command"
>allow-transfer</B
>,
etc.</P
><P
>Using ACLs allows you to have finer control over who can access
Andreas Gustafsson's avatar
Andreas Gustafsson committed
140
your name server, without cluttering up your config files with huge
141 142
lists of IP addresses.</P
><P
Mark Andrews's avatar
Mark Andrews committed
143 144 145
>It is a <SPAN
CLASS="emphasis"
><I
146 147
CLASS="emphasis"
>good idea</I
Mark Andrews's avatar
Mark Andrews committed
148
></SPAN
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
> to use ACLs, and to
control access to your server. Limiting access to your server by
outside parties can help prevent spoofing and DoS attacks against
your server.</P
><P
>Here is an example of how to properly apply ACLs:</P
><PRE
CLASS="programlisting"
>&#13;// Set up an ACL named "bogusnets" that will block RFC1918 space,
// which is commonly used in spoofing attacks.
acl bogusnets { 0.0.0.0/8; 1.0.0.0/8; 2.0.0.0/8; 192.0.2.0/24; 224.0.0.0/3; 10.0.0.0/8; 172.16.0.0/12; 192.168.0.0/16; };
// Set up an ACL called our-nets. Replace this with the real IP numbers.
acl our-nets { x.x.x.x/24; x.x.x.x/21; }; 
options {
  ...
  ...
  allow-query { our-nets; };
  allow-recursion { our-nets; };
  ...
  blackhole { bogusnets; };
  ...
};
zone "example.com" {
  type master;
  file "m/example.com";
  allow-query { any; };
};
</PRE
><P
>This allows recursive queries of the server from the outside
unless recursion has been previously disabled.</P
><P
>For more information on how to use ACLs to protect your server,
Mark Andrews's avatar
Mark Andrews committed
182 183 184
see the <SPAN
CLASS="emphasis"
><I
185 186
CLASS="emphasis"
>AUSCERT</I
Mark Andrews's avatar
Mark Andrews committed
187
></SPAN
188 189 190 191 192 193 194 195 196 197 198 199
> advisory at
<A
HREF="ftp://ftp.auscert.org.au/pub/auscert/advisory/AL-1999.004.dns_dos"
TARGET="_top"
>ftp://ftp.auscert.org.au/pub/auscert/advisory/AL-1999.004.dns_dos</A
></P
></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
Mark Andrews's avatar
regen  
Mark Andrews committed
200
NAME="AEN4808"
201 202 203 204 205 206 207 208 209 210
>7.2. <B
CLASS="command"
>chroot</B
> and <B
CLASS="command"
>setuid</B
> (for
UNIX servers)</A
></H1
><P
Mark Andrews's avatar
regen  
Mark Andrews committed
211
>On UNIX servers, it is possible to run <ACRONYM
212
CLASS="acronym"
Mark Andrews's avatar
regen  
Mark Andrews committed
213
>BIND</ACRONYM
Mark Andrews's avatar
Mark Andrews committed
214 215 216
> in a <SPAN
CLASS="emphasis"
><I
217 218
CLASS="emphasis"
>chrooted</I
Mark Andrews's avatar
Mark Andrews committed
219
></SPAN
220 221 222 223
> environment
(<B
CLASS="command"
>chroot()</B
Mark Andrews's avatar
regen  
Mark Andrews committed
224
>) by specifying the "<VAR
225
CLASS="option"
Mark Andrews's avatar
regen  
Mark Andrews committed
226
>-t</VAR
227
>"
Mark Andrews's avatar
regen  
Mark Andrews committed
228
option. This can help improve system security by placing <ACRONYM
229
CLASS="acronym"
Mark Andrews's avatar
regen  
Mark Andrews committed
230
>BIND</ACRONYM
231
> in
Andreas Gustafsson's avatar
Andreas Gustafsson committed
232
a "sandbox", which will limit the damage done if a server is compromised.</P
233
><P
Mark Andrews's avatar
regen  
Mark Andrews committed
234
>Another useful feature in the UNIX version of <ACRONYM
235
CLASS="acronym"
Mark Andrews's avatar
regen  
Mark Andrews committed
236
>BIND</ACRONYM
237
> is the
Mark Andrews's avatar
regen  
Mark Andrews committed
238
ability to run the daemon as an unprivileged user ( <VAR
239
CLASS="option"
Mark Andrews's avatar
regen  
Mark Andrews committed
240 241
>-u</VAR
> <VAR
242
CLASS="replaceable"
Mark Andrews's avatar
regen  
Mark Andrews committed
243
>user</VAR
244
> ).
Andreas Gustafsson's avatar
Andreas Gustafsson committed
245
We suggest running as an unprivileged user when using the <B
246 247 248 249
CLASS="command"
>chroot</B
> feature.</P
><P
Mark Andrews's avatar
regen  
Mark Andrews committed
250
>Here is an example command line to load <ACRONYM
251
CLASS="acronym"
Mark Andrews's avatar
regen  
Mark Andrews committed
252
>BIND</ACRONYM
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
> in a <B
CLASS="command"
>chroot()</B
> sandbox, 
<B
CLASS="command"
>/var/named</B
>, and to run <B
CLASS="command"
>named</B
> <B
CLASS="command"
>setuid</B
> to
user 202:</P
><P
Mark Andrews's avatar
regen  
Mark Andrews committed
269
><KBD
270
CLASS="userinput"
Mark Andrews's avatar
regen  
Mark Andrews committed
271
>/usr/local/bin/named -u 202 -t /var/named</KBD
272 273 274 275 276 277
></P
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
Mark Andrews's avatar
regen  
Mark Andrews committed
278
NAME="AEN4831"
279 280 281 282 283 284 285 286 287 288
>7.2.1. The <B
CLASS="command"
>chroot</B
> Environment</A
></H2
><P
>In order for a <B
CLASS="command"
>chroot()</B
> environment to
Andreas Gustafsson's avatar
Andreas Gustafsson committed
289 290
work properly in a particular directory
(for example, <TT
291 292 293 294
CLASS="filename"
>/var/named</TT
>),
you will need to set up an environment that includes everything
Mark Andrews's avatar
regen  
Mark Andrews committed
295
<ACRONYM
296
CLASS="acronym"
Mark Andrews's avatar
regen  
Mark Andrews committed
297
>BIND</ACRONYM
Andreas Gustafsson's avatar
Andreas Gustafsson committed
298
> needs to run.
Mark Andrews's avatar
regen  
Mark Andrews committed
299
From <ACRONYM
300
CLASS="acronym"
Mark Andrews's avatar
regen  
Mark Andrews committed
301
>BIND</ACRONYM
302 303 304 305
>'s point of view, <TT
CLASS="filename"
>/var/named</TT
> is
Andreas Gustafsson's avatar
Andreas Gustafsson committed
306 307
the root of the filesystem.  You will need to adjust the values of options like
like <B
308
CLASS="command"
Andreas Gustafsson's avatar
Andreas Gustafsson committed
309 310 311 312 313 314 315
>directory</B
> and <B
CLASS="command"
>pid-file</B
> to account
for this.
</P
316
><P
Andreas Gustafsson's avatar
Andreas Gustafsson committed
317
>&#13;Unlike with earlier versions of BIND, you will typically
Mark Andrews's avatar
Mark Andrews committed
318 319 320
<SPAN
CLASS="emphasis"
><I
Andreas Gustafsson's avatar
Andreas Gustafsson committed
321 322
CLASS="emphasis"
>not</I
Mark Andrews's avatar
Mark Andrews committed
323
></SPAN
Andreas Gustafsson's avatar
Andreas Gustafsson committed
324
> need to compile <B
325
CLASS="command"
Andreas Gustafsson's avatar
Andreas Gustafsson committed
326 327 328
>named</B
>
statically nor install shared libraries under the new root.
Andreas Gustafsson's avatar
Andreas Gustafsson committed
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
However, depending on your operating system, you may need
to set up things like
<TT
CLASS="filename"
>/dev/zero</TT
>,
<TT
CLASS="filename"
>/dev/random</TT
>,
<TT
CLASS="filename"
>/dev/log</TT
>, and/or
<TT
CLASS="filename"
>/etc/localtime</TT
>.
Andreas Gustafsson's avatar
Andreas Gustafsson committed
347
</P
348 349 350 351 352 353
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
Mark Andrews's avatar
regen  
Mark Andrews committed
354
NAME="AEN4849"
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
>7.2.2. Using the <B
CLASS="command"
>setuid</B
> Function</A
></H2
><P
>Prior to running the <B
CLASS="command"
>named</B
> daemon, use
the <B
CLASS="command"
>touch</B
> utility (to change file access and
modification times) or the <B
CLASS="command"
>chown</B
> utility (to
Andreas Gustafsson's avatar
Andreas Gustafsson committed
373
set the user id and/or group id) on files
Mark Andrews's avatar
regen  
Mark Andrews committed
374
to which you want <ACRONYM
375
CLASS="acronym"
Mark Andrews's avatar
regen  
Mark Andrews committed
376
>BIND</ACRONYM
377
>
378 379 380
to write.  Note that if the <B
CLASS="command"
>named</B
Andreas Gustafsson's avatar
Andreas Gustafsson committed
381 382
> daemon is running as an
unprivileged user, it will not be able to bind to new restricted ports if the
383
server is reloaded.</P
384 385 386 387 388 389 390
></DIV
></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
Andreas Gustafsson's avatar
Andreas Gustafsson committed
391 392
NAME="dynamic_update_security"
>7.3. Dynamic Update Security</A
393 394
></H1
><P
Andreas Gustafsson's avatar
Andreas Gustafsson committed
395 396
>Access to the dynamic
update facility should be strictly limited.  In earlier versions of
Mark Andrews's avatar
regen  
Mark Andrews committed
397
<ACRONYM
398
CLASS="acronym"
Mark Andrews's avatar
regen  
Mark Andrews committed
399
>BIND</ACRONYM
Andreas Gustafsson's avatar
Andreas Gustafsson committed
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
> the only way to do this was based on the IP
address of the host requesting the update, by listing an IP address or
network prefix in the <B
CLASS="command"
>allow-update</B
> zone option.
This method is insecure since the source address of the update UDP packet
is easily forged.  Also note that if the IP addresses allowed by the
<B
CLASS="command"
>allow-update</B
> option include the address of a slave
server which performs forwarding of dynamic updates, the master can be
trivially attacked by sending the update to the slave, which will
forward it to the master with its own source IP address causing the
master to approve it without question.</P
><P
>For these reasons, we strongly recommend that updates be
418 419
cryptographically authenticated by means of transaction signatures
(TSIG).  That is, the <B
Andreas Gustafsson's avatar
Andreas Gustafsson committed
420 421
CLASS="command"
>allow-update</B
422 423 424
> option should
list only TSIG key names, not IP addresses or network
prefixes. Alternatively, the new <B
Andreas Gustafsson's avatar
Andreas Gustafsson committed
425 426
CLASS="command"
>update-policy</B
427 428
>
option can be used.</P
429 430 431 432 433 434 435 436 437 438 439 440 441
><P
>Some sites choose to keep all dynamically updated DNS data
in a subdomain and delegate that subdomain to a separate zone. This
way, the top-level zone containing critical data such as the IP addresses
of public web and mail servers need not allow dynamic update at
all.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
Mark Andrews's avatar
Mark Andrews committed
442
SUMMARY="Footer navigation table"
443 444 445 446 447 448 449 450 451 452 453
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="Bv9ARM.ch06.html"
Mark Andrews's avatar
Mark Andrews committed
454
ACCESSKEY="P"
455 456 457 458 459 460 461 462
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="Bv9ARM.html"
Mark Andrews's avatar
Mark Andrews committed
463
ACCESSKEY="H"
464 465 466 467 468 469 470 471
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="Bv9ARM.ch08.html"
Mark Andrews's avatar
Mark Andrews committed
472
ACCESSKEY="N"
473 474 475 476 477 478 479 480
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
Mark Andrews's avatar
regen  
Mark Andrews committed
481
><ACRONYM
482
CLASS="acronym"
Mark Andrews's avatar
regen  
Mark Andrews committed
483
>BIND</ACRONYM
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
> 9 Configuration Reference</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Troubleshooting</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>