<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Best Practices for Use of SASL ANONYMOUS</title>
  <abstract>This document specifies best practices for use of the SASL ANONYMOUS mechanism in the context of client authentication with an XMPP server.</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>0175</number>
  <status>Active</status>
  <type>Informational</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</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.2</version>
    <date>2009-09-30</date>
    <initials>psa</initials>
    <remark><p>Provided more detailed recommendations regarding usage restrictions for anonymous users, including the concept of different deployment types; added note about the account/anonymous service discovery identity.</p></remark>
  </revision>
  <revision>
    <version>1.1</version>
    <date>2007-11-07</date>
    <initials>psa</initials>
    <remark><p>Recommended that node identifier be a UUID; recommended that trace data not be included.</p></remark>
  </revision>
  <revision>
    <version>1.0</version>
    <date>2006-09-20</date>
    <initials>psa</initials>
    <remark><p>Per a vote of the Jabber Council, advanced status to Active.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2006-02-09</date>
    <initials>psa</initials>
    <remark><p>Initial version; modified flow to remove unecessary challenge.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2006-01-24</date>
    <initials>psa</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>
<section1 topic="Introduction" anchor="intro">
  <p><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> allows XMPP server implementations to support any SASL mechanism (see <span class="ref"><link url="http://tools.ietf.org/html/rfc4422">RFC 4422</link></span> <note>RFC 4422: Simple Authentication and Security Layer (SASL) &lt;<link url="http://tools.ietf.org/html/rfc4422">http://tools.ietf.org/html/rfc4422</link>&gt;.</note>) when authenticating clients. This document provides recommendations regarding use of the SASL ANONYMOUS mechanism (see <span class="ref"><link url="http://tools.ietf.org/html/rfc4505">RFC 4505</link></span> <note>RFC 4505: The SASL ANONYMOUS Mechanism &lt;<link url="http://tools.ietf.org/html/rfc4505">http://tools.ietf.org/html/rfc4505</link>&gt;.</note>) in XMPP systems.</p>
</section1>
<section1 topic="Deployment Types" anchor="deployments">
  <p>XMPP server implementations can be deployed in a variety of settings. Although it is difficult to provide recommendations for every kind of XMPP deployment, this document attempts to strike a balance between more and less controlled settings by defining three different deployment types:</p>
  <ul>
    <li>Public deployments, such as well-known instant messaging (IM) services on the open Internet.</li>
    <li>Private deployments, such as enterprise IM services, technical support departments, and helplines.</li>
    <li>Specialized deployments that typically will be accessed in a controlled fashion, such as gaming services, members-only websites, and applications that are not used directly by human users.</li>
  </ul>
</section1>
<section1 topic="Recommendations" anchor="recommendations">
  <p>An XMPP server implementation SHOULD NOT enable the SASL ANONYMOUS mechanism by default, but instead SHOULD force the administrator of a given service to explicitly enable support in the context of that deployment.</p>
  <p>When a client authenticates using SASL ANONYMOUS, an XMPP server SHOULD assign a temporary, unique bare JID &lt;localpart@domain.tld&gt; to the client. Although the method for ensuring the uniqueness of the localpart is a matter of implementation, it is RECOMMENDED for the localpart to be a UUID as specified in <span class="ref"><link url="http://tools.ietf.org/html/rfc4122">RFC 4122</link></span> <note>RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace &lt;<link url="http://tools.ietf.org/html/rfc4122">http://tools.ietf.org/html/rfc4122</link>&gt;.</note>.</p>
  <p>Although <span class="ref"><link url="http://tools.ietf.org/html/rfc4505">RFC 4505</link></span> <note>RFC 4505: The SASL ANONYMOUS Mechanism &lt;<link url="http://tools.ietf.org/html/rfc4505">http://tools.ietf.org/html/rfc4505</link>&gt;.</note> allows the client to provide so-called "trace data" when authenticating via SASL ANONYMOUS, it is NOT RECOMMENDED for the client to include trace data as the XML character data of the &lt;auth/&gt; element (instead, the &lt;auth/&gt; element SHOULD be empty). However, if trace data is included, the server MUST NOT use it for any purpose other than tracing (e.g., not use it as the resource identifier of the anonymous user's full JID).</p>
  <p>Because an anonymous user is unknown to the server, the server SHOULD appropriately restrict the user's access in order to limit the possibility of malicious behavior (such as denial of service attacks as described in <span class="ref"><link url="https://xmpp.org/extensions/xep-0205.html">Best Practices to Discourage Denial of Service Attacks (XEP-0205)</link></span> <note>XEP-0205: Best Practices to Discourage Denial of Service Attacks &lt;<link url="https://xmpp.org/extensions/xep-0205.html">https://xmpp.org/extensions/xep-0205.html</link>&gt;.</note>), especially on public deployments. The following restrictions are encouraged on public deployments. Administrators of private deployments and specialized deployments are advised to take these restrictions into account when configuring their services, but can reasonably relax these restrictions if they have appropriate access controls in place or their deployment requirements cannot be met using the more restrictive profile applied in public deployments.</p>
  <ol start="1">
    <li><p>During resource binding, the server MAY ignore the resource identifier provided by the client (if any) and instead assign a resource identifier that it generates on behalf of the client.</p></li>
    <li><p>The server SHOULD NOT allow the client to initiate communication with entities hosted at remote servers.</p></li>
    <li><p>The server MAY allow the client to establish relationships with local services and users; such relationships might include presence subscriptions and roster additions (see <span class="ref"><link url="http://tools.ietf.org/html/rfc6121">XMPP IM</link></span> <note>RFC 6121: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence &lt;<link url="http://tools.ietf.org/html/rfc6121">http://tools.ietf.org/html/rfc6121</link>&gt;.</note>), <span class="ref"><link url="https://xmpp.org/extensions/xep-0045.html">Multi-User Chat (XEP-0045)</link></span> <note>XEP-0045: Multi-User Chat &lt;<link url="https://xmpp.org/extensions/xep-0045.html">https://xmpp.org/extensions/xep-0045.html</link>&gt;.</note> registrations, and <span class="ref"><link url="https://xmpp.org/extensions/xep-0060.html">Publish-Subscribe (XEP-0060)</link></span> <note>XEP-0060: Publish-Subscribe &lt;<link url="https://xmpp.org/extensions/xep-0060.html">https://xmpp.org/extensions/xep-0060.html</link>&gt;.</note> subscriptions. (Note that allowing presence subscriptions and roster additions can create a sub-optimal user experience for the added contacts.) However, if the server permits such relationships, it MUST cancel them when the client's session ends.</p></li>
    <li><p>The server MAY allow the client to store information on the server for the purpsoe of providing an optimal user experience (e.g., storage of client preferences using <span class="ref"><link url="https://xmpp.org/extensions/xep-0049.html">Private XML Storage (XEP-0049)</link></span> <note>XEP-0049: Private XML Storage &lt;<link url="https://xmpp.org/extensions/xep-0049.html">https://xmpp.org/extensions/xep-0049.html</link>&gt;.</note>). However, if the server allows this, it SHOULD remove such information when the client's session ends.</p></li>
    <li><p>The server SHOULD NOT allow the client to send large numbers of XMPP stanzas or otherwise use large amounts of system resources (e.g., by binding multiple resource identifiers or creating multiple <span class="ref"><link url="https://xmpp.org/extensions/xep-0065.html">SOCKS5 Bytestreams (XEP-0065)</link></span> <note>XEP-0065: SOCKS5 Bytestreams &lt;<link url="https://xmpp.org/extensions/xep-0065.html">https://xmpp.org/extensions/xep-0065.html</link>&gt;.</note> sessions).</p></li>
  </ol>
</section1>
<section1 topic="Protocol Flow" anchor="flow">
  <p>The RECOMMENDED protocol flow following TLS negotiation (refer to <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>) is as follows:</p>
  <ol>
    <li>
      <p>Client initiates stream to server.</p>
      <example caption="Stream initiation"><![CDATA[
<stream:stream
        xmlns:stream='http://etherx.jabber.org/streams'
        xmlns='jabber:client'
        to='example.com'
        version='1.0'>
]]></example>
    </li>
    <li>
      <p>Server replies with stream header.</p>
      <example caption="Stream header reply"><![CDATA[
<stream:stream
        xmlns:stream='http://etherx.jabber.org/streams'
        xmlns='jabber:client'
        id='c2s_234'
        from='example.com'
        version='1.0'>
]]></example>
    </li>
    <li>
      <p>Server advertises stream features.</p>
      <example caption="Stream features advertisement"><![CDATA[
<stream:features>
  <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
    <mechanism>DIGEST-MD5</mechanism>
    <mechanism>ANONYMOUS</mechanism>
  </mechanisms>
</stream:features>
]]></example>
    </li>
    <li>
      <p>Client requests SASL ANONYMOUS mechanism.</p>
      <example caption="Requesting SASL ANONYMOUS"><![CDATA[
<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>
]]></example>
    </li>
    <li>
      <p>Server sends &lt;success/&gt;.</p>
      <example caption="Sending success"><![CDATA[
<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
]]></example>
    </li>
    <li>
      <p>Client opens new stream.</p>
      <example caption="Initiating a new stream"><![CDATA[
<stream:stream
        xmlns:stream='http://etherx.jabber.org/streams'
        xmlns='jabber:client'
        to='example.com'
        version='1.0'>
]]></example>
    </li>
    <li>
      <p>Server tells client that resource binding is required.</p>
      <example caption="Stream header reply with features"><![CDATA[
<stream:stream
        xmlns:stream='http://etherx.jabber.org/streams'
        xmlns='jabber:client'
        id='c2s_345'
        from='example.com'
        version='1.0'>
<stream:features>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
</stream:features>
]]></example>
    </li>
    <li>
      <p>Client requests that server create a resource for it.</p>
      <example caption="Requesting resource creation"><![CDATA[
<iq type='set' id='bind_1'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
</iq>
]]></example>
    </li>
    <li>
      <p>Server replies with full JID.</p>
      <example caption="Server informs client of full JID"><![CDATA[
<iq type='result' id='bind_1'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <jid>59BEC12A-9BAB-452B-88F8-D1563F09E549@example.com/2384F02A7E01</jid>
  </bind>
</iq>
]]></example>
    </li>
  </ol>
</section1>
<section1 topic="Service Discovery" anchor="disco">
  <p>A server MUST reply 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 ("disco#info") request sent to the bare JID &lt;localpart@domain.tld&gt; of the user with an identity of "account/anonymous", as shown in the following example.</p>
  <example caption="Server informs client of full JID"><![CDATA[
<iq from='59BEC12A-9BAB-452B-88F8-D1563F09E549@example.com'
    id='kj37vd95'
    to='requester@example.com/foo'
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <identity category='account' type='anonymous'/>
    <feature var='http://jabber.org/protocol/disco#info'/>
    <feature var='http://jabber.org/protocol/disco#items'/>
  </query>
</iq>
]]></example>
</section1>
<section1 topic="Security Considerations" anchor="security">
  <p>The security considerations discussed 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 <cite>RFC 4505</cite> apply to the use of SASL ANONYMOUS in XMPP; specific suggestions regarding usage restrictions for anonymous users are provided under the <link url="#rec">Recommendations</link> section of this document.</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 <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>.</p>
</section1>
<section1 topic="Acknowledgements" anchor="ack">
  <p>Thanks to Dave Cridland, Tuomas Koski, Jack Moffitt, Andy Skelton, and Kurt Zeilenga for their feedback.</p>
</section1>
</xep>
