<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Recommended Order of Stream Feature Negotiation</title>
  <abstract>This document specifies a recommended order for negotiation of XMPP stream features.</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>0170</number>
  <status>Active</status>
  <type>Informational</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0077</spec>
    <spec>XEP-0079</spec>
    <spec>XEP-0138</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>N/A</shortname>
  
  <author>
    <firstname>Peter</firstname>
    <surname>Saint-Andre</surname>
    <email>stpeter@stpeter.im</email>
    <jid>stpeter@jabber.org</jid>
    <uri>https://stpeter.im/</uri>
  </author>

  <revision>
    <version>1.0</version>
    <date>2007-01-04</date>
    <initials>psa</initials>
    <remark><p>Per a vote of the XMPP Council, advanced status to Active.</p></remark>
  </revision>
  <revision>
    <version>0.5</version>
    <date>2006-12-06</date>
    <initials>psa</initials>
    <remark><p>Per Council feedback, removed section on deprecated jabber:iq:auth protocol.</p></remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2006-08-02</date>
    <initials>psa</initials>
    <remark><p>Modified recommended order of for server-to-server negotiations if service provisioning requires dialback after TLS negotiation.</p></remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2006-01-24</date>
    <initials>psa</initials>
    <remark><p>Split into client-to-server and server-to-server sections; specified recommended order of server-to-server negotiations.</p></remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2006-01-16</date>
    <initials>psa</initials>
    <remark><p>Changed order of SASL and stream compression to reflect list discussion.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2006-01-11</date>
    <initials>psa</initials>
    <remark><p>Initial version.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2006-01-10</date>
    <initials>psa</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>
<section1 topic="Introduction" anchor="intro">
  <p>During its formalization of the core Jabber protocols, the IETF's XMPP WG introduced the concept of XML stream features. While the order in which features shall be negotiated is clearly defined for the features specified in <span class="ref"><link url="http://tools.ietf.org/html/rfc3920">RFC 3920</link></span> <note>RFC 3920: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc3920">http://tools.ietf.org/html/rfc3920</link>&gt;.</note> and <span class="ref"><link url="http://tools.ietf.org/html/rfc3921">RFC 3921</link></span> <note>RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence &lt;<link url="http://tools.ietf.org/html/rfc3921">http://tools.ietf.org/html/rfc3921</link>&gt;.</note>, the number of possible features is open-ended (which is why 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> maintains a registry of stream features). This document specifies the recommended order for negotiation of various stream features.</p>
</section1>
<section1 topic="Client-to-Server Recommendations" anchor="c2s">
  <section2 topic="Standard XMPP Features" anchor="c2s-xmpp">
    <p>The XMPP RFCs define an ordering for the features defined therein, namely:</p>
    <ol>
      <li>TLS</li>
      <li>SASL</li>
      <li>Resource binding</li>
    </ol>
    <p>That order MUST be followed if no other stream features are negotiated.</p>
  </section2>
  <section2 topic="Stream Compression" anchor="c2s-compress">
    <p><span class="ref"><link url="https://xmpp.org/extensions/xep-0138.html">Stream Compression (XEP-0138)</link></span> <note>XEP-0138: Stream Compression &lt;<link url="https://xmpp.org/extensions/xep-0138.html">https://xmpp.org/extensions/xep-0138.html</link>&gt;.</note> is negotiated when it is not possible to set up TLS compression for whatever reason. It seems safest to negotiate stream compression after negotiation of both TLS (to safely complete the negotiation) and SASL (to prevent certain denial-of-service attacks caused by consumption of server resources for compression before the connecting entity is authenticated). Therefore the following order is RECOMMENDED:</p>
    <ol>
      <li>TLS</li>
      <li>SASL</li>
      <li>Stream compression</li>
      <li>Resource binding</li>
    </ol>
  </section2>
  <section2 topic="In-Band Registration" anchor="c2s-register">
    <p>The <span class="ref"><link url="https://xmpp.org/extensions/xep-0077.html">In-Band Registration (XEP-0077)</link></span> <note>XEP-0077: In-Band Registration &lt;<link url="https://xmpp.org/extensions/xep-0077.html">https://xmpp.org/extensions/xep-0077.html</link>&gt;.</note> protocol can be used to establish an account before logging in. That step would be completed before SASL because an entity cannot authenticate if it does not first create an account. Therefore the following order is RECOMMENDED:</p>
    <ol>
      <li>TLS</li>
      <li>In-band registration</li>
      <li>SASL</li>
      <li>Resource binding</li>
    </ol>
    <p>If both stream compression and in-band registration are negotiated, the following order is RECOMMENDED:</p>
    <ol>
      <li>TLS</li>
      <li>In-band registration</li>
      <li>SASL</li>
      <li>Stream compression</li>
      <li>Resource binding</li>
    </ol>
  </section2>
</section1>
<section1 topic="Server-to-Server Recommendations" anchor="s2s">
  <section2 topic="Standard XMPP Features" anchor="s2s-xmpp">
    <p>The XMPP RFCs define an ordering for the features defined therein, namely:</p>
    <ol>
      <li>TLS</li>
      <li>SASL</li>
    </ol>
    <p>That order MUST be followed if no other stream features are negotiated.</p>
  </section2>
  <section2 topic="Dialback" anchor="s2s-dialback">
    <p>RFC 3920 requires SASL negotiation after TLS negotiation. When the certificate presented by the initiating entity makes reference to a trusted root certification authority, SASL negotiation provides meaningful authentication. In that case, the order shown above is recommended.</p>
    <p>However, it is possible that the initiating entity will present a self-signed certificate or a certificate whose associated root certification authority is not trusted by the receiving entity. In this situation, service provisioning policies at the receiving entity may dictate the use of server dialback in order to provide a stronger level of trust for the server-to-server stream (where such trust is essentially trust in the underlying Domain Name System), even though server dialback explicitly does not provide authentication. In this case, the following order is RECOMMENDED:</p>
    <ol>
      <li>TLS</li>
      <li>Dialback</li>
    </ol>
  </section2>
  <section2 topic="Stream Compression" anchor="s2s-compress">
    <p><span class="ref"><link url="https://xmpp.org/extensions/xep-0138.html">Stream Compression (XEP-0138)</link></span> <note>XEP-0138: Stream Compression &lt;<link url="https://xmpp.org/extensions/xep-0138.html">https://xmpp.org/extensions/xep-0138.html</link>&gt;.</note> is negotiated when it is not possible to set up TLS compression for whatever reason. It seems safest to negotiate stream compression after negotiation of both TLS (to safely complete the negotiation) and SASL (to prevent certain denial-of-service attacks). Therefore the following order is RECOMMENDED:</p>
    <ol>
      <li>TLS</li>
      <li>SASL</li>
      <li>Stream compression</li>
    </ol>
    <p>If stream compression is negotiated in addition to TLS and dialback, it is RECOMMENDED to negotiate it after both TLS and dialback:</p>
    <ol>
      <li>TLS</li>
      <li>Dialback</li>
      <li>Stream compression</li>
    </ol>
  </section2>
</section1>
<section1 topic="Security Considerations" anchor="security">
  <p>The order of negotiated stream features has security implications and may be security-critical. In particular, TLS MUST be negotiated first.</p>
</section1>
<section1 topic="IANA Considerations" anchor="iana">
  <p>This document requires 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>.</p>
</section1>
<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <p>This document requires no interaction with the XMPP Registrar.</p>
</section1>
</xep>
