Internet Engineering Task Force (IETF)                   D. Eastlake 3rd
Request for Comments: 7873                                        Huawei
Category: Standards Track                                     M. Andrews
ISSN: 2070-1721                                                      ISC
                                                                May 2016
        
Internet Engineering Task Force (IETF)                   D. Eastlake 3rd
Request for Comments: 7873                                        Huawei
Category: Standards Track                                     M. Andrews
ISSN: 2070-1721                                                      ISC
                                                                May 2016
        

Domain Name System (DNS) Cookies

域名系统(DNS)Cookies

Abstract

摘要

DNS Cookies are a lightweight DNS transaction security mechanism that provides limited protection to DNS servers and clients against a variety of increasingly common denial-of-service and amplification/ forgery or cache poisoning attacks by off-path attackers. DNS Cookies are tolerant of NAT, NAT-PT (Network Address Translation - Protocol Translation), and anycast and can be incrementally deployed. (Since DNS Cookies are only returned to the IP address from which they were originally received, they cannot be used to generally track Internet users.)

DNS Cookie是一种轻量级DNS事务安全机制,为DNS服务器和客户端提供有限的保护,以抵御各种越来越常见的拒绝服务攻击、放大/伪造或缓存中毒攻击,这些攻击由非路径攻击者发起。DNS Cookie可以容忍NAT、NAT-PT(网络地址转换-协议转换)和选播,并且可以增量部署。(由于DNS Cookie仅返回到最初接收它们的IP地址,因此它们不能用于跟踪Internet用户。)

Status of This Memo

关于下段备忘

This is an Internet Standards Track document.

这是一份互联网标准跟踪文件。

This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841.

本文件是互联网工程任务组(IETF)的产品。它代表了IETF社区的共识。它已经接受了公众审查,并已被互联网工程指导小组(IESG)批准出版。有关互联网标准的更多信息,请参见RFC 7841第2节。

Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at http://www.rfc-editor.org/info/rfc7873.

有关本文件当前状态、任何勘误表以及如何提供反馈的信息,请访问http://www.rfc-editor.org/info/rfc7873.

Copyright Notice

版权公告

Copyright (c) 2016 IETF Trust and the persons identified as the document authors. All rights reserved.

版权所有(c)2016 IETF信托基金和确定为文件作者的人员。版权所有。

This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

本文件受BCP 78和IETF信托有关IETF文件的法律规定的约束(http://trustee.ietf.org/license-info)自本文件出版之日起生效。请仔细阅读这些文件,因为它们描述了您对本文件的权利和限制。从本文件中提取的代码组件必须包括信托法律条款第4.e节中所述的简化BSD许可证文本,并提供简化BSD许可证中所述的无担保。

Table of Contents

目录

   1. Introduction ....................................................4
      1.1. Contents of This Document ..................................4
      1.2. Definitions ................................................5
   2. Threats Considered ..............................................5
      2.1. Denial-of-Service Attacks ..................................6
           2.1.1. DNS Amplification Attacks ...........................6
           2.1.2. DNS Server Denial of Service ........................6
      2.2. Cache Poisoning and Answer Forgery Attacks .................7
   3. Comments on Existing DNS Security ...............................7
      3.1. Existing DNS Data Security .................................7
      3.2. DNS Message/Transaction Security ...........................8
      3.3. Conclusions on Existing DNS Security .......................8
   4. DNS COOKIE Option ...............................................8
      4.1. Client Cookie .............................................10
      4.2. Server Cookie .............................................10
   5. DNS Cookies Protocol Specification .............................11
      5.1. Originating a Request .....................................11
      5.2. Responding to a Request ...................................11
           5.2.1. No OPT RR or No COOKIE Option ......................12
           5.2.2. Malformed COOKIE Option ............................12
           5.2.3. Only a Client Cookie ...............................12
           5.2.4. A Client Cookie and an Invalid Server Cookie .......13
           5.2.5. A Client Cookie and a Valid Server Cookie ..........13
      5.3. Processing Responses ......................................14
      5.4. Querying for a Server Cookie ..............................14
   6. NAT Considerations and Anycast Server Considerations ...........15
   7. Operational and Deployment Considerations ......................17
      7.1. Client and Server Secret Rollover .........................17
      7.2. Counters ..................................................18
   8. IANA Considerations ............................................18
   9. Security Considerations ........................................19
      9.1. Cookie Algorithm Considerations ...........................20
   10. Implementation Considerations .................................20
   11. References ....................................................20
      11.1. Normative References .....................................20
      11.2. Informative References ...................................21
   Appendix A. Example Client Cookie Algorithms ......................23
      A.1. A Simple Algorithm ........................................23
      A.2. A More Complex Algorithm ..................................23
   Appendix B. Example Server Cookie Algorithms ......................23
      B.1. A Simple Algorithm ........................................23
      B.2. A More Complex Algorithm ..................................24
   Acknowledgments ...................................................25
   Authors' Addresses ................................................25
        
   1. Introduction ....................................................4
      1.1. Contents of This Document ..................................4
      1.2. Definitions ................................................5
   2. Threats Considered ..............................................5
      2.1. Denial-of-Service Attacks ..................................6
           2.1.1. DNS Amplification Attacks ...........................6
           2.1.2. DNS Server Denial of Service ........................6
      2.2. Cache Poisoning and Answer Forgery Attacks .................7
   3. Comments on Existing DNS Security ...............................7
      3.1. Existing DNS Data Security .................................7
      3.2. DNS Message/Transaction Security ...........................8
      3.3. Conclusions on Existing DNS Security .......................8
   4. DNS COOKIE Option ...............................................8
      4.1. Client Cookie .............................................10
      4.2. Server Cookie .............................................10
   5. DNS Cookies Protocol Specification .............................11
      5.1. Originating a Request .....................................11
      5.2. Responding to a Request ...................................11
           5.2.1. No OPT RR or No COOKIE Option ......................12
           5.2.2. Malformed COOKIE Option ............................12
           5.2.3. Only a Client Cookie ...............................12
           5.2.4. A Client Cookie and an Invalid Server Cookie .......13
           5.2.5. A Client Cookie and a Valid Server Cookie ..........13
      5.3. Processing Responses ......................................14
      5.4. Querying for a Server Cookie ..............................14
   6. NAT Considerations and Anycast Server Considerations ...........15
   7. Operational and Deployment Considerations ......................17
      7.1. Client and Server Secret Rollover .........................17
      7.2. Counters ..................................................18
   8. IANA Considerations ............................................18
   9. Security Considerations ........................................19
      9.1. Cookie Algorithm Considerations ...........................20
   10. Implementation Considerations .................................20
   11. References ....................................................20
      11.1. Normative References .....................................20
      11.2. Informative References ...................................21
   Appendix A. Example Client Cookie Algorithms ......................23
      A.1. A Simple Algorithm ........................................23
      A.2. A More Complex Algorithm ..................................23
   Appendix B. Example Server Cookie Algorithms ......................23
      B.1. A Simple Algorithm ........................................23
      B.2. A More Complex Algorithm ..................................24
   Acknowledgments ...................................................25
   Authors' Addresses ................................................25
        
1. Introduction
1. 介绍

As with many core Internet protocols, the Domain Name System (DNS) was originally designed at a time when the Internet had only a small pool of trusted users. As the Internet has grown exponentially to a global information utility, the DNS has increasingly been subject to abuse.

与许多核心互联网协议一样,域名系统(DNS)最初是在互联网只有一小部分可信用户的时候设计的。随着互联网以指数级增长成为一个全球性的信息实用工具,DNS越来越受到滥用。

This document describes DNS Cookies, a lightweight DNS transaction security mechanism specified as an OPT [RFC6891] option. The DNS Cookie mechanism provides limited protection to DNS servers and clients against a variety of increasingly common abuses by off-path attackers. It is compatible with, and can be used in conjunction with, other DNS transaction forgery resistance measures such as those in [RFC5452]. (Since DNS Cookies are only returned to the IP address from which they were originally received, they cannot be used to generally track Internet users.)

本文档介绍DNS Cookie,这是一种轻量级DNS事务安全机制,指定为OPT[RFC6891]选项。DNS Cookie机制为DNS服务器和客户端提供有限的保护,以防止非路径攻击者日益常见的各种滥用行为。它与[RFC5452]中的其他DNS交易防伪措施兼容,并可与之结合使用。(由于DNS Cookie仅返回到最初接收它们的IP地址,因此它们不能用于跟踪Internet用户。)

The protection provided by DNS Cookies is similar to that provided by using TCP for DNS transactions. Bypassing the weak protection provided by using TCP requires, among other things, that an off-path attacker guess the 32-bit TCP sequence number in use. Bypassing the weak protection provided by DNS Cookies requires such an attacker to guess a 64-bit pseudorandom "cookie" quantity. Where DNS Cookies are not available but TCP is, falling back to using TCP is reasonable.

DNS Cookie提供的保护与使用TCP进行DNS事务提供的保护类似。绕过使用TCP提供的弱保护,除其他外,需要路径外攻击者猜测正在使用的32位TCP序列号。绕过DNS cookie提供的弱保护要求此类攻击者猜测64位伪随机“cookie”数量。当DNS cookie不可用但TCP可用时,退回到使用TCP是合理的。

If only one party to a DNS transaction supports DNS Cookies, the mechanism does not provide a benefit or significantly interfere, but if both support it, the additional security provided is automatically available.

如果DNS事务只有一方支持DNS Cookie,则该机制不会提供好处或显著干扰,但如果双方都支持,则提供的附加安全性将自动可用。

The DNS Cookie mechanism is designed to work in the presence of NAT and NAT-PT (Network Address Translation - Protocol Translation) boxes, and guidance is provided herein on supporting the DNS Cookie mechanism in anycast servers.

DNS Cookie机制设计为在NAT和NAT-PT(网络地址转换-协议转换)框中工作,本文提供了在任意广播服务器中支持DNS Cookie机制的指南。

1.1. Contents of This Document
1.1. 本文件的内容

In Section 2, we discuss the threats against which the DNS Cookie mechanism provides some protection.

在第2节中,我们将讨论DNS Cookie机制提供某种保护的威胁。

Section 3 describes existing DNS security mechanisms and why they are not adequate substitutes for DNS Cookies.

第3节描述了现有的DNS安全机制,以及为什么它们不能充分替代DNS cookie。

Section 4 describes the COOKIE option.

第4节描述了COOKIE选项。

Section 5 provides a protocol description.

第5节提供了协议描述。

Section 6 discusses some NAT considerations and anycast-related DNS Cookies design considerations.

第6节讨论了一些NAT注意事项和与选播相关的DNS Cookies设计注意事项。

Section 7 discusses incremental deployment considerations.

第7节讨论了增量部署注意事项。

Sections 8 and 9 describe IANA considerations and security considerations, respectively.

第8节和第9节分别描述了IANA注意事项和安全注意事项。

1.2. Definitions
1.2. 定义

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119].

本文件中的关键词“必须”、“不得”、“必需”、“应”、“不应”、“建议”、“不建议”、“可”和“可选”应按照[RFC2119]中的说明进行解释。

"Off-path attacker", for a particular DNS client and server, is defined as an attacker who cannot observe the DNS request and response messages between that client and server.

对于特定DNS客户端和服务器,“非路径攻击者”被定义为无法观察该客户端和服务器之间的DNS请求和响应消息的攻击者。

"Soft state" indicates information that is learned or derived by a host and that may be discarded when indicated by the policies of that host but can be re-instantiated later if needed. For example, it could be discarded after a period of time or when storage for caching such data becomes full. If operations that require soft state continue after the information has been discarded, the information will be automatically regenerated, albeit at some cost.

“软状态”表示由主机学习或派生的信息,当该主机的策略指示时,这些信息可能会被丢弃,但如果需要,可以稍后重新实例化。例如,它可能在一段时间后或用于缓存此类数据的存储空间已满时被丢弃。如果需要软状态的操作在信息被丢弃后继续,则信息将自动重新生成,尽管会付出一定的代价。

"Silently discarded" indicates that there are no DNS protocol message consequences.

“静默丢弃”表示没有DNS协议消息后果。

"IP address" is used herein as a length-independent term and includes both IPv4 and IPv6 addresses.

“IP地址”在本文中用作独立于长度的术语,包括IPv4和IPv6地址。

2. Threats Considered
2. 考虑到的威胁

DNS Cookies are intended to provide significant but limited protection against certain attacks by off-path attackers, as described below. These attacks include denial of service, cache poisoning, and answer forgery.

DNS Cookie旨在针对路径外攻击者的某些攻击提供重要但有限的保护,如下所述。这些攻击包括拒绝服务、缓存中毒和应答伪造。

2.1. Denial-of-Service Attacks
2.1. 拒绝服务攻击

The typical form of the denial-of-service attacks considered herein is to send DNS requests with forged source IP addresses to a server. The intent can be to attack that server or some other selected host, as described below.

本文考虑的拒绝服务攻击的典型形式是向服务器发送具有伪造源IP地址的DNS请求。其目的可能是攻击该服务器或某些其他选定主机,如下所述。

There are also on-path denial-of-service attacks that attempt to saturate a server with DNS requests having correct source addresses. Cookies do not protect against such attacks, but successful cookie validation improves the probability that the correct source IP address for the requests is known. This facilitates contacting the managers of the networks from which the requests originate or taking other actions for those networks.

还存在路径拒绝服务攻击,这些攻击试图使用具有正确源地址的DNS请求使服务器饱和。cookie不能防止此类攻击,但成功的cookie验证提高了已知请求的正确源IP地址的概率。这有助于联系发起请求的网络的管理者或为这些网络采取其他行动。

2.1.1. DNS Amplification Attacks
2.1.1. DNS放大攻击

A request with a forged source IP address generally causes a response to be sent to that forged IP address. Thus, the forging of many such requests with a particular source IP address can result in enough traffic being sent to the forged IP address to interfere with service to the host at the IP address. Furthermore, it is generally easy in the DNS to create short requests that produce much longer responses, thus amplifying the attack.

具有伪造源IP地址的请求通常会导致向该伪造IP地址发送响应。因此,使用特定源IP地址伪造许多这样的请求可以导致向伪造的IP地址发送足够的通信量,从而干扰在该IP地址处向主机提供的服务。此外,在DNS中,通常很容易创建产生更长响应的短请求,从而放大攻击。

The DNS Cookie mechanism can severely limit the traffic amplification obtained by requests from an attacker that is off the path between the server and the request's source address. Enforced DNS Cookies would make it hard for an off-path attacker to cause any more than rate-limited short error responses to be sent to a forged IP address, so the attack would be attenuated rather than amplified. DNS Cookies make it more effective to implement a rate-limiting scheme for error responses from the server. Such a scheme would further restrict selected host denial-of-service traffic from that server.

DNS Cookie机制可以严重限制来自服务器和请求源地址之间路径之外的攻击者的请求所获得的流量放大。强制DNS Cookie会使非路径攻击者很难向伪造IP地址发送任何超过速率限制的短错误响应,因此攻击会减弱而不是增强。DNS Cookie可以更有效地对服务器的错误响应实施速率限制方案。这样的方案将进一步限制来自该服务器的选定主机拒绝服务流量。

2.1.2. DNS Server Denial of Service
2.1.2. DNS服务器拒绝服务

DNS requests that are accepted cause work on the part of DNS servers. This is particularly true for recursive servers that may issue one or more requests and process the responses thereto, in order to determine their response to the initial request; the situation can be even worse for recursive servers implementing DNSSEC [RFC4033] [RFC4034] [RFC4035], because they may be induced to perform burdensome cryptographic computations in attempts to verify the authenticity of data they retrieve in trying to answer the request.

接受的DNS请求会导致DNS服务器工作。这对于可能发出一个或多个请求并处理其响应以确定其对初始请求的响应的递归服务器尤其如此;对于实现DNSSEC[RFC4033][RFC4034][RFC4035]的递归服务器,情况可能更糟,因为它们可能会被诱导执行繁重的加密计算,以尝试验证它们在尝试回答请求时检索的数据的真实性。

The computational or communications burden caused by such requests may not depend on a forged source IP address, but the use of such addresses makes

此类请求造成的计算或通信负担可能不取决于伪造的源IP地址,但使用此类地址会导致

+ the source of the requests causing the denial-of-service attack harder to find and

+ 导致拒绝服务攻击的请求源更难查找和识别

+ restriction of the IP addresses from which such requests should be honored hard or impossible to specify or verify.

+ 对IP地址的限制很难或不可能指定或验证此类请求。

The use of DNS Cookies should enable a server to reject forged requests from an off-path attacker with relative ease and before any recursive queries or public key cryptographic operations are performed.

DNS Cookie的使用应使服务器能够在执行任何递归查询或公钥加密操作之前,相对轻松地拒绝来自非路径攻击者的伪造请求。

2.2. Cache Poisoning and Answer Forgery Attacks
2.2. 缓存中毒和应答伪造攻击

The form of the cache poisoning attacks considered is to send forged replies to a resolver. Modern network speeds for well-connected hosts are such that, by forging replies from the IP addresses of a DNS server to a resolver for names that resolver has been induced to resolve or for common names whose resource records have short time-to-live values, there can be an unacceptably high probability of randomly coming up with a reply that will be accepted and cause false DNS information to be cached by that resolver (the Dan Kaminsky attack [Kaminsky]). This can be used to facilitate phishing attacks and other diversions of legitimate traffic to a compromised or malicious host such as a web server.

考虑的缓存中毒攻击的形式是向解析程序发送伪造回复。连接良好的主机的现代网络速度是这样的:通过伪造DNS服务器IP地址对解析程序解析的名称或资源记录具有短生存时间值的常见名称的回复,随机给出一个将被接受的回复并导致解析程序缓存错误的DNS信息的概率高得令人无法接受(Dan Kaminsky攻击[Kaminsky])。这可用于促进网络钓鱼攻击和将合法流量转移到受损或恶意主机(如web服务器)的其他转移。

With the use of DNS Cookies, a resolver can generally reject such forged replies.

通过使用DNS Cookie,解析程序通常可以拒绝此类伪造回复。

3. Comments on Existing DNS Security
3. 对现有DNS安全性的评论

Two forms of security have been added to DNS: data security and message/transaction security.

DNS中添加了两种形式的安全性:数据安全性和消息/事务安全性。

3.1. Existing DNS Data Security
3.1. 现有DNS数据安全

DNS data security is one part of DNSSEC and is described in [RFC4033], [RFC4034], [RFC4035], and updates thereto. It provides data origin authentication and authenticated denial of existence. DNSSEC is being deployed and can provide strong protection against forged data and cache poisoning; however, it has the unintended effect of making some denial-of-service attacks worse because of the cryptographic computational load it can require and the increased size in DNS response packets that it tends to produce.

DNS数据安全是DNSSEC的一部分,在[RFC4033]、[RFC4034]、[RFC4035]及其更新中进行了描述。它提供数据源身份验证和身份验证拒绝存在。DNSSEC正在部署中,可针对伪造数据和缓存中毒提供强大保护;但是,由于它可能需要的加密计算负载以及它往往会产生的DNS响应数据包的增加,因此它会产生使某些拒绝服务攻击变得更糟的意外效果。

3.2. DNS Message/Transaction Security
3.2. DNS消息/事务安全

The second form of security that has been added to DNS provides "transaction" security through TSIG [RFC2845] or SIG(0) [RFC2931]. TSIG could provide strong protection against the attacks for which the DNS Cookie mechanism provides weaker protection; however, TSIG is non-trivial to deploy in the general Internet because of the burdens it imposes. Among these burdens are pre-agreement and key distribution between client and server, keeping track of server-side key state, and required time synchronization between client and server.

添加到DNS的第二种形式的安全性通过TSIG[RFC2845]或SIG(0)[RFC2931]提供“事务”安全性。TSIG可以针对DNS Cookie机制提供较弱保护的攻击提供强大保护;然而,由于TSIG带来的负担,它在一般互联网中的部署并非微不足道。这些负担包括客户端和服务器之间的预协议和密钥分配、跟踪服务器端密钥状态以及客户端和服务器之间所需的时间同步。

TKEY [RFC2930] can solve the problem of key distribution for TSIG, but some modes of TKEY impose a substantial cryptographic computation load and can be dependent on the deployment of DNS data security (see Section 3.1).

TKEY[RFC2930]可以解决TSIG的密钥分配问题,但TKEY的某些模式会带来大量的密码计算负载,并且可能依赖于DNS数据安全的部署(参见第3.1节)。

SIG(0) [RFC2931] provides less denial-of-service protection than TSIG or, in one way, even DNS Cookies, because it authenticates complete transactions but does not authenticate requests. In any case, it also depends on the deployment of DNS data security and requires computationally burdensome public key cryptographic operations.

SIG(0)[RFC2931]提供的拒绝服务保护比TSIG更少,在某种程度上甚至比DNS Cookie更少,因为它对完整事务进行身份验证,但不对请求进行身份验证。在任何情况下,它还取决于DNS数据安全的部署,并且需要计算繁重的公钥加密操作。

3.3. Conclusions on Existing DNS Security
3.3. 关于现有DNS安全性的结论

The existing DNS security mechanisms do not provide the services provided by the DNS Cookie mechanism: lightweight message authentication of DNS requests and responses with no requirement for pre-configuration or per-client server-side state.

现有的DNS安全机制不提供DNS Cookie机制提供的服务:DNS请求和响应的轻量级消息身份验证,不需要预配置或每个客户端服务器端状态。

4. DNS COOKIE Option
4. DNS COOKIE选项

The DNS COOKIE option is an OPT RR [RFC6891] option that can be included in the RDATA portion of an OPT RR in DNS requests and responses. The option length varies, depending on the circumstances in which it is being used. There are two cases, as described below. Both use the same OPTION-CODE; they are distinguished by their length.

DNS COOKIE选项是一个OPT RR[RFC6891]选项,可以包含在DNS请求和响应中OPT RR的RDATA部分中。选项的长度根据使用它的环境而变化。有两种情况,如下所述。两者使用相同的选项代码;它们因长度而与众不同。

In a request sent by a client to a server when the client does not know the server's cookie, its length is 8, consisting of an 8-byte Client Cookie, as shown in Figure 1.

当客户端不知道服务器的cookie时,客户端向服务器发送的请求中,其长度为8,由8字节的客户端cookie组成,如图1所示。

                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
     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
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |        OPTION-CODE = 10      |       OPTION-LENGTH = 8        |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                                                               |
    +-+-    Client Cookie (fixed size, 8 bytes)              -+-+-+-+
    |                                                               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        
                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
     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
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |        OPTION-CODE = 10      |       OPTION-LENGTH = 8        |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                                                               |
    +-+-    Client Cookie (fixed size, 8 bytes)              -+-+-+-+
    |                                                               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        

Figure 1: COOKIE Option, Unknown Server Cookie

图1:COOKIE选项,未知服务器COOKIE

In a request sent by a client when a Server Cookie is known, and in all responses to such a request, the length is variable -- from 16 to 40 bytes, consisting of an 8-byte Client Cookie followed by the variable-length (8 bytes to 32 bytes) Server Cookie, as shown in Figure 2. The variability of the option length stems from the variable-length Server Cookie. The Server Cookie is an integer number of bytes, with a minimum size of 8 bytes for security and a maximum size of 32 bytes for convenience of implementation.

当服务器Cookie已知时,在客户端发送的请求中,以及在对此类请求的所有响应中,长度是可变的——从16到40字节,由8字节的客户端Cookie和可变长度(8字节到32字节)的服务器Cookie组成,如图2所示。选项长度的可变性源于可变长度服务器Cookie。服务器Cookie是一个整数字节数,为安全起见,最小大小为8字节,为便于实现,最大大小为32字节。

                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
     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
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |        OPTION-CODE = 10      |   OPTION-LENGTH >= 16, <= 40   |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                                                               |
    +-+-    Client Cookie (fixed size, 8 bytes)              -+-+-+-+
    |                                                               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                                                               |
    /       Server Cookie  (variable size, 8 to 32 bytes)           /
    /                                                               /
    +-+-+-+-...
        
                         1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
     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
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |        OPTION-CODE = 10      |   OPTION-LENGTH >= 16, <= 40   |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                                                               |
    +-+-    Client Cookie (fixed size, 8 bytes)              -+-+-+-+
    |                                                               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                                                               |
    /       Server Cookie  (variable size, 8 to 32 bytes)           /
    /                                                               /
    +-+-+-+-...
        

Figure 2: COOKIE Option, Known Server Cookie

图2:COOKIE选项,已知服务器COOKIE

4.1. Client Cookie
4.1. 客户端Cookie

The Client Cookie SHOULD be a pseudorandom function of the Client IP Address, the Server IP Address, and a secret quantity known only to the client. This Client Secret SHOULD have at least 64 bits of entropy [RFC4086] and be changed periodically (see Section 7.1). The selection of the pseudorandom function is a matter private to the client, as only the client needs to recognize its own DNS Cookies.

客户机Cookie应该是客户机IP地址、服务器IP地址和只有客户机知道的秘密量的伪随机函数。该客户机机密应至少具有64位熵[RFC4086],并应定期更改(见第7.1节)。伪随机函数的选择是客户机的私事,因为只有客户机需要识别自己的DNS cookie。

The Client IP Address is included so that the Client Cookie cannot be used to (1) track a client if the Client IP Address changes due to privacy mechanisms or (2) impersonate the client by some network device that was formerly on path but is no longer on path when the Client IP Address changes due to mobility. However, if the Client IP Address is being changed very often, it may be necessary to fix the Client Cookie for a particular server for several requests, to avoid undue inefficiency due to retries caused by that server not recognizing the Client Cookie.

包括客户端IP地址,因此客户端Cookie不能用于(1)如果客户端IP地址因隐私机制而更改,则跟踪客户端;或(2)当客户端IP地址因移动性而更改时,由以前在路径上但不再在路径上的某个网络设备模拟客户端。但是,如果客户机IP地址经常更改,则可能需要为特定服务器修复多个请求的客户机Cookie,以避免由于该服务器未识别客户机Cookie而导致的重试而导致效率不高。

For further discussion of the Client Cookie field, see Section 5.1. For example methods of determining a Client Cookie, see Appendix A.

有关客户端Cookie字段的进一步讨论,请参阅第5.1节。有关确定客户端Cookie的示例方法,请参见附录a。

In order to provide minimal authentication, a client MUST send Client Cookies that will usually be different for any two servers at different IP addresses.

为了提供最低限度的身份验证,客户端必须发送客户端cookie,对于位于不同IP地址的任意两台服务器,这些cookie通常是不同的。

4.2. Server Cookie
4.2. 服务器Cookie

The Server Cookie SHOULD consist of or include a 64-bit or larger pseudorandom function of the request source (client) IP address, a secret quantity known only to the server, and the request Client Cookie. (See Section 6 for a discussion of why the Client Cookie is used as input to the Server Cookie but the Server Cookie is not used as an input to the Client Cookie.) This Server Secret SHOULD have at least 64 bits of entropy [RFC4086] and be changed periodically (see Section 7.1). The selection of the pseudorandom function is a matter private to the server, as only the server needs to recognize its own DNS Cookies.

服务器Cookie应包括或包含请求源(客户端)IP地址的64位或更大的伪随机函数、仅服务器知道的秘密量以及请求客户端Cookie。(有关为什么将客户端Cookie用作服务器Cookie的输入,而不将服务器Cookie用作客户端Cookie的输入的讨论,请参见第6节。)此服务器机密应至少具有64位熵[RFC4086],并定期更改(请参见第7.1节)。伪随机函数的选择是服务器的私事,因为只有服务器需要识别自己的DNS cookie。

For further discussion of the Server Cookie field, see Section 5.2. For example methods of determining a Server Cookie, see Appendix B. When implemented as recommended, the server need not maintain any cookie-related per-client state.

有关服务器Cookie字段的进一步讨论,请参阅第5.2节。例如,确定服务器Cookie的方法,请参见附录B。按照建议实施时,服务器无需维护与每个客户端状态相关的任何Cookie。

In order to provide minimal authentication, a server MUST send Server Cookies that will usually be different for clients at any two different IP addresses or with different Client Cookies.

为了提供最低限度的身份验证,服务器必须发送服务器cookie,这些cookie对于位于任意两个不同IP地址的客户端或具有不同客户端cookie的客户端通常是不同的。

5. DNS Cookies Protocol Specification
5. DNS Cookies协议规范

This section discusses using DNS Cookies in the DNS protocol. The cycle of originating a request, responding to that request, and processing responses is covered in Sections 5.1, 5.2, and 5.3. A de facto extension to QUERY to allow the prefetching of a Server Cookie is specified in Section 5.4. Rollover of the Client Secrets and Server Secrets, and transient retention of the old cookie or secret, are covered in Section 7.1.

本节讨论在DNS协议中使用DNS Cookie。第5.1、5.2和5.3节介绍了发起请求、响应该请求和处理响应的周期。第5.4节规定了允许预取服务器Cookie的事实上的查询扩展。第7.1节介绍了客户机机密和服务器机密的滚动,以及旧cookie或机密的暂时保留。

DNS clients and servers SHOULD implement DNS Cookies to decrease their vulnerability to the threats discussed in Section 2.

DNS客户端和服务器应实现DNS Cookie,以降低其对第2节中讨论的威胁的脆弱性。

5.1. Originating a Request
5.1. 发起请求

A DNS client that implements DNS Cookies includes one DNS COOKIE option containing a Client Cookie in every DNS request it sends, unless DNS Cookies are disabled.

实现DNS COOKIE的DNS客户端包括一个DNS COOKIE选项,该选项在其发送的每个DNS请求中包含一个客户端COOKIE,除非禁用了DNS COOKIE。

If the client has a cached Server Cookie for the server against its IP address, it uses the longer cookie form and includes that Server Cookie in the option along with the Client Cookie (Figure 2). Otherwise, it just sends the shorter-form option with a Client Cookie (Figure 1).

如果客户机针对其IP地址为服务器缓存了一个服务器Cookie,它将使用较长的Cookie表单,并将该服务器Cookie与客户机Cookie一起包含在选项中(图2)。否则,它只发送带有客户端Cookie的较短格式选项(图1)。

5.2. Responding to a Request
5.2. 响应请求

The Server Cookie, when it occurs in a COOKIE option in a request, is intended to weakly assure the server that the request came from a client that is both at the source IP address of the request and using the Client Cookie included in the option. This assurance is provided by the Server Cookie that server sent to that client in an earlier response appearing as the Server Cookie field in the request.

当服务器Cookie出现在请求中的Cookie选项中时,其目的是弱地向服务器保证请求来自一个客户端,该客户端位于请求的源IP地址,并且使用该选项中包含的客户端Cookie。此保证由服务器在请求中作为服务器Cookie字段出现的早期响应中发送给该客户端的服务器Cookie提供。

At a server where DNS Cookies are not implemented and enabled, the presence of a COOKIE option is ignored and the server responds as if no COOKIE option had been included in the request.

在未实现和启用DNS COOKIE的服务器上,将忽略COOKIE选项的存在,并且服务器会做出响应,就像请求中未包含COOKIE选项一样。

When DNS Cookies are implemented and enabled, there are five possibilities:

实施并启用DNS Cookie时,有五种可能性:

(1) There is no OPT RR at all in the request, or there is an OPT RR but the COOKIE option is absent from the OPT RR.

(1) 请求中根本没有OPT-RR,或者存在OPT-RR,但OPT-RR中没有COOKIE选项。

(2) A COOKIE option is present but is not a legal length or is otherwise malformed.

(2) 存在COOKIE选项,但该选项不是合法长度或格式不正确。

(3) There is a COOKIE option of valid length in the request with no Server Cookie.

(3) 在没有服务器COOKIE的请求中有一个有效长度的COOKIE选项。

(4) There is a COOKIE option of valid length in the request with a Server Cookie, but that Server Cookie is invalid.

(4) 在具有服务器COOKIE的请求中存在有效长度的COOKIE选项,但该服务器COOKIE无效。

(5) There is a COOKIE option of valid length in the request with a correct Server Cookie.

(5) 请求中有一个具有正确服务器COOKIE的有效长度的COOKIE选项。

These five possibilities are discussed in the subsections below.

以下小节将讨论这五种可能性。

In all cases of multiple COOKIE options in a request, only the first (the one closest to the DNS header) is considered. All others are ignored.

在一个请求中有多个COOKIE选项的所有情况下,只考虑第一个(最接近DNS头的一个)。其他的都被忽略了。

5.2.1. No OPT RR or No COOKIE Option
5.2.1. 没有OPT-RR或没有COOKIE选项

If there is no OPT record or no COOKIE option present in the request, then the server responds to the request as if the server doesn't implement the COOKIE option.

如果请求中没有OPT记录或COOKIE选项,则服务器将响应请求,就像服务器没有实现COOKIE选项一样。

5.2.2. Malformed COOKIE Option
5.2.2. 格式错误的COOKIE选项

If the COOKIE option is too short to contain a Client Cookie, then FORMERR is generated. If the COOKIE option is longer than that required to hold a COOKIE option with just a Client Cookie (8 bytes) but is shorter than the minimum COOKIE option with both a Client Cookie and a Server Cookie (16 bytes), then FORMERR is generated. If the COOKIE option is longer than the maximum valid COOKIE option (40 bytes), then FORMERR is generated.

如果COOKIE选项太短,无法包含客户端COOKIE,则会生成FORMERR。如果COOKIE选项的长度大于仅包含客户端COOKIE(8字节)的COOKIE选项所需的长度,但小于包含客户端COOKIE和服务器COOKIE(16字节)的最小COOKIE选项,则会生成FORMERR。如果COOKIE选项长于最大有效COOKIE选项(40字节),则会生成FORMERR。

In summary, valid cookie lengths are 8 and 16 to 40 inclusive.

总之,有效cookie长度为8和16到40(含8和16到40)。

5.2.3. Only a Client Cookie
5.2.3. 只有一个客户端Cookie

Based on server policy, including rate limiting, the server chooses one of the following:

根据服务器策略(包括速率限制),服务器选择以下选项之一:

(1) Silently discard the request.

(1) 默默地放弃请求。

(2) Send a BADCOOKIE error response.

(2) 发送BADCOOKIE错误响应。

(3) Process the request and provide a normal response. The RCODE is NOERROR, unless some non-cookie error occurs in processing the request.

(3) 处理请求并提供正常响应。除非在处理请求时发生一些非cookie错误,否则RCODE不会出错。

If the server responds choosing (2) or (3) above, it SHALL generate its own COOKIE option containing both the Client Cookie copied from the request and a Server Cookie it has generated, and it will add this COOKIE option to the response's OPT record. Servers MUST, at least occasionally, respond to such requests to inform the client of the correct Server Cookie. This is necessary so that such a client can bootstrap to the more secure state where requests and responses have recognized Server Cookies and Client Cookies. A server is not expected to maintain per-client state to achieve this. For example, it could respond to every Nth request across all clients.

如果服务器响应上面选择(2)或(3),它将生成自己的COOKIE选项,其中包含从请求复制的客户端COOKIE和它生成的服务器COOKIE,并将此COOKIE选项添加到响应的OPT记录中。服务器必须至少偶尔响应此类请求,以通知客户端正确的服务器Cookie。这是必要的,以便这样的客户端可以引导到更安全的状态,其中请求和响应已识别服务器cookie和客户端cookie。服务器不需要维护每个客户端的状态来实现这一点。例如,它可以跨所有客户端响应每N个请求。

If the request was received over TCP, the server SHOULD take the authentication provided by the use of TCP into account and SHOULD choose (3). In this case, if the server is not willing to accept the security provided by TCP as a substitute for the security provided by DNS Cookies but instead chooses (2), there is some danger of an indefinite loop of retries (see Section 5.3).

如果请求是通过TCP接收的,则服务器应考虑使用TCP提供的身份验证,并应选择(3)。在这种情况下,如果服务器不愿意接受TCP提供的安全性作为DNS Cookie提供的安全性的替代,而是选择(2),则存在无限重试循环的危险(参见第5.3节)。

5.2.4. A Client Cookie and an Invalid Server Cookie
5.2.4. 客户端Cookie和无效的服务器Cookie

The server examines the Server Cookie to determine if it is a valid Server Cookie that it had generated previously. This determination normally involves recalculating the Server Cookie (or the Hash part thereof) based on the Server Secret (or the previous Server Secret, if it has just changed); the received Client Cookie; the Client IP Address; and, possibly, other fields. See Appendix B.2 for an example. If the cookie is invalid, it could be because

服务器检查服务器Cookie以确定它是否是以前生成的有效服务器Cookie。此确定通常涉及基于服务器机密(或之前的服务器机密,如果刚刚更改)重新计算服务器Cookie(或其哈希部分);接收到的客户端Cookie;客户端IP地址;可能还有其他领域。示例见附录B.2。如果cookie无效,可能是因为

+ it is too old

+ 它太旧了

+ a client's IP address or Client Cookie changed, and the DNS server is not aware of the change

+ 客户端的IP地址或客户端Cookie已更改,并且DNS服务器不知道该更改

+ an anycast cluster of servers is not consistently configured, or

+ 服务器的选播群集配置不一致,或

+ an attempt to spoof the client has occurred

+ 已尝试欺骗客户端

The server SHALL process the request as if the invalid Server Cookie was not present, as described in Section 5.2.3.

如第5.2.3节所述,服务器应处理请求,就像不存在无效的服务器Cookie一样。

5.2.5. A Client Cookie and a Valid Server Cookie
5.2.5. 客户端Cookie和有效的服务器Cookie

When a valid Server Cookie is present in the request, the server can assume that the request is from a client that it has talked to before and defensive measures for spoofed UDP requests, if any, are no longer required.

当请求中存在有效的服务器Cookie时,服务器可以假定该请求来自它以前与之交谈过的客户端,并且不再需要对伪造的UDP请求(如果有)采取防御措施。

The server SHALL process the request and include a COOKIE option in the response by (a) copying the complete COOKIE option from the request or (b) generating a new COOKIE option containing both the Client Cookie copied from the request and a valid Server Cookie it has generated.

服务器应通过(a)从请求中复制完整的COOKIE选项或(b)生成一个新的COOKIE选项,其中包含从请求中复制的客户端COOKIE及其生成的有效服务器COOKIE,来处理请求并在响应中包含COOKIE选项。

5.3. Processing Responses
5.3. 处理响应

The Client Cookie, when it occurs in a COOKIE option in a DNS reply, is intended to weakly assure the client that the reply came from a server at the source IP address used in the response packet, because the Client Cookie value is the value that client would send to that server in a request. In a DNS reply with multiple COOKIE options, all but the first (the one closest to the DNS header) are ignored.

当客户端Cookie出现在DNS应答中的Cookie选项中时,其目的是弱地向客户端保证应答来自响应数据包中使用的源IP地址处的服务器,因为客户端Cookie值是客户端将在请求中发送给该服务器的值。在具有多个COOKIE选项的DNS应答中,除第一个(最接近DNS标头的一个)外,其他所有选项都将被忽略。

A DNS client where DNS Cookies are implemented and enabled examines the response for DNS Cookies and MUST discard the response if it contains an illegal COOKIE option length or an incorrect Client Cookie value. If the client is expecting the response to contain a COOKIE option and it is missing, the response MUST be discarded. If the COOKIE option Client Cookie is correct, the client caches the Server Cookie provided, even if the response is an error response (RCODE non-zero).

实施并启用DNS COOKIE的DNS客户端将检查DNS COOKIE的响应,如果响应包含非法的COOKIE选项长度或不正确的客户端COOKIE值,则必须放弃该响应。如果客户端希望响应包含COOKIE选项,但该选项丢失,则必须放弃响应。如果COOKIE选项Client COOKIE正确,则即使响应是错误响应(RCODE非零),客户端也会缓存提供的服务器COOKIE。

If the extended RCODE in the reply is BADCOOKIE and the Client Cookie in the reply matches what was sent, it means that the server was unwilling to process the request because it did not have the correct Server Cookie in it. The client SHOULD retry the request using the new Server Cookie from the response. Repeated BADCOOKIE responses to requests that use the Server Cookie provided in the previous response may be an indication that either the shared secrets or the method for generating secrets in an anycast cluster of servers is inconsistent. If the reply to a retried request with a fresh Server Cookie is BADCOOKIE, the client SHOULD retry using TCP as the transport, since the server will likely process the request normally based on the security provided by TCP (see Section 5.2.3).

如果回复中的扩展RCODE是BADCOOKIE,并且回复中的客户端Cookie与发送的内容匹配,则表示服务器不愿意处理请求,因为其中没有正确的服务器Cookie。客户端应使用响应中的新服务器Cookie重试请求。对使用前一个响应中提供的服务器Cookie的请求的重复BADCOOKIE响应可能表示共享机密或在任意广播服务器集群中生成机密的方法不一致。如果使用新服务器Cookie对重试请求的回复为BADCOOKIE,则客户端应使用TCP作为传输进行重试,因为服务器可能会根据TCP提供的安全性正常处理请求(参见第5.2.3节)。

If the RCODE is some value other than BADCOOKIE, including zero, the further processing of the response proceeds normally.

如果RCODE是BADCOOKIE以外的某个值,包括零,则响应的进一步处理将正常进行。

5.4. Querying for a Server Cookie
5.4. 查询服务器Cookie

In many cases, a client will learn the Server Cookie for a server as the "side effect" of another transaction; however, there may be times when this is not desirable. Therefore, a means is provided for obtaining a Server Cookie through an extension to the QUERY opcode for which opcode most existing implementations require that QDCOUNT be one (1) (see Section 4.1.2 of [RFC1035]).

在许多情况下,客户机会将服务器Cookie作为另一个事务的“副作用”来学习;然而,有时可能不可取。因此,提供了一种通过查询操作码的扩展来获取服务器Cookie的方法,大多数现有实现的操作码要求QDCOUNT为一(1)(参见[RFC1035]第4.1.2节)。

For servers with DNS Cookies enabled, the QUERY opcode behavior is extended to support queries with an empty Question Section (a QDCOUNT of zero (0)), provided that an OPT record is present with a COOKIE option. Such servers will send a reply that has an empty Answer Section and has a COOKIE option containing the Client Cookie and a valid Server Cookie.

对于启用DNS COOKIE的服务器,如果存在带有COOKIE选项的OPT记录,则查询操作码行为将扩展以支持带有空问题部分(QDCOUNT为零(0))的查询。这样的服务器将发送一个应答,该应答有一个空的应答部分,并且有一个包含客户端COOKIE和有效服务器COOKIE的COOKIE选项。

If such a query provided just a Client Cookie and no Server Cookie, the response SHALL have the RCODE NOERROR.

如果这样的查询只提供了一个客户端Cookie,而没有提供服务器Cookie,那么响应应该具有RCODE NOERROR。

This mechanism can also be used to confirm/re-establish an existing Server Cookie by sending a cached Server Cookie with the Client Cookie. In this case, the response SHALL have the RCODE BADCOOKIE if the Server Cookie sent with the query was invalid and the RCODE NOERROR if it was valid.

此机制还可用于通过发送缓存的服务器Cookie和客户端Cookie来确认/重新建立现有的服务器Cookie。在这种情况下,如果与查询一起发送的服务器Cookie无效,则响应应具有RCODE BADCOOKIE,如果有效,则响应应具有RCODE NOERROR。

Servers that don't support the COOKIE option will normally send FORMERR in response to such a query, though REFUSED, NOTIMP, and NOERROR without a COOKIE option are also possible in such responses.

不支持COOKIE选项的服务器通常会发送FORMERR来响应此类查询,但在此类响应中也可能会拒绝、NOTIMP和NOERROR(没有COOKIE选项)。

6. NAT Considerations and Anycast Server Considerations
6. NAT注意事项和选播服务器注意事项

In the classic Internet, DNS Cookies could simply be a pseudorandom function of the Client IP Address and a Server Secret or the Server IP Address and a Client Secret. You would want to compute the Server Cookie that way, so a client could cache its Server Cookie for a particular server for an indefinite amount of time and the server could easily regenerate and check it. You could consider the Client Cookie to be a weak client signature over the Server IP Address that the client checks in replies, and you could extend this signature to cover the request ID, for example, or any other information that is returned unchanged in the reply.

在经典的互联网中,DNS cookie可能只是客户机IP地址和服务器机密或服务器IP地址和客户机机密的伪随机函数。您可能希望以这种方式计算服务器Cookie,这样客户机就可以无限期地缓存特定服务器的服务器Cookie,并且服务器可以轻松地重新生成和检查它。您可以认为客户端Cookie是客户端在答复中检查的服务器IP地址上的弱客户端签名,并且可以扩展此签名以覆盖请求ID,或者在答复中返回不变的任何其他信息。

But we have this reality called "NAT" [RFC3022] (including, for the purposes of this document, NAT-PT, which has been declared Historic [RFC4966]). There is no problem with DNS transactions between clients and servers behind a NAT box using local IP addresses. Nor is there a problem with NAT translation of internal addresses to external addresses or translations between IPv4 and IPv6 addresses, as long as the address mapping is relatively stable. Should the external IP address to which an internal client is being mapped change occasionally, the disruption is little more than when a client rolls over its COOKIE secret. Also, external access to a DNS server behind a NAT box is normally handled by a fixed mapping that forwards externally received DNS requests to a specific host.

但我们将这一现实称为“NAT”[RFC3022](就本文件而言,包括NAT-PT,其已被宣布为历史[RFC4966])。使用本地IP地址的NAT箱后面的客户端和服务器之间的DNS事务没有问题。只要地址映射相对稳定,内部地址到外部地址的NAT转换或IPv4和IPv6地址之间的转换也不存在问题。如果内部客户机映射到的外部IP地址偶尔发生更改,则中断只会比客户机翻滚其COOKIE机密时大一点。此外,对NAT箱后面的DNS服务器的外部访问通常由固定映射处理,该映射将外部接收的DNS请求转发到特定主机。

However, NAT devices sometimes also map ports. This can cause multiple DNS requests and responses from multiple internal hosts to be mapped to a smaller number of external IP addresses, such as one address. Thus, there could be many clients behind a NAT box that appear to come from the same source IP address to a server outside that NAT box. If one of these were an attacker (think "zombie" or "botnet") behind a NAT box, that attacker could get the Server Cookie for some server for the outgoing IP address by just making some random request to that server. It could then include that Server Cookie in the COOKIE option of requests to the server with the forged local IP address of some other host and/or client behind the NAT box. (An attacker's possession of this Server Cookie will not help in forging responses to cause cache poisoning, as such responses are protected by the required Client Cookie.)

然而,NAT设备有时也映射端口。这可能会导致来自多个内部主机的多个DNS请求和响应映射到数量较少的外部IP地址,例如一个地址。因此,一个NAT盒后面可能有许多客户端,它们似乎来自该NAT盒外部服务器的同一源IP地址。如果其中一个是NAT盒后面的攻击者(比如“僵尸”或“僵尸网络”),那么该攻击者只需向某个服务器发出一些随机请求,就可以获得某个服务器传出IP地址的服务器Cookie。然后,它可以将该服务器Cookie包含在请求服务器的Cookie选项中,请求服务器的本地IP地址为NAT框后面某个其他主机和/或客户端的伪造IP地址。(攻击者拥有此服务器Cookie无助于伪造响应以导致缓存中毒,因为此类响应受所需客户端Cookie的保护。)

To fix this potential defect, it is necessary to distinguish different clients behind a NAT box from the point of view of the server. This is why the Server Cookie is specified as a pseudorandom function of both the request source IP address and the Client Cookie. From this inclusion of the Client Cookie in the calculation of the Server Cookie, it follows that, for any particular server, a stable Client Cookie is needed. If, for example, the request ID was included in the calculation of the Client Cookie, it would normally change with each request to a particular server. This would mean that each request would have to be sent twice: first, to learn the new Server Cookie based on this new Client Cookie based on the new ID, and then again using this new Client Cookie to actually get an answer. Thus, the input to the Client Cookie computation must be limited to the Server IP Address and one or more things that change slowly, such as the Client Secret.

要修复此潜在缺陷,必须从服务器的角度区分NAT盒后面的不同客户端。这就是为什么服务器Cookie被指定为请求源IP地址和客户端Cookie的伪随机函数。从计算服务器Cookie时包含的客户端Cookie可以看出,对于任何特定的服务器,都需要一个稳定的客户端Cookie。例如,如果客户机Cookie的计算中包含了请求ID,则它通常会随着对特定服务器的每个请求而改变。这意味着每个请求必须发送两次:首先,基于新ID的新客户机Cookie学习新服务器Cookie,然后再次使用新客户机Cookie实际获得答案。因此,客户端Cookie计算的输入必须限于服务器IP地址和一个或多个变化缓慢的内容,例如客户端机密。

In principle, there could be a similar problem for servers, not due to NAT but due to mechanisms like anycast that may cause requests to a DNS server at an IP address to be delivered to any one of several machines. (External requests to a DNS server behind a NAT box usually occur via port forwarding such that all such requests go to one host.) However, it is impossible to solve this in the way that the similar problem was solved for NATed clients; if the Server Cookie was included in the calculation of the Client Cookie in the same way that the Client Cookie is included in the Server Cookie, you would just get an almost infinite series of errors as a request was repeatedly retried.

原则上,服务器可能存在类似的问题,这不是因为NAT,而是因为像anycast这样的机制可能导致对IP地址的DNS服务器的请求被传递到多台机器中的任何一台。(对NAT箱后面的DNS服务器的外部请求通常通过端口转发发生,以便所有此类请求都发送到一台主机。)但是,不可能用为NAT客户端解决类似问题的方式来解决这一问题;如果服务器Cookie以与客户端Cookie包含在服务器Cookie中相同的方式包含在客户端Cookie的计算中,那么当请求被重复重试时,您将得到几乎无限的一系列错误。

For servers accessed via anycast, to successfully support DNS Cookies, either (1) the server clones must all use the same Server Secret or (2) the mechanism that distributes requests to the server clones must cause the requests from a particular client to go to a particular server for a sufficiently long period of time that

对于通过anycast访问的服务器,要成功支持DNS Cookie,要么(1)服务器克隆必须全部使用相同的服务器机密,要么(2)向服务器克隆分发请求的机制必须使来自特定客户端的请求在足够长的时间内转到特定服务器

extra requests due to changes in Server Cookies resulting from accessing different server machines are not unduly burdensome. (When such anycast-accessed servers act as recursive servers or otherwise act as clients, they normally use a different unique address to source their requests, to avoid confusion in the delivery of responses.)

由于访问不同的服务器机器而导致的服务器cookie更改而产生的额外请求不会造成不必要的负担。(当这种选播访问的服务器充当递归服务器或以其他方式充当客户机时,它们通常使用不同的唯一地址作为请求的来源,以避免在传递响应时出现混淆。)

For simplicity, it is RECOMMENDED that the same Server Secret be used by each DNS server in a set of anycast servers. If there is limited time skew in updating this secret in different anycast servers, this can be handled by a server accepting requests containing a Server Cookie based on either its old or new secret for the maximum likely time period of such time skew (see also Section 7.1).

为简单起见,建议一组选播服务器中的每个DNS服务器使用相同的服务器机密。如果在不同的选播服务器中更新此机密时存在有限的时间偏差,则可由服务器根据其旧机密或新机密接受包含服务器Cookie的请求,并在此类时间偏差的最长可能时间段内进行处理(另请参见第7.1节)。

7. Operational and Deployment Considerations
7. 业务和部署考虑事项

The DNS Cookie mechanism is designed for incremental deployment and to complement the orthogonal techniques in [RFC5452]. Either or both techniques can be deployed independently at each DNS server and client. Thus, installation at the client and server end need not be synchronized.

DNS Cookie机制设计用于增量部署,并补充[RFC5452]中的正交技术。两种技术中的一种或两种都可以在每个DNS服务器和客户端独立部署。因此,客户端和服务器端的安装不需要同步。

In particular, a DNS server or client that implements the DNS Cookie mechanism can interoperate successfully with a DNS client or server that does not implement this mechanism, although, of course, in this case it will not get the benefit of the mechanism and the server involved might choose to severely rate-limit responses. When such a server or client interoperates with a client or server that also implements the DNS Cookie mechanism, these servers and clients get the security benefits of the DNS Cookie mechanism.

特别是,实现DNS Cookie机制的DNS服务器或客户端可以与未实现此机制的DNS客户端或服务器成功互操作,当然,在这种情况下,它不会从该机制中获益,并且所涉及的服务器可能会选择严格限制响应的速率。当这样的服务器或客户端与同时实现DNS Cookie机制的客户端或服务器进行互操作时,这些服务器和客户端将获得DNS Cookie机制的安全优势。

7.1. Client and Server Secret Rollover
7.1. 客户端和服务器秘密翻转

The longer a secret is used, the higher the probability that it has been compromised. Thus, clients and servers are configured with a lifetime setting for their secret, and they roll over to a new secret when that lifetime expires, or earlier due to deliberate jitter as described below. The default lifetime is one day, and the maximum permitted is one month. To be precise and to make it practical to stay within limits despite long holiday weekends, daylight saving time shifts, and the like, clients and servers MUST NOT continue to use the same secret in new requests and responses for more than 36 days and SHOULD NOT continue to do so for more than 26 hours.

一个秘密被使用的时间越长,它被泄露的概率就越高。因此,客户机和服务器为其机密配置了一个生存期设置,并且当该生存期到期时,或者由于如下所述的故意抖动,它们会滚动到一个新的机密。默认生存期为一天,允许的最大生存期为一个月。准确地说,为了在长假周末、夏令时轮班等情况下保持在限制范围内,客户端和服务器在新请求和响应中使用同一秘密的时间不得超过36天,也不得超过26小时。

Many clients rolling over their secret at the same time could briefly increase server traffic, and exactly predictable rollover times for clients or servers might facilitate guessing attacks. For example, an attacker might increase the priority of attacking secrets they

许多客户端同时翻滚其秘密可能会短暂增加服务器流量,而客户端或服务器准确可预测的翻滚时间可能有助于猜测攻击。例如,攻击者可能会提高攻击其机密的优先级

believe will be in effect for an extended period of time. To avoid rollover synchronization and predictability, it is RECOMMENDED that pseudorandom jitter in the range of plus zero to minus at least 40% be applied to the time until a scheduled rollover of a COOKIE secret.

“相信”将在一段较长的时间内生效。为了避免滚动同步和可预测性,建议对COOKIE密钥的计划滚动之前的时间应用正负至少40%范围内的伪随机抖动。

It is RECOMMENDED that a client keep the Client Cookie it is expecting in a reply until there is no longer an outstanding request associated with that Client Cookie that the client is tracking. This avoids rejection of replies due to a bad Client Cookie right after a change in the Client Secret.

建议客户机在回复中保留它期望的客户机Cookie,直到不再有与客户机正在跟踪的客户机Cookie关联的未完成请求为止。这避免了在客户端密码更改后立即由于错误的客户端Cookie而拒绝回复。

It is RECOMMENDED that a server retain its previous secret after a rollover to a new secret for a configurable period of time not less than 1 second or more than 300 seconds, with a default configuration of 150 seconds. Requests with Server Cookies based on its previous secret are treated as a correct Server Cookie during that time. When a server responds to a request containing an old Server Cookie that the server is treating as correct, the server MUST include a new Server Cookie in its response.

建议服务器在滚动到新机密后保留其以前的机密,保留时间可配置为不少于1秒或超过300秒,默认配置为150秒。在此期间,具有基于其先前机密的服务器Cookie的请求将被视为正确的服务器Cookie。当服务器响应包含服务器认为正确的旧服务器Cookie的请求时,服务器必须在其响应中包含新的服务器Cookie。

7.2. Counters
7.2. 计数器

It is RECOMMENDED that implementations include counters of the occurrences of the various types of requests and responses described in Section 5.

建议实现包括第5节中描述的各种类型的请求和响应的发生计数器。

8. IANA Considerations
8. IANA考虑

IANA has assigned the following DNS EDNS0 option code:

IANA已分配以下DNS EDNS0选项代码:

       Value       Name      Status        Reference
      --------    ------    --------    ---------------
         10       COOKIE    Standard       RFC 7873
        
       Value       Name      Status        Reference
      --------    ------    --------    ---------------
         10       COOKIE    Standard       RFC 7873
        

IANA has assigned the following DNS error code as an early allocation per [RFC7120]:

IANA已根据[RFC7120]将以下DNS错误代码分配为早期分配:

       RCODE       Name       Description                 Reference
      --------  ---------  -------------------------   ---------------
         23     BADCOOKIE  Bad/missing Server Cookie      RFC 7873
        
       RCODE       Name       Description                 Reference
      --------  ---------  -------------------------   ---------------
         23     BADCOOKIE  Bad/missing Server Cookie      RFC 7873
        
9. Security Considerations
9. 安全考虑

DNS Cookies provide a weak form of authentication of DNS requests and responses. In particular, they provide no protection against "on-path" adversaries; that is, they provide no protection against any adversary that can observe the plaintext DNS traffic, such as an on-path router, bridge, or any device on an on-path shared link (unless the DNS traffic in question on that path is encrypted).

DNS Cookie提供DNS请求和响应的弱身份验证形式。特别是,它们无法抵御“路上”的对手;也就是说,它们不提供针对任何能够观察到明文DNS流量的对手的保护,例如路径上路由器、网桥或路径上共享链路上的任何设备(除非该路径上有问题的DNS流量被加密)。

For example, if a host is connected via an unsecured IEEE Std. 802.11 link (Wi-Fi), any device in the vicinity that could receive and decode the 802.11 transmissions must be considered "on path". On the other hand, in a similar situation but one where 802.11 Robust Security (WPA2, also called "Wi-Fi Protected Access 2") is appropriately deployed on the Wi-Fi network nodes, only the Access Point via which the host is connecting is "on path" as far as the 802.11 link is concerned.

例如,如果主机通过不安全的IEEE标准802.11链路(Wi-Fi)连接,则附近可能接收和解码802.11传输的任何设备都必须被视为“在路径上”。另一方面,在类似的情况下,但在Wi-Fi网络节点上适当部署了802.11鲁棒安全性(WPA2,也称为“Wi-Fi保护的接入2”)的情况下,就802.11链路而言,只有主机所连接的接入点是“路径上”的。

Despite these limitations, deployment of DNS Cookies on the global Internet is expected to provide a significant reduction in the available launch points for the traffic amplification and denial-of-service forgery attacks described in Section 2 above.

尽管存在这些限制,在全球互联网上部署DNS cookie预计将大大减少上文第2节所述的流量放大和拒绝服务伪造攻击的可用启动点。

Work is underway in the IETF DPRIVE working group to provide confidentiality for DNS requests and responses that would be compatible with DNS Cookies.

IETF DPRIVE工作组正在开展工作,为与DNS cookie兼容的DNS请求和响应提供保密性。

Should stronger message/transaction security be desired, it is suggested that TSIG or SIG(0) security be used (see Section 3.2); however, it may be useful to use DNS Cookies in conjunction with these features. In particular, DNS Cookies could screen out many DNS messages before the cryptographic computations of TSIG or SIG(0) are required, and if SIG(0) is in use, DNS Cookies could usefully screen out many requests given that SIG(0) does not screen requests but only authenticates the response of complete transactions.

如果需要更强的消息/事务安全性,建议使用TSIG或SIG(0)安全性(见第3.2节);但是,将DNS cookie与这些功能结合使用可能会很有用。特别是,DNS Cookie可以在需要TSIG或SIG(0)的加密计算之前筛选出许多DNS消息,并且如果正在使用SIG(0),DNS Cookie可以有效地筛选出许多请求,因为SIG(0)不筛选请求,而只是验证完整事务的响应。

An attacker that does not know the Server Cookie could do a variety of things, such as omitting the COOKIE option or sending a random Server Cookie. In general, DNS servers need to take other measures, including rate-limiting responses, to protect from abuse in such cases. See further information in Section 5.2.

不知道服务器Cookie的攻击者可以执行多种操作,例如忽略Cookie选项或发送随机服务器Cookie。一般来说,DNS服务器需要采取其他措施,包括速率限制响应,以防止在此类情况下被滥用。更多信息见第5.2节。

When a server or client starts receiving an increased level of requests with bad Server Cookies or replies with bad Client Cookies, it would be reasonable for it to believe that it is likely under attack, and it should consider a more frequent rollover of its secret. More rapid rollover decreases the benefit to a cookie-guessing attacker if they succeed in guessing a cookie.

当服务器或客户端开始接收到带有坏的服务器cookies或具有坏客户端cookie的答复的请求级别增加时,它就有理由相信它很可能受到攻击,并且应该考虑更频繁地翻转其秘密。如果cookie猜测攻击者成功猜测cookie,则更快速的翻转会降低其收益。

9.1. Cookie Algorithm Considerations
9.1. Cookie算法注意事项

The cookie computation algorithm for use in DNS Cookies SHOULD be based on a pseudorandom function at least as strong as 64-bit FNV (Fowler/Noll/Vo [FNV]), because an excessively weak or trivial algorithm could enable adversaries to guess cookies. However, in light of the lightweight plaintext token security provided by DNS Cookies, a strong cryptography hash algorithm may not be warranted in many cases and would cause an increased computational burden. Nevertheless, there is nothing wrong with using something stronger -- for example, HMAC-SHA-256 [RFC6234] truncated to 64 bits, assuming that a DNS processor has adequate computational resources available. DNS implementations or applications that need somewhat stronger security without a significant increase in computational load should consider more frequent changes in their client and/or Server Secret; however, this does require more frequent generation of a cryptographically strong random number [RFC4086]. See Appendices A and B for specific examples of cookie computation algorithms.

DNS cookie中使用的cookie计算算法应基于至少与64位FNV(Fowler/Noll/Vo[FNV])一样强的伪随机函数,因为过于弱或微不足道的算法可能使对手猜测cookie。然而,鉴于DNS Cookie提供的轻量级明文令牌安全性,在许多情况下可能不保证使用强加密哈希算法,这将导致计算负担增加。然而,如果DNS处理器有足够的可用计算资源,那么使用更强的功能并没有什么错——例如,HMAC-SHA-256[RFC6234]被截断为64位。DNS实现或应用程序需要更强的安全性而不需要显著增加计算负载,应考虑更频繁地改变客户端和/或服务器的秘密;然而,这确实需要更频繁地生成加密强随机数[RFC4086]。有关cookie计算算法的具体示例,请参见附录A和附录B。

10. Implementation Considerations
10. 实施考虑

The DNS COOKIE option specified herein is implemented in BIND 9.10 using an experimental option code. BIND 9.10.3 (and later) use the allocated option code.

本文指定的DNS COOKIE选项在BIND 9.10中使用实验性选项代码实现。BIND 9.10.3(及更高版本)使用分配的选项代码。

11. References
11. 工具书类
11.1. Normative References
11.1. 规范性引用文件

[RFC1035] Mockapetris, P., "Domain names - implementation and specification", STD 13, RFC 1035, DOI 10.17487/RFC1035, November 1987, <http://www.rfc-editor.org/info/rfc1035>.

[RFC1035]Mockapetris,P.,“域名-实现和规范”,STD 13,RFC 1035,DOI 10.17487/RFC1035,1987年11月<http://www.rfc-editor.org/info/rfc1035>.

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, <http://www.rfc-editor.org/info/rfc2119>.

[RFC2119]Bradner,S.,“RFC中用于表示需求水平的关键词”,BCP 14,RFC 2119,DOI 10.17487/RFC2119,1997年3月<http://www.rfc-editor.org/info/rfc2119>.

[RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, "Randomness Requirements for Security", BCP 106, RFC 4086, DOI 10.17487/RFC4086, June 2005, <http://www.rfc-editor.org/info/rfc4086>.

[RFC4086]Eastlake 3rd,D.,Schiller,J.,和S.Crocker,“安全的随机性要求”,BCP 106,RFC 4086,DOI 10.17487/RFC4086,2005年6月<http://www.rfc-editor.org/info/rfc4086>.

[RFC6891] Damas, J., Graff, M., and P. Vixie, "Extension Mechanisms for DNS (EDNS(0))", STD 75, RFC 6891, DOI 10.17487/RFC6891, April 2013, <http://www.rfc-editor.org/info/rfc6891>.

[RFC6891]Damas,J.,Graff,M.,和P.Vixie,“DNS的扩展机制(EDNS(0)),STD 75,RFC 6891,DOI 10.17487/RFC68911913年4月<http://www.rfc-editor.org/info/rfc6891>.

[RFC7120] Cotton, M., "Early IANA Allocation of Standards Track Code Points", BCP 100, RFC 7120, DOI 10.17487/RFC7120, January 2014, <http://www.rfc-editor.org/info/rfc7120>.

[RFC7120]Cotton,M.,“标准轨道代码点的早期IANA分配”,BCP 100,RFC 7120,DOI 10.17487/RFC7120,2014年1月<http://www.rfc-editor.org/info/rfc7120>.

11.2. Informative References
11.2. 资料性引用

[FNV] Fowler, G., Noll, L., Vo, K., and D. Eastlake 3rd, "The FNV Non-Cryptographic Hash Algorithm", Work in Progress, draft-eastlake-fnv-10, October 2015.

[FNV]Fowler,G.,Noll,L.,Vo,K.,和D.Eastlake 3rd,“FNV非加密散列算法”,正在进行的工作,草稿-Eastlake-FNV-10,2015年10月。

[Kaminsky] Olney, M., Mullen, P., and K. Miklavcic, "Dan Kaminsky's 2008 DNS Vulnerability", July 2008, <https://www.ietf.org/ mail-archive/web/dnsop/current/pdf2jgx6rzxN4.pdf>.

[Kaminsky]Olney,M.,Mullen,P.,和K.Miklavcic,“Dan Kaminsky的2008 DNS漏洞”,2008年7月<https://www.ietf.org/ 邮件存档/web/dnsop/current/pdf2jgx6rzxN4.pdf>。

[RFC2845] Vixie, P., Gudmundsson, O., Eastlake 3rd, D., and B. Wellington, "Secret Key Transaction Authentication for DNS (TSIG)", RFC 2845, DOI 10.17487/RFC2845, May 2000, <http://www.rfc-editor.org/info/rfc2845>.

[RFC2845]Vixie,P.,Gudmundsson,O.,Eastlake 3rd,D.,和B.Wellington,“DNS秘密密钥交易认证(TSIG)”,RFC 2845,DOI 10.17487/RFC2845,2000年5月<http://www.rfc-editor.org/info/rfc2845>.

[RFC2930] Eastlake 3rd, D., "Secret Key Establishment for DNS (TKEY RR)", RFC 2930, DOI 10.17487/RFC2930, September 2000, <http://www.rfc-editor.org/info/rfc2930>.

[RFC2930]Eastlake 3rd,D.,“DNS密钥建立(TKEY RR)”,RFC 2930,DOI 10.17487/RFC2930,2000年9月<http://www.rfc-editor.org/info/rfc2930>.

[RFC2931] Eastlake 3rd, D., "DNS Request and Transaction Signatures ( SIG(0)s )", RFC 2931, DOI 10.17487/RFC2931, September 2000, <http://www.rfc-editor.org/info/rfc2931>.

[RFC2931]Eastlake 3rd,D.,“DNS请求和事务签名(SIG(0)s)”,RFC 2931,DOI 10.17487/RFC293119000年9月<http://www.rfc-editor.org/info/rfc2931>.

[RFC3022] Srisuresh, P. and K. Egevang, "Traditional IP Network Address Translator (Traditional NAT)", RFC 3022, DOI 10.17487/RFC3022, January 2001, <http://www.rfc-editor.org/info/rfc3022>.

[RFC3022]Srisuresh,P.和K.Egevang,“传统IP网络地址转换器(传统NAT)”,RFC 3022,DOI 10.17487/RFC3022,2001年1月<http://www.rfc-editor.org/info/rfc3022>.

[RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., and S. Rose, "DNS Security Introduction and Requirements", RFC 4033, DOI 10.17487/RFC4033, March 2005, <http://www.rfc-editor.org/info/rfc4033>.

[RFC4033]Arends,R.,Austein,R.,Larson,M.,Massey,D.,和S.Rose,“DNS安全介绍和要求”,RFC 4033,DOI 10.17487/RFC4033,2005年3月<http://www.rfc-editor.org/info/rfc4033>.

[RFC4034] Arends, R., Austein, R., Larson, M., Massey, D., and S. Rose, "Resource Records for the DNS Security Extensions", RFC 4034, DOI 10.17487/RFC4034, March 2005, <http://www.rfc-editor.org/info/rfc4034>.

[RFC4034]Arends,R.,Austein,R.,Larson,M.,Massey,D.,和S.Rose,“DNS安全扩展的资源记录”,RFC 4034,DOI 10.17487/RFC4034,2005年3月<http://www.rfc-editor.org/info/rfc4034>.

[RFC4035] Arends, R., Austein, R., Larson, M., Massey, D., and S. Rose, "Protocol Modifications for the DNS Security Extensions", RFC 4035, DOI 10.17487/RFC4035, March 2005, <http://www.rfc-editor.org/info/rfc4035>.

[RFC4035]Arends,R.,Austein,R.,Larson,M.,Massey,D.,和S.Rose,“DNS安全扩展的协议修改”,RFC 4035,DOI 10.17487/RFC4035,2005年3月<http://www.rfc-editor.org/info/rfc4035>.

[RFC4966] Aoun, C. and E. Davies, "Reasons to Move the Network Address Translator - Protocol Translator (NAT-PT) to Historic Status", RFC 4966, DOI 10.17487/RFC4966, July 2007, <http://www.rfc-editor.org/info/rfc4966>.

[RFC4966]Aoun,C.和E.Davies,“将网络地址转换器-协议转换器(NAT-PT)移动到历史状态的原因”,RFC 4966,DOI 10.17487/RFC4966,2007年7月<http://www.rfc-editor.org/info/rfc4966>.

[RFC5452] Hubert, A. and R. van Mook, "Measures for Making DNS More Resilient against Forged Answers", RFC 5452, DOI 10.17487/RFC5452, January 2009, <http://www.rfc-editor.org/info/rfc5452>.

[RFC5452]Hubert,A.和R.van Mook,“使DNS对伪造答案更具弹性的措施”,RFC 5452,DOI 10.17487/RFC5452,2009年1月<http://www.rfc-editor.org/info/rfc5452>.

[RFC6234] Eastlake 3rd, D. and T. Hansen, "US Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF)", RFC 6234, DOI 10.17487/RFC6234, May 2011, <http://www.rfc-editor.org/info/rfc6234>.

[RFC6234]Eastlake 3rd,D.和T.Hansen,“美国安全哈希算法(基于SHA和SHA的HMAC和HKDF)”,RFC 6234,DOI 10.17487/RFC6234,2011年5月<http://www.rfc-editor.org/info/rfc6234>.

Appendix A. Example Client Cookie Algorithms
附录A.客户端Cookie算法示例
A.1. A Simple Algorithm
A.1. 一种简单的算法

A simple example method to compute Client Cookies is the FNV64 [FNV] of the Client IP Address, the Server IP Address, and the Client Secret:

计算客户端cookie的一个简单示例方法是客户端IP地址、服务器IP地址和客户端密码的FNV64[FNV]:

Client Cookie = FNV64( Client IP Address | Server IP Address | Client Secret )

客户端Cookie=FNV64(客户端IP地址|服务器IP地址|客户端机密)

where "|" indicates concatenation. Some computational resources may be saved by pre-computing FNV64 through the Client IP Address. (If the order of the items concatenated above is changed to put the Server IP Address last, it might be possible to further reduce the computational effort by pre-computing FNV64 through the bytes of both the Client IP Address and the Client Secret, but this would reduce the strength of the Client Cookie and is NOT RECOMMENDED.)

其中“|”表示串联。通过客户端IP地址预计算FNV64可以节省一些计算资源。(如果将上面连接的项的顺序更改为将服务器IP地址放在最后,则可以通过通过客户端IP地址和客户端密码的字节预计算FNV64来进一步减少计算工作量,但这会降低客户端Cookie的强度,因此不建议这样做。)

A.2. A More Complex Algorithm
A.2. 更复杂的算法

A more complex algorithm to calculate Client Cookies is given below. It uses more computational resources than the simpler algorithm shown in Appendix A.1.

下面给出了计算客户端cookie的更复杂的算法。它比附录A.1中所示的更简单的算法使用更多的计算资源。

Client Cookie = HMAC-SHA256-64( Client IP Address | Server IP Address, Client Secret )

客户端Cookie=HMAC-SHA256-64(客户端IP地址|服务器IP地址,客户端机密)

Appendix B. Example Server Cookie Algorithms
附录B.服务器Cookie算法示例
B.1. A Simple Algorithm
B.1. 一种简单的算法

An example of a simple method producing a 64-bit Server Cookie is the FNV64 [FNV] of the request IP address, the Client Cookie, and the Server Secret.

生成64位服务器Cookie的简单方法的一个示例是请求IP地址的FNV64[FNV]、客户端Cookie和服务器机密。

Server Cookie = FNV64( Client IP Address | Client Cookie | Server Secret )

服务器Cookie=FNV64(客户端IP地址|客户端Cookie |服务器机密)

where "|" represents concatenation. (If the order of the items concatenated was changed, it might be possible to reduce the computational effort by pre-computing FNV64 through the bytes of the Server Secret and Client Cookie, but this would reduce the strength of the Server Cookie and is NOT RECOMMENDED.)

其中“|”表示串联。(如果连接项的顺序已更改,则可以通过服务器机密和客户端Cookie的字节预计算FNV64来减少计算工作量,但这会降低服务器Cookie的强度,因此不建议这样做。)

B.2. A More Complex Algorithm
B.2. 更复杂的算法

Since the Server Cookie has a variable size, the server can store various information in that field as long as it is hard for an adversary to guess the entire quantity used for authentication. There should be 64 bits of entropy in the Server Cookie; for example, it could have a sub-field of 64 bits computed pseudorandomly with the Server Secret as one of the inputs to the pseudorandom function. Types of additional information that could be stored include a timestamp and/or a nonce.

由于服务器Cookie的大小是可变的,服务器可以在该字段中存储各种信息,只要对手很难猜出用于身份验证的全部数量。服务器Cookie中应该有64位熵;例如,它可以有一个64位的子字段,以服务器机密作为伪随机函数的输入之一,进行伪随机计算。可以存储的附加信息类型包括时间戳和/或nonce。

The example below is one variation of the Server Cookie that has been implemented in BIND 9.10.3 (and later) releases, where the Server Cookie is 128 bits, composed as follows:

下面的示例是BIND 9.10.3(及更高版本)中实现的服务器Cookie的一个变体,其中服务器Cookie为128位,组成如下:

         Sub-field      Size
         ---------   ---------
           Nonce      32 bits
           Time       32 bits
           Hash       64 bits
        
         Sub-field      Size
         ---------   ---------
           Nonce      32 bits
           Time       32 bits
           Hash       64 bits
        

With this algorithm, the server sends a new 128-bit cookie back with every request. The Nonce field assures a low probability that there would be a duplicate.

使用此算法,服务器会在每个请求中发送一个新的128位cookie。Nonce字段确保存在重复的低概率。

The Time field gives the server time and makes it easy to reject old cookies.

时间字段为服务器提供时间,并使其易于拒绝旧cookie。

The Hash part of the Server Cookie is the part that is hard to guess. In BIND 9.10.3 (and later), its computation can be configured to use AES, HMAC-SHA-1, or, as shown below, HMAC-SHA-256:

服务器Cookie的哈希部分是难以猜测的部分。在BIND 9.10.3(及更高版本)中,其计算可配置为使用AES、HMAC-SHA-1或HMAC-SHA-256,如下所示:

hash = HMAC-SHA256-64( Server Secret, (Client Cookie | Nonce | Time | Client IP Address) )

hash=HMAC-SHA256-64(服务器机密,(客户端Cookie | Nonce | Time |客户端IP地址))

where "|" represents concatenation.

其中“|”表示串联。

Acknowledgments

致谢

The suggestions and contributions of the following are gratefully acknowledged:

感谢以下各方的建议和贡献:

Alissa Cooper, Bob Harold, Paul Hoffman, David Malone, Yoav Nir, Gayle Noble, Dan Romascanu, Tim Wicinski, and Peter Yee

Alissa Cooper、Bob Harold、Paul Hoffman、David Malone、Yoav Nir、Gayle Noble、Dan Romascanu、Tim Wicinski和Peter Yee

Authors' Addresses

作者地址

Donald E. Eastlake 3rd Huawei Technologies 155 Beaver Street Milford, MA 01757 United States

Donald E.Eastlake第三华为技术有限公司美国马萨诸塞州米尔福德海狸街155号01757

   Phone: +1-508-333-2270
   Email: d3e3e3@gmail.com
        
   Phone: +1-508-333-2270
   Email: d3e3e3@gmail.com
        

Mark Andrews Internet Systems Consortium 950 Charter Street Redwood City, CA 94063 United States

美国加利福尼亚州红木市查特街950号马克·安德鲁斯互联网系统联合会,邮编94063

   Email: marka@isc.org
        
   Email: marka@isc.org