Bv9ARM.ch07.html revision fa535fa05f36a1a45027faf9d116cfa3249d9d72
286N/A<!--
286N/A - Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC")
286N/A - Copyright (C) 2000-2003 Internet Software Consortium.
286N/A -
286N/A - Permission to use, copy, modify, and/or distribute this software for any
286N/A - purpose with or without fee is hereby granted, provided that the above
286N/A - copyright notice and this permission notice appear in all copies.
286N/A -
286N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
286N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
286N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
286N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
286N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
286N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
286N/A - PERFORMANCE OF THIS SOFTWARE.
286N/A-->
286N/A<!-- $Id$ -->
286N/A<html>
286N/A<head>
286N/A<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
286N/A<title>Chapter�7.�BIND 9 Security Considerations</title>
286N/A<meta name="generator" content="DocBook XSL Stylesheets V1.71.1">
286N/A<link rel="start" href="Bv9ARM.html" title="BIND 9 Administrator Reference Manual">
286N/A<link rel="up" href="Bv9ARM.html" title="BIND 9 Administrator Reference Manual">
286N/A<link rel="prev" href="Bv9ARM.ch06.html" title="Chapter�6.�BIND 9 Configuration Reference">
286N/A<link rel="next" href="Bv9ARM.ch08.html" title="Chapter�8.�Troubleshooting">
286N/A</head>
286N/A<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
286N/A<div class="navheader">
286N/A<table width="100%" summary="Navigation header">
286N/A<tr><th colspan="3" align="center">Chapter�7.�<acronym class="acronym">BIND</acronym> 9 Security Considerations</th></tr>
286N/A<tr>
293N/A<td width="20%" align="left">
286N/A<a accesskey="p" href="Bv9ARM.ch06.html">Prev</a>�</td>
286N/A<th width="60%" align="center">�</th>
286N/A<td width="20%" align="right">�<a accesskey="n" href="Bv9ARM.ch08.html">Next</a>
286N/A</td>
286N/A</tr>
286N/A</table>
286N/A<hr>
286N/A</div>
286N/A<div class="chapter" lang="en">
286N/A<div class="titlepage"><div><div><h2 class="title">
286N/A<a name="Bv9ARM.ch07"></a>Chapter�7.�<acronym class="acronym">BIND</acronym> 9 Security Considerations</h2></div></div></div>
286N/A<div class="toc">
286N/A<p><b>Table of Contents</b></p>
286N/A<dl>
286N/A<dt><span class="sect1"><a href="Bv9ARM.ch07.html#Access_Control_Lists">Access Control Lists</a></span></dt>
286N/A<dt><span class="sect1"><a href="Bv9ARM.ch07.html#id2608664"><span><strong class="command">Chroot</strong></span> and <span><strong class="command">Setuid</strong></span></a></span></dt>
286N/A<dd><dl>
286N/A<dt><span class="sect2"><a href="Bv9ARM.ch07.html#id2608813">The <span><strong class="command">chroot</strong></span> Environment</a></span></dt>
286N/A<dt><span class="sect2"><a href="Bv9ARM.ch07.html#id2608873">Using the <span><strong class="command">setuid</strong></span> Function</a></span></dt>
286N/A</dl></dd>
286N/A<dt><span class="sect1"><a href="Bv9ARM.ch07.html#dynamic_update_security">Dynamic Update Security</a></span></dt>
286N/A</dl>
286N/A</div>
286N/A<div class="sect1" lang="en">
286N/A<div class="titlepage"><div><div><h2 class="title" style="clear: both">
286N/A<a name="Access_Control_Lists"></a>Access Control Lists</h2></div></div></div>
286N/A<p>
286N/A Access Control Lists (ACLs) are address match lists that
286N/A you can set up and nickname for future use in
286N/A <span><strong class="command">allow-notify</strong></span>, <span><strong class="command">allow-query</strong></span>,
286N/A <span><strong class="command">allow-query-on</strong></span>, <span><strong class="command">allow-recursion</strong></span>,
286N/A <span><strong class="command">blackhole</strong></span>, <span><strong class="command">allow-transfer</strong></span>,
286N/A <span><strong class="command">match-clients</strong></span>, etc.
286N/A </p>
286N/A<p>
286N/A Using ACLs allows you to have finer control over who can access
286N/A your name server, without cluttering up your config files with huge
286N/A lists of IP addresses.
286N/A </p>
286N/A<p>
286N/A It is a <span class="emphasis"><em>good idea</em></span> to use ACLs, and to
286N/A control access to your server. Limiting access to your server by
286N/A outside parties can help prevent spoofing and denial of service
286N/A (DoS) attacks against your server.
286N/A </p>
286N/A<p>
286N/A ACLs match clients on the basis of up to three characteristics:
286N/A 1) The client's IP address; 2) the TSIG or SIG(0) key that was
286N/A used to sign the request, if any; and 3) an address prefix
286N/A encoded in an EDNS Client Subnet option, if any.
286N/A </p>
286N/A<p>
286N/A Here is an example of ACLs based on client addresses:
286N/A </p>
286N/A<pre class="programlisting">
286N/A// Set up an ACL named "bogusnets" that will block
286N/A// RFC1918 space and some reserved space, which is
286N/A// commonly used in spoofing attacks.
286N/Aacl bogusnets {
286N/A 0.0.0.0/8; 192.0.2.0/24; 224.0.0.0/3;
286N/A 10.0.0.0/8; 172.16.0.0/12; 192.168.0.0/16;
286N/A};
286N/A
286N/A// Set up an ACL called our-nets. Replace this with the
286N/A// real IP numbers.
286N/Aacl our-nets { x.x.x.x/24; x.x.x.x/21; };
286N/Aoptions {
286N/A ...
286N/A ...
286N/A allow-query { our-nets; };
286N/A allow-recursion { our-nets; };
286N/A ...
286N/A blackhole { bogusnets; };
286N/A ...
286N/A};
286N/A
286N/Azone "example.com" {
286N/A type master;
286N/A file "m/example.com";
286N/A allow-query { any; };
286N/A};
286N/A</pre>
286N/A<p>
286N/A This allows authoritative queries for "example.com" from any
286N/A address, but recursive queries only from the networks specified
286N/A in "our-nets", and no queries at all from the networks
286N/A specified in "bogusnets".
286N/A </p>
286N/A<p>
286N/A In addition to network addresses and prefixes, which are
286N/A matched against the source address of the DNS request, ACLs
286N/A may include <code class="option">key</code> elements, which specify the
286N/A name of a TSIG or SIG(0) key, or <code class="option">ecs</code>
286N/A elements, which specify a network prefix but are only matched
286N/A if that prefix matches an EDNS client subnet option included
286N/A in the request.
286N/A </p>
286N/A<p>
286N/A The EDNS Client Subnet (ECS) option is used by a recursive
286N/A resolver to inform an authoritative name server of the network
286N/A address block from which the original query was received, enabling
286N/A authoritative servers to give different answers to the same
286N/A resolver for different resolver clients. An ACL containing
286N/A an element of the form
286N/A <span><strong class="command">ecs <em class="replaceable"><code>prefix</code></em></strong></span>
286N/A will match if a request arrives in containing an ECS option
286N/A encoding an address within that prefix. If the request has no
286N/A ECS option, then "ecs" elements are simply ignored. Addresses
286N/A in ACLs that are not prefixed with "ecs" are matched only
286N/A against the source address.
286N/A </p>
286N/A<p>
286N/A When <acronym class="acronym">BIND</acronym> 9 is built with GeoIP support,
286N/A ACLs can also be used for geographic access restrictions.
286N/A This is done by specifying an ACL element of the form:
286N/A <span><strong class="command">geoip [<span class="optional">db <em class="replaceable"><code>database</code></em></span>] <em class="replaceable"><code>field</code></em> <em class="replaceable"><code>value</code></em></strong></span>
286N/A </p>
286N/A<p>
286N/A The <em class="replaceable"><code>field</code></em> indicates which field
286N/A to search for a match. Available fields are "country",
286N/A "region", "city", "continent", "postal" (postal code),
286N/A "metro" (metro code), "area" (area code), "tz" (timezone),
286N/A "isp", "org", "asnum", "domain" and "netspeed".
286N/A </p>
286N/A<p>
286N/A <em class="replaceable"><code>value</code></em> is the value to search
286N/A for within the database. A string may be quoted if it
286N/A contains spaces or other special characters. If this is
286N/A an "asnum" search, then the leading "ASNNNN" string can be
286N/A used, otherwise the full description must be used (e.g.
293N/A "ASNNNN Example Company Name"). If this is a "country"
286N/A search and the string is two characters long, then it must
286N/A be a standard ISO-3166-1 two-letter country code, and if it
286N/A is three characters long then it must be an ISO-3166-1
286N/A three-letter country code; otherwise it is the full name
286N/A of the country. Similarly, if this is a "region" search
286N/A and the string is two characters long, then it must be a
286N/A standard two-letter state or province abbreviation;
286N/A otherwise it is the full name of the state or province.
286N/A </p>
286N/A<p>
286N/A The <em class="replaceable"><code>database</code></em> field indicates which
286N/A GeoIP database to search for a match. In most cases this is
286N/A unnecessary, because most search fields can only be found in
286N/A a single database. However, searches for country can be
286N/A answered from the "city", "region", or "country" databases,
286N/A and searches for region (i.e., state or province) can be
286N/A answered from the "city" or "region" databases. For these
286N/A search types, specifying a <em class="replaceable"><code>database</code></em>
286N/A will force the query to be answered from that database and no
286N/A other. If <em class="replaceable"><code>database</code></em> is not
286N/A specified, then these queries will be answered from the "city",
286N/A database if it is installed, or the "region" database if it is
286N/A installed, or the "country" database, in that order.
286N/A </p>
286N/A<p>
286N/A By default, if a DNS query includes an EDNS Client Subnet (ECS)
286N/A option which encodes a non-zero address prefix, then GeoIP ACLs
286N/A will be matched against that address prefix. Otherwise, they
286N/A are matched against the source address of the query. To
286N/A prevent GeoIP ACLs from matching against ECS options, set
286N/A the <span><strong class="command">geoip-use-ecs</strong></span> to <code class="literal">no</code>.
286N/A </p>
286N/A<p>
286N/A Some example GeoIP ACLs:
286N/A </p>
286N/A<pre class="programlisting">geoip country US;
286N/Ageoip country JAP;
286N/Ageoip db country country Canada;
286N/Ageoip db region region WA;
286N/Ageoip city "San Francisco";
286N/Ageoip region Oklahoma;
286N/Ageoip postal 95062;
286N/Ageoip tz "America/Los_Angeles";
286N/Ageoip org "Internet Systems Consortium";
286N/A</pre>
286N/A<p>
286N/A ACLs use a "first-match" logic rather than "best-match":
286N/A if an address prefix matches an ACL element, then that ACL
286N/A is considered to have matched even if a later element would
286N/A have matched more specifically. For example, the ACL
286N/A <span><strong class="command"> { 10/8; !10.0.0.1; }</strong></span> would actually
286N/A match a query from 10.0.0.1, because the first element
286N/A indicated that the query should be accepted, and the second
286N/A element is ignored.
286N/A </p>
286N/A<p>
286N/A When using "nested" ACLs (that is, ACLs included or referenced
286N/A within other ACLs), a negative match of a nested ACL will
286N/A the containing ACL to continue looking for matches. This
286N/A enables complex ACLs to be constructed, in which multiple
286N/A client characteristics can be checked at the same time. For
286N/A example, to construct an ACL which allows queries only when
286N/A it originates from a particular network <span class="emphasis"><em>and</em></span>
286N/A only when it is signed with a particular key, use:
286N/A </p>
286N/A<pre class="programlisting">
286N/Aallow-query { !{ !10/8; any; }; key example; };
286N/A</pre>
286N/A<p>
286N/A Within the nested ACL, any address that is
286N/A <span class="emphasis"><em>not</em></span> in the 10/8 network prefix will
286N/A be rejected, and this will terminate processing of the
286N/A ACL. Any address that <span class="emphasis"><em>is</em></span> in the 10/8
286N/A network prefix will be accepted, but this causes a negative
286N/A match of the nested ACL, so the containing ACL continues
286N/A processing. The query will then be accepted if it is signed
286N/A by the key "example", and rejected otherwise. The ACL, then,
286N/A will only matches when <span class="emphasis"><em>both</em></span> conditions
286N/A are true.
286N/A </p>
286N/A</div>
286N/A<div class="sect1" lang="en">
286N/A<div class="titlepage"><div><div><h2 class="title" style="clear: both">
286N/A<a name="id2608664"></a><span><strong class="command">Chroot</strong></span> and <span><strong class="command">Setuid</strong></span>
286N/A</h2></div></div></div>
286N/A<p>
286N/A On UNIX servers, it is possible to run <acronym class="acronym">BIND</acronym>
286N/A in a <span class="emphasis"><em>chrooted</em></span> environment (using
286N/A the <span><strong class="command">chroot()</strong></span> function) by specifying
286N/A the <code class="option">-t</code> option for <span><strong class="command">named</strong></span>.
286N/A This can help improve system security by placing
286N/A <acronym class="acronym">BIND</acronym> in a "sandbox", which will limit
286N/A the damage done if a server is compromised.
286N/A </p>
286N/A<p>
286N/A Another useful feature in the UNIX version of <acronym class="acronym">BIND</acronym> is the
286N/A ability to run the daemon as an unprivileged user ( <code class="option">-u</code> <em class="replaceable"><code>user</code></em> ).
286N/A We suggest running as an unprivileged user when using the <span><strong class="command">chroot</strong></span> feature.
286N/A </p>
286N/A<p>
286N/A Here is an example command line to load <acronym class="acronym">BIND</acronym> in a <span><strong class="command">chroot</strong></span> sandbox,
286N/A <span><strong class="command">/var/named</strong></span>, and to run <span><strong class="command">named</strong></span> <span><strong class="command">setuid</strong></span> to
286N/A user 202:
286N/A </p>
286N/A<p>
286N/A <strong class="userinput"><code>/usr/local/sbin/named -u 202 -t /var/named</code></strong>
286N/A </p>
286N/A<div class="sect2" lang="en">
286N/A<div class="titlepage"><div><div><h3 class="title">
286N/A<a name="id2608813"></a>The <span><strong class="command">chroot</strong></span> Environment</h3></div></div></div>
286N/A<p>
286N/A In order for a <span><strong class="command">chroot</strong></span> environment
286N/A to
286N/A work properly in a particular directory
286N/A (for example, <code class="filename">/var/named</code>),
286N/A you will need to set up an environment that includes everything
286N/A <acronym class="acronym">BIND</acronym> needs to run.
286N/A From <acronym class="acronym">BIND</acronym>'s point of view, <code class="filename">/var/named</code> is
286N/A the root of the filesystem. You will need to adjust the values of
286N/A options like
286N/A like <span><strong class="command">directory</strong></span> and <span><strong class="command">pid-file</strong></span> to account
286N/A for this.
286N/A </p>
286N/A<p>
286N/A Unlike with earlier versions of BIND, you typically will
286N/A <span class="emphasis"><em>not</em></span> need to compile <span><strong class="command">named</strong></span>
286N/A statically nor install shared libraries under the new root.
286N/A However, depending on your operating system, you may need
286N/A to set up things like
286N/A <code class="filename">/dev/zero</code>,
286N/A <code class="filename">/dev/random</code>,
286N/A <code class="filename">/dev/log</code>, and
286N/A <code class="filename">/etc/localtime</code>.
286N/A </p>
286N/A</div>
286N/A<div class="sect2" lang="en">
286N/A<div class="titlepage"><div><div><h3 class="title">
286N/A<a name="id2608873"></a>Using the <span><strong class="command">setuid</strong></span> Function</h3></div></div></div>
286N/A<p>
286N/A Prior to running the <span><strong class="command">named</strong></span> daemon,
286N/A use
286N/A the <span><strong class="command">touch</strong></span> utility (to change file
286N/A access and
286N/A modification times) or the <span><strong class="command">chown</strong></span>
286N/A utility (to
286N/A set the user id and/or group id) on files
286N/A to which you want <acronym class="acronym">BIND</acronym>
286N/A to write.
286N/A </p>
286N/A<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
286N/A<h3 class="title">Note</h3>
286N/A Note that if the <span><strong class="command">named</strong></span> daemon is running as an
286N/A unprivileged user, it will not be able to bind to new restricted
286N/A ports if the server is reloaded.
286N/A </div>
286N/A</div>
286N/A</div>
286N/A<div class="sect1" lang="en">
286N/A<div class="titlepage"><div><div><h2 class="title" style="clear: both">
286N/A<a name="dynamic_update_security"></a>Dynamic Update Security</h2></div></div></div>
286N/A<p>
286N/A Access to the dynamic
286N/A update facility should be strictly limited. In earlier versions of
286N/A <acronym class="acronym">BIND</acronym>, the only way to do this was
286N/A based on the IP
286N/A address of the host requesting the update, by listing an IP address
286N/A or
286N/A network prefix in the <span><strong class="command">allow-update</strong></span>
286N/A zone option.
286N/A This method is insecure since the source address of the update UDP
286N/A packet
286N/A is easily forged. Also note that if the IP addresses allowed by the
286N/A <span><strong class="command">allow-update</strong></span> option include the
286N/A address of a slave
286N/A server which performs forwarding of dynamic updates, the master can
286N/A be
286N/A trivially attacked by sending the update to the slave, which will
286N/A forward it to the master with its own source IP address causing the
286N/A master to approve it without question.
286N/A </p>
286N/A<p>
286N/A For these reasons, we strongly recommend that updates be
286N/A cryptographically authenticated by means of transaction signatures
286N/A (TSIG). That is, the <span><strong class="command">allow-update</strong></span>
286N/A option should
286N/A list only TSIG key names, not IP addresses or network
286N/A prefixes. Alternatively, the new <span><strong class="command">update-policy</strong></span>
286N/A option can be used.
286N/A </p>
286N/A<p>
286N/A Some sites choose to keep all dynamically-updated DNS data
286N/A in a subdomain and delegate that subdomain to a separate zone. This
286N/A way, the top-level zone containing critical data such as the IP
286N/A addresses
286N/A of public web and mail servers need not allow dynamic update at
286N/A all.
286N/A </p>
286N/A</div>
286N/A</div>
286N/A<div class="navfooter">
286N/A<hr>
286N/A<table width="100%" summary="Navigation footer">
286N/A<tr>
286N/A<td width="40%" align="left">
286N/A<a accesskey="p" href="Bv9ARM.ch06.html">Prev</a>�</td>
286N/A<td width="20%" align="center">�</td>
286N/A<td width="40%" align="right">�<a accesskey="n" href="Bv9ARM.ch08.html">Next</a>
286N/A</td>
286N/A</tr>
286N/A<tr>
286N/A<td width="40%" align="left" valign="top">Chapter�6.�<acronym class="acronym">BIND</acronym> 9 Configuration Reference�</td>
286N/A<td width="20%" align="center"><a accesskey="h" href="Bv9ARM.html">Home</a></td>
286N/A<td width="40%" align="right" valign="top">�Chapter�8.�Troubleshooting</td>
286N/A</tr>
286N/A</table>
286N/A</div>
286N/A<p style="text-align: center;">BIND 9.11.0pre-alpha</p>
286N/A</body>
286N/A</html>
286N/A