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_advanced_discussions: 13 14 Advanced Discussions 15 -------------------- 16 17 .. _signature_validity_periods: 18 19 Signature Validity Periods and Zone Re-Signing Intervals 20 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 21 22 In :ref:`how_are_answers_verified`, we saw that record signatures 23 have a validity period outside of which they are not valid. This means 24 that at some point, a signature will no longer be valid and a query for 25 the associated record will fail DNSSEC validation. But how long should a 26 signature be valid for? 27 28 The maximum value for the validity period should be determined by the impact of a 29 replay attack: if this is low, the period can be long; if high, 30 the period should be shorter. There is no "right" value, but periods of 31 between a few days to a month are common. 32 33 Deciding a minimum value is probably an easier task. Should something 34 fail (e.g., a hidden primary distributing to secondary servers that 35 actually answer queries), how long will it take before the failure is 36 noticed, and how long before it is fixed? If you are a large 24x7 37 operation with operators always on-site, the answer might be less than 38 an hour. In smaller companies, if the failure occurs 39 just after everyone has gone home for a long weekend, the answer might 40 be several days. 41 42 Again, there are no "right" values - they depend on your circumstances. The 43 signature validity period you decide to use should be a value between 44 the two bounds. At the time of this writing (mid-2020), the default policy used by BIND 45 sets a value of 14 days. 46 47 To keep the zone valid, the signatures must be periodically refreshed 48 since they expire - i.e., the zone must be periodically 49 re-signed. The frequency of the re-signing depends on your network's 50 individual needs. For example, signing puts a load on your server, so if 51 the server is very highly loaded, a lower re-signing frequency is better. Another 52 consideration is the signature lifetime: obviously the intervals between 53 signings must not be longer than the signature validity period. But if 54 you have set a signature lifetime close to the minimum (see above), the 55 signing interval must be much shorter. What would happen if the system 56 failed just before the zone was re-signed? 57 58 Again, there is no single "right" answer; it depends on your circumstances. The 59 BIND 9 default policy sets the signature refresh interval to 5 days. 60 61 .. _advanced_discussions_proof_of_nonexistence: 62 63 Proof of Non-Existence (NSEC and NSEC3) 64 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 65 66 How do you prove that something does not exist? This zen-like question 67 is an interesting one, and in this section we provide an overview 68 of how DNSSEC solves the problem. 69 70 Why is it even important to have authenticated denial of existence in DNS? 71 Couldn't we just send back "hey, what you asked for does not exist," 72 and somehow generate a digital signature to go with it, proving it 73 really is from the correct authoritative source? Aside from the technical 74 challenge of signing something that doesn't exist, this solution has flaws, one of 75 which is it gives an attacker a way to create the appearance of denial 76 of service by replaying this message on the network. 77 78 Let's use a little story, told three different ways, to 79 illustrate how proof of nonexistence works. In our story, we run a small 80 company with three employees: Alice, Edward, and Susan. For reasons that 81 are far too complicated to go into, they don't have email accounts; 82 instead, email for them is sent to a single account and a nameless 83 intern passes the message to them. The intern has access to our private 84 DNSSEC key to create signatures for their responses. 85 86 If we followed the approach of giving back the same answer no matter 87 what was asked, when people emailed and asked for the message to be 88 passed to "Bob," our intern would simply answer "Sorry, that person 89 doesnt work here" and sign this message. This answer could be validated 90 because our intern signed the response with our private DNSSEC key. 91 However, since the signature doesnt change, an attacker could record 92 this message. If the attacker were able to intercept our email, when the next 93 person emailed asking for the message to be passed to Susan, the attacker 94 could return the exact same message: "Sorry, that person doesnt work 95 here," with the same signature. Now the attacker has successfully fooled 96 the sender into thinking that Susan doesnt work at our company, and 97 might even be able to convince all senders that no one works at this 98 company. 99 100 To solve this problem, two different solutions were created. We will 101 look at the first one, NSEC, next. 102 103 .. _advanced_discussions_nsec: 104 .. _NSEC: 105 106 NSEC 107 ^^^^ 108 109 The NSEC record is used to prove that something does not exist, by 110 providing the name before it and the name after it. Using our tiny 111 company example, this would be analogous to someone sending an email for 112 Bob and our nameless intern responding with with: "I'm sorry, that 113 person doesn't work here. The name before the location where 'Bob' 114 would be is Alice, and the name after that is Edward." Let's say 115 another email was received for a 116 non-existent person, this time Oliver; our intern would respond "I'm 117 sorry, that person doesn't work here. The name before the location 118 where 'Oliver' would be is Edward, 119 and the name after that is Susan." If another sender asked for Todd, the 120 answer would be: "I'm sorry, that person doesn't work here. The name 121 before the location where 'Todd' would be is Susan, and there are no 122 other names after that." 123 124 So we end up with four NSEC records: 125 126 :: 127 128 example.com. 300 IN NSEC alice.example.com. A RRSIG NSEC 129 alice.example.com. 300 IN NSEC edward.example.com. A RRSIG NSEC 130 edward.example.com. 300 IN NSEC susan.example.com. A RRSIG NSEC 131 susan.example.com. 300 IN NSEC example.com. A RRSIG NSEC 132 133 What if the attacker tried to use the same replay method described 134 earlier? If someone sent an email for Edward, none of the four answers 135 would fit. If attacker replied with message #2, "I'm sorry, that person 136 doesn't work here. The name before it is Alice, and the name after it is 137 Edward," it is obviously false, since "Edward" is in the response; and the same 138 goes for #3, Edward and Susan. As for #1 and #4, Edward does not fall in 139 the alphabetical range before Alice or after Susan, so the sender can logically deduce 140 that it was an incorrect answer. 141 142 When BIND signs your zone, the zone data is automatically sorted on 143 the fly before generating NSEC records, much like how a phone directory 144 is sorted. 145 146 The NSEC record allows for a proof of non-existence for record types. If 147 you ask a signed zone for a name that exists but for a record type that 148 doesn't (for that name), the signed NSEC record returned lists all of 149 the record types that *do* exist for the requested domain name. 150 151 NSEC records can also be used to show whether a record was generated as 152 the result of a wildcard expansion. The details of this are not 153 within the scope of this document, but are described well in 154 :rfc:`7129`. 155 156 Unfortunately, the NSEC solution has a few drawbacks, one of which is 157 trivial "zone walking." In our story, a curious person can keep sending emails, and 158 our nameless, gullible intern keeps divulging information about our 159 employees. Imagine if the sender first asked: "Is Bob there?" and 160 received back the names Alice and Edward. Our sender could then email 161 again: "Is Edwarda there?", and will get back Edward and Susan. (No, 162 "Edwarda" is not a real name. However, it is the first name 163 alphabetically after "Edward" and that is enough to get the intern to reply 164 with a message telling us the next valid name after Edward.) Repeat the 165 process enough times and the person sending the emails eventually 166 learns every name in our company phone directory. For many of you, this 167 may not be a problem, since the very idea of DNS is similar to a public 168 phone book: if you don't want a name to be known publicly, don't put it 169 in DNS! Consider using DNS views (split DNS) and only display your 170 sensitive names to a select audience. 171 172 The second potential drawback of NSEC is a bigger zone file and memory consumption; 173 there is no opt-out mechanism for insecure child zones, so each name 174 in the zone will get an additional NSEC record and a RRSIG record to go with 175 it. In practice this is a problem only for parent-zone operators dealing with 176 mostly insecure child zones, such as ``com.``. To learn more about opt-out, 177 please see :ref:`advanced_discussions_nsec3_optout`. 178 179 .. _advanced_discussions_nsec3: 180 .. _nsec3: 181 182 NSEC3 183 ^^^^^ 184 185 NSEC3 adds two additional features that NSEC does not have: 186 187 1. It offers no easy zone enumeration. 188 189 2. It provides a mechanism for the parent zone to exclude insecure 190 delegations (i.e., delegations to zones that are not signed) from the 191 proof of non-existence. 192 193 Recall that in :ref:`advanced_discussions_nsec` we provided a range of 194 names to prove that something does not exist. But as it turns 195 out, even disclosing these ranges of names becomes a problem: this made 196 it very easy for the curious-minded to look at our entire zone. Not 197 only that, unlike a zone transfer, this "zone walking" is more 198 resource-intensive. So how do we disclose something without actually disclosing 199 it? 200 201 The answer is actually quite simple: hashing functions, or one-way 202 hashes. Without going into many details, think of it like a magical meat 203 grinder. A juicy piece of ribeye steak goes in one end, and out comes a 204 predictable shape and size of ground meat (hash) with a somewhat unique 205 pattern. No matter how hard you try, you cannot turn the ground meat 206 back into the ribeye steak: that's what we call a one-way hash. 207 208 NSEC3 basically runs the names through a one-way hash before giving them 209 out, so the recipients can verify the non-existence without any 210 knowledge of the other names in the zone. 211 212 So let's tell our little story for the third time, this 213 time with NSEC3. In this version, our intern is not given a list of actual 214 names; he is given a list of "hashed" names. So instead of Alice, 215 Edward, and Susan, the list he is given reads like this (hashes 216 shortened for easier reading): 217 218 :: 219 220 FSK5.... (produced from Edward) 221 JKMA.... (produced from Susan) 222 NTQ0.... (produced from Alice) 223 224 Then, an email is received for Bob again. Our intern takes the name Bob 225 through a hash function, and the result is L8J2..., so he replies: "I'm 226 sorry, that person doesn't work here. The name before that is JKMA..., 227 and the name after that is NTQ0...". There, we proved Bob doesn't exist, 228 without giving away any names! To put that into proper NSEC3 resource 229 records, they would look like this (again, hashes shortened for 230 ease of display): 231 232 :: 233 234 FSK5....example.com. 300 IN NSEC3 1 0 0 - JKMA... A RRSIG 235 JKMA....example.com. 300 IN NSEC3 1 0 0 - NTQ0... A RRSIG 236 NTQ0....example.com. 300 IN NSEC3 1 0 0 - FSK5... A RRSIG 237 238 .. note:: 239 240 Just because we employed one-way hash functions does not mean there is 241 no way for a determined individual to figure out our zone data. 242 243 Most names published in the DNS are rarely secret or unpredictable. They are 244 published to be memorable, used and consumed by humans. They are often recorded 245 in many other network logs such as email logs, certificate transparency logs, 246 web page links, intrusion detection systems, malware scanners, email archives, 247 etc. Many times a simple dictionary of commonly used domain-name prefixes 248 (www, mail, imap, login, database, etc.) can be used to quickly reveal a large 249 number of labels within a zone. Additionally, if an adversary really wants to 250 expend significant CPU resources to mount an offline dictionary attack on a 251 zone's NSEC3 chain, they will likely be able to find most of the "guessable" 252 names despite any level of hashing. 253 254 Also, it is still possible to gather all of our NSEC3 records and hashed 255 names and perform an offline brute-force attack by trying all 256 possible combinations to figure out what the original name is. In our 257 meat-grinder analogy, this would be like someone 258 buying all available cuts of meat and grinding them up at home using 259 the same model of meat grinder, and comparing the output with the meat 260 you gave him. It is expensive and time-consuming (especially with 261 real meat), but like everything else in cryptography, if someone has 262 enough resources and time, nothing is truly private forever. If you 263 are concerned about someone performing this type of attack on your 264 zone data, use some of the special techniques described in :rfc:`4470`. 265 266 .. _advanced_discussions_nsec3param: 267 268 NSEC3PARAM 269 ++++++++++ 270 271 .. warning:: 272 Before we dive into the details of NSEC3 parametrization, please note: 273 the defaults should not be changed without a strong justification and a full 274 understanding of the potential impact. See :rfc:`9276`. 275 276 The above NSEC3 examples used four parameters: 1, 0, 0, and 277 zero-length salt. 1 represents the algorithm, 0 represents the opt-out 278 flag, 0 represents the number of additional iterations, and - is the 279 salt. Let's look at how each one can be configured: 280 281 .. glossary:: 282 283 Algorithm 284 NSEC3 Hashing Algorithm 285 The only currently defined value is 1 for SHA-1, so there 286 is no configuration field for it. 287 288 Opt-out 289 Setting this bit to 1 enables NSEC3 opt-out, which is 290 discussed in :ref:`advanced_discussions_nsec3_optout`. 291 292 Iterations 293 Iterations defines the number of _additional_ times to 294 apply the algorithm when generating an NSEC3 hash. More iterations 295 consume more resources for both authoritative servers and validating 296 resolvers. The considerations here are similar to those seen in 297 :ref:`key_sizes`, of security versus resources. 298 299 .. warning:: 300 Do not use values higher than zero. A value of zero provides one round 301 of SHA-1 hashing and protects from non-determined attackers. 302 303 A greater number of additional iterations causes interoperability problems 304 and opens servers to CPU-exhausting DoS attacks, while providing 305 only doubtful security benefits. 306 307 Salt 308 A salt value, which can be combined with an FQDN to influence the 309 resulting hash. Salt is discussed in more detail in 310 :ref:`advanced_discussions_nsec3_salt`. 311 312 .. _advanced_discussions_nsec3_optout: 313 314 NSEC3 Opt-Out 315 +++++++++++++ 316 317 First things first: For most DNS administrators who do not manage a huge number 318 of insecure delegations, the NSEC3 opt-out featuere is not relevant. See :rfc:`9276`. 319 320 Opt-out allows for blocks of unsigned delegations to be covered by a single NSEC3 321 record. In other words, use of the opt-out allows large registries to only sign as 322 many NSEC3 records as there are signed DS or other RRsets in the zone; with 323 opt-out, unsigned delegations do not require additional NSEC3 records. This 324 sacrifices the tamper-resistance proof of non-existence offered by NSEC3 in 325 order to reduce memory and CPU overheads, and decreases the effectiveness of the cache 326 (:rfc:`8198`). 327 328 Why would that ever be desirable? If a significant number of delegations 329 are not yet securely delegated, meaning they lack DS records and are still 330 insecure or unsigned, generating DNSSEC records for all their NS records 331 might consume lots of memory and is not strictly required by the child zones. 332 333 This resource-saving typically makes a difference only for *huge* zones like ``com.``. 334 Imagine that you are the operator of busy top-level domains such as ``com.``, 335 with millions of insecure delegated domain names. 336 As of mid-2022, around 3% of all ``com.`` zones are signed. Basically, 337 without opt-out, with 1,000,000 delegations, only 30,000 of which are secure, you 338 still have to generate NSEC RRsets for the other 970,000 delegations; with 339 NSEC3 opt-out, you will have saved yourself 970,000 sets of records. 340 341 In contrast, for a small zone the difference is operationally negligible 342 and the drawbacks outweigh the benefits. 343 344 If NSEC3 opt-out is truly essential for a zone, the following 345 configuration can be added to :any:`dnssec-policy`; for example, to create an 346 NSEC3 chain using the SHA-1 hash algorithm, with the opt-out flag, 347 no additional iterations, and no extra salt, use: 348 349 .. code-block:: none 350 351 dnssec-policy "nsec3" { 352 ... 353 nsec3param iterations 0 optout yes salt-length 0; 354 }; 355 356 357 358 To learn more about how to configure NSEC3 opt-out, please see 359 :ref:`recipes_nsec3_optout`. 360 361 .. _advanced_discussions_nsec3_salt: 362 363 NSEC3 Salt 364 ++++++++++ 365 366 .. warning:: 367 Contrary to popular belief, adding salt provides little value. 368 Each DNS zone is always uniquely salted using the zone name. **Operators should 369 use a zero-length salt value.** 370 371 The properties of this extra salt are complicated and beyond scope of this 372 document. For detailed description why the salt in the context of DNSSEC 373 provides little value please see :rfc:`9276`. 374 375 .. _advanced_discussions_nsec_or_nsec3: 376 377 NSEC or NSEC3? 378 ^^^^^^^^^^^^^^ 379 380 So which is better: NSEC or NSEC3? There is no single right 381 answer here that fits everyone; it comes down to a given network's needs or 382 requirements. 383 384 In most cases, NSEC is a good choice for zone administrators. It 385 relieves the authoritative servers and resolver of the additional cryptographic 386 operations that NSEC3 requires, and NSEC is comparatively easier to 387 troubleshoot than NSEC3. 388 389 NSEC3 comes with many drawbacks and should be implemented only if zone 390 enumeration prevention is really needed, or when opt-out provides a 391 significant reduction in memory and CPU overheads (in other words, with a 392 huge zone with mostly insecure delegations). 393 394 .. _advanced_discussions_key_generation: 395 396 DNSSEC Keys 397 ~~~~~~~~~~~ 398 399 Types of Keys 400 ^^^^^^^^^^^^^ 401 402 Although DNSSEC 403 documentation talks about three types of keys, they are all the same 404 thing - but they have different roles. The roles are: 405 406 Zone-Signing Key (ZSK) 407 This is the key used to sign the zone. It signs all records in the 408 zone apart from the DNSSEC key-related RRsets: DNSKEY, CDS, and 409 CDNSKEY. 410 411 Key-Signing Key (KSK) 412 This is the key used to sign the DNSSEC key-related RRsets and is the 413 key used to link the parent and child zones. The parent zone stores a 414 digest of the KSK. When a resolver verifies the chain of trust it 415 checks to see that the DS record in the parent (which holds the 416 digest of a key) matches a key in the DNSKEY RRset, and that it is 417 able to use that key to verify the DNSKEY RRset. If it can do 418 that, the resolver knows that it can trust the DNSKEY resource 419 records, and so can use one of them to validate the other records in 420 the zone. 421 422 Combined Signing Key (CSK) 423 A CSK combines the functionality of a ZSK and a KSK. Instead of 424 having one key for signing the zone and one for linking the parent 425 and child zones, a CSK is a single key that serves both roles. 426 427 It is important to realize the terms ZSK, KSK, and CSK describe how the 428 keys are used - all these keys are represented by DNSKEY records. The 429 following examples are the DNSKEY records from a zone signed with a KSK 430 and ZSK: 431 432 :: 433 434 $ dig @192.168.1.12 example.com DNSKEY 435 436 ; <<>> DiG 9.16.0 <<>> @192.168.1.12 example.com dnskey +multiline 437 ; (1 server found) 438 ;; global options: +cmd 439 ;; Got answer: 440 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54989 441 ;; flags: qr aa rd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 442 ;; WARNING: recursion requested but not available 443 444 ;; OPT PSEUDOSECTION: 445 ; EDNS: version: 0, flags:; udp: 4096 446 ; COOKIE: 5258d7ed09db0d76010000005ea1cc8c672d8db27a464e37 (good) 447 ;; QUESTION SECTION: 448 ;example.com. IN DNSKEY 449 450 ;; ANSWER SECTION: 451 example.com. 60 IN DNSKEY 256 3 13 ( 452 tAeXLtIQ3aVDqqS/1UVRt9AE6/nzfoAuaT1Vy4dYl2CK 453 pLNcUJxME1Z//pnGXY+HqDU7Gr5HkJY8V0W3r5fzlw== 454 ) ; ZSK; alg = ECDSAP256SHA256 ; key id = 63722 455 example.com. 60 IN DNSKEY 257 3 13 ( 456 cxkNegsgubBPXSra5ug2P8rWy63B8jTnS4n0IYSsD9eW 457 VhiyQDmdgevKUhfG3SE1wbLChjJc2FAbvSZ1qk03Nw== 458 ) ; KSK; alg = ECDSAP256SHA256 ; key id = 42933 459 460 ... and a zone signed with just a CSK: 461 462 :: 463 464 $ dig @192.168.1.13 example.com DNSKEY 465 466 ; <<>> DiG 9.16.0 <<>> @192.168.1.13 example.com dnskey +multiline 467 ; (1 server found) 468 ;; global options: +cmd 469 ;; Got answer: 470 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22628 471 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 472 ;; WARNING: recursion requested but not available 473 474 ;; OPT PSEUDOSECTION: 475 ; EDNS: version: 0, flags:; udp: 4096 476 ; COOKIE: bf19ee914b5df46e010000005ea1cd02b66c06885d274647 (good) 477 ;; QUESTION SECTION: 478 ;example.com. IN DNSKEY 479 480 ;; ANSWER SECTION: 481 example.com. 60 IN DNSKEY 257 3 13 ( 482 p0XM6AJ68qid2vtOdyGaeH1jnrdk2GhZeVvGzXfP/PNa 483 71wGtzR6jdUrTbXo5Z1W5QeeJF4dls4lh4z7DByF5Q== 484 ) ; KSK; alg = ECDSAP256SHA256 ; key id = 1231 485 486 The only visible difference between the records (apart from the key data 487 itself) is the value of the flags fields; this is 256 488 for a ZSK and 257 for a KSK or CSK. Even then, the flags field is only a 489 hint to the software using it as to the role of the key: zones can be 490 signed by any key. The fact that a CSK and KSK both have the same flags 491 emphasizes this. A KSK usually only signs the DNSSEC key-related RRsets 492 in a zone, whereas a CSK is used to sign all records in the zone. 493 494 The original idea of separating the function of the key into a KSK and 495 ZSK was operational. With a single key, changing it for any reason is 496 "expensive," as it requires interaction with the parent zone 497 (e.g., uploading the key to the parent may require manual interaction 498 with the organization running that zone). By splitting it, interaction 499 with the parent is required only if the KSK is changed; the ZSK can be 500 changed as often as required without involving the parent. 501 502 The split also allows the keys to be of different lengths. So the ZSK, 503 which is used to sign the record in the zone, can be of a (relatively) 504 short length, lowering the load on the server. The KSK, which is used 505 only infrequently, can be of a much longer length. The relatively 506 infrequent use also allows the private part of the key to be stored in a 507 way that is more secure but that may require more overhead to access, e.g., on 508 an HSM (see :ref:`hardware_security_modules`). 509 510 In the early days of DNSSEC, the idea of splitting the key went more or 511 less unchallenged. However, with the advent of more powerful computers 512 and the introduction of signaling methods between the parent and child 513 zones (see :ref:`cds_cdnskey`), the advantages of a ZSK/KSK split are 514 less clear and, for many zones, a single key is all that is required. 515 516 As with many questions related to the choice of DNSSEC policy, the 517 decision on which is "best" is not clear and depends on your circumstances. 518 519 Which Algorithm? 520 ^^^^^^^^^^^^^^^^ 521 522 There are three algorithm choices for DNSSEC as of this writing 523 (mid-2020): 524 525 - RSA 526 527 - Elliptic Curve DSA (ECDSA) 528 529 - Edwards Curve Digital Security Algorithm (EdDSA) 530 531 All are supported in BIND 9, but only RSA and ECDSA (specifically 532 RSASHA256 and ECDSAP256SHA256) are mandatory to implement in DNSSEC. 533 However, RSA is a little long in the tooth, and ECDSA/EdDSA are emerging 534 as the next new cryptographic standards. In fact, the US federal 535 government recommended discontinuing RSA use altogether by September 2015 536 and migrating to using ECDSA or similar algorithms. 537 538 For now, use ECDSAP256SHA256 but keep abreast of developments in this 539 area. For details about rolling over DNSKEYs to a new algorithm, see 540 :ref:`advanced_discussions_DNSKEY_algorithm_rollovers`. 541 542 .. _key_sizes: 543 544 Key Sizes 545 ^^^^^^^^^ 546 547 If using RSA keys, the choice of key sizes is a classic issue of finding 548 the balance between performance and security. The larger the key size, 549 the longer it takes for an attacker to crack the key; but larger keys 550 also mean more resources are needed both when generating signatures 551 (authoritative servers) and verifying signatures (recursive servers). 552 553 Of the two sets of keys, ZSK is used much more frequently. ZSK is used whenever zone 554 data changes or when signatures expire, so performance 555 certainly is of a bigger concern. As for KSK, it is used less 556 frequently, so performance is less of a factor, but its impact is bigger 557 because of its role in signing other keys. 558 559 In earlier versions of this guide, the following key lengths were 560 chosen for each set, with the recommendation that they be rotated more 561 frequently for better security: 562 563 - *ZSK*: RSA 1024 bits, rollover every year 564 565 - *KSK*: RSA 2048 bits, rollover every five years 566 567 These should be considered minimum RSA key sizes. At the time 568 of this writing (mid-2020), the root zone and many TLDs are already using 2048 569 bit ZSKs. If you choose to implement larger key sizes, keep in mind that 570 larger key sizes result in larger DNS responses, which this may mean more 571 load on network resources. Depending on your network configuration, end users 572 may even experience resolution failures due to the increased response 573 sizes, as discussed in :ref:`whats_edns0_all_about`. 574 575 ECDSA key sizes can be much smaller for the same level of security, e.g., 576 an ECDSA key length of 224 bits provides the same level of security as a 577 2048-bit RSA key. Currently BIND 9 sets a key size of 256 for all ECDSA keys. 578 579 .. _advanced_discussions_key_storage: 580 581 Key Storage 582 ^^^^^^^^^^^ 583 584 Public Key Storage 585 ++++++++++++++++++ 586 587 The beauty of a public key cryptography system is that the public key 588 portion can and should be distributed to as many people as possible. As 589 the administrator, you may want to keep the public keys on an easily 590 accessible file system for operational ease, but there is no need to 591 securely store them, since both ZSK and KSK public keys are published in 592 the zone data as DNSKEY resource records. 593 594 Additionally, a hash of the KSK public key is also uploaded to the 595 parent zone (see :ref:`working_with_parent_zone` for more details), 596 and is published by the parent zone as DS records. 597 598 Private Key Storage 599 +++++++++++++++++++ 600 601 Ideally, private keys should be stored offline, in secure devices such 602 as a smart card. Operationally, however, this creates certain 603 challenges, since the private key is needed to create RRSIG resource 604 records, and it is a hassle to bring the private key out of 605 storage every time the zone file changes or signatures expire. 606 607 A common approach to strike the balance between security and 608 practicality is to have two sets of keys: a ZSK set and a KSK set. A ZSK 609 private key is used to sign zone data, and can be kept online for ease 610 of use, while a KSK private key is used to sign just the DNSKEY (the ZSK); it is 611 used less frequently, and can be stored in a much more secure and 612 restricted fashion. 613 614 For example, a KSK private key stored on a USB flash drive that is kept 615 in a fireproof safe, only brought online once a year to sign a new pair 616 of ZSKs, combined with a ZSK private key stored on the network 617 file system and available for routine use, may be a good balance between 618 operational flexibility and security. 619 620 For more information on changing keys, please see 621 :ref:`key_rollovers`. 622 623 .. _hardware_security_modules: 624 625 Hardware Security Modules (HSMs) 626 ++++++++++++++++++++++++++++++++ 627 628 A Hardware Security Module (HSM) may come in different shapes and sizes, 629 but as the name indicates, it is a physical device or devices, usually 630 with some or all of the following features: 631 632 - Tamper-resistant key storage 633 634 - Strong random-number generation 635 636 - Hardware for faster cryptographic operations 637 638 Most organizations do not incorporate HSMs into their security practices 639 due to cost and the added operational complexity. 640 641 BIND supports Public Key Cryptography Standard #11 (PKCS #11) for 642 communication with HSMs and other cryptographic support devices. For 643 more information on how to configure BIND to work with an HSM, please 644 refer to the `BIND 9 Administrator Reference 645 Manual <https://bind9.readthedocs.io/en/latest/index.html>`_. 646 647 .. _advanced_discussions_key_management: 648 649 Rollovers 650 ~~~~~~~~~ 651 652 .. _key_rollovers: 653 654 Key Rollovers 655 ^^^^^^^^^^^^^ 656 657 A key rollover is where one key in a zone is replaced by a new one. 658 There are arguments for and against regularly rolling keys. In essence 659 these are: 660 661 Pros: 662 663 1. Regularly changing the key hinders attempts at determination of the 664 private part of the key by cryptanalysis of signatures. 665 666 2. It gives administrators practice at changing a key; should a key ever need to be 667 changed in an emergency, they would not be doing it for the first time. 668 669 Cons: 670 671 1. A lot of effort is required to hack a key, and there are probably 672 easier ways of obtaining it, e.g., by breaking into the systems on 673 which it is stored. 674 675 2. Rolling the key adds complexity to the system and introduces the 676 possibility of error. We are more likely to 677 have an interruption to our service than if we had not rolled it. 678 679 Whether and when to roll the key is up to you. How serious would the 680 damage be if a key were compromised without you knowing about it? How 681 serious would a key roll failure be? 682 683 Before going any further, it is worth noting that if you sign your zone 684 with :any:`dnssec-policy`, you don't really need to concern yourself with the 685 details of a key rollover: BIND 9 takes care of it all for you. If you are 686 doing a manual key roll, you do need to familiarize yourself with the various 687 steps involved and the timing details. 688 689 Rolling a key is not as simple as replacing the DNSKEY statement in the 690 zone. That is an essential part of it, but timing is everything. For 691 example, suppose that we run the ``example.com`` zone and that a friend 692 queries for the AAAA record of ``www.example.com``. As part of the 693 resolution process (described in 694 :ref:`how_does_dnssec_change_dns_lookup`), their recursive server 695 looks up the keys for the ``example.com`` zone and uses them to verify 696 the signature associated with the AAAA record. We'll assume that the 697 records validated successfully, so they can use the 698 address to visit ``example.com``'s website. 699 700 Let's also assume that immediately after the lookup, we want to roll the ZSK 701 for ``example.com``. Our first attempt at this is to remove the old 702 DNSKEY record and signatures, add a new DNSKEY record, and re-sign the 703 zone with it. So one minute our server is serving the old DNSKEY and 704 records signed with the old key, and the next minute it is serving the 705 new key and records signed with it. We've achieved our goal - we are 706 serving a zone signed with the new keys; to check this is really the 707 case, we booted up our laptop and looked up the AAAA record 708 ``ftp.example.com``. The lookup succeeded so all must be well. Or is it? 709 Just to be sure, we called our friend and asked them to check. They 710 tried to lookup ``ftp.example.com`` but got a SERVFAIL response from 711 their recursive server. What's going on? 712 713 The answer, in a word, is "caching." When our friend looked up 714 ``www.example.com``, their recursive server retrieved and cached 715 not only the AAAA record, but also a lot of other records. It cached 716 the NS records for ``com`` and ``example.com``, as well as 717 the AAAA (and A) records for those name servers (and this action may, in turn, have 718 caused the lookup and caching of other NS and AAAA/A records). Most 719 importantly for this example, it also looked up and cached the DNSKEY 720 records for the root, ``com``, and ``example.com`` zones. When a query 721 was made for ``ftp.example.com``, the recursive server believed it 722 already had most of the information 723 we needed. It knew what nameservers served ``example.com`` and their 724 addresses, so it went directly to one of those to get the AAAA record for 725 ``ftp.example.com`` and its associated signature. But when it tried to 726 validate the signature, it used the cached copy of the DNSKEY, and that 727 is when our friend had the problem. Their recursive server had a copy of 728 the old DNSKEY in its cache, but the AAAA record for ``ftp.example.com`` 729 was signed with the new key. So, not surprisingly, the signature could not 730 validate. 731 732 How should we roll the keys for ``example.com``? A clue to the 733 answer is to note that the problem came about because the DNSKEY records 734 were cached by the recursive server. What would have happened had our 735 friend flushed the DNSKEY records from the recursive server's cache before 736 making the query? That would have worked; those records would have been 737 retrieved from ``example.com``'s nameservers at the same time that we 738 retrieved the AAAA record for ``ftp.example.com``. Our friend's server would have 739 obtained the new key along with the AAAA record and associated signature 740 created with the new key, and all would have been well. 741 742 As it is obviously impossible for us to notify all recursive server 743 operators to flush our DNSKEY records every time we roll a key, we must 744 use another solution. That solution is to wait 745 for the recursive servers to remove old records from caches when they 746 reach their TTL. How exactly we do this depends on whether we are trying 747 to roll a ZSK, a KSK, or a CSK. 748 749 .. _zsk_rollover_methods: 750 751 ZSK Rollover Methods 752 ++++++++++++++++++++ 753 754 The ZSK can be rolled in one of the following two ways: 755 756 1. *Pre-Publication*: Publish the new ZSK into zone data before it is 757 actually used. Wait at least one TTL interval, so the world's recursive servers 758 know about both keys, then stop using the old key and generate a new 759 RRSIG using the new key. Wait at least another TTL, so the cached old 760 key data is expunged from the world's recursive servers, and then remove 761 the old key. 762 763 The benefit of the pre-publication approach is it does not 764 dramatically increase the zone size; however, the duration of the rollover 765 is longer. If insufficient time has passed after the new ZSK is 766 published, some resolvers may only have the old ZSK cached when the 767 new RRSIG records are published, and validation may fail. This is the 768 method described in :ref:`recipes_zsk_rollover`. 769 770 2. *Double-Signature*: Publish the new ZSK and new RRSIG, essentially 771 doubling the size of the zone. Wait at least one TTL interval, and then remove 772 the old ZSK and old RRSIG. 773 774 The benefit of the double-signature approach is that it is easier to 775 understand and execute, but it causes a significantly increased zone size 776 during a rollover event. 777 778 .. _ksk_rollover_methods: 779 780 KSK Rollover Methods 781 ++++++++++++++++++++ 782 783 Rolling the KSK requires interaction with the parent zone, so 784 operationally this may be more complex than rolling ZSKs. There are 785 three methods of rolling the KSK: 786 787 1. *Double-KSK*: Add the new KSK to the DNSKEY RRset, which is then 788 signed with both the old and new keys. After waiting for the old RRset 789 to expire from caches, change the DS record in the parent zone. 790 After waiting a further TTL interval for this change to be reflected in 791 caches, remove the old key from the RRset. 792 793 Basically, the new KSK is added first at the child zone and 794 used to sign the DNSKEY; then the DS record is changed, followed by the 795 removal of the old KSK. Double-KSK keeps the interaction with the 796 parent zone to a minimum, but for the duration of the rollover, the 797 size of the DNSKEY RRset is increased. 798 799 2. *Double-DS*: Publish the new DS record. After waiting for this 800 change to propagate into caches, change the KSK. After a further TTL 801 interval during which the old DNSKEY RRset expires from caches, remove the 802 old DS record. 803 804 Double-DS is the reverse of Double-KSK: the new DS is published at 805 the parent first, then the KSK at the child is updated, then 806 the old DS at the parent is removed. The benefit is that the size of the DNSKEY 807 RRset is kept to a minimum, but interactions with the parent zone are 808 increased to two events. This is the method described in 809 :ref:`recipes_ksk_rollover`. 810 811 3. *Double-RRset*: Add the new KSK to the DNSKEY RRset, which is 812 then signed with both the old and new key, and add the new DS record 813 to the parent zone. After waiting a suitable interval for the 814 old DS and DNSKEY RRsets to expire from caches, remove the old DNSKEY and 815 old DS record. 816 817 Double-RRset is the fastest way to roll the KSK (i.e., it has the shortest rollover 818 time), but has the drawbacks of both of the other methods: a larger 819 DNSKEY RRset and two interactions with the parent. 820 821 .. _csk_rollover_methods: 822 823 CSK Rollover Methods 824 ++++++++++++++++++++ 825 826 Rolling the CSK is more complex than rolling either the ZSK or KSK, as 827 the timing constraints relating to both the parent zone and the caching 828 of records by downstream recursive servers must be taken into 829 account. There are numerous possible methods that are a combination of ZSK 830 rollover and KSK rollover methods. BIND 9 automatic signing uses a 831 combination of ZSK Pre-Publication and Double-KSK rollover. 832 833 .. _advanced_discussions_emergency_rollovers: 834 835 Emergency Key Rollovers 836 ^^^^^^^^^^^^^^^^^^^^^^^ 837 838 Keys are generally rolled on a regular schedule - if you choose 839 to roll them at all. But sometimes, you may have to rollover keys 840 out-of-schedule due to a security incident. The aim of an emergency 841 rollover is to re-sign the zone with a new key as soon as possible, because 842 when a key is suspected of being compromised, a malicious attacker (or 843 anyone who has access to the key) could impersonate your server and trick other 844 validating resolvers into believing that they are receiving authentic, 845 validated answers. 846 847 During an emergency rollover, follow the same operational 848 procedures described in :ref:`recipes_rollovers`, with the added 849 task of reducing the TTL of the current active (potentially compromised) DNSKEY 850 RRset, in an attempt to phase out the compromised key faster before the new 851 key takes effect. The time frame should be significantly reduced from 852 the 30-days-apart example, since you probably do not want to wait up to 853 60 days for the compromised key to be removed from your zone. 854 855 Another method is to carry a spare key with you at all times. If 856 you have a second key pre-published and that one 857 is not compromised at the same time as the first key, 858 you could save yourself some time by immediately 859 activating the spare key if the active 860 key is compromised. With pre-publication, all validating resolvers should already 861 have this spare key cached, thus saving you some time. 862 863 With a KSK emergency rollover, you also need to consider factors 864 related to your parent zone, such as how quickly they can remove the old 865 DS records and publish the new ones. 866 867 As with many other facets of DNSSEC, there are multiple aspects to take into 868 account when it comes to emergency key rollovers. For more in-depth 869 considerations, please check out :rfc:`7583`. 870 871 .. _advanced_discussions_DNSKEY_algorithm_rollovers: 872 873 Algorithm Rollovers 874 ^^^^^^^^^^^^^^^^^^^ 875 876 From time to time, new digital signature algorithms with improved 877 security are introduced, and it may be desirable for administrators to 878 roll over DNSKEYs to a new algorithm, e.g., from RSASHA1 (algorithm 5 or 879 7) to RSASHA256 (algorithm 8). The algorithm rollover steps must be followed with 880 care to avoid breaking DNSSEC validation. 881 882 If you are managing DNSSEC by using the :any:`dnssec-policy` configuration, 883 :iscman:`named` handles these steps for you. Simply change the algorithm 884 for the relevant keys, and :iscman:`named` uses the new algorithm when the 885 key is next rolled. It performs a smooth transition to the new 886 algorithm, ensuring that the zone remains valid throughout rollover. 887 888 Other Topics 889 ~~~~~~~~~~~~ 890 891 DNSSEC and Dynamic Updates 892 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 893 894 Dynamic DNS (DDNS) is actually independent of DNSSEC. DDNS provides a 895 mechanism, separate from editing the zone file or zone database, to edit DNS 896 data. Most DNS clients and servers are able to handle dynamic 897 updates, and DDNS can also be integrated as part of your DHCP 898 environment. 899 900 When you have both DNSSEC and dynamic updates in your environment, 901 updating zone data works the same way as with traditional (insecure) 902 DNS: you can use :option:`rndc freeze` before editing the zone file, and 903 :option:`rndc thaw` when you have finished editing, or you can use the 904 command :iscman:`nsupdate` to add, edit, or remove records like this: 905 906 :: 907 908 $ nsupdate 909 > server 192.168.1.13 910 > update add xyz.example.com. 300 IN A 1.1.1.1 911 > send 912 > quit 913 914 The examples provided in this guide make :iscman:`named` automatically 915 re-sign the zone whenever its content has changed. If you decide to sign 916 your own zone file manually, you need to remember to execute the 917 :iscman:`dnssec-signzone` command whenever your zone file has been updated. 918 919 As far as system resources and performance are concerned, be mindful that 920 with a DNSSEC zone that changes frequently, every time the zone 921 changes your system is executing a series of cryptographic operations 922 to (re)generate signatures and NSEC or NSEC3 records. 923 924 .. _dnssec_on_private_networks: 925 926 DNSSEC on Private Networks 927 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 928 929 Let's clarify what we mean: in this section, "private networks" really refers to 930 a private or internal DNS view. Most DNS products offer the ability to 931 have different versions of DNS answers, depending on the origin of the 932 query. This feature is often called "DNS views" or "split DNS," and is most 933 commonly implemented as an "internal" versus an "external" setup. 934 935 For instance, your organization may have a version of ``example.com`` 936 that is offered to the world, and its names most likely resolve to 937 publicly reachable IP addresses. You may also have an internal version 938 of ``example.com`` that is only accessible when you are on the company's 939 private networks or via a VPN connection. These private networks typically 940 fall under 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16 for IPv4. 941 942 So what if you want to offer DNSSEC for your internal version of 943 ``example.com``? This can be done: the golden rule is to use the same 944 key for both the internal and external versions of the zones. This 945 avoids problems that can occur when machines (e.g., laptops) move 946 between accessing the internal and external zones, when it is possible 947 that they may have cached records from the wrong zone. 948 949 .. _introduction_to_dane: 950 951 Introduction to DANE 952 ^^^^^^^^^^^^^^^^^^^^ 953 954 With your DNS infrastructure secured with DNSSEC, information can 955 now be stored in DNS and its integrity and authenticity can be proved. 956 One of the new features that takes advantage of this is the DNS-Based 957 Authentication of Named Entities, or DANE. This improves security in a 958 number of ways, including: 959 960 - The ability to store self-signed X.509 certificates and bypass having to pay a third 961 party (such as a Certificate Authority) to sign the certificates 962 (:rfc:`6698`). 963 964 - Improved security for clients connecting to mail servers (:rfc:`7672`). 965 966 - A secure way of getting public PGP keys (:rfc:`7929`). 967 968 Disadvantages of DNSSEC 969 ~~~~~~~~~~~~~~~~~~~~~~~ 970 971 DNSSEC, like many things in this world, is not without its problems. 972 Below are a few challenges and disadvantages that DNSSEC faces. 973 974 1. *Increased, well, everything*: With DNSSEC, signed zones are larger, 975 thus taking up more disk space; for DNSSEC-aware servers, the 976 additional cryptographic computation usually results in increased 977 system load; and the network packets are bigger, possibly putting 978 more strains on the network infrastructure. 979 980 2. *Different security considerations*: DNSSEC addresses many security 981 concerns, most notably cache poisoning. But at the same time, it may 982 introduce a set of different security considerations, such as 983 amplification attack and zone enumeration through NSEC. These 984 concerns are still being identified and addressed by the Internet 985 community. 986 987 3. *More complexity*: If you have read this far, you have probably already 988 concluded this yourself. With additional resource records, keys, 989 signatures, and rotations, DNSSEC adds many more moving pieces on top of 990 the existing DNS machine. The job of the DNS administrator changes, 991 as DNS becomes the new secure repository of everything from spam 992 avoidance to encryption keys, and the amount of work involved to 993 troubleshoot a DNS-related issue becomes more challenging. 994 995 4. *Increased fragility*: The increased complexity means more 996 opportunities for things to go wrong. Before DNSSEC, DNS 997 was essentially "add something to the zone and forget it." With DNSSEC, 998 each new component - re-signing, key rollover, interaction with 999 parent zone, key management - adds more opportunity for error. It is 1000 entirely possible that a failure to validate a name may come down to 1001 errors on the part of one or more zone operators rather than the 1002 result of a deliberate attack on the DNS. 1003 1004 5. *New maintenance tasks*: Even if your new secure DNS infrastructure 1005 runs without any hiccups or security breaches, it still requires 1006 regular attention, from re-signing to key rollovers. While most of 1007 these can be automated, some of the tasks, such as KSK rollover, 1008 remain manual for the time being. 1009 1010 6. *Not enough people are using it today*: While it's estimated (as of 1011 mid-2020) that roughly 30% of the global Internet DNS traffic is 1012 validating, [#apnic_validating_stats]_ that doesn't mean that many of 1013 the DNS zones are actually signed. What this means is, even if your 1014 company's zone is signed today, fewer than 30% of the Internet's 1015 servers are taking advantage of this extra security. It gets worse: 1016 with less than 1.5% of the ``com.`` domains signed, even if your 1017 DNSSEC validation is enabled today, it's not likely to buy you or 1018 your users a whole lot more protection until these popular domain 1019 names decide to sign their zones. 1020 1021 The last point may have more impact than you realize. Consider this: 1022 HTTP and HTTPS make up the majority of traffic on the Internet. While you may have 1023 secured your DNS infrastructure through DNSSEC, if your web hosting is 1024 outsourced to a third party that does not yet support DNSSEC in its 1025 own domain, or if your web page loads contents and components from 1026 insecure domains, end users may experience validation problems when 1027 trying to access your web page. For example, although you may have signed 1028 the zone ``company.com``, the web address ``www.company.com`` may actually be a 1029 CNAME to ``foo.random-cloud-provider.com``. As long as 1030 ``random-cloud-provider.com`` remains an insecure DNS zone, users cannot 1031 fully validate everything when they visit your web page and could be 1032 redirected elsewhere by a cache poisoning attack. 1033 1034 .. [#apnic_validating_stats] 1035 Based on APNIC statistics at 1036 `<https://stats.labs.apnic.net/dnssec/XA>`__ 1037