<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
    <!ENTITY rfc2119 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml'>
    <!ENTITY rfc8174 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml'>
    <!ENTITY rfc3629 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.3629.xml'> <!--UTF-8-->
    <!ENTITY rfc4422 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4422.xml'> <!--SASL1-->
    <!ENTITY rfc4510 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4510.xml'> <!--LDAP-->
    <!ENTITY rfc4616 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4616.xml'> <!--PLAIN-->
    <!ENTITY rfc4648 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4648.xml'> <!--base64, etc-->
    <!ENTITY rfc4949 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4949.xml'> <!--Internet Security Glossary, Version 2-->
    <!ENTITY rfc5056 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5056.xml'> <!--Channel Bindings-->
    <!ENTITY rfc5226 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5226.xml'> <!--Guidelines on writing IANA Considerations-->
    <!ENTITY rfc5246 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5246.xml'> <!--TLS 1.2-->
    <!ENTITY rfc6238 PUBLIC '' 'https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6238.xml'> <!--TOTP-->
  ]>

  <?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>

<?rfc toc="yes" ?>
<?rfc tocindent="no" ?>
<?rfc autobreaks="no" ?>
<?rfc comments="yes" ?>
<?rfc inline="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes"?>
<?rfc iprnotified="no" ?>
<?rfc strict="no" ?>
<?rfc compact="no"?>

<rfc ipr="trust200902" category="std" docName="draft-melnikov-sasl2-01">
    <front>
	<title abbrev="Extended SASL">Extensible Simple Authentication and Security Layer (SASL)</title>

	<author initials='D.' surname="Cridland" fullname="Dave Cridland">
	    <organization></organization>
	    <address>
		    <email>dave@cridland.net</email>
	    </address>
	</author>
  <author initials='T.' surname="Molitor" fullname="Thilo Molitor">
	    <organization></organization>
	    <address>
		    <email>thilo+xmpp@eightysoft.de</email>
	    </address>
	</author>
	<author initials='M.' surname="Wild" fullname="Matthew Wild">
	    <organization></organization>
	    <address>
		    <email>mwild1@gmail.com</email>
	    </address>
	</author>
	<author initials='A.' surname="Melnikov" fullname="Alexey Melnikov">
	    <organization>Isode Ltd</organization>
	    <address>
		    <email>Alexey.Melnikov@isode.com</email>
	    </address>
	</author>
      
  <date year="2023"/>
	<area>Security</area>
	<keyword>SASL</keyword>
	<keyword>KITTEN</keyword>
	<keyword>2FA task</keyword>
	<keyword>upgrade task</keyword>
	<keyword>reauthentication</keyword>
	<abstract>

    <t>
   The Simple Authentication and Security Layer (SASL) is a framework
   for providing authentication and data security services in
   connection-oriented protocols via replaceable mechanisms.  It
   provides a structured interface between protocols and mechanisms.
   The resulting framework allows new protocols to reuse existing
   mechanisms and allows old protocols to make use of new mechanisms.
   The framework also provides a protocol for securing subsequent
   protocol exchanges within a data security layer.
    </t>

    <t>
   This document describes how a SASL mechanism is structured, describes
   how protocols include support for SASL, and defines the protocol for
   carrying a data security layer over a connection.  This document
   also defines how servers can request fulfillment of extra authentication
   related tasks, such as two factor authentication and/or password change.
    </t>

 <!--///Alexey: Decide whether we are going to specify just delta from RFC 4422 or chose to replace in its entirety
    <t>
    This document obsoletes RFC 4422.
    </t>
   -->

  </abstract>
    </front>

    <middle>

	<section title="Introduction">

    <t>
    The Simple Authentication and Security Layer (SASL) is a framework
    for providing authentication and data security services in
    connection-oriented protocols via replaceable mechanisms.  SASL
    provides a structured interface between protocols and mechanisms.
    SASL also provides a protocol for securing subsequent protocol
    exchanges within a data security layer.  The data security layer can
    provide data integrity, data confidentiality, and other services.
    </t>
    
    <t>
    SASL's design is intended to allow new protocols to reuse existing
    mechanisms without requiring redesign of the mechanisms and allows
    existing protocols to make use of new mechanisms without redesign of
    protocols.
    </t>
    
    <t>
    SASL is conceptually a framework that provides an abstraction layer
    between protocols and mechanisms as illustrated in the following
    diagram.
    </t>

<figure><artwork type='abnf'>
<![CDATA[
                  SMTP    LDAP    XMPP   Other protocols ...
                     \       |    |      /
                      \      |    |     /
                     SASL abstraction layer
                      /      |    |     \
                     /       |    |      \
              EXTERNAL   GSSAPI  PLAIN   Other mechanisms ...
]]>
</artwork>
</figure>

<t>
    It is through the interfaces of this abstraction layer that the
    framework allows any protocol to utilize any mechanism.  While this
    layer does generally hide the particulars of protocols from
    mechanisms and the particulars of mechanisms from protocols, this
    layer does not generally hide the particulars of mechanisms from
    protocol implementations.  For example, different mechanisms require
    different information to operate, some of them use password-based
    authentication, some of then require realm information, others make
    use of Kerberos tickets, certificates, etc.  Also, in order to
    perform authorization, server implementations generally have to
    implement identity mapping between authentication identities, whose
    form is mechanism specific, and authorization identities, whose form
    is application protocol specific.  Section 2 discusses identity
    concepts.
    </t>
    
    <t>
    It is possible to design and implement this framework in ways that do
    abstract away particulars of similar mechanisms.  Such a framework
    implementation, as well as mechanisms implementations, could be
    designed not only to be shared by multiple implementations of a
    particular protocol but to be shared by implementations of multiple
    protocols.
    </t>
       
    <t>
    Since the publication of <xref target="RFC4422"/> a number of shortcomings
    in the SASL framework were identified that are addressed in this document.
    [[Note that the current draft only shows changes from RFC 4422.]]
    </t>

    <t>
    </t>

    <t>
    This specification addresses a number of shortfalls in <xref target="RFC4422"/>:

      <list style='symbols'>

        <t>
        Support for Two-factor authentication (2FA) or Multi-factor authentication (MFA) tasks.
        </t>

        <t>
        Support for mandatory password change tasks.
        </t>

        <t>
        Channel Binding advertisement.
        </t>
        
        <t>
        Shared key derivation after successful authentication.
        </t>
        
      </list>

  <!--///Alexey: can improve/clarify?-->
    Extensions to SASL documented herein are primarily to allow for better capability discovery,
    and additional results beyond total success or abject failure.
    </t>

<!--
    <t>
    Two-factor authentication (2FA) is a way to add additional security to an authentication
    exchange. The first "factor" is a password. The second "factor" is a verification code
    retrieved from an application on a mobile device or computer.
    2FA is conceptually similar to a security token device that banks in some countries
    require for online banking. Some examples of 2FA systems are OTP (one-time password)
    and TOTP (Time-based One-time Password algorithm, such as <xref target="RFC6238"/>).
    </t>
  -->

<!--///Alexey: remaining text copied from the Introduction of RFC 4422. Some of it is probably needed?
    <t>
    The framework incorporates interfaces with both protocols and
    mechanisms in which authentication exchanges are carried out.
    Section 3 discusses SASL authentication exchanges.
    </t>
    
    <t>
    To use SASL, each protocol (amongst other items) provides a method
    for identifying which mechanism is to be used, a method for exchange
    of mechanism-specific server-challenges and client-responses, and a
    method for communicating the outcome of the authentication exchange.
    Section 4 discusses SASL protocol requirements.
    </t>
    
    <t>
    Each SASL mechanism defines (amongst other items) a series of
    server-challenges and client-responses that provide authentication
    services and negotiate data security services.  Section 5 discusses
    SASL mechanism requirements.
    </t>
    
    <t>
    Section 6 discusses security considerations.  Section 7 discusses
    IANA considerations.  Appendix A defines the SASL EXTERNAL mechanism.
    </t>
-->

  </section>

	<section anchor="conv" title="Conventions Used in This Document">

	  <t>
    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
    "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
    "OPTIONAL" in this document are to be interpreted as described in
    BCP 14 <xref target='RFC2119'/> <xref target='RFC8174'/> when, and only when, they appear in all
    capitals, as shown here.
    </t>

    <t>
    Character names in this document use the notation for code points and
    names from the Unicode Standard <xref target='Unicode'/>.  For example, the letter
    "a" may be represented as either &lt;U+0061&gt; or &lt;LATIN SMALL LETTER A&gt;.
    </t>

    <t>
    Note: a glossary of terms used in Unicode can be found in <xref target='Glossary'/>.
    Information on the Unicode character encoding model can be found in
    <xref target='CharModel'/>.
    </t>

    <t>
    Example lines prefaced by "C:" are sent by the client and ones prefaced by "S:" by the server.
    If a single "C:" or "S:" label applies to multiple lines, then the line breaks between
    those lines are for editorial clarity only, and are not part of the actual protocol
		exchange.
    </t>

	</section>

	<section anchor="tasks" title="Tasks">

	  <t>
    A protocol profile might have a way to indicate that while the SASL exchange was successful,
    it is insufficient to allow authentication at this time. We call this indicator a "continue outcome message".
    This can be used to indicate a need to execute extra task(s),
    for example, that the Client needs to perform a Second Factor Authentication ("2FA")<!--e.g. TOTP = "RFC6238"-->
    and/or is required to change password (this list is not meant to be exhaustive in any way).
    </t>

    <t>
    These tasks are analogous to a SASL mechanism, but have a number of differences -
    they may never attempt to negotiate a new authorization identifier, nor a new security layer.
    </t>

    <t>
    Each task has a name ([[need to define syntax and maximum length]]) that SHOULD be registered with IANA. 
    </t>

    <t>
    A client MAY choose any one of the offered tasks; if multiple are required,
    once a task is successfully completed, the server will indicate that another one
    is required, and so on, until all mandatory tasks are complete.
    </t>

    <t>
    The continue outcome message MAY include SASL mechanism specific additional data, as the successful outcome message does.
    </t>

    <t>
    Finally, the continue outcome message MAY contain a textual data, which contains human-readable data explaining the nature of the step required.
    </t>

    <figure><artwork>
<![CDATA[
Example 1. Continue Required (using XMPP protocol)

S: <continue xmlns='urn:xmpp:sasl:2'>
  <additional-data>
    SSdtIGJvcmVkIG5vdy4=
  </additional-data>
  <tasks>
    <task>HOTP-EXAMPLE</task>
    <task>TOTP-EXAMPLE</task>
  </tasks>
  <text>This account requires 2FA</text>
</continue>
]]>
    </artwork></figure>


    <t>
    If any SASL security layer was negotiated, it takes effect after the final octet of the first continue outcome message.
    </t>

    <t>
    Clients respond with a task initiation message, which has a single mandatory parameter containing the selected task name,
    and MAY contain any task specific data.
    </t>

  <!--XMPP specific:
    The concrete elements exchanged for each task after the <next/> reside inside a <task-data/> wrapper element in the namespace
    "urn:xmpp:sasl:2". Each wrapper element can contain any other element as defined in a future protocol defining this concrete task.
    -->

    <t>
    Each task MUST end either by the server sending a task failure indicator message, if the task failed,
    a continue outcome message, if the task was completed successfully and the server requests the client
    to perform a new task, or a successful outcome message, indicating that the task was completed successfully
    and no further tasks are needed.
    </t>

    <figure>
      <artwork>
<![CDATA[
Example 2. Fictional TOTP task
<!-- Client starts TOTP-EXAMPLE task -->

<next xmlns='urn:xmpp:sasl:2' task='TOTP-EXAMPLE'>
  <totp xmlns="urn:totp:example">
    SSd2ZSBydW4gb3V0IG9mIGlkZWFzIGhlcmUu
  </totp>
</next>

<!-- Server provides needed data to Client -->
<task-data xmlns='urn:xmpp:sasl:2'>
  <totp xmlns="urn:totp:example">
    94d27acffa2e99a42ba7786162a9e73e7ab17b9d
  </totp>
</task-data>

<!-- Client responds with requested TOP data -->
<task-data xmlns='urn:xmpp:sasl:2'>
  <totp xmlns="urn:totp:example">
    OTRkMjdhY2ZmYTJlOTlhNDJiYTc3ODYxNjJhOWU3M2U3YWIxN2I5ZAo=
  </totp>
</task-data>

<!-- Server indicates successful completion of TOTP-EXAMPLE task -->
<success xmlns='urn:xmpp:sasl:2'>
  <totp xmlns="urn:totp:example">
    SGFkIHlvdSBnb2luZywgdGhlcmUsIGRpZG4ndCBJPw==
  </totp>
  <authorization-identifier>juliet@montague.example</authorization-identifier>
</success>    
]]>
</artwork>
</figure>

  </section>

	<section anchor="channel-binding-advertisement" title="Channel Binding advertisement">

    <t>Most modern SASL mechanism are expected to support channel bindings <xref target="RFC5056"/>.</t>

    <t>Explicit advertisement of server supported channel binding types improves interoperability and is also necessary to prevent certain MITM attacks.</t>

    <figure>
      <artwork>
<![CDATA[
Example 3. Channel Binding Type advertisement in XMPP (XEP-0440).
Note that the <sasl-channel-binding> element is the new channel
binding advertisement.

<stream:features>
  <sasl-channel-binding xmlns='urn:xmpp:sasl-cb:0'>
    <channel-binding type='tls-server-end-point'/>
    <channel-binding type='tls-exporter'/>
  </sasl-channel-binding>
  <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
    <mechanism>EXTERNAL</mechanism>
    <mechanism>SCRAM-SHA-1-PLUS</mechanism>
    <mechanism>PLAIN</mechanism>
  </mechanisms>
</stream:features>
]]>
</artwork>
</figure>
    
  </section>

  <section title="Extra Protocol Requirements">

    <t>[[Note that the item number continues the numbering of requirements from Section 4 of RFC 4422.]]</t>
    
    <t>[[Alexey: All of the features below are optional (in order to remain backward compatible with RFC 4422).
    However if any is implemented, all of them MUST be implemented in a protocol.
    This makes client implementations easier.]]</t>

    <t>
      
  <!--Or can try <list counter="9" style="format %d">?-->
		<list style='empty'>

		  <t>
      9) Facility to advertise the list of Channel Bindings that the server supports.
      See <xref target="channel-binding-advertisement"/>.
      </t>

      <t>
      10) Detail any task negotiation facility that the protocol
        provides<!-- (see Section 3.2)-->.

        [[Alexey: does this need to be done before authentication starts, or is it sufficient
        to discover these at the end of SASL mechanism exchange, when specific extra tasks are requested?]]
        
        A protocol MUST specify a facility through which the client may
        discover, the names of the SASL tasks that the server makes available to the
        client.  <!--///Alexey: Do we need a requirement for this to be discoverable before a SASL mechanism
        authentication exchange is started?-->
        <!--The latter is important to allow the client to detect
        downgrade attacks.-->  This facility is typically provided through
        the protocol's extensions or capabilities discovery facility (so that the client can be made aware of
        which tasks might be required to complete authentication before starting any authentication),
        as well as provided at the end of a SASL authentication exchange.
      </t>

      <t>
      11) Definition of the messages necessary for executing tasks,
          including the following:

      <list style='letters'>
          <t>
          A message to initiate execution of a task (see <xref target="tasks"/>).

          This message MUST contain a field for carrying the name of the
          task selected by the client.

          This message MUST allow for an optional field for carrying an
          initial task related data.  The specification MUST describe how messages with an empty
          initial task related data are distinguished from messages with no
          initial task related data.  This field MUST be capable of carrying
          arbitrary sequences of octets (including zero-length sequences
          and sequences containing zero-valued octets).
          </t>

          <t>
          Messages to transfer task related data from server and from client
          (see <xref target="tasks"/>).

          Each of these messages MUST be capable of carrying arbitrary
          sequences of octets (including zero-length sequences and
          sequences containing zero-valued octets).
          </t>

          <t>
          A message to indicate the outcome of the task execution
          and whether or not execution of further tasks is required by the server
          (see <xref target="tasks"/>).

          This message MUST allow for an optional field for carrying
          additional data with a successful outcome.  The specification MUST describe how
          messages with an empty additional data are distinguished from
          messages with no additional data.  This field MUST be capable
          of carrying arbitrary sequences of octets (including zero-
          length sequences and sequences containing zero-valued octets).
        </t>
      </list>
      </t>
        
    </list>

	  </t>

	</section>
      
      
	<section title="Extra Mechanism Requirements">

    <t>[[Note that the number continues the numbering of requirements from Section 5 of RFC 4422.]]</t>
    
    <t>
      
  <!--Or can try <list counter="9" style="format %d">?-->
		<list style='empty'>

      <t>
      6) Optional facility for SASL mechanism shared key derivation after a successful authentication.
          <!--(see Section X.X for more details)-->.
      </t>

    </list>

	  </t>

	</section>



	<section title="Example of a Protocol fulfilling extra requirements">

    <t>
    [[Ideally need 2 protocols. For example XMPP and IMAP. IMAP can have a new command for tasks.]]
    </t>

<!--    
    <figure><artwork>
<![CDATA[
]]>
    </artwork></figure>
  -->

    <t>
    </t>

  </section>



	<section title="Open Issues">

	  <t></t>

  </section>
      
	<section title="Security Considerations">

	  <t>TBD</t>

  </section>

	<section anchor='iana' title="IANA Considerations">

    <t>
    IANA is requested to create a new subregistry of "SASL tasks"
    for registering SASL tasks as specified in this document.
    </t>

	  <t>The registration template is as follows:</t>

    <figure>
      <artwork>
        <![CDATA[
Task Name: <need to define syntax!>
Task Type: <define the list of types and whether or not it will be extensible>
Pointer to specification text:
Notes (optional):
		    ]]>
      </artwork>
    </figure>

    <t>The registration procedure for the above registry is Expert Review.</t>

<!--
    <t>IANA is requested to register a new value in the subregistry defined above:</t>
    <figure>
      <artwork>
        <![CDATA[
Task Name: <need to define syntax!>
Task Type: <define the list of types and whether or not it will be extensible>
Pointer to specification text:
Notes (optional):
		    ]]>
      </artwork>
    </figure>
  -->

  </section>

	<section title="Acknowledgements">

    <t>TBD. Thank you XSF for XEP-0388, XEP-0440 and XEP-scram-upgrade.</t>

    <!--    
    <t>Thank you to Stephen Farrell for motivating creation of this document and
    to Dave Cridland for describing how TOTP can be used with XMPP in XEP-0400.
    Thank you to Rick van Rein, Simon Josefsson and Ludovic Bocquet for comments and corrections,
    but all final errors in this document remain mine.</t>
  -->
    
	</section>


<!--
	<section title="Internet-Draft Change History">

	    <t>(RFC Editor: Please delete this section and all subsections.)</t>

	    <t>Changes since -00

		<list style='symbols'>

		    <t></t>

		</list>

	    </t>

	</section>
-->

    </middle>

    <back>
      
	<references title="Normative References">
    
      &rfc2119;
      &rfc8174;
      &rfc4422;
      &rfc4949;
      &rfc5056;
<!--
      &rfc5929;
-->

    <reference anchor="Unicode" target="https://www.unicode.org/versions/Unicode15.0.0/">
      <front>
        <title>Unicode 15.0.0</title>
        <author fullname="Unicode Consortium">
          <organization/>
        </author>
        <date day="13" month="September" year="2022"/>
      </front>
      <seriesInfo name="Unicode" value="15.0.0"/>
      <format target="https://www.unicode.org/reports/tr17/" type="HTML"/>
    </reference>




    <reference anchor="Glossary" target="https://www.unicode.org/glossary/">
      <front>
        <title>Glossary of Unicode Terms</title>
        <author fullname="Unicode Consortium">
          <organization/>
        </author>
        <date year="2023"/>
      </front>
      <seriesInfo name="Unicode" value="glossary"/>
      <format target="https://www.unicode.org/glossary/" type="HTML"/>
    </reference>
      
    <reference anchor="CharModel" target="https://www.unicode.org/reports/tr17/">
      <front>
        <title>Unicode character encoding model</title>
        <author fullname="Ken Whistler" initials="K." surname="Whistler">
        </author>
        <author fullname="Asmus Freytag" initials="A." surname="Freytag">
        </author>
        <date day="11" month="November" year="2022"/>
      </front>
      <seriesInfo name="Unicode" value="tr17"/>
      <format target="https://www.unicode.org/reports/tr17/" type="HTML"/>
    </reference>
      

  </references>

  <references title="Informative References">

      &rfc6238;
      
<!--
    <reference anchor="draft-schmaus-kitten-sasl-ht" target="https://www.ietf.org/archive/id/draft-schmaus-kitten-sasl-ht-09.txt">
      <front>
        <title>The Hashed Token SASL Mechanism</title>
        <author fullname="Florian Schmaus" initials="F." surname="Schmaus">
          <organization>FAU Erlangen-Nürnberg</organization>
        </author>
        <author fullname="Christoph Egger" initials="C." surname="Egger">
          <organization>FAU Erlangen-Nürnberg</organization>
        </author>
        <date day="6" month="November" year="2022"/>
        <abstract>
          <t>This document specifies the family of Hashed Token SASL mechanisms which enable a proof-of-possession-based authentication scheme and are meant to be used for quick re-authentication of a previous session. The Hashed Token SASL mechanism's authentication sequence consists of only one round-trip. The usage of short-lived, exclusively ephemeral hashed tokens is achieving the single round- trip property. The SASL mechanism specified herin further provides hash agility, mutual authentication and support for channel binding.</t>
        </abstract>
      </front>
      <seriesInfo name="Internet-Draft" value="draft-schmaus-kitten-sasl-ht-09"/>
      <format target="https://www.ietf.org/archive/id/draft-schmaus-kitten-sasl-ht-09.txt" type="TXT"/>
    </reference>
-->
      
  </references>
      
    </back>

</rfc>
