idnits 2.17.1 draft-ietf-dnsop-cookies-02.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 (June 16, 2015) is 3230 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) -- Looks like a reference, but probably isn't: '10' on line 675 -- Looks like a reference, but probably isn't: '23' on line 682 -- Obsolete informational reference (is this intentional?): RFC 2845 (Obsoleted by RFC 8945) Summary: 0 errors (**), 0 flaws (~~), 1 warning (==), 4 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: December 15, 2015 June 16, 2015 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. 19 Status of This Document 21 This Internet-Draft is submitted to IETF in full conformance with the 22 provisions of BCP 78 and BCP 79. 24 Distribution of this document is unlimited. Comments should be sent 25 to the author or the DNSEXT mailing list . 27 Internet-Drafts are working documents of the Internet Engineering 28 Task Force (IETF), its areas, and its working groups. Note that 29 other groups may also distribute working documents as Internet- 30 Drafts. 32 Internet-Drafts are draft documents valid for a maximum of six months 33 and may be updated, replaced, or obsoleted by other documents at any 34 time. It is inappropriate to use Internet-Drafts as reference 35 material or to cite them other than as "work in progress." 37 The list of current Internet-Drafts can be accessed at 38 http://www.ietf.org/1id-abstracts.html. The list of Internet-Draft 39 Shadow Directories can be accessed at 40 http://www.ietf.org/shadow.html. 42 Table of Contents 44 1. Introduction............................................4 45 1.1 Contents of This Document..............................4 46 1.2 Definitions............................................5 48 2. Threats Considered......................................6 49 2.1 Denial-of-Service Attacks..............................6 50 2.1.1 DNS Amplification Attacks............................6 51 2.1.2 DNS Server Denial-of-Service.........................6 52 2.2 Cache Poisoning and Answer Forgery Attacks.............7 54 3. Comments on Existing DNS Security.......................8 55 3.1 Existing DNS Data Security.............................8 56 3.2 DNS Message/Transaction Security.......................8 57 3.3 Conclusions on Existing DNS Security...................8 59 4. DNS Cookie Option.......................................9 60 4.1 Client Cookie.........................................10 61 4.2 Server Cookie.........................................10 63 5. DNS Cookies Protocol Description.......................11 64 5.1 Originating Requests..................................11 65 5.2 Responding to Request.................................11 66 5.2.1 No Opt RR or No COOKIE OPT option...................12 67 5.2.2 Malformed COOKIE OPT option.........................12 68 5.2.3 Only a Client Cookie................................12 69 5.2.4 A Client Cookie and Server Cookie...................13 70 5.2.4.1 A Client Cookie and Invalid Server Cookie.........13 71 5.2.4.2 A Client Cookie and Valid Server Cookie...........13 72 5.3 Processing Responses..................................13 73 5.4 Client and Server Secret Rollover.....................14 74 5.5 Implementation Requirement............................15 76 6. NAT Considerations and AnyCast Server Considerations...16 77 7. Deployment.............................................18 78 8. IANA Considerations....................................19 80 9. Security Considerations................................20 81 9.1 Cookie Algorithm Considerations.......................20 83 10. Implementation Considerations.........................21 85 Normative References......................................22 86 Informative References....................................22 88 Acknowledgements..........................................24 90 Appendix A: Example Client Cookie Algorithms..............25 91 A.1 A Simple Algorithm....................................25 92 A.2 A More Complex Algorithm..............................25 94 Table of Contents (continued) 96 Appendix B: Example Server Cookie Algorithms..............26 97 B.1 A Simple Algorithm....................................26 98 B.2 A More Complex Algorithm..............................26 100 Author's Address..........................................28 102 1. Introduction 104 As with many core Internet protocols, the Domain Name System (DNS) 105 was originally designed at a time when the Internet had only a small 106 pool of trusted users. As the Internet has grown exponentially to a 107 global information utility, the DNS has increasingly been subject to 108 abuse. 110 This document describes DNS cookies, a lightweight DNS transaction 111 security mechanism specified as an OPT [RFC6891] option. The DNS 112 cookies mechanism provides limited protection to DNS servers and 113 clients against a variety of increasingly common abuses by off-path 114 attackers. It is compatible with and can be used in conjunction with 115 other DNS transaction forgery resistance measures such as those in 116 [RFC5452]. 118 The protection provided by DNS cookies bears some resemblance to that 119 provided by using TCP for DNS transactions. To bypass the weak 120 protection provided by using TCP requires an off-path attacker 121 guessing the 32-bit TCP sequence number in use. To bypass the weak 122 protection provided by DNS Cookies requires such an attacker to guess 123 a 64-bit pseudo-random quantity. Where DNS Cookies are not available 124 but TCP is, a fall back to using TCP is a reasonable strategy. 126 If only one party to a DNS transaction supports DNS cookies, the 127 mechanism does not provide a benefit or significantly interfere; but, 128 if both support it, the additional security provided is automatically 129 available. 131 The DNS cookies mechanism is designed to work in the presence of NAT 132 and NAT-PT boxes and guidance is provided herein on supporting the 133 DNS cookies mechanism in anycast servers. 135 1.1 Contents of This Document 137 In Section 2, we discuss the threats against which the DNS cookie 138 mechanism provides some protection. 140 Section 3 describes existing DNS security mechanisms and why they are 141 not adequate substitutes for DNS cookies. 143 Section 4 describes the COOKIE OPT option. 145 Section 5 provides a protocol description. 147 Section 6 discusses some NAT and anycast related DNS Cookies design 148 considerations. 150 Section 7 discusses incremental deployment considerations. 152 Sections 8 and 9 describe IANA and Security Considerations. 154 1.2 Definitions 156 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 157 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 158 document are to be interpreted as described in [RFC2119]. 160 An "off-path attacker", for a particular DNS client and server, is 161 defined as an attacker who cannot observe the DNS request and 162 response messages between that client and server. 164 "Soft state" indicates information learned or derived by a host which 165 may be discarded when indicated by the policies of that host but can 166 be later re-instantiated if needed. For example, it could be 167 discarded after a period of time or when storage for caching such 168 data becomes full. If operations requiring that soft state continue 169 after it has been discarded, it will be automatically re-generated, 170 albeit at some cost. 172 "Silently discarded" indicates that there are no DNS protocol message 173 consequences; however, it is RECOMMENDED that appropriate network 174 management facilities be included in implementations, such as a 175 counter of the occurrences of each such event type. 177 "IP address" is used herein as a length independent term and includes 178 both IPv4 and IPv6 addresses. 180 2. Threats Considered 182 DNS cookies are intended to provide significant but limited 183 protection against certain attacks by off-path attackers as described 184 below. These attacks include denial-of-service, cache poisoning and 185 answer forgery. 187 2.1 Denial-of-Service Attacks 189 The typical form of the denial-of-service attacks considered herein 190 is to send DNS requests with forged source IP addresses to a server. 191 The intent can be to attack that server or some other selected host 192 as described below. 194 2.1.1 DNS Amplification Attacks 196 A request with a forged IP address generally causes a response to be 197 sent to that forged IP address. Thus the forging of many such 198 requests with a particular source IP address can result in enough 199 traffic being sent to the forged IP address to interfere with service 200 to the host at the IP address. Furthermore, it is generally easy in 201 the DNS to create short requests that produce much longer responses, 202 thus amplifying the attack. 204 The DNS Cookies mechanism can severely limit the traffic 205 amplification obtained by attackers off path for the server and the 206 attacked host. Enforced DNS cookies would make it hard for an off 207 path attacker to cause any more than rate-limited short error 208 responses to be sent to a forged IP address so the attack would be 209 attenuated rather than amplified. DNS cookies make it more effective 210 to implement a rate limiting scheme for error responses from the 211 server. Such a scheme would further restrict selected host denial- 212 of-service traffic from that server. 214 2.1.2 DNS Server Denial-of-Service 216 DNS requests that are accepted cause work on the part of DNS servers. 217 This is particularly true for recursive servers that may issue one or 218 more requests and process the responses thereto, in order to 219 determine their response to the initial request. And the situation 220 can be even worse for recursive servers implementing DNSSEC 221 ([RFC4033] [RFC4034] [RFC4035]) because they may be induced to 222 perform burdensome cryptographic computations in attempts to verify 223 the authenticity of data they retrieve in trying to answer the 224 request. 226 The computational or communications burden caused by such requests 227 may not dependent on a forged IP source address, but the use of such 228 addresses makes 229 + the source of the requests causing the denial-of-service attack 230 harder to find and 231 + restriction of the IP addresses from which such requests should 232 be honored hard or impossible to specify or verify. 234 Use of DNS cookies should enables a server to reject forged queries 235 from an off path attacker with relative ease and before any recursive 236 queries or public key cryptographic operations are performed. 238 2.2 Cache Poisoning and Answer Forgery Attacks 240 The form of the cache poisoning attacks considered is to send forged 241 replies to a resolver. Modern network speeds for well-connected hosts 242 are such that, by forging replies from the IP addresses of a DNS 243 server to a resolver for common names or names that resolver has been 244 induced to resolve, there can be an unacceptably high probability of 245 randomly coming up with a reply that will be accepted and cause false 246 DNS information to be cached by that resolver (the Dan Kaminsky 247 attack). This can be used to facilitate phishing attacks and other 248 diversion of legitimate traffic to a compromised or malicious host 249 such as a web server. 251 With the use of DNS cookies, a resolver can generally reject such 252 forged replies. 254 3. Comments on Existing DNS Security 256 Two forms of security have been added to DNS, data security and 257 message/transaction security. 259 3.1 Existing DNS Data Security 261 DNS data security is one part of DNSSEC and is described in 262 [RFC4033], [RFC4034], and [RFC4035] and updates thereto. It provides 263 data origin authentication and authenticated denial of existence. 264 DNSSEC is being deployed and can provide strong protection against 265 forged data; however, it has the unintended effect of making some 266 denial-of-service attacks worse because of the cryptographic 267 computational load it can require and the increased size in DNS 268 response packets that it tends to produce. 270 3.2 DNS Message/Transaction Security 272 The second form of security that has been added to DNS provides 273 "transaction" security through TSIG [RFC2845] or SIG(0) [RFC2931]. 274 TSIG could provide strong protection against the attacks for which 275 the DNS Cookies mechanism provide weak protection; however, TSIG is 276 non-trivial to deploy in the general Internet because of the burden 277 it imposes of pre-agreement and key distribution between client- 278 server pairs, the burden of server side key state, and because it 279 requires time synchronization between client and server. 281 TKEY [RFC2930] can solve the problem of key distribution for TSIG but 282 some modes of TKEY impose a substantial cryptographic computation 283 loads and can be dependent on the deployment of DNS data security 284 (see Section 3.1). 286 SIG(0) [RFC2931] provides less denial of service protection than TSIG 287 or, in one way, even DNS cookies, because it does not authenticate 288 requests, only complete transactions. In any case, it also depends 289 on the deployment of DNS data security and requires computationally 290 burdensome public key cryptographic operations. 292 3.3 Conclusions on Existing DNS Security 294 The existing DNS security mechanisms do not provide the services 295 provided by the DNS Cookies mechanism: lightweight message 296 authentication of DNS requests and responses with no requirement for 297 pre-configuration or per client server side state. 299 4. DNS Cookie Option 301 The DNS Cookie Option is an OPT RR [RFC6891] option that can be 302 included in the RDATA portion of an OPT RR in DNS requests and 303 responses. The option length varies depending on the circumstances 304 in which it is being used. There are two cases as described below. 305 Both use the same OPTION-CODE; they are distinguished by their 306 length. 308 In a request sent by a client to a server when the client does not 309 know the server cookie, its length is 8, consisting an 8 byte Client 310 Cookie as shown in Figure 1. 312 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 313 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 314 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 315 | OPTION-CODE = TBD1 | OPTION-LENGTH = 8 | 316 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 317 | | 318 +-+- Client Cookie (fixed size, 8 bytes) -+-+-+-+ 319 | | 320 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 322 Figure 1. COOKIE Option, Unknown Server Cookie 324 In a request sent by a client when a server cookie is known and in 325 all responses, the length is variable from 16 to 40 bytes, consisting 326 of an 8 bytes Client Cookie followed by the variable 8 to 32 bytes 327 Server Cookie as shown in Figure 2. The variability of the option 328 length stems from the variable length Server Cookie. The Server 329 Cookie is an integer number of bytes with a minimum size of 8 bytes 330 for security and a maximum size of 32 bytes for implementation 331 convenience. 333 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 334 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 335 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 336 | OPTION-CODE = TBD1 | OPTION-LENGTH >= 16, <= 40 | 337 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 338 | | 339 +-+- Client Cookie (fixed size, 8 bytes) -+-+-+-+ 340 | | 341 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 342 | | 343 / Server Cookie (variable size, 8 to 32 bytes) / 344 / / 345 +-+-+-+-... 347 Figure 2. COOKIE Option, Known Server Cookie 349 4.1 Client Cookie 351 The Client Cookie SHOULD be a pseudo-random function of the server IP 352 address and a secret quantity known only to the client. This client 353 secret SHOULD have at least 64 bits of entropy [RFC4086] and be 354 changed periodically (see Section 5.4). The selection of the pseudo- 355 random function is a matter private to the client as only the client 356 needs to recognize its own DNS cookies. 358 For further discussion of the Client Cookie field, see Section 5.1. 359 For example methods of determining a Client Cookie, see Appendix A. 361 A client MUST NOT use the same Client Cookie value for queries to all 362 servers. 364 4.2 Server Cookie 366 The Server Cookie SHOULD consist of or include a 64-bit or larger 367 pseudo-random function of the request source IP address, the request 368 Client Cookie, and a secret quantity known only to the server. (See 369 Section 6 for a discussion of why the Client Cookie is used as input 370 to the Server Cookie but the Server Cookie is not used as an input to 371 the Client Cookie.) This server secret SHOULD have at least 64 bits 372 of entropy [RFC4086] and be changed periodically (see Section 5.4). 373 The selection of the pseudo-random function is a matter private to 374 the server as only the server needs to recognize its own DNS cookies. 376 For further discussion of the Server Cookie field see Section 5.2. 377 For example methods of determining a Server Cookie, see Appendix B. 379 A server MUST NOT use the same Server Cookie value for responses to 380 all clients. 382 5. DNS Cookies Protocol Description 384 This section discusses using DNS Cookies in the DNS Protocol. 386 5.1 Originating Requests 388 A DNS client that implements DNS includes one DNS COOKIE OPT option 389 containing a Client Cookie in every DNS request it sends unless DNS 390 cookies are disabled. 392 If the client has a cached server cookie for the server against its 393 IP address it uses the longer cookie form and includes that server 394 cookie in the option along with the client cookie (Figure 2) 395 otherwise it just sends the shorter form option with a client cookie 396 (Figure 1). 398 5.2 Responding to Request 400 The Server Cookie, when it occurs in a COOKIE OPT option in a 401 request, is intended to weakly assure the server that the request 402 came from a client that is both at the source IP address of the 403 request and using the Client Cookie included in the option. This weak 404 assurance is provided by the Server Cookie that server would send to 405 that client in an earlier response appearing as the Server Cookie 406 field in the request. 408 At a server where DNS Cookies are not implemented and enabled, 409 presence of a COOKIE OPT option is ignored and the server responds as 410 before. 412 When DNS Cookies are implemented and enabled, there are four 413 possibilities: (1) there is no OPT RR at all in the request; (2) 414 there is no valid Client Cookie in the request because the COOKIE OPT 415 option in absent from the request or one is present but not a legal 416 length; (3) there is a valid length cookie option in the request with 417 no Server Cookie or an incorrect Server Cookie; or (4) there is a 418 cookie option in the request with a correct Server Cookie. The four 419 possibilities are discussed in the subsections below. 421 In all cases of multiple COOKIE OPT options in a request, only the 422 first (the one closest to the DNS header) is considered. All others 423 are ignored. 425 5.2.1 No Opt RR or No COOKIE OPT option 427 If there is no OPT record or on COOKIE OPT option present in the 428 request then the server responds to the request as if the server 429 doesn't understand the COOKIE OPT. 431 5.2.2 Malformed COOKIE OPT option 433 If the COOKIE OPT is too short to contain a Client Cookie then 434 FORMERR is generated. If the COOKIE OPT is longer than that required 435 to hold a COOKIE OPT with just a Client Cookie (8) but is shorter 436 that the minimum COOKIE OPT with both a Client and Server Cookie (16) 437 then FORMERR is generated. If the COOKIE OPT is longer than the 438 maximum valid COOKIE OPT (40) then a FORMERR is generated. 440 In summary, valid cookie lengths are 8 and 16 to 40 inclusive. 442 5.2.3 Only a Client Cookie 444 Based on server policy, including rate limiting, the server chooses 445 one of the following: 447 (1) Silently discard the request. 449 (2) Send a BADCOOKIE error response. 451 (3) Process the request and provide a normal response. The RCODE is 452 zero unless some non-cookie error occurs in processing the 453 request. 455 If the server responds, choosing 2 or 3 above, it SHALL generate its 456 own COOKIE OPT containing both the client cookie copied from the 457 request and a server cookie it has generated and adds this COOKIE OPT 458 to the response's OPT record. Servers MUST, at least occasionally, 459 respond to such requests to inform the client of the correct server 460 cookie. This is necessary so that such a client can bootstrap to the 461 weakly secure state where requests and responses have recognized 462 server cookies and client cookies. If the request was received over 463 TCP, the server SHOULD take the weak authentication provided by the 464 use of TCP into account, increasing the probability of choice 3 466 5.2.4 A Client Cookie and Server Cookie 468 The server examines the server cookie to determine if it is a valid 469 server cookie it has generated. This examination will result in a 470 determination of whether the server cookie is valid or not. These 471 cases are discussed below. 473 5.2.4.1 A Client Cookie and Invalid Server Cookie 475 This can occur due to a stale server Cookie being returned, a 476 client's IP address or client cookie changing without the DNS server 477 being aware, or an attempt to spoof the client. 479 The server SHALL process the query as if the invalid server cookie 480 was not present as described in Section 5.2.3. 482 5.2.4.2 A Client Cookie and Valid Server Cookie 484 When this occurs the server can assume that it is talking to a client 485 that it has talked to before and defensive measures for spoofed UDP 486 queries, if any, are no longer required. 488 The server SHALL process the query and include a COOKIE OPT in the 489 response by (a) copying the complete COOKIE OPT from the request or 490 (b) generating a new COOKIE OPT containing both the client cookie 491 copied from the request and a valid server cookie it has generated. 493 5.3 Processing Responses 495 The client cookie, when it occurs in a COOKIE OPT option in a DNS 496 reply, is intended to weakly assure the client that the reply came 497 from a server at the source IP address use in the response packet 498 because the client cookie value is the value that client would send 499 to that server in a request. In a DNS reply with multiple COOKIE OPT 500 options, all but the first (the one closest to the DNS Header) are 501 ignored. 503 A DNS client where DNS cookies are implemented and enabled examines 504 response for DNS cookies and MUST discard the response if it contains 505 an illegal COOKIE OPT option length or an incorrect client cookie 506 value. If the COOKIE OPT option client cookie is correct, the client 507 caches the server cookie provided even if the response is an error 508 response (RCODE non-zero). 510 If the reply extended RCDOE is BADCOOKIE, it means that the server 511 was unwilling to process the request because it did not have the 512 correct server cookie in it. The client should retry the request 513 using the new server cookie from the response. 515 If the reply extended RCODE is BADCOOKIE and the client cookie 516 matches what was sent, it means that the server was unwilling to 517 process the request because it did not have the correct server cookie 518 in it. The client SHOULD retry the request using the new server 519 cookie from the response. Multiple BADCOOKIE responses may be an 520 indication that the shared secrets / secret generation method in an 521 anycast cluster of servers are not consistent. If the reply to a 522 retried query with a fresh server cookie is BADCOOKIE, the client 523 SHOULD retry using TCP as the transport since the server will be more 524 likely to process the query normally based on the weak security 525 provided by TCP. 527 If the RCODE is some value other than BADCOOKIE, including zero, the 528 further processing of the response proceedes normally. 530 5.4 Client and Server Secret Rollover 532 Clients and servers MUST NOT continue to use the same secret in new 533 queries and responses, respectively, for more than 35 days and SHOULD 534 NOT continue to do so for more than 25 hours. Many clients rolling 535 over their secret at the same time could briefly increase server 536 traffic and exactly predictable rollover times for clients or servers 537 might facilitate guessing attacks. For example, an attacker might 538 increase the priority of attacking secrets they believe will be in 539 effect for an extended period of time. To avoid rollover 540 synchronization and predictability, it is RECOMMENDED that 541 pseudorandom jitter in the range of plus zero to minus at least 40% 542 be applied to the time until a scheduled rollover of a DNS cookie 543 secret. 545 It is RECOMMENDED that a client keep the client cookie it is 546 expecting in a reply associated with the outstanding query to avoid 547 rejection of replies due to a bad client cookie right after a change 548 in the client secret. It is RECOMMENDED that a server retain its 549 previous secret for a period of time not less than 1 second or more 550 than 3 minutes, after a change in its secret, and consider queries 551 with server cookies based on its previous secret to have a correct 552 server cookie during that time. 554 Receiving a sudden increased level of requests with bad server 555 cookies or replies with bad client cookies would be reason to believe 556 a server or client is likely to be under attack and should consider 557 more frequent rollover of its secret. 559 5.5 Implementation Requirement 561 DNS clients and servers SHOULD implement DNS cookies to decrease 562 their vulnerability to the threats discussed in Section 2. 564 6. NAT Considerations and AnyCast Server Considerations 566 In the Classic Internet, DNS Cookies could simply be a pseudo-random 567 function of the client IP address and a sever secret or the server IP 568 address and a client secret. You would want to compute the Server 569 Cookie that way, so a client could cache its Server Cookie for a 570 particular server for an indefinitely amount of time and the server 571 could easily regenerate and check it. You could consider the Client 572 Cookie to be a weak client signature over the server IP address that 573 the client checks in replies and you could extend this weak signature 574 to cover the request ID, for example, or any other information that 575 is returned unchanged in the reply. 577 But we have this reality called NAT [RFC3022], Network Address 578 Translation (including, for the purposes of this document, NAT-PT, 579 Network Address and Protocol Translation, which has been declared 580 Historic [RFC4966]). There is no problem with DNS transactions 581 between clients and servers behind a NAT box using local IP 582 addresses. Nor is there a problem with NAT translation of internal 583 addresses to external addresses or translations between IPv4 and IPv6 584 addresses, as long as the address mapping is relatively stable. 585 Should the external IP address an internal client is being mapped to 586 change occasionally, the disruption is little more than when a client 587 rolls-over its DNS COOKIE secret. And normally external access to a 588 DNS server behind a NAT box is handled by a fixed mapping which 589 forwards externally received DNS requests to a specific host. 591 However, NAT devices sometimes also map ports. This can cause 592 multiple DNS requests and responses from multiple internal hosts to 593 be mapped to a smaller number of external IP addresses, such as one 594 address. Thus there could be many clients behind a NAT box that 595 appear to come from the same source IP address to a server outside 596 that NAT box. If one of these were an attacker (think Zombie or 597 Botnet), that behind-NAT attacker could get the Server Cookie for 598 some server for the outgoing IP address by just making some random 599 request to that server. It could then include that Server Cookie in 600 the COOKIE OPT of requests to the server with the forged local IP 601 address of some other host and/or client behind the NAT box. 602 (Attacker possession of this server cookie will not help in forging 603 responses to cause cache poisoning as such responses are protected by 604 the required Client Cookie.) 606 To fix this potential defect, it is necessary to distinguish 607 different clients behind a NAT box from the point of view of the 608 server. It is for this reason that the Server Cookie is specified as 609 a pseudo-random function of both the request source IP address and 610 the Client Cookie. From this inclusion of the Client Cookie in the 611 calculation of the Server Cookie, it follows that a stable Client 612 Cookie, for any particular server, is needed. If, for example, the 613 request ID was included in the calculation of the Client Cookie, it 614 would normally change with each request to a particular server. This 615 would mean that each request would have to be sent twice: first to 616 learn the new Server Cookie based on this new Client Cookie based on 617 the new ID and then again using this new Client Cookie to actually 618 get an answer. Thus the input to the Client Cookie computation must 619 be limited to the server IP address and one or more things that 620 change slowly such as the client secret. 622 In principle, there could be a similar problem for servers, not due 623 to NAT but due to mechanisms like anycast which may cause queries to 624 a DNS server at an IP address to be delivered to any one of several 625 machines. (External queries to a DNS server behind a NAT box usually 626 occur via port forwarding such that all such queries go to one host.) 627 However, it is impossible to solve this the way the similar problem 628 was solved for NATed clients; if the Server Cookie was included in 629 the calculation of the Client Cookie the same way the Client Cookie 630 is included in the Server Cookie, you would just get an almost 631 infinite series of errors as a request was repeatedly retried. 633 For servers accessed via anycast to successfully support DNS COOKIES, 634 the server clones must either all use the same server secret or the 635 mechanism that distributes queries to them must cause the queries 636 from a particular client to go to a particular server for a 637 sufficiently long period of time that extra queries due to changes in 638 Server Cookie resulting from accessing different server machines are 639 not unduly burdensome. (When such anycast-accessed servers act as 640 recursive servers or otherwise act as clients they normally use a 641 different unique address to source their queries to avoid confusion 642 in the delivery of responses.) 644 For simplicity, it is RECOMMENDED that the same server secret be used 645 by each DNS server in a set of anycast servers. If there is limited 646 time skew in updating this secret in different anycast servers, this 647 can be handled by a server accepting requests containing a Server 648 Cookie based on either its old or new secret for the maximum likely 649 time period of such time skew (see also Section 5.4). 651 7. Deployment 653 The DNS cookies mechanism is designed for incremental deployment and 654 to complement the orthogonal techniques in [RFC5452]. Either or both 655 techniques can be deployed independently at each DNS server and 656 client. 658 In particular, a DNS server or client that implements the DNS COOKIE 659 mechanism can interoperate successfully with a DNS client or server 660 that does not implement this mechanism although, of course, in this 661 case it will not get the benefit of the mechanism and the server 662 involved might choose to severely rate limit responses. When such a 663 server or client interoperates with a client or server which also 664 implements the DNS cookies mechanism, they get the weak security 665 benefits of the DNS Cookies mechanism. 667 8. IANA Considerations 669 IANA is requested to assign the following two code points: 671 A new OPT option value as shown below: 673 Value Name Status Reference 674 -------- ------ -------- --------------- 675 TBD1[10] COOKIE Standard [this document] 677 A new DNS error code in the range above 16 and below 3,840 as 678 shown below: 680 RCODE Name Description Reference 681 -------- --------- ------------------------- --------------- 682 TBD2[23] BADCOOKIE Bad/missing server cookie [this document] 684 9. Security Considerations 686 DNS Cookies provide a weak form of authentication of DNS requests and 687 responses. In particular, they provide no protection against "on- 688 path" adversaries; that is, they provide no protection against any 689 adversary that can observe the plain text DNS traffic, such as an on- 690 path router, bridge, or any device on an on-path shared link (unless 691 the DNS traffic in question on that path is encrypted). 693 For example, if a host is connected via an unsecured IEEE Std 802.11 694 link (Wi-Fi), any device in the vicinity that could receive and 695 decode the 802.11 transmissions must be considered "on-path". On the 696 other hand, in a similar situation but one where 802.11 Robust 697 Security (WPAv2) is appropriately deployed on the Wi-Fi network 698 nodes, only the Access Point via which the host is connecting is "on- 699 path" as far as the 802.11 link is concerned. 701 Despite these limitations, deployment of DNS Cookies on the global 702 Internet is expected to provide a substantial reduction in the 703 available launch points for the traffic amplification and denial of 704 service forgery attacks described in Section 2 above. 706 Should stronger message/transaction security be desired, it is 707 suggested that TSIG or SIG(0) security be used (see Section 3.2); 708 however, it may be useful to use DNS Cookies in conjunction with 709 these features. In particular, DNS Cookies could screen out many DNS 710 messages before the cryptographic computations of TSIG or SIG(0) are 711 required and, if SIG(0) is in use, DNS Cookies could usefully screen 712 out many requests given that SIG(0) does not screen requests but only 713 authenticates the response of complete transactions. 715 9.1 Cookie Algorithm Considerations 717 The cookie computation algorithm for use in DNS Cookies SHOULD be 718 based on a pseudo-random function at least as strong as [FNV] because 719 an excessively weak or trivial algorithm could enable adversaries to 720 guess cookies. However, in light of the weak plain-text token 721 security provided by DNS Cookies, a strong cryptography hash 722 algorithm may not be warranted in many cases, and would cause an 723 increased computational burden. Nevertheless there is nothing wrong 724 with using something stronger, for example, HMAC-SHA256-64 [RFC6234], 725 assuming a DNS processor has adequate computational resources 726 available. DNS processors that feel the need for somewhat stronger 727 security without a significant increase in computational load should 728 consider more frequent changes in their client and/or server secret; 729 however, this does require more frequent generation of a 730 cryptographically strong random number [RFC4086]. See Appendices A 731 and B for specific examples of cookie computation algorithms. 733 10. Implementation Considerations 735 The DNS Cookie Option specified herein is implemented in BIND 9.10 736 using a experimental option code. 738 Normative References 740 [RFC2119] - Bradner, S., "Key words for use in RFCs to Indicate 741 Requirement Levels", BCP 14, RFC 2119, March 1997. 743 [RFC4086] - Eastlake 3rd, D., Schiller, J., and S. Crocker, 744 "Randomness Requirements for Security", BCP 106, RFC 4086, June 745 2005. 747 [RFC6891] - Damas, J., Graff, M., and P. Vixie, "Extension Mechanisms 748 for DNS (EDNS(0))", STD 75, RFC 6891, April 2013. 750 Informative References 752 [FNV] - G. Fowler, L. C. Noll, K.-P. Vo, D. Eastlake, "The FNV Non- 753 Cryptographic Hash Algorithm", draft-eastlake-fnv, work in 754 progress. 756 [RFC2845] - Vixie, P., Gudmundsson, O., Eastlake 3rd, D., and B. 757 Wellington, "Secret Key Transaction Authentication for DNS 758 (TSIG)", RFC 2845, May 2000. 760 [RFC2930] - Eastlake 3rd, D., "Secret Key Establishment for DNS (TKEY 761 RR)", RFC 2930, September 2000. 763 [RFC2931] - Eastlake 3rd, D., "DNS Request and Transaction Signatures 764 ( SIG(0)s )", RFC 2931, September 2000. 766 [RFC3022] - Srisuresh, P. and K. Egevang, "Traditional IP Network 767 Address Translator (Traditional NAT)", RFC 3022, January 2001. 769 [RFC4033] - Arends, R., Austein, R., Larson, M., Massey, D., and S. 770 Rose, "DNS Security Introduction and Requirements", RFC 4033, 771 March 2005. 773 [RFC4034] - Arends, R., Austein, R., Larson, M., Massey, D., and S. 774 Rose, "Resource Records for the DNS Security Extensions", RFC 775 4034, March 2005. 777 [RFC4035] - Arends, R., Austein, R., Larson, M., Massey, D., and S. 778 Rose, "Protocol Modifications for the DNS Security Extensions", 779 RFC 4035, March 2005. 781 [RFC4966] - Aoun, C. and E. Davies, "Reasons to Move the Network 782 Address Translator - Protocol Translator (NAT-PT) to Historic 783 Status", RFC 4966, July 2007. 785 [RFC5452] - Hubert, A. and R. van Mook, "Measures for Making DNS More 786 Resilient against Forged Answers", RFC 5452, January 2009. 788 [RFC6234] - Eastlake 3rd, D. and T. Hansen, "US Secure Hash 789 Algorithms (SHA and SHA-based HMAC and HKDF)", RFC 6234, May 790 2011. 792 Acknowledgements 794 The contributions of the following are gratefully acknowledged: 796 Tim Wicinski 798 The document was prepared in raw nroff. All macros used were defined 799 within the source file. 801 Appendix A: Example Client Cookie Algorithms 803 A.1 A Simple Algorithm 805 An simple example method to compute Client Cookies is the FNV-64 806 [FNV] of the server IP address and the client secret. That is 808 Client Cookie = FNV-64 ( Client Secret | Server IP Address ) 810 where "|" indicates concatenation. 812 A.2 A More Complex Algorithm 814 A more complex algorithm to calculate Client Cookies is give below. 815 It uses more computational resources than the simpler algorithm shown 816 in A.1. 818 Client Cookie = HMAC-SHA256-64 ( Client Secret, 819 Server IP Address ) 821 Appendix B: Example Server Cookie Algorithms 823 B.1 A Simple Algorithm 825 An example simple method producing a 64-bit Server Cookie is the 826 FNV-64 [FNV] of the request IP address, the Client Cookie, and the 827 server secret. That is 829 Server Cookie = 830 FNV-64 ( Server Secret | Request IP Address | Client Cookie ) 832 where "|" represents concatenation. 834 B.2 A More Complex Algorithm 836 Since the Server Cookie is variable size, the server can store 837 various information in that field as long as it is hard for an 838 adversary to guess the entire quantity used for weak authentication. 839 There should be 64 bits of entropy in the Server Cookie; for example 840 it could have a sub-field of 64-bits computed pseudo-randomly with 841 the server secret as one of the inputs to the pseudo-random function. 842 Types of additional information that could be stored include a time 843 stamp and/or a nonce. 845 The example below is one variation for the Server Cookie that has 846 been implemented in a beta release of BIND where the Server Cookie is 847 128 bits composed as follows: 849 Sub-field Size 850 --------- --------- 851 Nonce 32 bits 852 Time 32 bits 853 Hash 64 bits 855 With this algorithm, the server sends a new 128-bit cookie back with 856 every request. The Nonce field assures a low probability that there 857 would be a duplicate. 859 The Time field gives the server time and makes it easy to reject old 860 cookies. 862 The Hash part of the Server Cookie is the hard-to-guess part. In the 863 beta release of BIND, its computation can be configured to use AES, 864 HMAC-SHA1, or, as shown below, HMAC-SHA256: 866 hash = 867 HMAC-SHA256-64 ( Server Secret, 868 (Client Cookie | nonce | time | client IP Address) ) 870 where "|" represents concatenation. 872 Author's Address 874 Donald E. Eastlake 3rd 875 Huawei Technologies 876 155 Beaver Street 877 Milford, MA 01757 USA 879 Telephone: +1-508-333-2270 880 EMail: d3e3e3@gmail.com 882 Mark Andrews 883 Internet Systems Consortium 884 950 Charter Street 885 Redwood City, CA 94063 USA 887 Email: marka@isc.org 889 Copyright, Disclaimer, and Additional IPR Provisions 891 Copyright (c) 2015 IETF Trust and the persons identified as the 892 document authors. All rights reserved. 894 This document is subject to BCP 78 and the IETF Trust's Legal 895 Provisions Relating to IETF Documents 896 (http://trustee.ietf.org/license-info) in effect on the date of 897 publication of this document. Please review these documents 898 carefully, as they describe your rights and restrictions with respect 899 to this document. Code Components extracted from this document must 900 include Simplified BSD License text as described in Section 4.e of 901 the Trust Legal Provisions and are provided without warranty as 902 described in the Simplified BSD License.