<p>While &xep0388; provides a modern and extensible way to use SASL in XMPP, it lacks support for SASL mechanism upgrades.</p>
<p>Modern XMPP server deployments typically store only the hash of a user's password, to improve account security. At times, it may be desirable for servers to upgrade to newer or different hash algorithms, e.g. so they can offer different authentication mechanisms for improved security or interoperability. Due to the security properties of one-way cryptographic hash algorithms, it is not possible for the server to extract the original data and simply hash it in a new format. To perform such upgrades, the cooperation of the client is necessary - because it has, or can obtain from the user, the original password to derive a hash from.</p>
<p>This specification fills that gap by providing a pluggable way to perform such SASL mechanism upgrades using &xep0388; tasks to provide the server with the needed data it does not yet have.</p>
<p>This specification also provides a concrete definition of SCRAM upgrade tasks in <linkurl="#scram">Section 3</link>.</p>
<p>Clients capable of SASL mechanism upgrades defined herein MUST send the desired bare JID they want to authenticate for in the "from" attribute of the stream-header unless they don't know it (e.g. when using the GSS-API SASL mechanism etc.) according to section 4.7.1 of &rfc6120;. Providing the bare JID in the "from" attribute, rather than introducing additional nonzas, saves one round-trip, see &xep0388;.</p>
<section2topic="Server advertising possible upgrade tasks"anchor="disco">
<p>To inform the client which SASL mechanism upgrades it supports, the server adds <upgrade/> elements in the namespace "urn:xmpp:sasl:upgrade:0", each containing the name of one upgrade task, to the SASL2 <authentication/> element inside the stream features.</p>
<p>Upgrade task names SHOULD have a prefix of "UPGR-" (to distinguish them from "normal" SASL mechanisms) followed by the SASL mechanism name to upgrade to, and if multiple mechanisms differ only in their support for channel-binding (e.g. SCRAM's -PLUS variants), implementations MUST use only the names of variants without channel-binding for the task names, because mechanism upgrades are independent of any channel-binding. Finally, upgrade tasks MUST NOT transmit plaintext passwords (or any reversible encoding of them) if the SASL mechanism to upgrade allows this to be avoided.</p>
<examplecaption="Server advertises support for SASL mechanism upgrades to fictional BLOOP2 and BLOOP-42 mechanisms"><![CDATA[
<!-- Client sending stream header -->
<stream:stream
from='user@example.org'
to='example.org'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
<!-- Server responding with stream header and features -->
<stream:stream
from='example.org'
id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
to='user@example.org'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
<stream:features>
<authenticationxmlns='urn:xmpp:sasl:2'>
<mechanism>SCRAM-SHA-1</mechanism>
<mechanism>SCRAM-SHA-1-PLUS</mechanism>
<inline>
<!-- Server indicates that XEP-0198 stream resumption can be done "inline" -->
<resumexmlns='urn:xmpp:sm:3'/>
<!-- Server indicates support for XEP-0386 Bind 2 -->
<p>The client SHOULD always request one or more upgrade tasks it recognises. To do this, it includes the <upgrade/> element namespaced to "urn:xmpp:sasl:upgrade:0" in its <authenticate/> element listing the upgrade tasks it wants to perform, as specified in the Initiation section of &xep0388;, one <upgrade> element for each task.</p>
<p>Upon successfully authenticating the client (including any secondary authentication steps required for the account), but before the final <success/> would be sent, the server sends a <continue/> element, which MUST contain a single task, matching whatever was selected by the client. If the client selected more than one upgrade task, as sequence of upgrade tasks occur. The client then initiates this upgrade task by providing a corresponding <next/> element providing the task name and optionally including any further child-elements as defined by the specification for this concrete upgrade task.</p>
<examplecaption="Client requests upgrades for fictional BLOOP2 and BLOOP-42 mechanisms"><![CDATA[
<!-- Client sends authentication request, requesting upgrades to BLOOP2 and BLOOP-42-->
<examplecaption="Server initiates first upgrade task for BLOOP2"><![CDATA[
<!-- Client authenticates using SCRAM-SHA-1-PLUS (or whatever mechanism was selected)-->
[...]
<!-- The Server requests the client to perform the first requested upgrade task for BLOOP2 -->
<continuexmlns='urn:xmpp:sasl:2'>
<additional-data>
SSdtIGJvcmVkIG5vdy4=
</additional-data>
<tasks>
<task>UPGR-BLOOP2</task>
</tasks>
<text>This account requires an upgrade to BLOOP2 as requested by the client</text>
</continue>
]]></example>
</section2>
<section2topic="Performing the upgrade"anchor="upgrade">
<p>Upon receiving the <next/> element for the upgrade, the server provides the elements and data needed for the client to calculate the requested data. The concrete elements and exchanges needed for the upgrade are specific to individual tasks. These tasks may be documented in other documents.</p>
</section2>
<examplecaption="SASL mechanism upgrades to fictional BLOOP2 and BLOOP-42 mechanisms"><![CDATA[
<!-- The Client initiates the task requested by the server in the <continue/> element -->
<p>For upgrades of SCRAM mechanisms as defined in &rfc5802;, the server has to provide the needed data for the client to calculate the SaltedPassword as defined in this RFC (or some RFC updating it), namely the iteration count and salt. To do so the server sends a <salt/> element namespaced to "urn:xmpp:scram-upgrade:0" containing the salt and an attribute named "iteration" containing the iteration count as defined in that RFC, omitting the "s=" and "i=" prefix. The <salt/> element is contained within a <task-data/> wrapper element as defined in &xep0388;.</p>
<p>The client then calculates the SaltedPassword and sends back its base64 encoded value inside a <hash/> element namespaced to "urn:xmpp:scram-upgrade:0". The <hash/> element is contained within a <task-data/> wrapper element as defined in &xep0388;.</p>
<p>The name of the upgrade task MUST NOT conain the "-PLUS" suffix, because channel-binding is not relevant for upgrade tasks.</p>
<examplecaption="SCRAM hash upgrade task for SCRAM-SHA-256 after successful SCRAM-SHA-1-PLUS authentication"><![CDATA[
<!-- Client sending stream header -->
<stream:stream
from='user@example.org'
to='example.org'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
<!-- Server responding with stream header and features -->
<stream:stream
from='example.org'
id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
to='user@example.org'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
<stream:features>
<authenticationxmlns='urn:xmpp:sasl:2'>
<mechanism>SCRAM-SHA-1</mechanism>
<mechanism>SCRAM-SHA-1-PLUS</mechanism>
<inline>
<!-- Server indicates that XEP-0198 stream resumption can be done "inline" -->
<resumexmlns='urn:xmpp:sm:3'/>
<!-- Server indicates support for XEP-0386 Bind 2 -->
<p>For compatibility purposes, the server SHOULD keep the older authentication data (password hashes etc.) of all configured mechanisms to continue offering the same mechanisms as before.</p>
<p>Clients SHOULD use channel-binding, if available, when requesting an upgrade to make sure no MITM can eavesdrop that hash and subsequently use it for authentication. Note that a client can always choose to not upgrade SASL mechanisms if it can not use channel-binding or the connection is otherwise deemed not secure enough.</p>