<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>DNS Queries over XMPP (DoX)</title>
  <abstract>This specification defines an XMPP protocol extension for sending DNS queries and getting DNS responses over XML streams. Each DNS query-response pair is mapped
   into an IQ exchange.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0418</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0030</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>dox</shortname>
  <schemaloc>
    <url>http://www.xmpp.org/schemas/dox.xsd</url>
  </schemaloc>
  
  <author>
    <firstname>Travis</firstname>
    <surname>Burtrum</surname>
    <email>travis@burtrum.org</email>
    <jid>travis@burtrum.org</jid>
    <uri>https://moparisthebest.com/</uri>
 </author>

  <revision>
    <version>0.1.0</version>
    <date>2019-03-29</date>
    <initials>XEP Editor (jsc)</initials>
    <remark>Accepted by vote of Council on 2019-03-13.</remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2019-03-11</date>
    <initials>tjb</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>

<section1 topic="Introduction" anchor="intro">
  <p>This document defines a specific protocol, DNS over XMPP (DoX), for
   sending DNS <span class="ref"><link url="http://tools.ietf.org/html/rfc1035">RFC 1035</link></span> <note>RFC 1035: Domain Names - Implementation and Specification &lt;<link url="http://tools.ietf.org/html/rfc1035">http://tools.ietf.org/html/rfc1035</link>&gt;.</note> queries and getting DNS responses over <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">XMPP Core</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note> (and therefore TLS <span class="ref"><link url="http://tools.ietf.org/html/rfc8446">RFC 8446</link></span> <note>RFC 8446: The Transport Layer Security (TLS) Protocol Version 1.3 &lt;<link url="http://tools.ietf.org/html/rfc8446">http://tools.ietf.org/html/rfc8446</link>&gt;.</note> security for integrity and confidentiality.</p>
   <p>The integration with XMPP provides a transport suitable for both
   existing DNS clients and native XMPP applications seeking access to
   the DNS.</p>
   <p>This protocol is almost identical in scope to DNS Queries over HTTPS (DoH) <span class="ref"><link url="http://tools.ietf.org/html/rfc8484">RFC 8484</link></span> <note>RFC 8484: DNS Queries over HTTPS (DoH) &lt;<link url="http://tools.ietf.org/html/rfc8484">http://tools.ietf.org/html/rfc8484</link>&gt;.</note></p>
</section1>

<section1 topic="Requirements" anchor="reqs">
  <p>This specification addresses the following requirements:</p>
  <ol start="1">
    <li>Sending a DNS query.</li>
    <li>Responding with a DNS response.</li>
  </ol>
</section1>

<section1 topic="Protocol" anchor="protocol">
  <p>The DoX protocol is extremely simple:</p>
  <ol>
    <li>The requesting entity (requestor) sends an IQ-get containing a &lt;dns/&gt; element qualified by the 'urn:xmpp:dox:0' namespace, which contains the DNS query.</li>
    <li>The resolving entity (resolver) returns either an IQ-result containing a &lt;dns/&gt; element qualified by the 'urn:xmpp:dox:0' namespace, which contains the DNS response (if it supports the namespace) or an IQ-error (if it does not).</li>
    <li>In both the query and response, the content of the &lt;dns/&gt; element is the DNS on-the-wire format as defined in <span class="ref"><link url="http://tools.ietf.org/html/rfc1035">RFC 1035</link></span> <note>RFC 1035: Domain Names - Implementation and Specification &lt;<link url="http://tools.ietf.org/html/rfc1035">http://tools.ietf.org/html/rfc1035</link>&gt;.</note>. The body MUST be encoded with base64 <span class="ref"><link url="http://tools.ietf.org/html/rfc4648">RFC 4648</link></span> <note>RFC 4648: The Base16, Base32, and Base64 Data Encodings &lt;<link url="http://tools.ietf.org/html/rfc4648">http://tools.ietf.org/html/rfc4648</link>&gt;.</note>. Padding characters for base64 MUST NOT be included.</li>
  </ol>
</section1>
<section1 topic="Use Cases" anchor="usecases">
    <p>Sending a DNS query is done by sending an &lt;iq/&gt; get over the stream from the requestor to the resolver.</p>
    <example caption="Query"><![CDATA[
<iq from='romeo@montague.lit/home' to='juliet@capulet.lit/chamber'
 id='s2c1' type='get'>
  <dns xmlns='urn:xmpp:dox:0'>vOIBIAABAAAAAAABB2V4YW1wbGUDb3JnAAABAAEAACkQAAAAAAAADAAKAAj5HO5JuEe+mA</dns>
</iq>
]]></example>
    <p>If the resolver supports the dns namespace, it MUST return an IQ-result, which contains the DNS response:</p>
    <example caption="Response"><![CDATA[
<iq from='juliet@capulet.lit/chamber' to='romeo@montague.lit/home'
 id='s2c1' type='result'>
  <dns xmlns='urn:xmpp:dox:0'>vOKBoAABAAEAAAABB2V4YW1wbGUDb3JnAAABAAHADAABAAEAAAhjAARduNgiAAApEAAAAAAAAAA</dns>
</iq>
]]></example>
    <p>If the resolver does not support the dns namespace, it MUST return a &lt;service-unavailable/&gt; error:</p>
    <example caption="DNS Not Supported"><![CDATA[
<iq from='juliet@capulet.lit/chamber' to='romeo@montague.lit/home' id='s2c1' type='error'>
  <dns xmlns='urn:xmpp:dox:0'>vOIBIAABAAAAAAABB2V4YW1wbGUDb3JnAAABAAEAACkQAAAAAAAADAAKAAj5HO5JuEe+mA</dns>
  <error type='cancel'>
    <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
]]></example>
    <p>The other error conditions defined in <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">RFC 6120</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note> could also be returned if appropriate.</p>
</section1>

<section1 topic="Determining Support" anchor="support">
  <p>If an entity supports the DoX protocol, it MUST report that fact by including a service discovery feature of "urn:xmpp:dox:0" in response to a <span class="ref"><link url="https://xmpp.org/extensions/xep-0030.html">Service Discovery (XEP-0030)</link></span> <note>XEP-0030: Service Discovery &lt;<link url="https://xmpp.org/extensions/xep-0030.html">https://xmpp.org/extensions/xep-0030.html</link>&gt;.</note> information request:</p>
  <example caption="Service Discovery information request"><![CDATA[
<iq type='get'
    from='juliet@capulet.lit/balcony'
    to='capulet.lit'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
]]></example>
  <example caption="Service Discovery information response"><![CDATA[
<iq type='result'
    from='capulet.lit'
    to='juliet@capulet.lit/balcony'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    ...
    <feature var='urn:xmpp:dox:0'/>
    ...
  </query>
</iq>
]]></example>
  <p>In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined in <span class="ref"><link url="https://xmpp.org/extensions/xep-0115.html">Entity Capabilities (XEP-0115)</link></span> <note>XEP-0115: Entity Capabilities &lt;<link url="https://xmpp.org/extensions/xep-0115.html">https://xmpp.org/extensions/xep-0115.html</link>&gt;.</note>. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.</p>
  <p>Support could also be pre-arranged between parties by putting a resolver at a known JID, in which case the requestor can just start sending queries to the resolver</p>
</section1>

<section1 topic="Implementation Notes" anchor="impl">
  <p>Some XMPP clients do not respond to IQ stanzas containing unsupported payloads. Although this is in violation of <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">XMPP Core</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note>, this behavior can result in disconnection of clients that are in fact actively connected to the server.</p>
</section1>

<section1 topic="Security Considerations" anchor="security">
  <p>Running DNS over XMPP relies on the security of the underlying XMPP
   transport, therefore all queries and responses MUST use TLS or equivalent connection security.  This mitigates classic amplification attacks for UDP-
   based DNS.</p>
  <p>Session-level encryption has well-known weaknesses with respect to
   traffic analysis, which might be particularly acute when dealing with
   DNS queries. DoX resolvers can also add DNS padding
   <span class="ref"><link url="http://tools.ietf.org/html/rfc7830">RFC 7830</link></span> <note>RFC 7830: The EDNS(0) Padding Option &lt;<link url="http://tools.ietf.org/html/rfc7830">http://tools.ietf.org/html/rfc7830</link>&gt;.</note> if the DoX requestor requests it in the DNS query.  An
   experimental effort to offer guidance on choosing the padding length
   can be found in <span class="ref"><link url="http://tools.ietf.org/html/rfc8467">RFC 8467</link></span> <note>RFC 8467: Padding Policies for Extension Mechanisms for DNS (EDNS(0)) &lt;<link url="http://tools.ietf.org/html/rfc8467">http://tools.ietf.org/html/rfc8467</link>&gt;.</note>.</p>
  <p>The TLS connection provides transport security for the interaction
   between the DoX resolver and requestor, but it does not provide the
   response integrity of DNS data provided by DNSSEC.  DNSSEC and DoX
   are independent and fully compatible protocols, each solving
   different problems.  The use of one does not diminish the need nor
   the usefulness of the other.  It is the choice of a requestor to either
   perform full DNSSEC validation of answers or to trust the DoX resolver
   to do DNSSEC validation and inspect the AD (Authentic Data) bit in
   the returned message to determine whether an answer was authentic or
   not.</p>
  <p>In the absence of DNSSEC information, a DoX resolver can give a requestor
   invalid data in response to a DNS query.  A DoX capable requestor MUST discard any responses not specifically requested, this prohibition does not guarantee protection against invalid data, but it does reduce the risk.</p>
  <p>If a server receives a dns request directed to a full JID &lt;localpart@domain.tld/resource&gt; associated with a registered account but there is no connected resource matching the 'to' address, <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">RFC 6120</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note> requires it to reply with a &lt;service-unavailable/&gt; error and set the 'from' address of the IQ-error to the full JID provided in the 'to' address of the dns request. If a connected resource receives a dns request but it does not want to reveal its network availability to the sender for any reason (e.g., because the sender is not authorized to know the connected resource's availability), then it too MUST reply with a &lt;service-unavailable/&gt; error. This consistency between the server response and the resolver response helps to prevent presence leaks.</p>
</section1>

<section1 topic="IANA Considerations" anchor="iana">
  <p>No interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note> is necessary as a result of this document.</p>
</section1>

<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <section2 topic="Protocol Namespaces" anchor="registrar-ns">
    <p>The <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note> includes "urn:xmpp:dox:0" in its registry of protocol namespaces (see &lt;<link url="https://xmpp.org/registrar/namespaces.html">https://xmpp.org/registrar/namespaces.html</link>&gt;).</p>
  </section2>
</section1>

<section1 topic="XML Schema" anchor="schema">
  <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:xmpp:dox:0'
    xmlns='urn:xmpp:dox:0'
    elementFormDefault='qualified'>

  <xs:annotation>
    <xs:documentation>
      The protocol documented by this schema is defined in
      XEP-XXXX: https://xmpp.org/extensions/inbox/dox.html
    </xs:documentation>
  </xs:annotation>

  <xs:element name='dns' type='base64Binary'/>

</xs:schema>
]]></code>
</section1>
</xep>
