xref: /netbsd-src/external/mpl/bind/dist/doc/arm/dnssec.inc.rst (revision 9689912e6b171cbda866ec33f15ae94a04e2c02d)
1.. Copyright (C) Internet Systems Consortium, Inc. ("ISC")
2..
3.. SPDX-License-Identifier: MPL-2.0
4..
5.. This Source Code Form is subject to the terms of the Mozilla Public
6.. License, v. 2.0.  If a copy of the MPL was not distributed with this
7.. file, you can obtain one at https://mozilla.org/MPL/2.0/.
8..
9.. See the COPYRIGHT file distributed with this work for additional
10.. information regarding copyright ownership.
11
12.. _dnssec:
13
14DNSSEC
15------
16DNS Security Extensions (DNSSEC) provide reliable protection from
17`cache poisoning`_ attacks. At the same time these extensions also provide other benefits:
18they limit the impact of `random subdomain attacks`_ on resolver caches and authoritative
19servers, and provide the foundation for modern applications like `authenticated
20and private e-mail transfer`_.
21
22To achieve this goal, DNSSEC adds `digital signatures`_ to DNS records in
23authoritative DNS zones, and DNS resolvers verify the validity of the signatures on the
24received records. If the signatures match the received data, the resolver can
25be sure that the data was not modified in transit.
26
27.. note::
28   DNSSEC and transport-level encryption are complementary!
29   Unlike typical transport-level encryption like DNS-over-TLS, DNS-over-HTTPS,
30   or VPN, DNSSEC makes DNS records verifiable at all points of the DNS
31   resolution chain.
32
33This section focuses on ways to deploy DNSSEC using BIND. For a more in-depth
34discussion of DNSSEC principles (e.g. :ref:`how_does_dnssec_change_dns_lookup`)
35please see :doc:`dnssec-guide`.
36
37.. _`cache poisoning`: https://en.wikipedia.org/wiki/DNS_cache_poisoning
38.. _`random subdomain attacks`: https://www.isc.org/blogs/nsec-caching-should-limit-excessive-queries-to-dns-root/
39.. _`digital signatures`: https://en.wikipedia.org/wiki/Digital_signature
40.. _`authenticated and private e-mail transfer`: https://github.com/internetstandards/toolbox-wiki/blob/main/DANE-for-SMTP-how-to.md
41
42
43.. _dnssec_zone_signing:
44
45Zone Signing
46~~~~~~~~~~~~
47
48BIND offers several ways to generate signatures and maintain their validity
49during the lifetime of a DNS zone:
50
51  - :ref:`dnssec_kasp` - **strongly recommended**
52  - :ref:`dnssec_tools` - discouraged, use only for debugging
53
54.. _zone_keys:
55
56Zone keys
57^^^^^^^^^
58Regardless of the :ref:`zone-signing <dnssec_zone_signing>` method in use, cryptographic keys are
59stored in files named like :file:`Kdnssec.example.+013+12345.key` and
60:file:`Kdnssec.example.+013+12345.private`.
61The private key (in the ``.private`` file) is used to generate signatures, and
62the public key (in the ``.key`` file) is used for signature verification.
63Additionally, the :ref:`dnssec_kasp` method creates a third file,
64:file:`Kdnssec.example+013+12345.state`, which is used to track DNSSEC key timings
65and to perform key rollovers safely.
66
67These filenames contain:
68
69   - the key name, which always matches the zone name (``dnssec.example.``),
70   - the `algorithm number`_ (013 is ECDSAP256SHA256, 008 is RSASHA256, etc.),
71   - and the key tag, i.e. a non-unique key identifier (12345 in this case).
72
73.. _`algorithm number`: https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml#dns-sec-alg-numbers-1
74
75
76.. warning::
77   Private keys are required for full disaster recovery. Back up key files in a
78   safe location and protect them from unauthorized access. Anyone with
79   access to the private key can create fake but seemingly valid DNS data.
80
81
82.. _dnssec_kasp:
83
84Fully Automated (Key and Signing Policy)
85^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86
87Key and Signing Policy (KASP) is a method of configuration that describes
88how to maintain DNSSEC signing keys and how to sign the zone.
89
90This is the recommended, fully automated way to sign and maintain DNS zones. For
91most use cases users can simply use the built-in default policy, which applies
92up-to-date DNSSEC practices:
93
94.. code-block:: none
95  :emphasize-lines: 4
96
97    zone "dnssec.example" {
98        type primary;
99        file "dnssec.example.db";
100        dnssec-policy default;
101    };
102
103The :any:`dnssec-policy` statement requires dynamic DNS to be set up, or
104:any:`inline-signing` to be enabled. In the example above we use the latter,
105because the ``default`` policy uses :any:`inline-signing`.
106
107This is sufficient to create the necessary signing keys, and generate
108``DNSKEY``, ``RRSIG``, and ``NSEC`` records for the zone. BIND also takes
109care of any DNSSEC maintenance for this zone, including replacing signatures
110that are about to expire and managing :ref:`key_rollovers`.
111
112.. note::
113   :any:`dnssec-policy` needs write access to the zone. Please see
114   :any:`dnssec-policy` for more details about implications for zone storage.
115
116The default policy creates one key that is used to sign the complete zone,
117and uses ``NSEC`` to enable authenticated denial of existence (a secure way
118to tell which records do not exist in a zone). This policy is recommended
119and typically does not need to be changed.
120
121If needed, a custom policy can be defined by adding a :any:`dnssec-policy` statement
122into the configuration:
123
124.. code-block:: none
125
126
127    dnssec-policy "custom" {
128        dnskey-ttl 600;
129        keys {
130            ksk lifetime P1Y algorithm ecdsap384sha384;
131            zsk lifetime 60d algorithm ecdsap384sha384;
132        };
133        nsec3param iterations 0 optout no salt-length 0;
134    };
135
136This ``custom`` policy, for example:
137
138  - uses a very short ``DNSKEY`` TTL (600 seconds),
139  - uses two keys to sign the zone: a Key Signing Key (KSK) to sign the key
140    related RRsets (``DNSKEY``, ``CDS``, and ``CDNSKEY``), and a Zone Signing
141    Key (ZSK) to sign the rest of the zone. The KSK is automatically
142    rotated after one year and the ZSK after 60 days.
143
144Also:
145  - The configured keys have a lifetime set and use the ECDSAP384SHA384
146    algorithm.
147  - The last line instructs BIND to generate NSEC3 records for
148    :ref:`Proof of Non-Existence <advanced_discussions_proof_of_nonexistence>`,
149    using zero extra iterations and no salt. NSEC3 opt-out is disabled, meaning
150    insecure delegations also get an NSEC3 record.
151
152For more information about KASP configuration see :any:`dnssec-policy`.
153
154The :ref:`dnssec_advanced_discussions` section in the DNSSEC Guide discusses the
155various policy settings and may be useful for determining values for specific
156needs.
157
158Key Rollover
159============
160
161When using a :any:`dnssec-policy`, a key lifetime can be set to trigger
162key rollovers. ZSK rollovers are fully automatic, but for KSK and CSK rollovers
163a DS record needs to be submitted to the parent. See
164:ref:`secure_delegation` for possible ways to do so.
165
166Once the DS is in the parent (and the DS of the predecessor key is withdrawn),
167BIND needs to be told that this event has happened. This can be done automatically
168by configuring parental agents:
169
170.. code-block:: none
171  :emphasize-lines: 5
172
173    zone "dnssec.example" {
174        type primary;
175        file "dnssec.example.db";
176        dnssec-policy default;
177        parental-agents { 192.0.2.1; };
178        checkds explicit;
179    };
180
181Here one server, ``192.0.2.1``, is configured for BIND to send DS queries to,
182to check the DS RRset for ``dnssec-example`` during key rollovers. This needs
183to be a trusted server, because BIND does not validate the response. The
184``checkds`` option makes BIND use the explicitly configured parental agents,
185rather than looking them up by querying for the parent NS records.
186
187If setting up a parental agent is undesirable, it is also possible to tell BIND that the
188DS is published in the parent with:
189:option:`rndc dnssec -checkds -key 12345 published dnssec.example. <rndc dnssec>`.
190and the DS for the predecessor key has been removed with:
191:option:`rndc dnssec -checkds -key 54321 withdrawn dnssec.example. <rndc dnssec>`.
192where 12345 and 54321 are the key tags of the successor and predecessor key,
193respectively.
194
195To roll a key sooner than scheduled, or to roll a key that
196has an unlimited lifetime, use:
197:option:`rndc dnssec -rollover -key 12345 dnssec.example. <rndc dnssec>`.
198
199To revert a signed zone back to an insecure zone, change
200the zone configuration to use the built-in "insecure" policy. Detailed
201instructions are described in :ref:`revert_to_unsigned`.
202
203.. _dnssec_multisigner_model:
204
205Multi-Signer Model
206==================
207
208Dynamic zones provide the ability to sign a zone by multiple providers, meaning
209each provider signs and serves the same zone independently, as is described
210in :rfc:`8901`. BIND 9 is able to support Model 2, where each provider has
211their own KSK and ZSK (or CSK). The keys from the other provider can be
212imported via Dynamic Update. For each active KSK there must be a corresponding
213DS record in the parent zone. Key rollovers require coordination in order
214to update the DS and DNSKEY RRset.
215
216.. _dnssec_tools:
217
218Manual Signing
219^^^^^^^^^^^^^^
220
221There are several tools available to manually sign a zone.
222
223.. warning::
224
225   Please note manual procedures are available mainly for backwards
226   compatibility and should be used only by expert users with specific needs.
227
228To set up a DNSSEC secure zone manually, a series of steps
229must be followed. Please see chapter
230:ref:`advanced_discussions_manual_signing` in the
231:doc:`dnssec-guide` for more information.
232
233Monitoring with Private Type Records
234^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
235
236The state of the signing process is signaled by private type records (with a
237default type value of 65534). When signing is complete, those records with a
238non-zero initial octet have a non-zero value for the final octet.
239
240If the first octet of a private type record is non-zero, the record indicates
241either that the zone needs to be signed with the key matching the record, or
242that all signatures that match the record should be removed. Here are the
243meanings of the different values of the first octet:
244
245   - algorithm (octet 1)
246
247   - key ID in network order (octet 2 and 3)
248
249   - removal flag (octet 4)
250
251   - complete flag (octet 5)
252
253Only records flagged as "complete" can be removed via dynamic update; attempts
254to remove other private type records are silently ignored.
255
256If the first octet is zero (this is a reserved algorithm number that should
257never appear in a ``DNSKEY`` record), the record indicates that changes to the
258``NSEC3`` chains are in progress. The rest of the record contains an
259``NSEC3PARAM`` record, while the flag field tells what operation to perform
260based on the flag bits:
261
262   0x01 OPTOUT
263
264   0x80 CREATE
265
266   0x40 REMOVE
267
268   0x20 NONSEC
269
270.. _secure_delegation:
271
272Secure Delegation
273~~~~~~~~~~~~~~~~~
274
275Once a zone is signed on the authoritative servers, the last remaining step
276is to establish chain of trust [#validation]_ between the parent zone
277(``example.``) and the local zone (``dnssec.example.``).
278
279Generally the procedure is:
280
281  - **Wait** for stale data to expire from caches. The amount of time required
282    is equal to the maximum TTL value used in the zone before signing. This
283    step ensures that unsigned data expire from caches and resolvers do not get
284    confused by missing signatures.
285  - Insert/update DS records in the parent zone (``dnssec.example. DS`` record).
286
287There are multiple ways to update DS records in the parent zone. Refer to the
288documentation for the parent zone to find out which options are applicable to
289a given case zone. Generally the options are, from most- to least-recommended:
290
291  - Automatically update the DS record in the parent zone using
292    ``CDS``/``CDNSKEY`` records automatically generated by BIND. This requires
293    support for :rfc:`7344` in either parent zone, registry, or registrar. In
294    that case, configure BIND to :ref:`monitor DS records in the parent
295    zone <cds_cdnskey>` and everything will happen automatically at the right
296    time.
297  - Query the zone for automatically generated ``CDS`` or ``CDNSKEY`` records using
298    :iscman:`dig`, and then insert these records into the parent zone using
299    the method specified by the parent zone (web form, e-mail, API, ...).
300  - Generate DS records manually using the :iscman:`dnssec-dsfromkey` utility on
301    `zone keys`_, and then insert them into the parent zone.
302
303.. [#validation] For further details on how the chain of trust is used in practice, see
304                :ref:`dnssec_12_steps` in the :doc:`dnssec-guide`.
305
306
307
308DNSSEC Validation
309~~~~~~~~~~~~~~~~~
310
311The BIND resolver validates answers from authoritative servers by default. This
312behavior is controlled by the configuration statement :namedconf:ref:`dnssec-validation`.
313
314By default a trust anchor for the DNS root zone is used.
315This trust anchor is provided as part of BIND and is kept up-to-date using
316:ref:`rfc5011.support`.
317
318.. note::
319   DNSSEC validation works "out of the box" and does not require
320   additional configuration. Additional configuration options are intended only
321   for special cases.
322
323To validate answers, the resolver needs at least one trusted starting point,
324a "trust anchor." Essentially, trust anchors are copies of ``DNSKEY`` RRs for
325zones that are used to form the first link in the cryptographic chain of trust.
326Alternative trust anchors can be specified using :any:`trust-anchors`, but
327this setup is very unusual and is recommended only for expert use.
328For more information, see :ref:`trust_anchors_description` in the
329:doc:`dnssec-guide`.
330
331The BIND authoritative server does not verify signatures on load, so zone keys
332for authoritative zones do not need to be specified in the configuration
333file.
334
335Validation Failures
336^^^^^^^^^^^^^^^^^^^
337
338When DNSSEC validation is configured, the resolver rejects any answers from
339signed, secure zones which fail to validate, and returns SERVFAIL to the
340client.
341
342Responses may fail to validate for any of several reasons, including
343missing, expired, or invalid signatures; a key which does not match the
344DS RRset in the parent zone; or an insecure response from a zone which,
345according to its parent, should have been secure.
346
347For more information see :ref:`dnssec_troubleshooting`.
348
349Coexistence With Unsigned (Insecure) Zones
350^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
351
352Zones not protected by DNSSEC are called "insecure," and these zones seamlessly
353coexist with signed zones.
354
355When the validator receives a response from an unsigned zone that has
356a signed parent, it must confirm with the parent that the zone was
357intentionally left unsigned. It does this by verifying, via signed
358and validated :ref:`NSEC/NSEC3 records
359<advanced_discussions_proof_of_nonexistence>`, that the parent zone contains no
360DS records for the child.
361
362If the validator *can* prove that the zone is insecure, then the
363response is accepted. However, if it cannot, the validator must assume an
364insecure response to be a forgery; it rejects the response and logs
365an error.
366
367The logged error reads "insecurity proof failed" and "got insecure
368response; parent indicates it should be secure."
369