7. Security Configurations

7.1. Threat Model

This section explains how to deploy BIND safely and evaluate potential vulnerabilities. It evolves with the attack landscape and our understanding.

7.1.1. Security Boundary

Unless stated otherwise below, network data is untrusted and subject to safety and correctness checks. No input, even malformed, should crash the server or significantly affect other conforming traffic.

BIND 9 assumes only administrators can access:

Unauthorized access or misuse can cause arbitrary misbehavior and is not a basis for CVE assignment or security-sensitive handling.

Client tools (dig, delv, nsupdate, ...) are run by a user against servers of the user's choosing. Crashes (including assertion failures), hangs, and wrong output caused by malicious responses are ordinary bugs.

7.1.2. Non-Standard Behavior

The DNS protocol does not define some behavior, such as handling responses from non-conforming servers. BIND fills these gaps with its own safety checks and limits, subject to change as the protocol and deployments evolve.

Unexpected behavior limited to zones on non-conforming servers, not affecting traffic to conforming servers and zones, is not a security issue in BIND.

7.1.3. Unsupported Features

Not a basis for CVE assignment or security-sensitive handling:

  • Problems triggered only by resources (views, zones, ...) with classes other than Internet (IN), such as CHAOS (CH) or HESIOD (HS)

  • Misbehavior of incorrectly implemented custom dlz, dyndb, or plugin modules

  • Problems reproducible only in non-standard builds (sanitizers, developer mode) with no corresponding effect in a release build, e.g., a benign data race reported by TSAN

  • Test code, sample and contrib modules

  • Compile-time options not exposed by the build system

  • Library code reachable only through calls BIND programs do not make

7.1.4. Authoritative Servers

primaries and UPDATE clients (within their authorization) are partially trusted: they may break data they control and consume resources up to configured limits, but should not otherwise affect other conforming zones or crash the server. By protocol design, content of catalog zones affects the set of served zones, so their primaries and UPDATE clients are administrators (see Security Boundary).

Authoritative zone limits are intentionally lenient by default (unlimited size, long transfer timeouts, etc.). Resource exhaustion within configured limits is not a security issue. Set options in Server Resource Limits and Zone Transfers to fit the deployment, including zones where malicious clients may be authorized for Dynamic Update.

Depending on configuration, NOTIFY and DS checks (checkds, parental-agents) can trigger outgoing queries, making the authoritative server act as a resolver. Resolver assumptions then apply.

7.1.5. Recursive Resolvers

Resolvers are inherently amplifiers: they legitimately send more traffic and do more work than the triggering client traffic. DNS specifications set no amplification limits, so BIND sets its own. Staying within max-query-count outgoing queries per client query is not a security issue. Other amplification is evaluated against Performance Impact baselines.

Server Resource Limits limit damage from misbehaving authoritative servers. All these limits balance interoperability and attack protection, are subject to change as deployments evolve, and can temporarily break resolution of zones with excessively complex configurations or resolution paths.

By protocol design, content of response policy zones can rewrite the answer to any query, so their primaries and UPDATE clients are administrators (see Security Boundary).

7.1.6. Forwarding Resolvers

forwarders are trusted for their name subtree: they can make its names unresolvable, provide fake data, and see forwarded queries.

7.1.7. Data Integrity and Confidentiality

Zones not DNSSEC-secure (RFC 4033) are spoofable, trivially by on-path attackers. Against off-path attackers, BIND applies only RFC 5452 measures, such as port and message ID randomization, and DNS COOKIES (RFC 7873, send-cookie) if both sides support them. Detecting traffic manipulation and data coherency issues is out of scope.

Source port randomization relies on the operating system, whose weaknesses (e.g., side channels revealing ephemeral ports) are out of scope.

DNSSEC provides data origin authentication and integrity, not confidentiality or availability against packet-manipulating attackers.

By DNS protocol definition, ancestors of the attacked zone are implicitly trusted. Misbehaving ones can always break resolution or sign fake data if DNSSEC is in use. BIND does not detect or defend against this.

TSIG and authenticated tls provide integrity in transit. TLS also provides confidentiality. Without either, attackers can impersonate configured servers.

7.1.8. Performance Impact

Attackers can send BIND large or very expensive-to-process data. As researcher Felix Linker put it, "A DNS resolver is essentially an interpreter executing a program provided by an attacker over the network." Resource usage within configured limits is not a security issue.

Availability and performance impact are measured against three baselines:

  • resolver cache hit / authoritative response

  • pseudo-random subdomain attack (PRSD, i.e., 100% negative responses)

  • large positive response (with or without wildcard)

Any attacker can trivially execute these, so scenarios not significantly worse than the worst of the three gain attackers nothing and are not a basis for CVE assignment. Report them anyway if otherwise interesting, e.g., as optimization opportunities.

Resource-limit bug severity is evaluated against the same baselines. Attacks are compared with baselines over the same transport.

7.1.9. CVSS Scoring Guidelines

See https://kb.isc.org/docs/isc-cvss-scoring-guidelines

7.2. Access Control Lists

Access Control Lists (ACLs) are address match lists that can be set up and nicknamed for future use in allow-notify, allow-query, allow-query-on, allow-recursion, blackhole, allow-transfer, match-clients, etc.

ACLs give users finer control over who can access the name server, without cluttering up configuration files with huge lists of IP addresses.

It is a good idea to use ACLs and to control access. Limiting access to the server by outside parties can help prevent spoofing and denial-of-service (DoS) attacks against the server.

ACLs match clients on the basis of up to three characteristics: 1) The client's IP address; 2) the TSIG or SIG(0) key that was used to sign the request, if any; and 3) an address prefix encoded in an EDNS Client-Subnet option, if any.

Here is an example of ACLs based on client addresses:

// Set up an ACL named "bogusnets" that blocks
// RFC1918 space and some reserved space, which is
// commonly used in spoofing attacks.
acl bogusnets {
    0.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 primary;
  file "m/example.com";
  allow-query { any; };
};

This allows authoritative queries for example.com from any address, but recursive queries only from the networks specified in our-nets, and no queries at all from the networks specified in bogusnets.

In addition to network addresses and prefixes, which are matched against the source address of the DNS request, ACLs may include key elements, which specify the name of a TSIG or SIG(0) key.

When BIND 9 is built with GeoIP support, ACLs can also be used for geographic access restrictions. This is done by specifying an ACL element of the form: geoip db database field value.

The field parameter indicates which field to search for a match. Available fields are country, region, city, continent, postal (postal code), metro (metro code), area (area code), tz (timezone), isp, asnum, and domain.

value is the value to search for within the database. A string may be quoted if it contains spaces or other special characters. An asnum search for autonomous system number can be specified using the string "ASNNNN" or the integer NNNN. If a country search is specified with a string that is two characters long, it must be a standard ISO-3166-1 two-letter country code; otherwise, it is interpreted as the full name of the country. Similarly, if region is the search term and the string is two characters long, it is treated as a standard two-letter state or province abbreviation; otherwise, it is treated as the full name of the state or province.

The database field indicates which GeoIP database to search for a match. In most cases this is unnecessary, because most search fields can only be found in a single database. However, searches for continent or country can be answered from either the city or country databases, so for these search types, specifying a database forces the query to be answered from that database and no other. If a database is not specified, these queries are first answered from the city database if it is installed, and then from the country database if it is installed. Valid database names are country, city, asnum, isp, and domain.

Some example GeoIP ACLs:

geoip country US;
geoip country JP;
geoip db country country Canada;
geoip region WA;
geoip city "San Francisco";
geoip region Oklahoma;
geoip postal 95062;
geoip tz "America/Los_Angeles";
geoip org "Internet Systems Consortium";

ACLs use a "first-match" logic rather than "best-match"; if an address prefix matches an ACL element, then that ACL is considered to have matched even if a later element would have matched more specifically. For example, the ACL { 10/8; !10.0.0.1; } would actually match a query from 10.0.0.1, because the first element indicates that the query should be accepted, and the second element is ignored.

When using "nested" ACLs (that is, ACLs included or referenced within other ACLs), a negative match of a nested ACL tells the containing ACL to continue looking for matches. This enables complex ACLs to be constructed, in which multiple client characteristics can be checked at the same time. For example, to construct an ACL which allows a query only when it originates from a particular network and only when it is signed with a particular key, use:

allow-query { !{ !10/8; any; }; key example; };

Within the nested ACL, any address that is not in the 10/8 network prefix is rejected, which terminates the processing of the ACL. Any address that is in the 10/8 network prefix is accepted, but this causes a negative match of the nested ACL, so the containing ACL continues processing. The query is accepted if it is signed by the key example, and rejected otherwise. The ACL, then, only matches when both conditions are true.

7.3. Chroot and Setuid

On Unix servers, it is possible to run BIND in a chrooted environment (using the chroot() function) by specifying the -t option for named. This can help improve system security by placing BIND in a "sandbox," which limits the damage done if a server is compromised.

Another useful feature in the Unix version of BIND is the ability to run the daemon as an unprivileged user (-u user). We suggest running as an unprivileged user when using the chroot feature.

Here is an example command line to load BIND in a chroot sandbox, /var/named, and to run named setuid to user 202:

/usr/local/sbin/named -u 202 -t /var/named

7.3.1. The chroot Environment

For a chroot environment to work properly in a particular directory (for example, /var/named), the environment must include everything BIND needs to run. From BIND's point of view, /var/named is the root of the filesystem; the values of options like directory and pid-file must be adjusted to account for this.

Unlike with earlier versions of BIND, named does not typically need to be compiled statically, nor do shared libraries need to be installed under the new root. However, depending on the operating system, it may be necessary to set up locations such as /dev/zero, /dev/random, /dev/log, and /etc/localtime.

7.3.2. Using the setuid Function

Prior to running the named daemon, use the touch utility (to change file access and modification times) or the chown utility (to set the user id and/or group id) on files where BIND should write.

Note

If the named daemon is running as an unprivileged user, it cannot bind to new restricted ports if the server is reloaded.

7.4. Dynamic Update Security

Access to the dynamic update facility should be strictly limited. In earlier versions of BIND, 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 allow-update 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 allow-update option include the address of a secondary server which performs forwarding of dynamic updates, the primary can be trivially attacked by sending the update to the secondary, which forwards it to the primary with its own source IP address - causing the primary to approve it without question.

For these reasons, we strongly recommend that updates be cryptographically authenticated by means of transaction signatures (TSIG). That is, the allow-update option should list only TSIG key names, not IP addresses or network prefixes. Alternatively, the update-policy option can be used.

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 updates at all.

7.5. TSIG

TSIG (Transaction SIGnatures) is a mechanism for authenticating DNS messages, originally specified in RFC 2845. It allows DNS messages to be cryptographically signed using a shared secret. TSIG can be used in any DNS transaction, as a way to restrict access to certain server functions (e.g., recursive queries) to authorized clients when IP-based access control is insufficient or needs to be overridden, or as a way to ensure message authenticity when it is critical to the integrity of the server, such as with dynamic UPDATE messages or zone transfers from a primary to a secondary server.

This section is a guide to setting up TSIG in BIND. It describes the configuration syntax and the process of creating TSIG keys.

named supports TSIG for server-to-server communication, and some of the tools included with BIND support it for sending messages to named:

7.5.1. Generating a Shared Key

TSIG keys can be generated using the tsig-keygen command; the output of the command is a key directive suitable for inclusion in named.conf. The key name, algorithm, and size can be specified by command-line parameters; the defaults are "tsig-key", HMAC-SHA256, and 256 bits, respectively.

Any string which is a valid DNS name can be used as a key name. For example, a key to be shared between servers called host1 and host2 could be called "host1-host2.", and this key can be generated using:

$ tsig-keygen host1-host2. > host1-host2.key

This key may then be copied to both hosts. The key name and secret must be identical on both hosts. (Note: copying a shared secret from one server to another is beyond the scope of the DNS. A secure transport mechanism should be used: secure FTP, SSL, ssh, telephone, encrypted email, etc.)

tsig-keygen can also be run as ddns-confgen, in which case its output includes additional configuration text for setting up dynamic DNS in named. See ddns-confgen - TSIG key generation tool for details.

7.5.2. Loading a New Key

For a key shared between servers called host1 and host2, the following could be added to each server's named.conf file:

key "host1-host2." {
    algorithm hmac-sha256;
    secret "DAopyf1mhCbFVZw7pgmNPBoLUq8wEUT7UuPoLENP2HY=";
};

(This is the same key generated above using tsig-keygen.)

Since this text contains a secret, it is recommended that either named.conf not be world-readable, or that the key directive be stored in a file which is not world-readable and which is included in named.conf via the include directive.

Once a key has been added to named.conf and the server has been restarted or reconfigured, the server can recognize the key. If the server receives a message signed by the key, it is able to verify the signature. If the signature is valid, the response is signed using the same key.

7.5.3. Instructing the Server to Use a Key

A server sending a request to another server must be told whether to use a key, and if so, which key to use.

For example, a key may be specified for each server in the primaries statement in the definition of a secondary zone; in this case, all SOA QUERY messages, NOTIFY messages, and zone transfer requests (AXFR or IXFR) are signed using the specified key. Keys may also be specified in the also-notify statement of a primary or secondary zone, causing NOTIFY messages to be signed using the specified key.

Keys can also be specified in a server directive. Adding the following on host1, if the IP address of host2 is 10.1.2.3, would cause all requests from host1 to host2, including normal DNS queries, to be signed using the host1-host2. key:

server 10.1.2.3 {
    keys { host1-host2. ;};
};

Multiple keys may be present in the keys statement, but only the first one is used. As this directive does not contain secrets, it can be used in a world-readable file.

Requests sent by host2 to host1 would not be signed, unless a similar server directive were in host2's configuration file.

When any server sends a TSIG-signed DNS request, it expects the response to be signed with the same key. If a response is not signed, or if the signature is not valid, the response is rejected.

7.5.4. TSIG-Based Access Control

TSIG keys may be specified in ACL definitions and ACL directives such as allow-query, allow-transfer, and allow-update. The above key would be denoted in an ACL element as key host1-host2.

Here is an example of an allow-update directive using a TSIG key:

allow-update { !{ !localnets; any; }; key host1-host2. ;};

This allows dynamic updates to succeed only if the UPDATE request comes from an address in localnets, and if it is signed using the host1-host2. key.

See Dynamic Update Policies for a discussion of the more flexible update-policy statement.

7.5.5. Errors

Processing of TSIG-signed messages can result in several errors:

  • If a TSIG-aware server receives a message signed by an unknown key, the response will be unsigned, with the TSIG extended error code set to BADKEY.

  • If a TSIG-aware server receives a message from a known key but with an invalid signature, the response will be unsigned, with the TSIG extended error code set to BADSIG.

  • If a TSIG-aware server receives a message with a time outside of the allowed range, the response will be signed but the TSIG extended error code set to BADTIME, and the time values will be adjusted so that the response can be successfully verified.

In all of the above cases, the server returns a response code of NOTAUTH (not authenticated).

7.6. SIG(0)

BIND partially supports DNSSEC SIG(0) transaction signatures as specified in RFC 2535 and RFC 2931. SIG(0) uses public/private keys to authenticate messages. Access control is performed in the same manner as with TSIG keys; privileges can be granted or denied in ACL directives based on the key name.

When a SIG(0) signed message is received, it is only verified if the key is known and trusted by the server. The server does not attempt to recursively fetch or validate the key.

SIG(0) signing of multiple-message TCP streams is not supported.

The only tool shipped with BIND 9 that generates SIG(0) signed messages is nsupdate.