<?xml version='1.0' encoding='utf-8'?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" category="std" consensus="true" docName="draft-ietf-dnsop-server-cookies-05" indexInclude="true" ipr="trust200902" number="9018" prepTime="2021-04-05T22:26:44" scripts="Common,Latin" sortRefs="true" submissionType="IETF" symRefs="true" tocDepth="3" tocInclude="true" updates="7873" xml:lang="en">
  <link href="https://datatracker.ietf.org/doc/draft-ietf-dnsop-server-cookies-05" rel="prev"/>
  <link href="https://dx.doi.org/10.17487/rfc9018" rel="alternate"/>
  <link href="urn:issn:2070-1721" rel="alternate"/>
  <front>
    <title abbrev="Interoperable DNS Server Cookies">Interoperable Domain Name System (DNS) Server Cookies</title>
    <seriesInfo value="9018" name="RFC" stream="IETF"/>
    <author initials="O." surname="Sury" fullname="Ondrej Sury">
      <organization showOnFrontPage="true">Internet Systems Consortium</organization>
      <address>
        <postal>
          <street/>
          <country>CZ</country>
        </postal>
        <email>ondrej@isc.org</email>
      </address>
    </author>
    <author initials="W." surname="Toorop" fullname="Willem Toorop">
      <organization showOnFrontPage="true">NLnet Labs</organization>
      <address>
        <postal>
          <street>Science Park 400</street>
          <city>Amsterdam</city>
          <code>1098 XH</code>
          <country>Netherlands</country>
        </postal>
        <email>willem@nlnetlabs.nl</email>
      </address>
    </author>
    <author initials="D." surname="Eastlake 3rd" fullname="Donald E. Eastlake 3rd">
      <organization showOnFrontPage="true">Futurewei Technologies</organization>
      <address>
        <postal>
          <street>2386 Panoramic Circle</street>
          <city>Apopka</city>
          <code>FL 32703</code>
          <country>United States of America</country>
        </postal>
        <phone>+1-508-333-2270</phone>
        <email>d3e3e3@gmail.com</email>
      </address>
    </author>
    <author initials="M." surname="Andrews" fullname="Mark Andrews">
      <organization showOnFrontPage="true">Internet Systems Consortium</organization>
      <address>
        <postal>
          <street>950 Charter Street</street>
          <city>Redwood City</city>
          <code>CA 94063</code>
          <country>United States of America</country>
        </postal>
        <email>marka@isc.org</email>
      </address>
    </author>
    <date month="04" year="2021"/>
    <area>Internet</area>
    <workgroup>DNSOP Working Group</workgroup>
    <keyword>Client</keyword>
    <keyword>Hash</keyword>
    <abstract pn="section-abstract">
      <t indent="0" pn="section-abstract-1">DNS Cookies, as specified in RFC 7873, are a
lightweight DNS transaction security mechanism that provide limited protection
to DNS servers and clients against a variety of denial-of-service
amplification, forgery, or cache-poisoning attacks by off-path attackers.</t>
      <t indent="0" pn="section-abstract-2">This document updates RFC 7873 with precise directions for creating Server
Cookies so that an anycast server set including diverse implementations will
interoperate with standard clients, with suggestions for constructing Client Cookies
in a privacy-preserving fashion, and with suggestions on how to update a Server
Secret.  An IANA registry listing the methods and associated pseudorandom
function suitable for creating DNS Server Cookies has been created with the method
described in this document as the first and, as of the time of publication, only entry.</t>
    </abstract>
    <boilerplate>
      <section anchor="status-of-memo" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.1">
        <name slugifiedName="name-status-of-this-memo">Status of This Memo</name>
        <t indent="0" pn="section-boilerplate.1-1">
            This is an Internet Standards Track document.
        </t>
        <t indent="0" pn="section-boilerplate.1-2">
            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.
        </t>
        <t indent="0" pn="section-boilerplate.1-3">
            Information about the current status of this document, any
            errata, and how to provide feedback on it may be obtained at
            <eref target="https://www.rfc-editor.org/info/rfc9018" brackets="none"/>.
        </t>
      </section>
      <section anchor="copyright" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.2">
        <name slugifiedName="name-copyright-notice">Copyright Notice</name>
        <t indent="0" pn="section-boilerplate.2-1">
            Copyright (c) 2021 IETF Trust and the persons identified as the
            document authors. All rights reserved.
        </t>
        <t indent="0" pn="section-boilerplate.2-2">
            This document is subject to BCP 78 and the IETF Trust's Legal
            Provisions Relating to IETF Documents
            (<eref target="https://trustee.ietf.org/license-info" brackets="none"/>) 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.
        </t>
      </section>
    </boilerplate>
    <toc>
      <section anchor="toc" numbered="false" removeInRFC="false" toc="exclude" pn="section-toc.1">
        <name slugifiedName="name-table-of-contents">Table of Contents</name>
        <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1">
          <li pn="section-toc.1-1.1">
            <t indent="0" keepWithNext="true" pn="section-toc.1-1.1.1"><xref derivedContent="1" format="counter" sectionFormat="of" target="section-1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-introduction">Introduction</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.1.2">
              <li pn="section-toc.1-1.1.2.1">
                <t indent="0" keepWithNext="true" pn="section-toc.1-1.1.2.1.1"><xref derivedContent="1.1" format="counter" sectionFormat="of" target="section-1.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-terminology-and-definitions">Terminology and Definitions</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.2">
            <t indent="0" keepWithNext="true" pn="section-toc.1-1.2.1"><xref derivedContent="2" format="counter" sectionFormat="of" target="section-2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-changes-to-rfc-7873">Changes to  RFC 7873</xref></t>
          </li>
          <li pn="section-toc.1-1.3">
            <t indent="0" pn="section-toc.1-1.3.1"><xref derivedContent="3" format="counter" sectionFormat="of" target="section-3"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-constructing-a-client-cooki">Constructing a Client Cookie</xref></t>
          </li>
          <li pn="section-toc.1-1.4">
            <t indent="0" pn="section-toc.1-1.4.1"><xref derivedContent="4" format="counter" sectionFormat="of" target="section-4"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-constructing-a-server-cooki">Constructing a Server Cookie</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.4.2">
              <li pn="section-toc.1-1.4.2.1">
                <t indent="0" pn="section-toc.1-1.4.2.1.1"><xref derivedContent="4.1" format="counter" sectionFormat="of" target="section-4.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-the-version-sub-field">The Version Sub-Field</xref></t>
              </li>
              <li pn="section-toc.1-1.4.2.2">
                <t indent="0" pn="section-toc.1-1.4.2.2.1"><xref derivedContent="4.2" format="counter" sectionFormat="of" target="section-4.2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-the-reserved-sub-field">The Reserved Sub-Field</xref></t>
              </li>
              <li pn="section-toc.1-1.4.2.3">
                <t indent="0" pn="section-toc.1-1.4.2.3.1"><xref derivedContent="4.3" format="counter" sectionFormat="of" target="section-4.3"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-the-timestamp-sub-field">The Timestamp Sub-Field</xref></t>
              </li>
              <li pn="section-toc.1-1.4.2.4">
                <t indent="0" pn="section-toc.1-1.4.2.4.1"><xref derivedContent="4.4" format="counter" sectionFormat="of" target="section-4.4"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-the-hash-sub-field">The Hash Sub-Field</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.5">
            <t indent="0" pn="section-toc.1-1.5.1"><xref derivedContent="5" format="counter" sectionFormat="of" target="section-5"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-updating-the-server-secret">Updating the Server Secret</xref></t>
          </li>
          <li pn="section-toc.1-1.6">
            <t indent="0" pn="section-toc.1-1.6.1"><xref derivedContent="6" format="counter" sectionFormat="of" target="section-6"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-cookie-algorithms">Cookie Algorithms</xref></t>
          </li>
          <li pn="section-toc.1-1.7">
            <t indent="0" pn="section-toc.1-1.7.1"><xref derivedContent="7" format="counter" sectionFormat="of" target="section-7"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-iana-considerations">IANA Considerations</xref></t>
          </li>
          <li pn="section-toc.1-1.8">
            <t indent="0" pn="section-toc.1-1.8.1"><xref derivedContent="8" format="counter" sectionFormat="of" target="section-8"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-security-and-privacy-consid">Security and Privacy Considerations</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.8.2">
              <li pn="section-toc.1-1.8.2.1">
                <t indent="0" pn="section-toc.1-1.8.2.1.1"><xref derivedContent="8.1" format="counter" sectionFormat="of" target="section-8.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-client-cookie-construction">Client Cookie Construction</xref></t>
              </li>
              <li pn="section-toc.1-1.8.2.2">
                <t indent="0" pn="section-toc.1-1.8.2.2.1"><xref derivedContent="8.2" format="counter" sectionFormat="of" target="section-8.2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-server-cookie-construction">Server Cookie Construction</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.9">
            <t indent="0" pn="section-toc.1-1.9.1"><xref derivedContent="9" format="counter" sectionFormat="of" target="section-9"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-references">References</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.9.2">
              <li pn="section-toc.1-1.9.2.1">
                <t indent="0" pn="section-toc.1-1.9.2.1.1"><xref derivedContent="9.1" format="counter" sectionFormat="of" target="section-9.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-normative-references">Normative References</xref></t>
              </li>
              <li pn="section-toc.1-1.9.2.2">
                <t indent="0" pn="section-toc.1-1.9.2.2.1"><xref derivedContent="9.2" format="counter" sectionFormat="of" target="section-9.2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-informative-references">Informative References</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.10">
            <t indent="0" pn="section-toc.1-1.10.1"><xref derivedContent="Appendix A" format="default" sectionFormat="of" target="section-appendix.a"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-test-vectors">Test Vectors</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.10.2">
              <li pn="section-toc.1-1.10.2.1">
                <t indent="0" pn="section-toc.1-1.10.2.1.1"><xref derivedContent="A.1" format="counter" sectionFormat="of" target="section-a.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-learning-a-new-server-cooki">Learning a New Server Cookie</xref></t>
              </li>
              <li pn="section-toc.1-1.10.2.2">
                <t indent="0" pn="section-toc.1-1.10.2.2.1"><xref derivedContent="A.2" format="counter" sectionFormat="of" target="section-a.2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-the-same-client-learning-a-">The Same Client Learning a Renewed (Fresh) Server Cookie</xref></t>
              </li>
              <li pn="section-toc.1-1.10.2.3">
                <t indent="0" pn="section-toc.1-1.10.2.3.1"><xref derivedContent="A.3" format="counter" sectionFormat="of" target="section-a.3"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-another-client-learning-a-r">Another Client Learning a Renewed Server Cookie</xref></t>
              </li>
              <li pn="section-toc.1-1.10.2.4">
                <t indent="0" pn="section-toc.1-1.10.2.4.1"><xref derivedContent="A.4" format="counter" sectionFormat="of" target="section-a.4"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-ipv6-query-with-rolled-over">IPv6 Query with Rolled Over Secret</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.11">
            <t indent="0" pn="section-toc.1-1.11.1"><xref derivedContent="Appendix B" format="default" sectionFormat="of" target="section-appendix.b"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-implementation-status">Implementation Status</xref></t>
          </li>
          <li pn="section-toc.1-1.12">
            <t indent="0" pn="section-toc.1-1.12.1"><xref derivedContent="" format="none" sectionFormat="of" target="section-appendix.c"/><xref derivedContent="" format="title" sectionFormat="of" target="name-acknowledgements">Acknowledgements</xref></t>
          </li>
          <li pn="section-toc.1-1.13">
            <t indent="0" pn="section-toc.1-1.13.1"><xref derivedContent="" format="none" sectionFormat="of" target="section-appendix.d"/><xref derivedContent="" format="title" sectionFormat="of" target="name-authors-addresses">Authors' Addresses</xref></t>
          </li>
        </ul>
      </section>
    </toc>
  </front>
  <middle>
    <section anchor="introduction" numbered="true" removeInRFC="false" toc="include" pn="section-1">
      <name slugifiedName="name-introduction">Introduction</name>
      <t indent="0" pn="section-1-1">DNS Cookies, as specified in <xref target="RFC7873" format="default" sectionFormat="of" derivedContent="RFC7873"/>, are a
lightweight DNS transaction security mechanism that provide limited protection
to DNS servers and clients against a variety of denial-of-service
amplification, forgery, or cache-poisoning attacks by off-path attackers. This
document specifies a means of producing interoperable cookies so that an
anycast server set including diverse implementations can be easily configured
to interoperate with standard clients.  Also, single-implementation or
non-anycast services can benefit from a well-studied standardized algorithm
for which the behavioral and security characteristics are more widely
known.</t>
      <t indent="0" pn="section-1-2">The threats considered for DNS Cookies and the properties of the DNS
Security features other than DNS Cookies are discussed in <xref target="RFC7873" format="default" sectionFormat="of" derivedContent="RFC7873"/>.</t>
      <t indent="0" pn="section-1-3">In <xref target="RFC7873" sectionFormat="of" section="6" format="default" derivedLink="https://rfc-editor.org/rfc/rfc7873#section-6" derivedContent="RFC7873"/>, for simplicity, it is 
"<bcp14>RECOMMENDED</bcp14> that the same Server Secret be used by
each DNS server in a set of anycast servers." However, how precisely a
Server Cookie is calculated from this Server Secret is left to the
implementation.</t>
      <t indent="0" pn="section-1-4">This guidance has led to a gallimaufry of DNS Cookie implementations,
calculating the Server Cookie in different ways. As a result, DNS Cookies
are impractical to deploy on multi-vendor anycast networks because even
when all DNS Software shares the same secret, as <bcp14>RECOMMENDED</bcp14> in <xref target="RFC7873" sectionFormat="of" section="6" format="default" derivedLink="https://rfc-editor.org/rfc/rfc7873#section-6" derivedContent="RFC7873"/>, the Server Cookie constructed by one implementation
cannot generally be validated by another.</t>
      <t indent="0" pn="section-1-5">There is no need for DNS client (resolver) Cookies to be interoperable
across different implementations. Each client need only be able to recognize
its own cookies. However, this document does contain recommendations for
constructing Client Cookies in a client-protecting fashion.</t>
      <section anchor="terminology-and-definitions" numbered="true" removeInRFC="false" toc="include" pn="section-1.1">
        <name slugifiedName="name-terminology-and-definitions">Terminology and Definitions</name>
        <t indent="0" pn="section-1.1-1">
    The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
    "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
    described in BCP 14 <xref target="RFC2119" format="default" sectionFormat="of" derivedContent="RFC2119"/> <xref target="RFC8174" format="default" sectionFormat="of" derivedContent="RFC8174"/> 
    when, and only when, they appear in all capitals, as shown here.
        </t>
        <t indent="0" pn="section-1.1-2">Note: "IP address" is used herein as a length-independent term covering
both IPv4 and IPv6 addresses.</t>
      </section>
    </section>
    <section anchor="changes" numbered="true" removeInRFC="false" toc="include" pn="section-2">
      <name slugifiedName="name-changes-to-rfc-7873">Changes to  RFC 7873</name>
      <t indent="0" pn="section-2-1">Appendices <xref target="RFC7873" sectionFormat="bare" section="A.1" format="default" derivedLink="https://rfc-editor.org/rfc/rfc7873#appendix-A.1" derivedContent="RFC7873"/> and <xref target="RFC7873" sectionFormat="bare" section="B.1" format="default" derivedLink="https://rfc-editor.org/rfc/rfc7873#appendix-B.1" derivedContent="RFC7873"/> of <xref target="RFC7873" format="default" sectionFormat="of" derivedContent="RFC7873"/> provide
example "simple" algorithms for computing Client and Server Cookies,
respectively.  These algorithms <bcp14>MUST NOT</bcp14> be used as the
resulting cookies are too weak when evaluated against modern security
standards.</t>
      <t indent="0" pn="section-2-2"><xref target="RFC7873" section="B.2" format="default" sectionFormat="of" derivedLink="https://rfc-editor.org/rfc/rfc7873#appendix-B.2" derivedContent="RFC7873"/> provides an example "more complex" server
algorithm. This algorithm is replaced by the interoperable specification in
<xref target="serverCookie" format="default" sectionFormat="of" derivedContent="Section 4"/> of this document, which <bcp14>MUST</bcp14> be used by Server Cookie
implementations.</t>
      <t indent="0" pn="section-2-3">This document has suggestions on Client Cookie construction in <xref target="clientCookie" format="default" sectionFormat="of" derivedContent="Section 3"/>.
The previous example in <xref target="RFC7873" section="A.2" format="default" sectionFormat="of" derivedLink="https://rfc-editor.org/rfc/rfc7873#appendix-A.2" derivedContent="RFC7873"/> is <bcp14>NOT RECOMMENDED</bcp14>.</t>
    </section>
    <section anchor="clientCookie" numbered="true" removeInRFC="false" toc="include" pn="section-3">
      <name slugifiedName="name-constructing-a-client-cooki">Constructing a Client Cookie</name>
      <t indent="0" pn="section-3-1">The Client Cookie acts as an identifier for a given client and its IP
address and needs to be unguessable. In order to provide minimal
authentication of the targeted server, a client <bcp14>MUST</bcp14> use a
different Client Cookie for each different Server IP address. This complicates
a server's ability to spoof answers for other DNS servers. The Client Cookie
<bcp14>SHOULD</bcp14> have 64 bits of entropy.</t>
      <t indent="0" pn="section-3-2">When a server does not support DNS Cookies, the client <bcp14>MUST NOT</bcp14> send the same
Client Cookie to that same server again. Instead, it is recommended that the
client does not send a Client Cookie to that server for a certain period
(for example, five minutes) before it retries with a new Client Cookie.</t>
      <t indent="0" pn="section-3-3">When a server does support DNS Cookies, the client should store the Client
Cookie alongside the Server Cookie it registered for that server.</t>
      <t indent="0" pn="section-3-4">Except for when the Client IP address changes, there is no need to change the
Client Cookie often. It is then reasonable to change the Client Cookie only if
it has been compromised or after a relatively long implementation-defined
period of time.  The time period should be no longer than a year, and in any
case, Client Cookies are not expected to survive a program restart.</t>
      <sourcecode type="" markers="false" pn="section-3-5">Client-Cookie = 64 bits of entropy
</sourcecode>
      <t indent="0" pn="section-3-6">Previously, the recommended algorithm to compute the Client Cookie included
the Client IP address as an input to a hashing function. However, when implementing
the DNS Cookies, several DNS vendors found it impractical to include the Client IP
as the Client Cookie is typically computed before the Client IP address is
known. Therefore, the requirement to put the Client IP address as input was
removed.</t>
      <t indent="0" pn="section-3-7">However, for privacy reasons, in order to prevent tracking of devices across
links and to not circumvent IPv6 Privacy Extensions <xref target="RFC8981" format="default" sectionFormat="of" derivedContent="RFC8981"/>, clients <bcp14>MUST NOT</bcp14> reuse a Client or Server Cookie after the Client IP address has changed.</t>
      <t indent="0" pn="section-3-8">One way to satisfy this requirement for non-reuse is to register the Client IP
address alongside the Server Cookie when it receives the Server Cookie.  In
subsequent queries to the server with that Server Cookie, the socket <bcp14>MUST</bcp14> be
bound to the Client IP address that was also used (and registered) when it
received the Server Cookie.  Failure to bind <bcp14>MUST</bcp14> then result in a new Client
Cookie.</t>
    </section>
    <section anchor="serverCookie" numbered="true" removeInRFC="false" toc="include" pn="section-4">
      <name slugifiedName="name-constructing-a-server-cooki">Constructing a Server Cookie</name>
      <t indent="0" pn="section-4-1">The Server Cookie is effectively a Message Authentication Code (MAC). 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 the server (or any other
 server from the anycast set) sent to that client in an earlier response and
 that appears as the Server Cookie field in the weakly authenticated request
 (see <xref sectionFormat="of" section="5.2" target="RFC7873" format="default" derivedLink="https://rfc-editor.org/rfc/rfc7873#section-5.2" derivedContent="RFC7873"/>).</t>
      <t indent="0" pn="section-4-2">DNS Cookies do not provide protection against "on-path"
adversaries (see <xref sectionFormat="of" section="9" target="RFC7873" format="default" derivedLink="https://rfc-editor.org/rfc/rfc7873#section-9" derivedContent="RFC7873"/>). An
on-path observer that has seen a Server Cookie for a client can abuse that
Server Cookie to spoof request for that client within the time span a Server
Cookie is valid (see <xref target="timestampField" format="default" sectionFormat="of" derivedContent="Section 4.3"/>).</t>
      <t indent="0" pn="section-4-3">



  The Server Cookie is calculated from the Client Cookie, a series of
  Sub-Fields specified below, the Client IP address, and a Server
  Secret that is known only to the server or only to the set of servers
  at the same anycast address.
</t>
      <t indent="0" pn="section-4-4">For calculation of the Server Cookie, a pseudorandom function is
<bcp14>RECOMMENDED</bcp14> with the property that an attacker that does not
know the Server Secret, cannot find (any information about) the Server Secret,
and cannot create a Server Cookie for any combination of the Client Cookie,
the series of Sub-Fields specified below, and the client IP address, for which
it has not seen a Server Cookie before. 

Because DNS servers need to use the pseudorandom function in order to verify
Server Cookies, it is <bcp14>RECOMMENDED</bcp14> that it be efficient to
calculate.

The pseudorandom function described in <xref target="SipHash-2-4" format="default" sectionFormat="of" derivedContent="SipHash-2-4"/> and
introduced in <xref target="hashField" format="default" sectionFormat="of" derivedContent="Section 4.4"/> of this document fits these
recommendations.</t>
      <t indent="0" pn="section-4-5">Changing the Server Secret regularly is <bcp14>RECOMMENDED</bcp14> but,
when a secure pseudorandom function is used, it need not be changed too
frequently.  Once a month, for example, would be adequate.  See <xref target="rollingSecret" format="default" sectionFormat="of" derivedContent="Section 5"/> on operator and implementation guidelines for
updating a Server Secret.</t>
      <t indent="0" pn="section-4-6">The 128-bit Server Cookie consists of the following Sub-Fields: a 1-octet Version Sub-Field,
a 3-octet Reserved Sub-Field, a 4-octet Timestamp Sub-Field, and an 8-octet Hash
Sub-Field.</t>
      <artwork type="ascii-art" align="left" pn="section-4-7"> 0                   1                   2                   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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    Version    |                   Reserved                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           Timestamp                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             Hash                              |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
      <section anchor="the-version-sub-field" numbered="true" removeInRFC="false" toc="include" pn="section-4.1">
        <name slugifiedName="name-the-version-sub-field">The Version Sub-Field</name>
        <t indent="0" pn="section-4.1-1">The Version Sub-Field prescribes the structure and Hash calculation formula.
This document defines Version 1 to be the structure and way to calculate the
Hash Sub-Field as defined in this section.</t>
      </section>
      <section anchor="the-reserved-sub-field" numbered="true" removeInRFC="false" toc="include" pn="section-4.2">
        <name slugifiedName="name-the-reserved-sub-field">The Reserved Sub-Field</name>
        <t indent="0" pn="section-4.2-1">The value of the Reserved Sub-Field is reserved for future versions of
server-side cookie construction.  On construction, it <bcp14>MUST</bcp14> be
set to zero octets.  On Server Cookie verification, the server <bcp14>MUST NOT</bcp14> enforce those fields to be zero, and the Hash should be computed
with the received value as described in <xref target="hashField" format="default" sectionFormat="of" derivedContent="Section 4.4"/>.</t>
      </section>
      <section anchor="timestampField" numbered="true" removeInRFC="false" toc="include" pn="section-4.3">
        <name slugifiedName="name-the-timestamp-sub-field">The Timestamp Sub-Field</name>
        <t indent="0" pn="section-4.3-1">The Timestamp value prevents Replay Attacks and <bcp14>MUST</bcp14> be
checked by the server to be within a defined period of time.  The DNS server
<bcp14>SHOULD</bcp14> allow cookies within a 1-hour period in the past and a
5-minute period into the future to allow operation of low-volume clients and
some limited time skew between the DNS servers in the anycast set.</t>
        <t indent="0" pn="section-4.3-2">The Timestamp value specifies a date and time in the form of a 32-bit
<strong>unsigned</strong> number of seconds elapsed since 1 January 1970
00:00:00 UTC, ignoring leap seconds, in network byte order.  All comparisons
involving these fields <bcp14>MUST</bcp14> use "Serial number
arithmetic", as defined in <xref target="RFC1982" format="default" sectionFormat="of" derivedContent="RFC1982"/>. <xref target="RFC1982" format="default" sectionFormat="of" derivedContent="RFC1982"/> specifies how the differences should be handled. This
handles any relative time window less than 68 years, at any time in the future
(2038, 2106, 2256, 22209, or later.)</t>
        <t indent="0" pn="section-4.3-3">The DNS server <bcp14>SHOULD</bcp14> generate a new Server Cookie at least if the received
Server Cookie from the client is more than half an hour old, but it <bcp14>MAY</bcp14>
generate a new cookie more often than that.</t>
      </section>
      <section anchor="hashField" numbered="true" removeInRFC="false" toc="include" pn="section-4.4">
        <name slugifiedName="name-the-hash-sub-field">The Hash Sub-Field</name>
        <t indent="0" pn="section-4.4-1">It's important that all the DNS servers use the same algorithm for computing
the Server Cookie.  This document defines the Version 1 of the server-side
algorithm to be:</t>
        <sourcecode type="" markers="false" pn="section-4.4-2">Hash = SipHash-2-4(
    Client Cookie | Version | Reserved | Timestamp | Client-IP,
    Server Secret )
</sourcecode>
        <t indent="0" pn="section-4.4-3">where "|" indicates concatenation.</t>
        <t indent="0" pn="section-4.4-4">Notice that Client-IP is used for hash generation even though it is not
included in the cookie value itself. Client-IP can be either 4 bytes for IPv4
or 16 bytes for IPv6. The length of all the concatenated elements (the input
into <xref target="SipHash-2-4" format="default" sectionFormat="of" derivedContent="SipHash-2-4"/>) <bcp14>MUST</bcp14> be either precisely 20 bytes in case of an IPv4
Client-IP or precisely 32 bytes in case of an IPv6 Client-IP.</t>
        <t indent="0" pn="section-4.4-5">When a DNS server receives a Server Cookie version 1 for validation, the length
of the received COOKIE option <bcp14>MUST</bcp14> be precisely 24 bytes: 8 bytes for the
Client Cookie plus 16 bytes for the Server Cookie. Verification of the length
of the received COOKIE option is <bcp14>REQUIRED</bcp14> to guarantee the length of the input
into <xref target="SipHash-2-4" format="default" sectionFormat="of" derivedContent="SipHash-2-4"/> to be precisely 20 bytes in the case of an IPv4 Client-IP and
precisely 32 bytes in the case of an IPv6 Client-IP. This ensures that the input
into <xref target="SipHash-2-4" format="default" sectionFormat="of" derivedContent="SipHash-2-4"/> is an injective function of the elements making up the
input, and thereby prevents data substitution attacks.  More specifically, this
prevents a 36-byte COOKIE option coming from an IPv4 Client-IP to be validated
as if it were coming from an IPv6 Client-IP.</t>
        <t indent="0" pn="section-4.4-6">The Server Secret <bcp14>MUST</bcp14> be configurable to make sure that servers in an anycast
network return consistent results.</t>
      </section>
    </section>
    <section anchor="rollingSecret" numbered="true" removeInRFC="false" toc="include" pn="section-5">
      <name slugifiedName="name-updating-the-server-secret">Updating the Server Secret</name>
      <t indent="0" pn="section-5-1">Changing the Server Secret regularly is <bcp14>RECOMMENDED</bcp14>.  All servers in an anycast
set must be able to verify the Server Cookies constructed by all other servers
in that anycast set at all times.  Therefore, it is vital that the Server Secret
is shared among all servers before it is used to generate Server Cookies on any
server.</t>
      <t indent="0" pn="section-5-2">Also, to maximize maintaining established relationships between clients and
servers, an old Server Secret should be valid for verification purposes for a
specific period.</t>
      <t indent="0" pn="section-5-3">To facilitate this, deployment of a new Server Secret <bcp14>MUST</bcp14> be done in three
stages:</t>
      <dl newline="true" indent="3" spacing="normal" pn="section-5-4">
        <dt pn="section-5-4.1">Stage 1</dt>
        <dd pn="section-5-4.2">
          <t indent="0" pn="section-5-4.2.1">
The new Server Secret is deployed on all the servers in an anycast set by
the operator.</t>
          <t indent="0" pn="section-5-4.2.2">Each server learns the new Server Secret but keeps using the previous Server
Secret to generate Server Cookies.</t>
          <t indent="0" pn="section-5-4.2.3">Server Cookies constructed with both the new Server Secret and the previous
Server Secret are considered valid when verifying.</t>
          <t indent="0" pn="section-5-4.2.4">After stage 1 is completed, all the servers in the anycast set have learned the
new Server Secret and can verify Server Cookies constructed with it, but keep
generating Server Cookies with the old Server Secret.</t>
        </dd>
        <dt pn="section-5-4.3">Stage 2</dt>
        <dd pn="section-5-4.4">
          <t indent="0" pn="section-5-4.4.1">
This stage is initiated by the operator after the Server Cookie is present
on all members in the anycast set.</t>
          <t indent="0" pn="section-5-4.4.2">When entering Stage 2, servers start generating Server Cookies with the new
Server Secret. The previous Server Secret is not yet removed/forgotten.</t>
          <t indent="0" pn="section-5-4.4.3">Server Cookies constructed with both the new Server Secret and the
previous Server Secret are considered valid when verifying.</t>
        </dd>
        <dt pn="section-5-4.5">Stage 3</dt>
        <dd pn="section-5-4.6">
          <t indent="0" pn="section-5-4.6.1">
This stage is initiated by the operator when it can be assumed that most
clients have obtained a Server Cookie derived from the new Server Secret.</t>
          <t indent="0" pn="section-5-4.6.2">With this stage, the previous Server Secret can be removed and <bcp14>MUST NOT</bcp14> be
used anymore for verifying.</t>
          <t indent="0" pn="section-5-4.6.3">It is <bcp14>RECOMMENDED</bcp14> that the operator wait, after initiating Stage 2
  and before initiating Stage 3, at least a period of time equal to
  the longest TTL in the zones served by the server plus 1 hour. 
</t>
          <t indent="0" pn="section-5-4.6.4">The operator <bcp14>SHOULD</bcp14> wait at least longer than the period clients are allowed
to use the same Server Cookie, which <bcp14>SHOULD</bcp14> be 1 hour (see <xref target="timestampField" format="default" sectionFormat="of" derivedContent="Section 4.3"/>).</t>
        </dd>
      </dl>
    </section>
    <section anchor="cookieAlgorithms" numbered="true" removeInRFC="false" toc="include" pn="section-6">
      <name slugifiedName="name-cookie-algorithms">Cookie Algorithms</name>
      <t indent="0" pn="section-6-1"><xref target="SipHash-2-4" format="default" sectionFormat="of" derivedContent="SipHash-2-4"/> is a pseudorandom function suitable as a Message Authentication
Code.  It is <bcp14>REQUIRED</bcp14> that a compliant DNS server use SipHash-2-4 as a
mandatory and default algorithm for DNS Cookies to ensure interoperability
between the DNS Implementations.</t>
      <t indent="0" pn="section-6-2">The construction method and pseudorandom function used in calculating and
verifying the Server Cookies are determined by the initial version byte and by
the length of the Server Cookie. Additional pseudorandom or construction
algorithms for Server Cookies might be added in the future.</t>
    </section>
    <section anchor="ianaConsiderations" numbered="true" removeInRFC="false" toc="include" pn="section-7">
      <name slugifiedName="name-iana-considerations">IANA Considerations</name>
      <t indent="0" pn="section-7-1">IANA has created a registry under the "Domain Name System (DNS) Parameters" heading as follows:</t>
      <dl indent="3" newline="false" spacing="normal" pn="section-7-2">
        <dt pn="section-7-2.1">Registry Name:
</dt>
        <dd pn="section-7-2.2">DNS Server Cookie Methods
</dd>
        <dt pn="section-7-2.3">Assignment Policy:
</dt>
        <dd pn="section-7-2.4">Expert Review
</dd>
        <dt pn="section-7-2.5">Reference:
</dt>
        <dd pn="section-7-2.6">[RFC9018], <xref target="RFC7873" format="default" sectionFormat="of" derivedContent="RFC7873"/>
        </dd>
        <dt pn="section-7-2.7">Note:
</dt>
        <dd pn="section-7-2.8">A Server Cookie method (construction and pseudorandom algorithm) is
determined by the Version in the first byte of the cookie and by the cookie
size. Server Cookie size is limited to the inclusive range of 8 to 32 bytes.
</dd>
      </dl>
      <table align="center" pn="table-1">
        <name slugifiedName="name-dns-server-cookie-methods">DNS Server Cookie Methods</name>
        <thead>
          <tr>
            <th align="right" colspan="1" rowspan="1">Version</th>
            <th align="right" colspan="1" rowspan="1">Size</th>
            <th align="left" colspan="1" rowspan="1">Method</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td align="right" colspan="1" rowspan="1">0</td>
            <td align="right" colspan="1" rowspan="1">8-32</td>
            <td align="left" colspan="1" rowspan="1">Reserved</td>
          </tr>
          <tr>
            <td align="right" colspan="1" rowspan="1">1</td>
            <td align="right" colspan="1" rowspan="1">8-15</td>
            <td align="left" colspan="1" rowspan="1">Unassigned</td>
          </tr>
          <tr>
            <td align="right" colspan="1" rowspan="1">1</td>
            <td align="right" colspan="1" rowspan="1">16</td>
            <td align="left" colspan="1" rowspan="1">SipHash-2-4 [RFC9018] <xref target="serverCookie" format="default" sectionFormat="of" derivedContent="Section 4"/></td>
          </tr>
          <tr>
            <td align="right" colspan="1" rowspan="1">1</td>
            <td align="right" colspan="1" rowspan="1">17-32</td>
            <td align="left" colspan="1" rowspan="1">Unassigned</td>
          </tr>
          <tr>
            <td align="right" colspan="1" rowspan="1">2-239</td>
            <td align="right" colspan="1" rowspan="1">8-32</td>
            <td align="left" colspan="1" rowspan="1">Unassigned</td>
          </tr>
          <tr>
            <td align="right" colspan="1" rowspan="1">240-254</td>
            <td align="right" colspan="1" rowspan="1">8-32</td>
            <td align="left" colspan="1" rowspan="1">Reserved for Private Use</td>
          </tr>
          <tr>
            <td align="right" colspan="1" rowspan="1">255</td>
            <td align="right" colspan="1" rowspan="1">8-32</td>
            <td align="left" colspan="1" rowspan="1">Reserved</td>
          </tr>
        </tbody>
      </table>
    </section>
    <section anchor="securityConsiderations" numbered="true" removeInRFC="false" toc="include" pn="section-8">
      <name slugifiedName="name-security-and-privacy-consid">Security and Privacy Considerations</name>
      <t indent="0" pn="section-8-1">DNS Cookies provide limited protection to DNS servers and clients against a
variety of denial-of-service amplification, forgery, or cache-poisoning attacks
by off-path attackers. They provide no protection against on-path adversaries
that can observe the plaintext DNS traffic. An on-path adversary that can
observe a Server Cookie for a client and server interaction can use that
Server Cookie for denial-of-service amplification, forgery, or cache-poisoning
attacks directed at that client for the lifetime of the Server Cookie.</t>
      <section anchor="client-cookie-construction" numbered="true" removeInRFC="false" toc="include" pn="section-8.1">
        <name slugifiedName="name-client-cookie-construction">Client Cookie Construction</name>
        <t indent="0" pn="section-8.1-1">In <xref target="RFC7873" format="default" sectionFormat="of" derivedContent="RFC7873"/>, it was <bcp14>RECOMMENDED</bcp14> to construct a Client Cookie by using a
pseudorandom function of the Client IP address, the Server IP address, and a
secret quantity known only to the client. The Client IP address was included to
ensure that a client could not be tracked if its IP address changes due to
privacy mechanisms or otherwise.</t>
        <t indent="0" pn="section-8.1-2">In this document, we changed Client Cookie construction to be just 64 bits of
entropy newly created for each new upstream server the client connects to.
As a consequence, additional care needs to be taken to prevent tracking of
clients.  To prevent tracking, a new Client Cookie for a server <bcp14>MUST</bcp14> be created
whenever the Client IP address changes.</t>
        <t indent="0" pn="section-8.1-3">Unfortunately, tracking Client IP address changes is impractical with servers
that do not support DNS Cookies. To prevent tracking of clients with non-DNS
Cookie-supporting servers, a client <bcp14>MUST NOT</bcp14> send a previously sent Client
Cookie to a server not known to support DNS Cookies. To prevent the creation of
a new Client Cookie for each query to a non-DNS Cookie-supporting server, it
is <bcp14>RECOMMENDED</bcp14> to not send a Client Cookie to that server for a certain period,
for example five minutes.</t>
        <t indent="0" pn="section-8.1-4">Summarizing:</t>
        <ul bare="false" empty="false" indent="3" spacing="normal" pn="section-8.1-5">
          <li pn="section-8.1-5.1">
            <t indent="0" pn="section-8.1-5.1.1">In order to provide minimal authentication, a client <bcp14>MUST</bcp14> use a
different Client Cookie for each different Server IP address.</t>
          </li>
          <li pn="section-8.1-5.2">
            <t indent="0" pn="section-8.1-5.2.1">To prevent tracking of clients, a new Client Cookie <bcp14>MUST</bcp14> be created
when the Client IP address changes.</t>
          </li>
          <li pn="section-8.1-5.3">
            <t indent="0" pn="section-8.1-5.3.1">To prevent tracking of clients by a non-DNS Cookie-supporting server,
a client <bcp14>MUST NOT</bcp14> send a previously sent Client Cookie to a server in the
absence of an associated Server Cookie.</t>
          </li>
        </ul>
        <t indent="0" pn="section-8.1-6">Note that it is infeasible for a client to detect a change in the public IP
address when the client is behind a routing device performing Network Address
Translation (NAT).  A server may track the public IP address of that routing
device performing the NAT. Preventing tracking of the public IP of a
NAT-performing routing device is beyond the scope of this document.</t>
      </section>
      <section anchor="server-cookie-construction" numbered="true" removeInRFC="false" toc="include" pn="section-8.2">
        <name slugifiedName="name-server-cookie-construction">Server Cookie Construction</name>
        <t indent="0" pn="section-8.2-1"><xref target="RFC7873" format="default" sectionFormat="of" derivedContent="RFC7873"/> did not give a precise recipe for constructing Server Cookies, but
it did recommend usage of a pseudorandom function strong enough to prevent
the guessing of cookies. In this document, SipHash-2-4 is assigned as the
pseudorandom function to be used for version 1 Server Cookies. SipHash-2-4 is
considered sufficiently strong for the immediate future, but predictions about
future development in cryptography and cryptanalysis are beyond the scope of
this document.</t>
        <t indent="0" pn="section-8.2-2">The precise structure of version 1 Server Cookies is defined in this
document.  A portion of the structure is made up of unhashed data elements
that are exposed in cleartext to an on-path observer. These unhashed data
elements are taken along as input to the SipHash-2-4 function of which the
result is the other portion of the Server Cookie, so the unhashed portion of
the Server Cookie cannot be changed by an on-path attacker without also
recalculating the hashed portion for which the Server Secret needs to be
known.

</t>
        <t indent="0" pn="section-8.2-3">One of the elements in the unhashed portion of version 1 Server Cookies is
a Timestamp used to prevent Replay Attacks.  Servers verifying version 1
Server Cookies need to have access to a reliable time value, one that cannot
be altered by an attacker, to compare with the Timestamp value. Furthermore,
all servers participating in an anycast set that validate version 1 Server
Cookies need to have their clocks synchronized.</t>
        <t indent="0" pn="section-8.2-4">
For an on-path adversary observing a Server Cookie (as mentioned in the first
paragraph of <xref target="securityConsiderations" format="default" sectionFormat="of" derivedContent="Section 8"/>), the cleartext Timestamp data element reveals the
lifetime during which the observed Server Cookie can be used to attack the
client.
</t>
        <t indent="0" pn="section-8.2-5">In addition to the Security Considerations in this section, the Security
Considerations section of <xref target="RFC7873" format="default" sectionFormat="of" derivedContent="RFC7873"/> still applies.</t>
      </section>
    </section>
  </middle>
  <back>
    <references pn="section-9">
      <name slugifiedName="name-references">References</name>
      <references pn="section-9.1">
        <name slugifiedName="name-normative-references">Normative References</name>
        <reference anchor="RFC1982" target="https://www.rfc-editor.org/info/rfc1982" quoteTitle="true" derivedAnchor="RFC1982">
          <front>
            <title>Serial Number Arithmetic</title>
            <author initials="R." surname="Elz" fullname="R. Elz">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="R." surname="Bush" fullname="R. Bush">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="1996" month="August"/>
            <abstract>
              <t indent="0">The DNS has long relied upon serial number arithmetic, a concept which has never really been defined, certainly not in an IETF document, though which has been widely understood.  This memo supplies the missing definition.  It is intended to update RFC1034 and RFC1035.  [STANDARDS-TRACK]</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="1982"/>
          <seriesInfo name="DOI" value="10.17487/RFC1982"/>
        </reference>
        <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119" quoteTitle="true" derivedAnchor="RFC2119">
          <front>
            <title>Key words for use in RFCs to Indicate Requirement Levels</title>
            <author initials="S." surname="Bradner" fullname="S. Bradner">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="1997" month="March"/>
            <abstract>
              <t indent="0">In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="2119"/>
          <seriesInfo name="DOI" value="10.17487/RFC2119"/>
        </reference>
        <reference anchor="RFC3339" target="https://www.rfc-editor.org/info/rfc3339" quoteTitle="true" derivedAnchor="RFC3339">
          <front>
            <title>Date and Time on the Internet: Timestamps</title>
            <author initials="G." surname="Klyne" fullname="G. Klyne">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="C." surname="Newman" fullname="C. Newman">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="2002" month="July"/>
            <abstract>
              <t indent="0">This document defines a date and time format for use in Internet protocols that is a profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="3339"/>
          <seriesInfo name="DOI" value="10.17487/RFC3339"/>
        </reference>
        <reference anchor="RFC7873" target="https://www.rfc-editor.org/info/rfc7873" quoteTitle="true" derivedAnchor="RFC7873">
          <front>
            <title>Domain Name System (DNS) Cookies</title>
            <author initials="D." surname="Eastlake 3rd" fullname="D. Eastlake 3rd">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="M." surname="Andrews" fullname="M. Andrews">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="2016" month="May"/>
            <abstract>
              <t indent="0">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.)</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="7873"/>
          <seriesInfo name="DOI" value="10.17487/RFC7873"/>
        </reference>
        <reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174" quoteTitle="true" derivedAnchor="RFC8174">
          <front>
            <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
            <author initials="B." surname="Leiba" fullname="B. Leiba">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="2017" month="May"/>
            <abstract>
              <t indent="0">RFC 2119 specifies common key words that may be used in protocol  specifications.  This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the  defined special meanings.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="8174"/>
          <seriesInfo name="DOI" value="10.17487/RFC8174"/>
        </reference>
        <reference anchor="SipHash-2-4" target="https://doi.org/10.1007/978-3-642-34931-7_28" quoteTitle="true" derivedAnchor="SipHash-2-4">
          <front>
            <title>SipHash: A Fast Short-Input PRF</title>
            <author fullname="Jean-Philippe Aumasson" initials="J." surname="Aumasson"/>
            <author fullname="Daniel J. Bernstein" initials="D. J." surname="Bernstein"/>
            <date year="2012" month="December"/>
          </front>
          <refcontent>Progress in Cryptology - INDOCRYPT 2012</refcontent>
          <refcontent>Lecture Notes in Computer Science, vol. 7668</refcontent>
        </reference>
      </references>
      <references pn="section-9.2">
        <name slugifiedName="name-informative-references">Informative References</name>
        <reference anchor="RFC8981" target="https://www.rfc-editor.org/info/rfc8981" quoteTitle="true" derivedAnchor="RFC8981">
          <front>
            <title>Temporary Address Extensions for Stateless Address Autoconfiguration in IPv6</title>
            <author initials="F." surname="Gont" fullname="F. Gont">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="S." surname="Krishnan" fullname="S. Krishnan">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="T." surname="Narten" fullname="T. Narten">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="R." surname="Draves" fullname="R. Draves">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="2021" month="February"/>
            <abstract>
              <t indent="0">This document describes an extension to IPv6 Stateless Address Autoconfiguration that causes hosts to generate temporary addresses with randomized interface identifiers for each prefix advertised with autoconfiguration enabled. Changing addresses over time limits the window of time during which eavesdroppers and other information collectors may trivially perform address-based network-activity correlation when the same address is employed for multiple transactions by the same host. Additionally, it reduces the window of exposure of a host as being accessible via an address that becomes revealed as a result of active communication. This document obsoletes RFC 4941.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="8981"/>
          <seriesInfo name="DOI" value="10.17487/RFC8981"/>
        </reference>
      </references>
    </references>
    <section anchor="testVectors" numbered="true" removeInRFC="false" toc="include" pn="section-appendix.a">
      <name slugifiedName="name-test-vectors">Test Vectors</name>
      <section anchor="learning-a-new-server-cookie" numbered="true" removeInRFC="false" toc="include" pn="section-a.1">
        <name slugifiedName="name-learning-a-new-server-cooki">Learning a New Server Cookie</name>
        <t indent="0" pn="section-a.1-1">A resolver (client) sending from IPv4 address 198.51.100.100 sends a query for
<tt>example.com</tt> to an authoritative server listening on 192.0.2.53 from
which it has not yet learned the server cookie.</t>
        <t indent="0" pn="section-a.1-2">The DNS requests and replies shown in this appendix are in a "dig"-like format.
The content of the DNS COOKIE Option is shown in hexadecimal format after
<tt>; COOKIE:</tt>.</t>
        <sourcecode type="" markers="false" pn="section-a.1-3">;; Sending:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 57406
;; flags:; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 2464c4abcf10c957
;; QUESTION SECTION:
;example.com.                IN      A

;; QUERY SIZE: 52
</sourcecode>
        <t indent="0" pn="section-a.1-4">The authoritative nameserver (server) is configured with the following secret:
e5e973e5a6b2a43f48e7dc849e37bfcf (as hex data).</t>
        <t indent="0" pn="section-a.1-5">It receives the query on Wed Jun  5 10:53:05 UTC 2019.</t>
        <t indent="0" pn="section-a.1-6">The content of the DNS COOKIE Option that the server will return is shown
below in hexadecimal format after <tt>; COOKIE:</tt>.</t>
        <t indent="0" pn="section-a.1-7">The Timestamp field <xref target="timestampField" format="default" sectionFormat="of" derivedContent="Section 4.3"/> in the returned Server Cookie has value
1559731985. In the format described in <xref target="RFC3339" format="default" sectionFormat="of" derivedContent="RFC3339"/>, this is 2019-06-05 10:53:05+00:00.</t>
        <sourcecode type="" markers="false" pn="section-a.1-8">;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 57406
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 2464c4abcf10c957010000005cf79f111f8130c3eee29480 (good)
;; QUESTION SECTION:
;example.com.                IN      A

;; ANSWER SECTION:
example.com.         86400   IN      A       192.0.2.34

;; Query time: 6 msec
;; SERVER: 192.0.2.53#53(192.0.2.53)
;; WHEN: Wed Jun  5 10:53:05 UTC 2019
;; MSD SIZE  rcvd: 84
</sourcecode>
      </section>
      <section anchor="the-same-client-learning-a-renewed-fresh-server-cookie" numbered="true" removeInRFC="false" toc="include" pn="section-a.2">
        <name slugifiedName="name-the-same-client-learning-a-">The Same Client Learning a Renewed (Fresh) Server Cookie</name>
        <t indent="0" pn="section-a.2-1">40 minutes later, the same resolver (client) queries the same server for
<tt>example.org</tt>. It reuses the Server Cookie it learned in the previous
query.</t>
        <t indent="0" pn="section-a.2-2">The Timestamp field in that previously learned Server Cookie, which is now sent
along in the request, was and is 1559731985. In the format of <xref target="RFC3339" format="default" sectionFormat="of" derivedContent="RFC3339"/>, this is
2019-06-05 10:53:05+00:00.</t>
        <sourcecode type="" markers="false" pn="section-a.2-3">;; Sending:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 50939
;; flags:; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 2464c4abcf10c957010000005cf79f111f8130c3eee29480
;; QUESTION SECTION:
;example.org.                IN      A

;; QUERY SIZE: 52
</sourcecode>
        <t indent="0" pn="section-a.2-4">The authoritative nameserver (server) now generates a new Server Cookie.
The server <bcp14>SHOULD</bcp14> do this because it can see the Server Cookie
sent by the client is older than half an hour (<xref target="timestampField" format="default" sectionFormat="of" derivedContent="Section 4.3"/>), but it is also fine for a server to generate
a new Server Cookie sooner or even for every answer.</t>
        <t indent="0" pn="section-a.2-5">The Timestamp field in the returned new Server Cookie has value 1559734385,
which, in the format of <xref target="RFC3339" format="default" sectionFormat="of" derivedContent="RFC3339"/>, is 2019-06-05 11:33:05+00:00.</t>
        <sourcecode type="" markers="false" pn="section-a.2-6">;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 50939
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 2464c4abcf10c957010000005cf7a871d4a564a1442aca77 (good)
;; QUESTION SECTION:
;example.org.                IN      A

;; ANSWER SECTION:
example.org.         86400   IN      A       192.0.2.34

;; Query time: 6 msec
;; SERVER: 192.0.2.53#53(192.0.2.53)
;; WHEN: Wed Jun  5 11:33:05 UTC 2019
;; MSD SIZE  rcvd: 84
</sourcecode>
      </section>
      <section anchor="another-client-learning-a-renewed-server-cookie" numbered="true" removeInRFC="false" toc="include" pn="section-a.3">
        <name slugifiedName="name-another-client-learning-a-r">Another Client Learning a Renewed Server Cookie</name>
        <t indent="0" pn="section-a.3-1">Another resolver (client) with IPv4 address 203.0.113.203 sends a request to
the same server with a valid Server Cookie that it learned before
(on Wed Jun  5 09:46:25 UTC 2019).</t>
        <t indent="0" pn="section-a.3-2">The Timestamp field of the Server Cookie in the request has value 1559727985,
which, in the format of <xref target="RFC3339" format="default" sectionFormat="of" derivedContent="RFC3339"/>, is 2019-06-05 09:46:25+00:00.</t>
        <t indent="0" pn="section-a.3-3">Note that the Server Cookie has Reserved bytes set but is still valid with the
configured secret; the Hash part is calculated taking along the Reserved bytes.</t>
        <sourcecode type="" markers="false" pn="section-a.3-4">;; Sending:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 34736
;; flags:; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: fc93fc62807ddb8601abcdef5cf78f71a314227b6679ebf5
;; QUESTION SECTION:
;example.com.                IN      A

;; QUERY SIZE: 52
</sourcecode>
        <t indent="0" pn="section-a.3-5">The authoritative nameserver (server) replies with a freshly generated Server
Cookie for this client conformant with this specification, i.e., with the Reserved
bits set to zero.</t>
        <t indent="0" pn="section-a.3-6">The Timestamp field in the returned new Server Cookie has value 1559734700,
which, in the format of <xref target="RFC3339" format="default" sectionFormat="of" derivedContent="RFC3339"/>, is 2019-06-05 11:38:20+00:00.</t>
        <sourcecode type="" markers="false" pn="section-a.3-7">;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 34736
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: fc93fc62807ddb86010000005cf7a9acf73a7810aca2381e (good)
;; QUESTION SECTION:
;example.com.                IN      A

;; ANSWER SECTION:
example.com.         86400   IN      A       192.0.2.34

;; Query time: 6 msec
;; SERVER: 192.0.2.53#53(192.0.2.53)
;; WHEN: Wed Jun  5 11:38:20 UTC 2019
;; MSD SIZE  rcvd: 84
</sourcecode>
      </section>
      <section anchor="ipv6-query-with-rolled-over-secret" numbered="true" removeInRFC="false" toc="include" pn="section-a.4">
        <name slugifiedName="name-ipv6-query-with-rolled-over">IPv6 Query with Rolled Over Secret</name>
        <t indent="0" pn="section-a.4-1">The query below is from a client with IPv6 address 2001:db8:220:1:59de:d0f4:8769:82b8 to a server
with IPv6 address 2001:db8:8f::53.  The client has learned a valid Server Cookie
before (on Wed Jun  5 13:36:57 UTC 2019) when the Server had the secret:
dd3bdf9344b678b185a6f5cb60fca715.  The server now uses a new secret, but it can still validate
the Server Cookie provided by the client as the old secret has not expired yet.</t>
        <t indent="0" pn="section-a.4-2">The Timestamp field in the Server Cookie in the request has value
1559741817, which, in the format of <xref target="RFC3339" format="default" sectionFormat="of" derivedContent="RFC3339"/>, is 2019-06-05 13:36:57+00:00.</t>
        <sourcecode type="" markers="false" pn="section-a.4-3">;; Sending:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 6774
;; flags:; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 22681ab97d52c298010000005cf7c57926556bd0934c72f8
;; QUESTION SECTION:
;example.net.                IN      A

;; QUERY SIZE: 52
</sourcecode>
        <t indent="0" pn="section-a.4-4">The authoritative nameserver (server) replies with a freshly generated server
cookie for this client with its new secret: 445536bcd2513298075a5d379663c962.</t>
        <t indent="0" pn="section-a.4-5">The Timestamp field in the returned new Server Cookie has value 1559741961,
which, in the format of <xref target="RFC3339" format="default" sectionFormat="of" derivedContent="RFC3339"/>, is
2019-06-05 13:39:21+00:00.</t>
        <sourcecode type="" markers="false" pn="section-a.4-6">;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 6774
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 22681ab97d52c298010000005cf7c609a6bb79d16625507a (good)
;; QUESTION SECTION:
;example.net.                IN      A

;; ANSWER SECTION:
example.net.         86400   IN      A       192.0.2.34

;; Query time: 6 msec
;; SERVER: 2001:db8:8f::53#53(2001:db8:8f::53)
;; WHEN: Wed Jun  5 13:36:57 UTC 2019
;; MSD SIZE  rcvd: 84
</sourcecode>
      </section>
    </section>
    <section anchor="implementation-status" numbered="true" removeInRFC="false" toc="include" pn="section-appendix.b">
      <name slugifiedName="name-implementation-status">Implementation Status</name>
      <t indent="0" pn="section-appendix.b-1">At the time of writing, BIND from version 9.16 and Knot DNS from version 2.9.0
create Server Cookies according to the recipe described in this document. Unbound
and NSD have a Proof-of-Concept implementation that has been tested for
interoperability during the hackathon at IETF 104 in Prague.  Construction
of privacy maintaining Client Cookies according to the directions in this document
have been implemented in the getdns library and will be in the upcoming
getdns-1.6.1 release and in Stubby version 0.3.1.</t>
    </section>
    <section anchor="acknowledgements" numbered="false" removeInRFC="false" toc="include" pn="section-appendix.c">
      <name slugifiedName="name-acknowledgements">Acknowledgements</name>
      <t indent="0" pn="section-appendix.c-1">Thanks to <contact fullname="Witold Krecicki"/> and <contact fullname="Pieter Lexis"/> for valuable input, suggestions, text, and above
all for implementing a prototype of an interoperable DNS Cookie in Bind9, Knot,
and PowerDNS during the hackathon at IETF 104 in Prague.  Thanks for valuable
input and suggestions go to <contact fullname="Ralph Dolmans"/>, <contact fullname="Bob Harold"/>, <contact fullname="Daniel Salzman"/>, <contact fullname="Martin Hoffmann"/>, <contact fullname="Mukund Sivaraman"/>, <contact fullname="Petr Spacek"/>, <contact fullname="Loganaden Velvindron"/>, <contact fullname="Bob Harold"/>, <contact fullname="Philip Homburg"/>, <contact fullname="Tim Wicinski"/>, and <contact fullname="Brian Dickson"/>.</t>
    </section>
    <section anchor="authors-addresses" numbered="false" removeInRFC="false" toc="include" pn="section-appendix.d">
      <name slugifiedName="name-authors-addresses">Authors' Addresses</name>
      <author initials="O." surname="Sury" fullname="Ondrej Sury">
        <organization showOnFrontPage="true">Internet Systems Consortium</organization>
        <address>
          <postal>
            <street/>
            <country>CZ</country>
          </postal>
          <email>ondrej@isc.org</email>
        </address>
      </author>
      <author initials="W." surname="Toorop" fullname="Willem Toorop">
        <organization showOnFrontPage="true">NLnet Labs</organization>
        <address>
          <postal>
            <street>Science Park 400</street>
            <city>Amsterdam</city>
            <code>1098 XH</code>
            <country>Netherlands</country>
          </postal>
          <email>willem@nlnetlabs.nl</email>
        </address>
      </author>
      <author initials="D." surname="Eastlake 3rd" fullname="Donald E. Eastlake 3rd">
        <organization showOnFrontPage="true">Futurewei Technologies</organization>
        <address>
          <postal>
            <street>2386 Panoramic Circle</street>
            <city>Apopka</city>
            <code>FL 32703</code>
            <country>United States of America</country>
          </postal>
          <phone>+1-508-333-2270</phone>
          <email>d3e3e3@gmail.com</email>
        </address>
      </author>
      <author initials="M." surname="Andrews" fullname="Mark Andrews">
        <organization showOnFrontPage="true">Internet Systems Consortium</organization>
        <address>
          <postal>
            <street>950 Charter Street</street>
            <city>Redwood City</city>
            <code>CA 94063</code>
            <country>United States of America</country>
          </postal>
          <email>marka@isc.org</email>
        </address>
      </author>
    </section>
  </back>
</rfc>
