<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY rfc1034 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.1034.xml">
<!ENTITY rfc1035 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.1035.xml">
<!ENTITY rfc2119 SYSTEM
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY rfc2308 SYSTEM
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.2308.xml">
<!ENTITY rfc4033 SYSTEM
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.4033.xml">
<!ENTITY rfc4035 SYSTEM
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.4035.xml">
<!ENTITY rfc5246 SYSTEM
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.5246.xml">
<!ENTITY rfc5936 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5936.xml">
<!ENTITY rfc6347 SYSTEM
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6347.xml">
<!ENTITY rfc6604 SYSTEM
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6604.xml">
<!ENTITY rfc6973 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6973.xml">
<!ENTITY rfc6982 SYSTEM
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6982.xml">
<!ENTITY rfc7626 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7626.xml">
<!ENTITY I-D.ietf-dnsop-qname-minimisation SYSTEM
"http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-dnsop-qname-minimisation">
<!ENTITY I-D.vixie-dnsext-resimprove SYSTEM
"http://xml.resource.org/public/rfc/bibxml3/reference.I-D.vixie-dnsext-resimprove.xml">
<!ENTITY I-D.fujiwara-dnsop-nsec-aggressiveuse SYSTEM
"http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.fujiwara-dnsop-nsec-aggressiveuse">
<!ENTITY I-D.ietf-dnsop-dns-terminology SYSTEM
"http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-dnsop-dns-terminology">
]>

<rfc docName="draft-bortzmeyer-dnsop-nxdomain-cut-02"
     category="std" ipr="trust200902" updates="1034,2308">
<?rfc toc="yes"?>
<?rfc strict="yes"?>
<front>
<title abbrev="NXDOMAIN cut">NXDOMAIN really means there is nothing underneath</title>
<author fullname="Stephane Bortzmeyer" initials="S." surname="Bortzmeyer">
<organization>AFNIC</organization>
<address><postal><street>1, rue Stephenson</street><code>78180</code><city>Montigny-le-Bretonneux</city><country>France</country></postal> <phone>+33 1 39 30 83 46</phone><email>bortzmeyer+ietf@nic.fr</email><uri>http://www.afnic.fr/</uri></address>
</author>
<author fullname="Shumon Huque" initials="S." surname="Huque">
<organization>Verisign labs</organization>
<address><postal><street>12061 Bluemont Way</street><code>20190</code><city>Reston</city><country>USA</country></postal> <email>shuque@verisign.com</email><uri>http://www.verisignlabs.com/</uri></address>
</author>
<date month="November" year="2015"/>
<workgroup>Domain Name System Operations (dnsop) Working Group</workgroup>
<abstract>
<t>This document states clearly that when a DNS resolver receives a
response with response code NXDOMAIN, it means that the name in the
question section AND ALL THE NAMES UNDER IT do not exist.</t>
<t>REMOVE BEFORE PUBLICATION: this document should be discussed in the
IETF DNSOP (DNS Operations) group, through its mailing list. The
source of the document, as well as a list of open issues, is currently
kept <eref
target="https://github.com/bortzmeyer/ietf-dnsop-nxdomain">at Github</eref>.</t>
</abstract>
</front>

<middle>
  <section anchor="intro" title="Introduction and background">
    <t>
      The DNS protocol <xref target="RFC1035"/> defines response code 
      3 as "Name Error", or "NXDOMAIN", i.e. the queried domain name
      does not exist in the DNS. Since domain names are represented as
      a tree of labels (<xref target="RFC1034"/>, Section 3.1),
      non-existence of a node implies non-existence of the entire sub-tree 
      rooted at this node.
    </t>
    <t>
      The DNS iterative resolution algorithm precisely interprets the
      NXDOMAIN signal in this manner. If it encounters an NXDOMAIN
      response code from an authoritative server, it immediately stops
      iteration and returns the NXDOMAIN response to the querier.
    </t>
    <t>However, in virtually all existing resolvers, a cached NXDOMAIN 
    is not considered "proof" that there can be no child domains
    underneath. This is due to an ambiguity in <xref
    target="RFC1034"/> that failed to distinguish ENT (empty
    nonterminal domain names, <xref
    target="I-D.ietf-dnsop-dns-terminology"/>) from nonexistent names.
    For DNSSEC, the IETF had to distinguish this case (<xref
    target="RFC4035"/>, section 3.1.3.2), but the implication on
    non-DNSSEC resolvers wasn't fully realized.</t>
    <t>
      This document specifies that an NXDOMAIN response for a domain
      name means that no child domains underneath the queried name
      exist either.  And furthermore, that DNS resolvers should
      interpret cached NXDOMAIN responses in this manner. Since the
      domain names are organized in a tree, it is a simple consequence
      of the tree structure: non-existence of a node implies
      non-existence of the entire sub-tree rooted at this node.</t>
      <section title="Requirements Terminology">
<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
   document are to be interpreted as described in <xref target="RFC2119"/>.</t>
</section>
  </section>

<section anchor="rules" title="Rules">
<t>When searching downward in its cache, an iterative caching DNS
resolver SHOULD stop searching if it encounters a cached NXDOMAIN.
The response to the triggering query should be NXDOMAIN.</t>
<t>TODO The next paragraph is challenged because too
implementation-oriented. Should we just keep the first paragraph? My
concern is that some resolvers may have an implementation of the cache made of a
tree plus a hashed index and therefore won't "search downward" if they
have a cached answer.</t>
<t>When an iterative caching DNS resolver stores an NXDOMAIN in its
 cache, all names and RRsets at or below that node SHOULD be deleted
since they will have become unreachable. "Deleted" means that
subsequent requests for these names will yield NXDOMAIN. [TODO: currently under
discussion, some people find it dangerous. MAY instead of SHOULD? Only
if the NXDOMAIN is DNSSEC-validated? Perhaps the resolver could be configured to not "bulk delete"
TLDs (or root). See <xref target="security"/>.]
[TODO: currently under discussion, some people find it costly for the
resolver. A large purge also
causes the resolver to do a lot of (possibly CPU intensive) work, and
could also affect the traffic levels between a recursive and authoritatives.
Perhaps a cache may want to limit the number of nodes/records that it deletes
per NXDOMAIN response.]</t>
<t>By implication, a stream of queries foo.example, then bar.foo.example, where
foo.example does not exist would normally cause both queries to be
forwarded to example's nameservers. Following this recommended
practice of "NXDOMAIN cut",
the second query and indeed any other query for names at or below
foo.example would not be forwarded.</t>
<t>These rules replace the second paragraph of section 5 of <xref
target="RFC2308"/>. Otherwise,  <xref
target="RFC2308"/> applies unchanged, and the fact that a subtree does
not exist is not forever: the NXDOMAIN is cached only for the duration
of the "negative TTL" (section 3 of xref
target="RFC2308"/>).</t>
<t>
  Validating resolvers need to select the necessary NSEC or NSEC3
  records and include them in the AUTHORITY section of the response to 
  provide authenticated denial of existence for names underneath the 
  NXDOMAIN boundary.
</t>
<t>Warning: because of <xref target="RFC6604"/>, the name whose existence is
denied by the NXDOMAIN is not always the QNAME. If there is a chain of
CNAME (or DNAME), the name which does not exist is the last of the
chain. TODO: find a dedicated terminology such as "NXDOMAINed name" or
"denied domain" instead of "QNAME".</t>
</section>

<section anchor="benefits" title="Benefits">
  <t>The main benefit is a better efficiency of the caches. In the
  example above, we send only one query instead of two, the second one
  being answered from the cache.</t>
  <t>The correct behavior (in <xref target="RFC1034"/> and made
  clearer in this document) is specially useful when combined with QNAME
  minimisation <xref
  target="I-D.ietf-dnsop-qname-minimisation"/> since it will allow to
  stop searching as soon as a NXDOMAIN is encountered.</t>
  <t>NXDOMAIN cut may also help mitigate certain types of random QNAME attacks <xref
  target="joost-dnsterror"/> <xref
  target="balakrichenan-dafa888"/>, where there is a fixed suffix which
  does not exist. In these attacks against the authoritative name
  server, queries are sent to resolvers for a QNAME composed 
  of a fixed suffix ("dafa888.wf" in one of the articles above), which is 
  typically nonexistent, and a random prefix, different for each request. A
  resolver receiving these requests have to forward them to the
  authoritative servers. With NXDOMAIN cut, we would just have to send
  to the resolver a query for the fixed suffix, the resolver would get
  a NXDOMAIN and then would stop forwarding the queries. (It would be
  better if the SOA record in the NXDOMAIN response were sufficient to
  find the non-existing domain but this is more delicate, see 
  <xref target="future"/>.)</t>
  <t>Since the principles set in this document are so great, why are
  the rules of <xref target="rules"/> SHOULD and not MUST? This is
  because some
  resolver may have a cache which is NOT organized as a tree (but, for
  instance, as a dictionary) and
  therefore have a good reason to ignore this.</t>
</section>

<section title="Possible issues">
  <t>Let's assume the TLD example exists but foobar.example is not
  delegated (so the example's name servers will reply NXDOMAIN for a
  query about anything.foobar.example). A system administrator decides
  to name the internal machines of his organization under
  office.foobar.example and use a trick of his resolver to forward
  requests about this zone to his local authoritative name
  servers. NXDOMAIN cut would create problems here, since, depending
  on the order of requests to the resolver, it may have cached the
  NXDOMAIN from example and therefore "deleted" everything under. This
  document assumes that such setup is rare and does not need to be supported.</t>
<t>Another issue that may happen: today, we see broken authoritative name servers which reply to ENT
(<xref target="I-D.ietf-dnsop-dns-terminology"/>, section 6) with
NXDOMAIN instead of the normal NODATA (<xref
target="I-D.ietf-dnsop-dns-terminology"/>, section 3).</t>
<t>RFC-EDITOR: REMOVE THE PARAGRAPH BEFORE PUBLICATION. An example today is
mta2._domainkey.cbs.nl (which exists) where querying _domainkey.cbs.nl
yields NXDOMAIN. Another example is
www.upenn.edu, redirected to www.upenn.edu-dscg.edgesuite.net while a
query for edu-dscg.edgesuite.net returns NXDOMAIN.</t>
<t>Such name servers are definitely broken and have always been. They MUST be fixed. Given
the advantages of NXDOMAIN cuts, there is little reason to support
this behavior.
</t>
</section>

<section anchor="future" title="Future work">
  <t>TODO: drop this section entirely? Or just downgrade it to an
  appendix "why can't we just use the owner name of the returned SOA"?</t>
  <t>In this document, we deduce the non-existence of a domain only
  for NXDOMAIN answers where the QNAME was this exact domain. If a
  resolver sends a query to the name servers of the TLD example, and
  asks the MX record for www.foobar.example, and receives a NXDOMAIN,
  it can only register the fact that www.foobar.example (and
  everything underneath) does not exist. Even if the accompanying SOA
  record is for example only, one cannot infer that
  foobar.example is nonexistent. The accompanying SOA indicates the
  apex of the zone, not the closest existing domain name.</t>
  <t>RFC-EDITOR: REMOVE
  BEFORE PUBLICATION: to use a real example today, ask the
  authoritative name servers of the TLD fr about
  anything.which.does.not.exist.gouv.fr. The SOA will indicate fr (the
  apex) even while gouv.fr does exist (there is no zone cut between
  gouv.fr and fr).</t>
<t>In the future, deducing the non-existence of a node from the SOA
  in the NXDOMAIN reply may certainly help with random qnames attacks
but this is out-of-scope for this document. It would require to address
the problems mentioned in the previous paragraph. A possible solution
would be, when receiving a NXDOMAIN with a SOA which is more than one
label up in the tree, to send requests for the domains which are between the
QNAME and the owner name of the SOA. (A resolver which does DNSSEC
validation or QNAME minimisation will need to do it, anyway.)</t>
<t>TODO a mention of <xref
target="I-D.fujiwara-dnsop-nsec-aggressiveuse"/>? Unlike NXDOMAIN cut,
it requires DNSSEC but it is more powerful since it can synthetize NXDOMAINs.</t>
</section>

<section title="IANA Considerations">
<t>This document has no actions for IANA.</t>
</section>

<section anchor="security" title="Security Considerations">
<t>The technique described here may help against a denial-of-service
attack named "random qnames" and described in <xref
target="benefits"/>. Apart from that, it is believed to have no
security consequences.</t>
<t>If a resolver does not validate the answers with DNSSEC, it can of
course be poisoned with a false NXDOMAIN, thus "deleting" a part of
the domain name tree. This denial-of-service attack is already
possible with the rules of this document (but "NXDOMAIN cut" may
increase its effects). The only solution is to use DNSSEC.</t>
</section>

<section title="Implementation status - RFC EDITOR: REMOVE BEFORE PUBLICATION">

<t>This section records the status of known implementations of the
protocol defined by this specification at the time of posting of this
Internet-Draft, and is based on a proposal described in <xref
target="RFC6982"/>. The description of implementations in this section
is intended to assist the IETF in its decision processes in
progressing drafts to RFCs.  Please note that the listing of any
individual implementation here does not imply endorsement by the IETF.
Furthermore, no effort has been spent to verify the information
presented here that was supplied by IETF contributors.  This is not
intended as, and must not be construed to be, a catalog of available
implementations or their features.  Readers are advised to note that
other implementations may exist.</t>
<t>According to <xref target="RFC6982"/>, "this will allow reviewers
and working groups to assign due consideration to documents that have
the benefit of running code, which may serve as evidence of valuable
experimentation and feedback that have made the implemented protocols
more mature.  It is up to the individual working groups to use this
information as they see fit".</t>
<t>As of today, all existing DNS resolvers are conservative: they
consider a NXDOMAIN as only significant for the name itself, not for
the names under. All
current recursive servers will upstream a query for out-of-cache
sub.example.com even if their cache contains an NXDOMAIN for
example.com.</t>
</section>

<section title="Acknowledgments">
<t>The text of this document was mostly copied from <xref
  target="I-D.vixie-dnsext-resimprove"/>, section 3. Thanks to its
authors, Paul Vixie, Rodney Joffe and Frederico Neves.</t>
<t>Thanks to Duane Wessels, Tony Finch and Jinmei Tatuya for fact checking and explanations.</t>
</section>

</middle>

<back>

<references title='Normative References'>
&rfc1034;
&rfc1035;
&rfc2119;
&rfc2308;
&rfc6604;
&I-D.ietf-dnsop-dns-terminology; 
</references>

<references title='Informative References'>
&rfc4035;
&rfc6982;
&I-D.vixie-dnsext-resimprove;
&I-D.ietf-dnsop-qname-minimisation;
&I-D.fujiwara-dnsop-nsec-aggressiveuse;

<reference anchor="joost-dnsterror" target="http://www.michael-joost.de/dnsterror.html">
<front>
<title>About DNS Attacks and ICMP Destination Unreachable Reports</title>
<author fullname="Michael Joost" initials="M." surname="Joost"/>
<date month="December" year="2014"/>
</front>
</reference>

<reference anchor="balakrichenan-dafa888"
	   target="https://indico.dns-oarc.net/event/20/session/3/contribution/37">
  <front>
    <title>Disturbance in the DNS - "Random qnames", the dafa888 DoS
    attack"</title>
    <author fullname="Sandoche Balakrichenan" initials="S."
	    surname="Balakrichenan"/>
    <date month="October" year="2014"/>
    <abstract><t>At the DNS-OARC meeting in Los Angeles</t></abstract>
  </front>
</reference>

</references>

</back>

</rfc>



