<?xml version="1.0" encoding="US-ASCII"?>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>

<!DOCTYPE rfc SYSTEM 'rfc2629.dtd' [
  <!ENTITY rfc1034 PUBLIC '' 
    'http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.1034.xml'>
  <!ENTITY rfc1035 PUBLIC ''
    'http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.1035.xml'>
  <!ENTITY rfc2119 PUBLIC ''
    'http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml'>
  <!ENTITY rfc5358 PUBLIC ''
    'http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5358.xml'>
  <!ENTITY rfc6895 PUBLIC ''
    'http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6895.xml'>
  <!ENTITY rfc7719 PUBLIC ''
    'http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7719.xml'>
  <!ENTITY rfc8174 PUBLIC ''
    'http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml'>
  <!ENTITY rfc8499 PUBLIC ''
    'http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8499.xml'>
]>

<rfc number="8482" category="std" submissionType="IETF" consensus="yes" ipr="trust200902" updates="1034, 1035"
 >

  <?rfc toc="yes" ?>
  <?rfc compact="yes"?>
  <?rfc subcompact="no"?>
  <?rfc symrefs="yes" ?>
  <?rfc sortrefs="yes"?>
  <?rfc iprnotified="no" ?>
  <?rfc strict="yes" ?>


  <front>
    <title abbrev="Minimal Responses for ANY Queries">Providing
      Minimal-Sized Responses to DNS Queries That Have QTYPE=ANY</title>

    <author initials='J.' surname="Abley" fullname='Joe Abley'>
      <organization>Afilias</organization>
      <address>
        <postal>
          <street>300-184 York Street</street>
          <city>London</city>
          <region>ON</region>
          <code>N6A 1B5</code>
          <country>Canada</country>
        </postal>
        <phone>+1 519 670 9327</phone>
        <email>jabley@afilias.info</email>
      </address>
    </author>

    <author initials="O." surname="Gudmundsson" fullname="Olafur Gudmundsson">
      <organization>Cloudflare Inc.</organization>
      <address>
        <email>olafur+ietf@cloudflare.com</email>
      </address>
    </author>

    <author initials="M." surname="Majkowski" fullname="Marek Majkowski">
      <organization>Cloudflare Inc.</organization>
      <address>
        <email>marek@cloudflare.com</email>
      </address>
    </author>

    <author initials="E." surname="Hunt" fullname="Evan Hunt">
     <organization>ISC</organization> 
     <address>
       <postal>
         <street>950 Charter St</street>
         <city>Redwood City</city> <region>CA</region>
         <code>94063</code>
         <country>United States of America</country>
       </postal>
       <email>each@isc.org</email>
     </address>
    </author>

    <date  month="January" year="2019"/>


    <abstract>
      <t>The Domain Name System (DNS) specifies a query type (QTYPE)
        "ANY". The operator of an authoritative DNS server might
        choose not to respond to such queries for reasons of local
        policy, motivated by security, performance, or other
        reasons.</t>

      <t>The DNS specification does not include specific guidance for the
	behavior of DNS servers or clients in this situation.  This
	document aims to provide such guidance.</t>

      <t>This document updates RFCs 1034 and 1035.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>The Domain Name System (DNS) specifies a query type (QTYPE)
	"ANY". The operator of an authoritative DNS server might
	choose not to respond to such queries for reasons of local
	policy, motivated by security, performance, or other
	reasons.</t>

      <t>The DNS specification <xref target="RFC1034"/> <xref
        target="RFC1035"/> does not include specific guidance for
        the behavior of DNS servers or clients in this situation.
        This document aims to provide such guidance.</t>

      <section title="Terminology">
        <t>This document uses terminology specific to the Domain
          Name System (DNS), descriptions of which can be found in
          <xref target="RFC8499"/>.</t>

<t>
<xref target="RFC1035"/> defined type 255 to be "*". However, DNS implementations commonly
use the keyword "ANY" to refer to that type code; this document follows that
common usage.
</t>

        <t>In this document, "ANY query" refers to a DNS meta-query
          with QTYPE=ANY. An "ANY response" is a response to such
          a query.</t>

	<t>In this document, "conventional ANY response" means an
	  ANY response that is constructed in accordance with the
	  algorithm documented in Section 4.3.2 of <xref
	  target="RFC1034"/> and specifically without implementing
	  any of the mechanisms described in this document.</t>

        <t>In an exchange of DNS messages between two hosts, this
          document refers to the host sending a DNS request as the
          "initiator" and the host sending a DNS response as the
          "responder".</t>

        <t>
    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 BCP&nbsp;14 <xref target="RFC2119"/> <xref target="RFC8174"/> 
    when, and only when, they appear in all capitals, as shown here.
        </t>

      </section>
    </section>

    <section title="Motivations for Use of ANY Queries">
      <t>ANY queries are legitimately used for debugging and checking
        the state of a DNS server for a particular name.</t>

      <t>ANY queries are sometimes used as an attempt to reduce the
        number of queries needed to get information, e.g., to obtain
        MX, A, and AAAA resource record sets (RRsets) for a mail domain in a single query.
        However, there is no documented guidance available for this use case,
        and some implementations have been observed not
        to function as their developers expected.  If implementers
        assume that an ANY query will ultimately be received
        by an authoritative server and will fetch all existing
        RRsets, they should include a fallback mechanism to use when
        that does not happen.</t>

      <t>ANY queries are frequently used to exploit the amplification
        potential of DNS servers and resolvers using spoofed source
        addresses and UDP transport (see <xref target="RFC5358"/>).
        Having the ability to return small responses to such queries
        makes DNS servers less attractive amplifiers.</t>

      <t>ANY queries are sometimes used to help mine authoritative-only
        DNS servers for zone data, since they are expected to return
        all RRsets for a particular query name. If DNS operators
        prefer to reduce the potential for information leaks, they
        might choose not to send large ANY responses.</t>

      <t>Some authoritative-only DNS server implementations require
        additional processing in order to send a conventional ANY
        response; avoiding that processing expense might be
        desirable.</t>
    </section>

    <section title="General Approach"> 
      <t>
   This proposal provides a mechanism for an authoritative DNS server
   to signal that conventional ANY queries are not supported
   for a particular QNAME. It does so in a way that is 
   both compatible with and triggers desirable behavior by 
   unmodified clients (e.g., DNS resolvers).
</t>


      <t>Alternative proposals for dealing with ANY queries have
        been discussed. One approach proposes using a new RCODE to
        signal that an authoritative server did not answer ANY
        queries in the standard way. 

   This approach was found to have an undesirable effect on both
   resolvers and authoritative-only servers; resolvers receiving an
   unknown RCODE would resend the same query to all available
   authoritative servers rather than suppress future ANY queries
   for the same QNAME.
</t>

      <t>The proposal described in this document avoids that outcome by returning a non-empty
        RRset in the ANY response, which provides resolvers with something
        to cache and effectively suppresses repeat queries to the
        same or different authoritative DNS servers.</t>
    </section>

   <section title="Behavior of DNS Responders" anchor="responder">
      <t>Below are the three different modes of behavior by DNS
        responders when processing queries with QNAMEs that exist,
        QCLASS=IN, and QTYPE=ANY.  Operators and implementers are free
        to choose whichever mechanism best suits their environment.

        <list style="numbers">
          <t>A DNS responder can choose to select one or a larger
            subset of the available RRsets at the QNAME.</t>

          <t>A DNS responder can return a synthesized HINFO resource
            record. See <xref target="hinfo"/> for discussion of
            the use of HINFO.</t>

          <t>A resolver can try to give out the most likely records
            the requester wants. This is not always possible, and
            the result might well be a large response.</t>
        </list>
      </t>

      <t>Except as described below in this section, the DNS responder
        MUST follow the standard algorithms when constructing a
        response.</t>

      <section title="Answer with a Subset of Available RRsets"
        anchor="answer1">
        <t>A DNS responder that receives an ANY query MAY decline
          to provide a conventional ANY response or MAY instead send
          a response with a single RRset (or a larger subset of
          available RRsets) in the answer section.</t>

        <t>The RRsets returned in the answer section of the response
          MAY consist of a single RRset owned by the name specified
          in the QNAME. Where multiple RRsets exist, the responder
          SHOULD choose a small subset of those available to reduce
          the amplification potential of the response.</t>

        <t>If the zone is signed, appropriate RRSIG records MUST
          be included in the answer.</t>

	<t>Note that this mechanism does not provide any signaling
	  to indicate to a client that an incomplete subset of the
	  available RRsets has been returned.</t>
      </section>

      <section title="Answer with a Synthesized HINFO RRset"
        anchor="answer2">
        <t>If there is no CNAME present at the owner name matching
          the QNAME, the resource record returned in the response
          MAY instead be synthesized. In this case, a single HINFO
          resource record SHOULD be returned.  

The CPU field of the
          HINFO RDATA SHOULD be set to "RFC8482". The
          OS field of the HINFO RDATA SHOULD be set to the null
          string to minimize the size of the response.</t>

        <t>The TTL encoded for the synthesized HINFO resource record SHOULD be
          chosen by the operator of the DNS responder to be large
          enough to suppress frequent subsequent ANY queries from
          the same initiator with the same QNAME, understanding
          that a TTL that is too long might make policy changes
          relating to ANY queries difficult to change in the future.

The specific value used SHOULD be configurable by the operator of the
nameserver according to local policy, based on the familiar considerations
involved in choosing a TTL value for any resource record in any zone.
</t>

        <t>If the DNS query includes DO=1 and the QNAME corresponds
          to a zone that is known by the responder to be signed, a
          valid RRSIG for the RRsets in the answer (or authority
          if answer is empty) section MUST be returned.  In the
          case of DO=0, the RRSIG SHOULD be omitted.</t>

        <t>A system that receives an HINFO response SHOULD NOT
	  infer that the response was generated according to this
	  specification and apply any special processing of the
	  response because, in general, it is not possible to tell
          with certainty whether the HINFO RRset received was
	  synthesized. In particular, systems SHOULD NOT rely upon
          the HINFO RDATA described in this section to distinguish
          between synthesized and non-synthesized HINFO RRsets.</t>
      </section>

      <section title="Answer with Best Guess as to Intention">
        <t>In some cases, it is possible to guess what the initiator
	  wants in the answer (but not always). Some implementations
	  have implemented the spirit of this document by returning
	  all RRsets of RRTYPE CNAME, MX, A, and AAAA that are present
	  at the owner name while suppressing others. This heuristic
	  seems to work well in practice; it satisfies the needs of
	  some applications whilst suppressing other RRsets such
	  as TXT and DNSKEY that can often contribute to large
	  responses. Whilst some applications may be satisfied by
	  this behavior, the resulting responses in the general
	  case are larger than in the approaches described in Sections <xref
	  target="answer1" format="counter"/> and <xref target="answer2" format="counter"/>.</t>

	<t>As before, if the zone is signed and the DO bit is set
	  on the corresponding query, an RRSIG RRset MUST be included
	  in the response.</t>
      </section>

      <section title="Transport Considerations">
        <t>A DNS responder MAY behave differently when processing
          ANY queries received over different transports, e.g., by
          providing a conventional ANY response over TCP whilst
          using one of the other mechanisms specified in this document
          in the case where a query was received using UDP.</t>

        <t>
Implementers MAY provide configuration options to allow operators to specify
different behaviour over different transports.
</t>
      </section>
    </section>

    <section title="Behavior of DNS Initiators">
      <t>A DNS initiator that sends a query with QTYPE=ANY and
        receives a response containing an HINFO resource record or
        a single RRset, as described in <xref target="responder"/>,
        MAY cache the response in the normal way. Such cached
        resource records SHOULD be retained in the cache following
        normal caching semantics, as with any other response
        received from a DNS responder.</t>

      <t>A DNS initiator MAY suppress queries with QTYPE=ANY in the
        event that the local cache contains a matching HINFO resource
        record with the CPU field of the HINFO RDATA, as described in <xref
        target="responder"/>.  A DNS initiator MAY instead respond to
        such queries with the contents of the local cache in the usual
        way.</t>
    </section>

    <section title="HINFO Considerations" anchor="hinfo">
      <t>It is possible that the synthesized HINFO RRset in an ANY
        response, once cached by the initiator, might suppress
        subsequent queries from the same initiator with QTYPE=HINFO.
        Thus, the use of HINFO in this proposal would
        effectively mask the HINFO RRset present in the zone.</t>

      <t>Operators of authoritative servers who serve zones that rely upon
        conventional use of the HINFO RRTYPE SHOULD sensibly choose
        the "single RRset" method described in this document or
        select another type.</t>

      <t>The HINFO RRTYPE is believed to be rarely used in the DNS
        at the time of writing, based on observations made in passive DNS and at
        recursive and authoritative DNS servers.</t>
    </section>

    <section title="Updates to RFCs 1034 and 1035">

      <t>This document extends the specification for processing ANY
	queries described in Section 4.3.2 of <xref target="RFC1034"/>.</t>

      <t>It is important to note that returning a subset of available
	RRsets when processing an ANY query is legitimate and
	consistent with <xref target="RFC1035"/>; it can be argued
	that ANY does not always mean ALL, as used in Section 3.2.3
	of <xref target="RFC1035"/>. 
   The main difference here is that
   the TC bit SHOULD NOT be set in the response, thus indicating that this is
   not a complete answer.

</t>

      <t>This document describes optional behavior for both DNS
        initiators and responders; implementation of the guidance
        provided by this document is OPTIONAL.</t>

      <t>RRSIG queries (i.e., queries with QTYPE=RRSIG) are similar to
        ANY queries in the sense that they have the potential to
        generate large responses as well as extra work for the
        responders that process them, e.g., in the case where
        signatures are generated on the fly. RRSIG RRsets are not
        usually obtained using such explicit queries but are rather
        included in the responses for other RRsets that the RRSIGs
        cover. This document does not specify appropriate behavior
        for RRSIG queries; however, future such advice might
        well benefit from consistency with and experience with the
        approaches for ANY queries described here.</t>
    </section>

    <section title="Implementation Experience"> 
      <t>In October 2015, the Cloudflare authoritative nameserver
        implementation implemented the HINFO response. A few minor
        problems were reported and have since been resolved.</t>

      <t>An implementation of the subset-mode response to ANY queries
        was implemented in NSD 4.1 in 2016.</t>

      <t>An implementation of a single RRset response to an ANY query
        was made for BIND9 by Tony Finch, and that functionality
        was subsequently made available in production releases
        starting in BIND 9.11.</t>
    </section>

    <section title="Security Considerations">
      <t>Queries with QTYPE=ANY are frequently observed as part of
        reflection attacks, since a relatively small query can be
        used to elicit a large response. This is a desirable
        characteristic if the goal is to maximize the amplification
        potential of a DNS server as part of a volumetric attack.
        The ability of a DNS operator to suppress such responses
        on a particular server makes that server a less useful
        amplifier.</t>

      <t>The optional behavior described in this document to reduce
        the size of responses to queries with QTYPE=ANY is compatible
        with the use of DNSSEC by both initiator and responder.</t>
    </section>

    <section title="IANA Considerations">
      <t>IANA has updated the following entry in the
        "Resource Record (RR) TYPEs" registry <xref target="RR_TYPES"/>:</t>

      <texttable>
        <ttcol>TYPE</ttcol>
        <ttcol>Value</ttcol>
        <ttcol>Meaning</ttcol>
        <ttcol>Reference</ttcol>

        <c>*</c>
        <c>255</c>
        <c>A request for some or all records the server has available</c>
        <c><xref target="RFC1035"/><xref target="RFC6895"/>
          [RFC8482]</c>
      </texttable>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      &rfc1034;
      &rfc1035;
      &rfc2119;
      &rfc8174;
    </references>

   <references title="Informative References">
      &rfc5358;
      &rfc6895;

<!-- RFC 7719 obsoleted by RFC 8499 -->

&rfc8499;



<reference anchor="RR_TYPES"
           target="https://www.iana.org/assignments/dns-parameters">
  <front>
    <title>Domain Name System (DNS) Parameters</title>
    <author><organization>IANA</organization></author>
    <date />
  </front>
</reference>  
  </references>

    <section title="Acknowledgements" numbered="no">
      <t>David Lawrence provided valuable observations
	and concrete suggestions. Jeremy Laidman helped make the
	document better. Tony Finch realized that this document was
	valuable and implemented it while under attack. Richard
	Gibson identified areas where more detail and accuracy were
	useful. A large number of other people also provided comments
	and suggestions; we thank them all for the feedback.</t>
    </section>
  </back>

</rfc>

