idnits 2.17.1 draft-ietf-dnsop-cookies-10.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (April 5, 2016) is 2943 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Obsolete informational reference (is this intentional?): RFC 2845 (Obsoleted by RFC 8945) Summary: 0 errors (**), 0 flaws (~~), 1 warning (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 1 INTERNET-DRAFT Donald Eastlake 2 Intended Status: Proposed Standard Huawei 3 Mark Andrews 4 ISC 5 Expires: October 4, 2016 April 5, 2016 7 Domain Name System (DNS) Cookies 8 10 Abstract 12 DNS cookies are a lightweight DNS transaction security mechanism that 13 provides limited protection to DNS servers and clients against a 14 variety of increasingly common denial-of-service and amplification / 15 forgery or cache poisoning attacks by off-path attackers. DNS Cookies 16 are tolerant of NAT, NAT-PT, and anycast and can be incrementally 17 deployed. (Since DNS Cookies are only returned to the IP address from 18 which they were originally received, they cannot be used to generally 19 track Internet users.) 21 Status of This Document 23 This Internet-Draft is submitted to IETF in full conformance with the 24 provisions of BCP 78 and BCP 79. 26 Distribution of this document is unlimited. Comments should be sent 27 to the author or the DNSEXT mailing list . 29 Internet-Drafts are working documents of the Internet Engineering 30 Task Force (IETF), its areas, and its working groups. Note that 31 other groups may also distribute working documents as Internet- 32 Drafts. 34 Internet-Drafts are draft documents valid for a maximum of six months 35 and may be updated, replaced, or obsoleted by other documents at any 36 time. It is inappropriate to use Internet-Drafts as reference 37 material or to cite them other than as "work in progress." 39 The list of current Internet-Drafts can be accessed at 40 http://www.ietf.org/1id-abstracts.html. The list of Internet-Draft 41 Shadow Directories can be accessed at 42 http://www.ietf.org/shadow.html. 44 Table of Contents 46 1. Introduction............................................4 47 1.1 Contents of This Document..............................4 48 1.2 Definitions............................................5 50 2. Threats Considered......................................6 51 2.1 Denial-of-Service Attacks..............................6 52 2.1.1 DNS Amplification Attacks............................6 53 2.1.2 DNS Server Denial-of-Service.........................7 54 2.2 Cache Poisoning and Answer Forgery Attacks.............7 56 3. Comments on Existing DNS Security.......................8 57 3.1 Existing DNS Data Security.............................8 58 3.2 DNS Message/Transaction Security.......................8 59 3.3 Conclusions on Existing DNS Security...................8 61 4. DNS Cookie Option......................................10 62 4.1 Client Cookie.........................................11 63 4.2 Server Cookie.........................................11 65 5. DNS Cookies Protocol Specification.....................12 66 5.1 Originating Requests..................................12 67 5.2 Responding to Request.................................12 68 5.2.1 No Opt RR or No COOKIE OPT option...................13 69 5.2.2 Malformed COOKIE OPT option.........................13 70 5.2.3 Only a Client Cookie................................13 71 5.2.4 A Client Cookie and an Invalid Server Cookie........14 72 5.2.5 A Client Cookie and a Valid Server Cookie...........14 73 5.3 Processing Responses..................................15 74 5.4 QUERYing for a Server Cookie..........................15 76 6. NAT Considerations and AnyCast Server Considerations...17 78 7. Operational and Deployment Considerations..............19 79 7.1 Client and Server Secret Rollover.....................19 80 7.2 Counters..............................................20 82 8. IANA Considerations....................................21 84 9. Security Considerations................................22 85 9.1 Cookie Algorithm Considerations.......................23 87 10. Implementation Considerations.........................24 89 Normative References......................................25 90 Informative References....................................25 92 Acknowledgements..........................................27 94 Table of Contents (continued) 96 Appendix A: Example Client Cookie Algorithms..............28 97 A.1 A Simple Algorithm....................................28 98 A.2 A More Complex Algorithm..............................28 100 Appendix B: Example Server Cookie Algorithms..............29 101 B.1 A Simple Algorithm....................................29 102 B.2 A More Complex Algorithm..............................29 104 Author's Address..........................................31 106 1. Introduction 108 As with many core Internet protocols, the Domain Name System (DNS) 109 was originally designed at a time when the Internet had only a small 110 pool of trusted users. As the Internet has grown exponentially to a 111 global information utility, the DNS has increasingly been subject to 112 abuse. 114 This document describes DNS cookies, a lightweight DNS transaction 115 security mechanism specified as an OPT [RFC6891] option. The DNS 116 cookies mechanism provides limited protection to DNS servers and 117 clients against a variety of increasingly common abuses by off-path 118 attackers. It is compatible with and can be used in conjunction with 119 other DNS transaction forgery resistance measures such as those in 120 [RFC5452]. (Since DNS Cookies are only returned to the IP address 121 from which they were originally received, they cannot be used to 122 generally track Internet users.) 124 The protection provided by DNS cookies is similar to that provided by 125 using TCP for DNS transactions. To bypass the weak protection 126 provided by using TCP requires, among other things, that an off-path 127 attacker guess the 32-bit TCP sequence number in use. To bypass the 128 weak protection provided by DNS Cookies requires such an attacker to 129 guess a 64-bit pseudo-random "cookie" quantity. Where DNS Cookies are 130 not available but TCP is, falling back to using TCP is reasonable. 132 If only one party to a DNS transaction supports DNS cookies, the 133 mechanism does not provide a benefit or significantly interfere; but, 134 if both support it, the additional security provided is automatically 135 available. 137 The DNS cookies mechanism is designed to work in the presence of NAT 138 and NAT-PT boxes and guidance is provided herein on supporting the 139 DNS cookies mechanism in anycast servers. 141 1.1 Contents of This Document 143 In Section 2, we discuss the threats against which the DNS cookie 144 mechanism provides some protection. 146 Section 3 describes existing DNS security mechanisms and why they are 147 not adequate substitutes for DNS cookies. 149 Section 4 describes the COOKIE OPT option. 151 Section 5 provides a protocol description. 153 Section 6 discusses some NAT and anycast related DNS Cookies design 154 considerations. 156 Section 7 discusses incremental deployment considerations. 158 Sections 8 and 9 describe IANA and Security Considerations. 160 1.2 Definitions 162 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 163 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 164 "OPTIONAL" in this document are to be interpreted as described in 165 [RFC2119]. 167 "Off-path attacker", for a particular DNS client and server, is 168 defined as an attacker who cannot observe the DNS request and 169 response messages between that client and server. 171 "Soft state" indicates information learned or derived by a host which 172 may be discarded when indicated by the policies of that host 173 but can be later re-instantiated if needed. For example, it 174 could be discarded after a period of time or when storage for 175 caching such data becomes full. If operations requiring that 176 soft state continue after it has been discarded, it will be 177 automatically re-generated, albeit at some cost. 179 "Silently discarded" indicates that there are no DNS protocol message 180 consequences. 182 "IP address" is used herein as a length independent term and includes 183 both IPv4 and IPv6 addresses. 185 2. Threats Considered 187 DNS cookies are intended to provide significant but limited 188 protection against certain attacks by off-path attackers as described 189 below. These attacks include denial-of-service, cache poisoning, and 190 answer forgery. 192 2.1 Denial-of-Service Attacks 194 The typical form of the denial-of-service attacks considered herein 195 is to send DNS requests with forged source IP addresses to a server. 196 The intent can be to attack that server or some other selected host 197 as described below. 199 There are also on-path denial of service attacks that attempt to 200 saturate a server with DNS requests having correct source addresses. 201 Cookies do not protect against such attacks but successful cookie 202 validation improves the probability that the correct source IP 203 address for the requests is known. This facilitates contacting the 204 managers of or taking other actions for the networks from which the 205 requests originate. 207 2.1.1 DNS Amplification Attacks 209 A request with a forged IP source address generally causes a response 210 to be sent to that forged IP address. Thus the forging of many such 211 requests with a particular source IP address can result in enough 212 traffic being sent to the forged IP address to interfere with service 213 to the host at the IP address. Furthermore, it is generally easy in 214 the DNS to create short requests that produce much longer responses, 215 thus amplifying the attack. 217 The DNS Cookies mechanism can severely limit the traffic 218 amplification obtained by attacker requests that are off the path 219 between the server and the request's source address. Enforced DNS 220 cookies would make it hard for an off path attacker to cause any more 221 than rate-limited short error responses to be sent to a forged IP 222 address so the attack would be attenuated rather than amplified. DNS 223 cookies make it more effective to implement a rate limiting scheme 224 for error responses from the server. Such a scheme would further 225 restrict selected host denial-of-service traffic from that server. 227 2.1.2 DNS Server Denial-of-Service 229 DNS requests that are accepted cause work on the part of DNS servers. 230 This is particularly true for recursive servers that may issue one or 231 more requests and process the responses thereto, in order to 232 determine their response to the initial request. And the situation 233 can be even worse for recursive servers implementing DNSSEC 234 ([RFC4033] [RFC4034] [RFC4035]) because they may be induced to 235 perform burdensome cryptographic computations in attempts to verify 236 the authenticity of data they retrieve in trying to answer the 237 request. 239 The computational or communications burden caused by such requests 240 may not depend on a forged IP source address, but the use of such 241 addresses makes 242 + the source of the requests causing the denial-of-service attack 243 harder to find and 244 + restriction of the IP addresses from which such requests should 245 be honored hard or impossible to specify or verify. 247 Use of DNS cookies should enable a server to reject forged requests 248 from an off path attacker with relative ease and before any recursive 249 queries or public key cryptographic operations are performed. 251 2.2 Cache Poisoning and Answer Forgery Attacks 253 The form of the cache poisoning attacks considered is to send forged 254 replies to a resolver. Modern network speeds for well-connected hosts 255 are such that, by forging replies from the IP addresses of a DNS 256 server to a resolver for names that resolver has been induced to 257 resolve or for common names whose resource records have short time- 258 to-live values, there can be an unacceptably high probability of 259 randomly coming up with a reply that will be accepted and cause false 260 DNS information to be cached by that resolver (the Dan Kaminsky 261 attack [Kaminsky]). This can be used to facilitate phishing attacks 262 and other diversion of legitimate traffic to a compromised or 263 malicious host such as a web server. 265 With the use of DNS cookies, a resolver can generally reject such 266 forged replies. 268 3. Comments on Existing DNS Security 270 Two forms of security have been added to DNS, data security and 271 message/transaction security. 273 3.1 Existing DNS Data Security 275 DNS data security is one part of DNSSEC and is described in 276 [RFC4033], [RFC4034], [RFC4035], and updates thereto. It provides 277 data origin authentication and authenticated denial of existence. 278 DNSSEC is being deployed and can provide strong protection against 279 forged data and cache poisoning; however, it has the unintended 280 effect of making some denial-of-service attacks worse because of the 281 cryptographic computational load it can require and the increased 282 size in DNS response packets that it tends to produce. 284 3.2 DNS Message/Transaction Security 286 The second form of security that has been added to DNS provides 287 "transaction" security through TSIG [RFC2845] or SIG(0) [RFC2931]. 288 TSIG could provide strong protection against the attacks for which 289 the DNS Cookies mechanism provides weaker protection; however, TSIG 290 is non-trivial to deploy in the general Internet because of the 291 burdens it imposes. Among these burdens are pre-agreement and key 292 distribution between client and server, keeping track of server side 293 key state, and required time synchronization between client and 294 server. 296 TKEY [RFC2930] can solve the problem of key distribution for TSIG but 297 some modes of TKEY impose a substantial cryptographic computation 298 load and can be dependent on the deployment of DNS data security (see 299 Section 3.1). 301 SIG(0) [RFC2931] provides less denial of service protection than TSIG 302 or, in one way, even DNS cookies, because it does not authenticate 303 requests, only complete transactions. In any case, it also depends 304 on the deployment of DNS data security and requires computationally 305 burdensome public key cryptographic operations. 307 3.3 Conclusions on Existing DNS Security 309 The existing DNS security mechanisms do not provide the services 310 provided by the DNS Cookies mechanism: lightweight message 311 authentication of DNS requests and responses with no requirement for 312 pre-configuration or per client server side state. 314 4. DNS Cookie Option 316 The DNS Cookie Option is an OPT RR [RFC6891] option that can be 317 included in the RDATA portion of an OPT RR in DNS requests and 318 responses. The option length varies depending on the circumstances 319 in which it is being used. There are two cases as described below. 320 Both use the same OPTION-CODE; they are distinguished by their 321 length. 323 In a request sent by a client to a server when the client does not 324 know the server's cookie, its length is 8, consisting of an 8 byte 325 Client Cookie as shown in Figure 1. 327 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 328 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 329 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 330 | OPTION-CODE = 10 | OPTION-LENGTH = 8 | 331 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 332 | | 333 +-+- Client Cookie (fixed size, 8 bytes) -+-+-+-+ 334 | | 335 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 337 Figure 1. COOKIE Option, Unknown Server Cookie 339 In a request sent by a client when a server cookie is known and in 340 all responses, the length is variable from 16 to 40 bytes, consisting 341 of an 8 bytes Client Cookie followed by the variable 8 to 32 bytes 342 Server Cookie as shown in Figure 2. The variability of the option 343 length stems from the variable length Server Cookie. The Server 344 Cookie is an integer number of bytes with a minimum size of 8 bytes 345 for security and a maximum size of 32 bytes for implementation 346 convenience. 348 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 349 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 350 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 351 | OPTION-CODE = 10 | OPTION-LENGTH >= 16, <= 40 | 352 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 353 | | 354 +-+- Client Cookie (fixed size, 8 bytes) -+-+-+-+ 355 | | 356 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 357 | | 358 / Server Cookie (variable size, 8 to 32 bytes) / 359 / / 360 +-+-+-+-... 362 Figure 2. COOKIE Option, Known Server Cookie 364 4.1 Client Cookie 366 The Client Cookie SHOULD be a pseudo-random function of the client IP 367 address, the server IP address, and a secret quantity known only to 368 the client. This client secret SHOULD have at least 64 bits of 369 entropy [RFC4086] and be changed periodically (see Section 7.1). The 370 selection of the pseudo-random function is a matter private to the 371 client as only the client needs to recognize its own DNS cookies. 373 The client IP address is included so that the Client Cookie cannot be 374 used (1) to track a client if the client IP address changes due to 375 privacy mechanisms or (2) to impersonate the client by some network 376 device that was formerly on path but is no longer on path when the 377 client IP address changes due to mobility. However, if the client IP 378 address is being changed very often, it may be necessary to fix the 379 Client Cookie for a particular server for several requests to avoid 380 undue inefficiency due to retries caused by that server not 381 recognizing the Client Cookie. 383 For further discussion of the Client Cookie field, see Section 5.1. 384 For example methods of determining a Client Cookie, see Appendix A. 386 In order to provide minimal authentication, a client MUST send Client 387 Cookies that will usually be different for any two servers at 388 different IP addresses. 390 4.2 Server Cookie 392 The Server Cookie SHOULD consist of or include a 64-bit or larger 393 pseudo-random function of the request source (client) IP address, a 394 secret quantity known only to the server, and the request Client 395 Cookie. (See Section 6 for a discussion of why the Client Cookie is 396 used as input to the Server Cookie but the Server Cookie is not used 397 as an input to the Client Cookie.) This server secret SHOULD have at 398 least 64 bits of entropy [RFC4086] and be changed periodically (see 399 Section 7.1). The selection of the pseudo-random function is a 400 matter private to the server as only the server needs to recognize 401 its own DNS cookies. 403 For further discussion of the Server Cookie field see Section 5.2. 404 For example methods of determining a Server Cookie, see Appendix B. 405 When implemented as recommended, the server need not maintain any 406 cookie related per client state. 408 In order to provide minimal authentication, a server MUST send Server 409 Cookies that will usually be different for clients at any two 410 different IP addresses or with different Client Cookies. 412 5. DNS Cookies Protocol Specification 414 This section discusses using DNS Cookies in the DNS Protocol. The 415 cycle of originating a request, responding to that request, and 416 processing the response are covered in Sections 5.1, 5.2, and 5.3. A 417 de facto extension to QUERY to allow pre-fetching a Server Cookie is 418 specified in Section 5.4. Rollover of the client and server secrets 419 and transient retention of the old cookie or secret is covered in 420 Section 7.1. 422 DNS clients and servers SHOULD implement DNS cookies to decrease 423 their vulnerability to the threats discussed in Section 2. 425 5.1 Originating Requests 427 A DNS client that implements DNS Cookies includes one DNS COOKIE OPT 428 option containing a Client Cookie in every DNS request it sends 429 unless DNS cookies are disabled. 431 If the client has a cached Server Cookie for the server against its 432 IP address it uses the longer cookie form and includes that Server 433 Cookie in the option along with the Client Cookie (Figure 2). 434 Otherwise it just sends the shorter form option with a Client Cookie 435 (Figure 1). 437 5.2 Responding to Request 439 The Server Cookie, when it occurs in a COOKIE OPT option in a 440 request, is intended to weakly assure the server that the request 441 came from a client that is both at the source IP address of the 442 request and using the Client Cookie included in the option. This 443 assurance is provided by the Server Cookie that server sent to that 444 client in an earlier response appearing as the Server Cookie field in 445 the request. 447 At a server where DNS Cookies are not implemented and enabled, 448 presence of a COOKIE OPT option is ignored and the server responds as 449 if no COOKIE OPT option had been included in the request. 451 When DNS Cookies are implemented and enabled, there are five 452 possibilities: (1) there is no OPT RR at all in the request or there 453 is a OPT RR but the COOKIE OPT option is absent from the OPT RR; (2) 454 a COOKIE OPT is present but is not a legal length or otherwise 455 malformed; (3) there is a valid length cookie option in the request 456 with no Server Cookie; (4) there is a valid length COOKIE OPT in the 457 request with a Server Cookie but that Server Cookie is invalid; or 458 (5) there is a valid length COOKIE OPT in the request with a correct 459 Server Cookie. 461 The five possibilities are discussed in the subsections below. 463 In all cases of multiple COOKIE OPT options in a request, only the 464 first (the one closest to the DNS header) is considered. All others 465 are ignored. 467 5.2.1 No Opt RR or No COOKIE OPT option 469 If there is no OPT record or no COOKIE OPT option present in the 470 request then the server responds to the request as if the server 471 doesn't implement the COOKIE OPT. 473 5.2.2 Malformed COOKIE OPT option 475 If the COOKIE OPT is too short to contain a Client Cookie then 476 FORMERR is generated. If the COOKIE OPT is longer than that required 477 to hold a COOKIE OPT with just a Client Cookie (8 bytes) but is 478 shorter that the minimum COOKIE OPT with both a Client and Server 479 Cookie (16 bytes) then FORMERR is generated. If the COOKIE OPT is 480 longer than the maximum valid COOKIE OPT (40 bytes) then a FORMERR is 481 generated. 483 In summary, valid cookie lengths are 8 and 16 to 40 inclusive. 485 5.2.3 Only a Client Cookie 487 Based on server policy, including rate limiting, the server chooses 488 one of the following: 490 (1) Silently discard the request. 492 (2) Send a BADCOOKIE error response. 494 (3) Process the request and provide a normal response. The RCODE is 495 NOERROR unless some non-cookie error occurs in processing the 496 request. 498 If the server responds, choosing 2 or 3 above, it SHALL generate its 499 own COOKIE OPT containing both the Client Cookie copied from the 500 request and a Server Cookie it has generated and adds this COOKIE OPT 501 to the response's OPT record. Servers MUST, at least occasionally, 502 respond to such requests to inform the client of the correct Server 503 Cookie. This is necessary so that such a client can bootstrap to the 504 more secure state where requests and responses have recognized Server 505 Cookies and Client Cookies. A server is not expected to maintain per 506 client state to achieve this. For example, it could respond to every 507 Nth request across all clients. 509 If the request was received over TCP, the server SHOULD take the 510 authentication provided by the use of TCP into account and SHOULD 511 choose 3. In this case, if the server is not willing to accept the 512 security provided by TCP as a substitute for the security provided by 513 DNS Cookies but instead chooses 2, there is some danger of an 514 indefinite loop of retries (see Section 5.3). 516 5.2.4 A Client Cookie and an Invalid Server Cookie 518 The server examines the Server Cookie to determine if it is a valid 519 Server Cookie it has generated. This determination normally involves 520 re-calculating the Server Cookie (or the hash part thereof) based on 521 the server secret (or the previous server secret if it has just 522 changed), the received Client Cookie, the client IP address, and 523 possibly other fields -- see Appendix B.2 for an example. If the 524 cookie is invalid, it can be because of a stale Server Cookie, or a 525 client's IP address or Client Cookie changing without the DNS server 526 being aware, or an anycast server cluster that is not consistently 527 configured, or an attempt to spoof the client. 529 The server SHALL process the request as if the invalid Server Cookie 530 was not present as described in Section 5.2.3. 532 5.2.5 A Client Cookie and a Valid Server Cookie 534 When a valid Server Cookie is present in the request the server can 535 assume that the request is from a client that it has talked to before 536 and defensive measures for spoofed UDP requests, if any, are no 537 longer required. 539 The server SHALL process the request and include a COOKIE OPT in the 540 response by (a) copying the complete COOKIE OPT from the request or 541 (b) generating a new COOKIE OPT containing both the Client Cookie 542 copied from the request and a valid Server Cookie it has generated. 544 5.3 Processing Responses 546 The Client Cookie, when it occurs in a COOKIE OPT option in a DNS 547 reply, is intended to weakly assure the client that the reply came 548 from a server at the source IP address used in the response packet 549 because the Client Cookie value is the value that client would send 550 to that server in a request. In a DNS reply with multiple COOKIE OPT 551 options, all but the first (the one closest to the DNS Header) are 552 ignored. 554 A DNS client where DNS cookies are implemented and enabled examines 555 the response for DNS cookies and MUST discard the response if it 556 contains an illegal COOKIE OPT option length or an incorrect Client 557 Cookie value. If the client is expecting the response to contain a 558 COOKIE OPT and it is missing the response MUST be discarded. If the 559 COOKIE OPT option Client Cookie is correct, the client caches the 560 Server Cookie provided even if the response is an error response 561 (RCODE non-zero). 563 If the reply extended RCODE is BADCOOKIE and the Client Cookie 564 matches what was sent, it means that the server was unwilling to 565 process the request because it did not have the correct Server Cookie 566 in it. The client SHOULD retry the request using the new Server 567 Cookie from the response. Repeated BADCOOKIE responses to requests 568 that use the Server Cookie provided in the previous response may be 569 an indication that the shared secrets / secret generation method in 570 an anycast cluster of servers are inconsistent. If the reply to a 571 retried request with a fresh Server Cookie is BADCOOKIE, the client 572 SHOULD retry using TCP as the transport since the server will likely 573 process the request normally based on the security provided by TCP 574 (see Section 5.2.3). 576 If the RCODE is some value other than BADCOOKIE, including zero, the 577 further processing of the response proceeds normally. 579 5.4 QUERYing for a Server Cookie 581 In many cases a client will learn the Server Cookie for a server as 582 the side effect of another transaction; however, there may be times 583 when this is not desirable. Therefore a means is provided for 584 obtaining a Server Cookie through an extension to the QUERY opcode 585 for which opcode most existing implementations require that QDCOUNT 586 be one (see Section 4.1.2 of [RFC1035]). 588 For servers with DNS Cookies enabled, the QUERY opcode behavior is 589 extended to support queries with an empty question section (QDCOUNT 590 zero) provided that an OPT record is present with a COOKIE option. 591 Such servers will reply with an empty answer section and a COOKIE 592 option giving the Client Cookie provided in the query and a valid 593 Server Cookie. 595 If such a query provided just a Client Cookie and no Server Cookie, 596 the response SHALL have the RCODE NOERROR. 598 This mechanism can also be used to confirm/re-establish an existing 599 Server Cookie by sending a cached Server Cookie with the Client 600 Cookie. In this case the response SHALL have the RCODE BADCOOKIE if 601 the Server Cookie sent with the query was invalid and the RCODE 602 NOERROR if it was valid. 604 Servers which don't support the COOKIE option will normally send 605 FORMERR in response to such a query, though REFUSED, NOTIMP, and 606 NOERROR without a COOKIE option are also possible in such responses. 608 6. NAT Considerations and AnyCast Server Considerations 610 In the Classic Internet, DNS Cookies could simply be a pseudo-random 611 function of the client IP address and a server secret or the server 612 IP address and a client secret. You would want to compute the Server 613 Cookie that way, so a client could cache its Server Cookie for a 614 particular server for an indefinite amount of time and the server 615 could easily regenerate and check it. You could consider the Client 616 Cookie to be a weak client signature over the server IP address that 617 the client checks in replies and you could extend this signature to 618 cover the request ID, for example, or any other information that is 619 returned unchanged in the reply. 621 But we have this reality called NAT [RFC3022], Network Address 622 Translation (including, for the purposes of this document, NAT-PT, 623 Network Address and Protocol Translation, which has been declared 624 Historic [RFC4966]). There is no problem with DNS transactions 625 between clients and servers behind a NAT box using local IP 626 addresses. Nor is there a problem with NAT translation of internal 627 addresses to external addresses or translations between IPv4 and IPv6 628 addresses, as long as the address mapping is relatively stable. 629 Should the external IP address an internal client is being mapped to 630 change occasionally, the disruption is little more than when a client 631 rolls-over its DNS COOKIE secret. And normally external access to a 632 DNS server behind a NAT box is handled by a fixed mapping which 633 forwards externally received DNS requests to a specific host. 635 However, NAT devices sometimes also map ports. This can cause 636 multiple DNS requests and responses from multiple internal hosts to 637 be mapped to a smaller number of external IP addresses, such as one 638 address. Thus there could be many clients behind a NAT box that 639 appear to come from the same source IP address to a server outside 640 that NAT box. If one of these were an attacker (think Zombie or 641 Botnet), that behind-NAT attacker could get the Server Cookie for 642 some server for the outgoing IP address by just making some random 643 request to that server. It could then include that Server Cookie in 644 the COOKIE OPT of requests to the server with the forged local IP 645 address of some other host and/or client behind the NAT box. 646 (Attacker possession of this Server Cookie will not help in forging 647 responses to cause cache poisoning as such responses are protected by 648 the required Client Cookie.) 650 To fix this potential defect, it is necessary to distinguish 651 different clients behind a NAT box from the point of view of the 652 server. It is for this reason that the Server Cookie is specified as 653 a pseudo-random function of both the request source IP address and 654 the Client Cookie. From this inclusion of the Client Cookie in the 655 calculation of the Server Cookie, it follows that a stable Client 656 Cookie, for any particular server, is needed. If, for example, the 657 request ID was included in the calculation of the Client Cookie, it 658 would normally change with each request to a particular server. This 659 would mean that each request would have to be sent twice: first to 660 learn the new Server Cookie based on this new Client Cookie based on 661 the new ID and then again using this new Client Cookie to actually 662 get an answer. Thus the input to the Client Cookie computation must 663 be limited to the server IP address and one or more things that 664 change slowly such as the client secret. 666 In principle, there could be a similar problem for servers, not due 667 to NAT but due to mechanisms like anycast which may cause requests to 668 a DNS server at an IP address to be delivered to any one of several 669 machines. (External requests to a DNS server behind a NAT box usually 670 occur via port forwarding such that all such requests go to one 671 host.) However, it is impossible to solve this the way the similar 672 problem was solved for NATed clients; if the Server Cookie was 673 included in the calculation of the Client Cookie the same way the 674 Client Cookie is included in the Server Cookie, you would just get an 675 almost infinite series of errors as a request was repeatedly retried. 677 For servers accessed via anycast to successfully support DNS COOKIES, 678 the server clones must either all use the same server secret or the 679 mechanism that distributes requests to them must cause the requests 680 from a particular client to go to a particular server for a 681 sufficiently long period of time that extra requests due to changes 682 in Server Cookie resulting from accessing different server machines 683 are not unduly burdensome. (When such anycast-accessed servers act 684 as recursive servers or otherwise act as clients they normally use a 685 different unique address to source their requests to avoid confusion 686 in the delivery of responses.) 688 For simplicity, it is RECOMMENDED that the same server secret be used 689 by each DNS server in a set of anycast servers. If there is limited 690 time skew in updating this secret in different anycast servers, this 691 can be handled by a server accepting requests containing a Server 692 Cookie based on either its old or new secret for the maximum likely 693 time period of such time skew (see also Section 7.1). 695 7. Operational and Deployment Considerations 697 The DNS cookies mechanism is designed for incremental deployment and 698 to complement the orthogonal techniques in [RFC5452]. Either or both 699 techniques can be deployed independently at each DNS server and 700 client. Thus installation at the client and server end need not be 701 synchronized. 703 In particular, a DNS server or client that implements the DNS COOKIE 704 mechanism can interoperate successfully with a DNS client or server 705 that does not implement this mechanism although, of course, in this 706 case it will not get the benefit of the mechanism and the server 707 involved might choose to severely rate limit responses. When such a 708 server or client interoperates with a client or server which also 709 implements the DNS cookies mechanism, they get the security benefits 710 of the DNS Cookies mechanism. 712 7.1 Client and Server Secret Rollover 714 The longer a secret is used, the higher the probability it has been 715 compromised. Thus clients and servers are configured with a lifetime 716 for their secret and rollover to a new secret when that lifetime 717 expires or earlier due to deliberate jitter as described below. The 718 default lifetime is one day and the maximum permitted is one month. 719 To be precise and to make it practical to stay within limits despite 720 long holiday weekends and daylight savings time shifts and the like, 721 clients and servers MUST NOT continue to use the same secret in new 722 requests and responses for more than 36 days and SHOULD NOT continue 723 to do so for more than 26 hours. 725 Many clients rolling over their secret at the same time could briefly 726 increase server traffic and exactly predictable rollover times for 727 clients or servers might facilitate guessing attacks. For example, an 728 attacker might increase the priority of attacking secrets they 729 believe will be in effect for an extended period of time. To avoid 730 rollover synchronization and predictability, it is RECOMMENDED that 731 pseudorandom jitter in the range of plus zero to minus at least 40% 732 be applied to the time until a scheduled rollover of a DNS cookie 733 secret. 735 It is RECOMMENDED that a client keep the Client Cookie it is 736 expecting in a reply until there is no longer an outstanding request 737 associated with that Client Cookie that the client is tracking. This 738 avoids rejection of replies due to a bad Client Cookie right after a 739 change in the client secret. 741 It is RECOMMENDED that a server retain its previous secret after a 742 rollover to a new secret for a configurable period of time not less 743 than 1 second or more than 5 minutes with default configuration of 2 744 1/2 minutes. Requests with Server Cookies based on its previous 745 secret are treated as a correct Server Cookie during that time. When 746 a server responds to a request containing a old Server Cookie that 747 the server is treating as correct, the server MUST include a new 748 Server Cookie in its response. 750 7.2 Counters 752 It is RECOMMENDED that implementations include counters of the 753 occurrences of the various types of requests and responses described 754 in Section 5. 756 8. IANA Considerations 758 IANA has assigned the following OPT option value: 760 Value Name Status Reference 761 -------- ------ -------- --------------- 762 10 COOKIE Standard [this document] 764 IANA has assigned the following DNS error code as an early 765 allocation: 767 RCODE Name Description Reference 768 -------- --------- ------------------------- --------------- 769 23 BADCOOKIE Bad/missing server cookie [this document] 771 9. Security Considerations 773 DNS Cookies provide a weak form of authentication of DNS requests and 774 responses. In particular, they provide no protection against "on- 775 path" adversaries; that is, they provide no protection against any 776 adversary that can observe the plain text DNS traffic, such as an on- 777 path router, bridge, or any device on an on-path shared link (unless 778 the DNS traffic in question on that path is encrypted). 780 For example, if a host is connected via an unsecured IEEE Std 802.11 781 link (Wi-Fi), any device in the vicinity that could receive and 782 decode the 802.11 transmissions must be considered "on-path". On the 783 other hand, in a similar situation but one where 802.11 Robust 784 Security (WPA2) is appropriately deployed on the Wi-Fi network nodes, 785 only the Access Point via which the host is connecting is "on-path" 786 as far as the 802.11 link is concerned. 788 Despite these limitations, deployment of DNS Cookies on the global 789 Internet is expected to provide a significant reduction in the 790 available launch points for the traffic amplification and denial of 791 service forgery attacks described in Section 2 above. 793 Work is underway in the IETF DPRIVE working group to provide 794 confidentiality for DNS requests and responses which would be 795 compatible with DNS cookies. 797 Should stronger message/transaction security be desired, it is 798 suggested that TSIG or SIG(0) security be used (see Section 3.2); 799 however, it may be useful to use DNS Cookies in conjunction with 800 these features. In particular, DNS Cookies could screen out many DNS 801 messages before the cryptographic computations of TSIG or SIG(0) are 802 required and, if SIG(0) is in use, DNS Cookies could usefully screen 803 out many requests given that SIG(0) does not screen requests but only 804 authenticates the response of complete transactions. 806 An attacker that does not know the Server Cookie could do a variety 807 of things, such as omitting the COOKIE OPT option or sending a random 808 Server Cookie. In general, DNS servers need to take other measures, 809 including rate limiting responses, to protect from abuse in such 810 cases. See further information in Section 5.2. 812 When a server or client starts receiving an increased level of 813 requests with bad server cookies or replies with bad client cookies, 814 it would be reasonable for it to believe it is likely under attack 815 and it should consider a more frequent rollover of its secret. More 816 rapid rollover decreases the benefit to a cookie guessing attacker if 817 they succeed in guessing a cookie. 819 9.1 Cookie Algorithm Considerations 821 The cookie computation algorithm for use in DNS Cookies SHOULD be 822 based on a pseudo-random function at least as strong as 64-bit FNV 823 (Fowler-Noll-Vo [FNV]) because an excessively weak or trivial 824 algorithm could enable adversaries to guess cookies. However, in 825 light of the lightweight plain-text token security provided by DNS 826 Cookies, a strong cryptography hash algorithm may not be warranted in 827 many cases, and would cause an increased computational burden. 828 Nevertheless there is nothing wrong with using something stronger, 829 for example, HMAC-SHA256 [RFC6234] truncated to 64 bits, assuming a 830 DNS processor has adequate computational resources available. DNS 831 processors that feel the need for somewhat stronger security without 832 a significant increase in computational load should consider more 833 frequent changes in their client and/or server secret; however, this 834 does require more frequent generation of a cryptographically strong 835 random number [RFC4086]. See Appendices A and B for specific examples 836 of cookie computation algorithms. 838 10. Implementation Considerations 840 The DNS Cookie Option specified herein is implemented in BIND 9.10 841 using an experimental option code. 843 Normative References 845 [RFC1035] - Mockapetris, P., "Domain names - implementation and 846 specification", STD 13, RFC 1035, DOI 10.17487/RFC1035, 847 November 1987, . 849 [RFC2119] - Bradner, S., "Key words for use in RFCs to Indicate 850 Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, 851 March 1997, . 853 [RFC4086] - Eastlake 3rd, D., Schiller, J., and S. Crocker, 854 "Randomness Requirements for Security", BCP 106, RFC 4086, DOI 855 10.17487/RFC4086, June 2005, . 858 [RFC6891] - Damas, J., Graff, M., and P. Vixie, "Extension Mechanisms 859 for DNS (EDNS(0))", STD 75, RFC 6891, DOI 10.17487/RFC6891, 860 April 2013, . 862 Informative References 864 [FNV] - G. Fowler, L. C. Noll, K.-P. Vo, D. Eastlake, "The FNV Non- 865 Cryptographic Hash Algorithm", draft-eastlake-fnv, work in 866 progress. 868 [Kaminsky] - Olney, M., P. Mullen, K. Miklavicic, "Dan Kaminsky's 869 2008 DNS Vulnerability", 25 July 2008, 870 . 873 [RFC2845] - Vixie, P., Gudmundsson, O., Eastlake 3rd, D., and B. 874 Wellington, "Secret Key Transaction Authentication for DNS 875 (TSIG)", RFC 2845, DOI 10.17487/RFC2845, May 2000, 876 . 878 [RFC2930] - Eastlake 3rd, D., "Secret Key Establishment for DNS (TKEY 879 RR)", RFC 2930, DOI 10.17487/RFC2930, September 2000, 880 . 882 [RFC2931] - Eastlake 3rd, D., "DNS Request and Transaction Signatures 883 ( SIG(0)s )", RFC 2931, DOI 10.17487/RFC2931, September 2000, 884 . 886 [RFC3022] - Srisuresh, P. and K. Egevang, "Traditional IP Network 887 Address Translator (Traditional NAT)", RFC 3022, DOI 888 10.17487/RFC3022, January 2001, . 891 [RFC4033] - Arends, R., Austein, R., Larson, M., Massey, D., and S. 892 Rose, "DNS Security Introduction and Requirements", RFC 4033, 893 DOI 10.17487/RFC4033, March 2005, . 896 [RFC4034] - Arends, R., Austein, R., Larson, M., Massey, D., and S. 897 Rose, "Resource Records for the DNS Security Extensions", RFC 898 4034, DOI 10.17487/RFC4034, March 2005, . 901 [RFC4035] - Arends, R., Austein, R., Larson, M., Massey, D., and S. 902 Rose, "Protocol Modifications for the DNS Security Extensions", 903 RFC 4035, DOI 10.17487/RFC4035, March 2005, . 906 [RFC4966] - Aoun, C. and E. Davies, "Reasons to Move the Network 907 Address Translator - Protocol Translator (NAT-PT) to Historic 908 Status", RFC 4966, DOI 10.17487/RFC4966, July 2007, 909 . 911 [RFC5452] - Hubert, A. and R. van Mook, "Measures for Making DNS More 912 Resilient against Forged Answers", RFC 5452, DOI 913 10.17487/RFC5452, January 2009, . 916 [RFC6234] - Eastlake 3rd, D. and T. Hansen, "US Secure Hash 917 Algorithms (SHA and SHA-based HMAC and HKDF)", RFC 6234, DOI 918 10.17487/RFC6234, May 2011, . 921 Acknowledgements 923 The suggestions and contributions of the following are gratefully 924 acknowledged: 926 Alissa Cooper, Bob Harold, Paul Hoffman, David Malone, Yoav Nir, 927 Gayle Noble, Dan Romascanu, 928 Tim Wicinski, Peter Yee 930 The document was prepared in raw nroff. All macros used were defined 931 within the source file. 933 Appendix A: Example Client Cookie Algorithms 935 A.1 A Simple Algorithm 937 A simple example method to compute Client Cookies is the FNV-64 [FNV] 938 of the client IP address, the server IP address, and the client 939 secret. That is 941 Client Cookie = 942 FNV-64( Client IP Address | Server IP Address | Client Secret ) 944 where "|" indicates concatenation. Some computational resources may 945 be saved by precomputing FNV-64 through the Client IP Address. (If 946 the order of the items concatenated above is changed to put the 947 Server IP Address last, it might be possible to further reduce the 948 computational effort by pre-computing FNV-64 through the bytes of 949 both the Client IP Address and the Client Secret but this would 950 reduce the strength of the Client Cookie and is NOT RECOMMENDED.) 952 A.2 A More Complex Algorithm 954 A more complex algorithm to calculate Client Cookies is given below. 955 It uses more computational resources than the simpler algorithm shown 956 in A.1. 958 Client Cookie = HMAC-SHA256-64( 959 Client IP Address | Server IP Address, 960 Client Secret ) 962 Appendix B: Example Server Cookie Algorithms 964 B.1 A Simple Algorithm 966 An example of a simple method producing a 64-bit Server Cookie is the 967 FNV-64 [FNV] of the request IP address, the Client Cookie, and the 968 server secret. 970 Server Cookie = 971 FNV-64( Client IP Address | Client Cookie | Server Secret ) 973 where "|" represents concatenation. (If the order of the items 974 concatenated was changed, it might be possible to reduce the 975 computational effort by pre-computing FNV-64 through the bytes of the 976 Sever Secret and Client Cookie but this would reduce the strength of 977 the Server Cookie and is NOT RECOMMENDED.) 979 B.2 A More Complex Algorithm 981 Since the Server Cookie has a variable size, the server can store 982 various information in that field as long as it is hard for an 983 adversary to guess the entire quantity used for authentication. There 984 should be 64 bits of entropy in the Server Cookie; for example it 985 could have a sub-field of 64-bits computed pseudo-randomly with the 986 server secret as one of the inputs to the pseudo-random function. 987 Types of additional information that could be stored include a time 988 stamp and/or a nonce. 990 The example below is one variation for the Server Cookie that has 991 been implemented in BIND 9.10.3 (and later) releases where the Server 992 Cookie is 128 bits composed as follows: 994 Sub-field Size 995 --------- --------- 996 Nonce 32 bits 997 Time 32 bits 998 Hash 64 bits 1000 With this algorithm, the server sends a new 128-bit cookie back with 1001 every request. The Nonce field assures a low probability that there 1002 would be a duplicate. 1004 The Time field gives the server time and makes it easy to reject old 1005 cookies. 1007 The Hash part of the Server Cookie is the hard-to-guess part. In BIND 1008 9.10.3 (and later), its computation can be configured to use AES, 1009 HMAC-SHA1, or, as shown below, HMAC-SHA256: 1011 hash = 1012 HMAC-SHA256-64( Server Secret, 1013 (Client Cookie | nonce | time | Client IP Address) ) 1015 where "|" represents concatenation. 1017 Author's Address 1019 Donald E. Eastlake 3rd 1020 Huawei Technologies 1021 155 Beaver Street 1022 Milford, MA 01757 USA 1024 Telephone: +1-508-333-2270 1025 EMail: d3e3e3@gmail.com 1027 Mark Andrews 1028 Internet Systems Consortium 1029 950 Charter Street 1030 Redwood City, CA 94063 USA 1032 Email: marka@isc.org 1034 Copyright, Disclaimer, and Additional IPR Provisions 1036 Copyright (c) 2016 IETF Trust and the persons identified as the 1037 document authors. All rights reserved. 1039 This document is subject to BCP 78 and the IETF Trust's Legal 1040 Provisions Relating to IETF Documents 1041 (http://trustee.ietf.org/license-info) in effect on the date of 1042 publication of this document. Please review these documents 1043 carefully, as they describe your rights and restrictions with respect 1044 to this document. Code Components extracted from this document must 1045 include Simplified BSD License text as described in Section 4.e of 1046 the Trust Legal Provisions and are provided without warranty as 1047 described in the Simplified BSD License.