From fd51bf0751b0b3688485448e72bb6a16ab5800ea Mon Sep 17 00:00:00 2001 From: Thilo Molitor Date: Wed, 7 Sep 2022 22:56:35 +0200 Subject: [PATCH] XEP-0388: Rework whole spec, namespace bump - Add reference to SASL Channel-Binding Type Capability (XEP-0440) [1] and RFC 5802 [2] - Update security considerations and business rules - Clarify and tasks - Add expansion point to inline stream resumption and BIND2 (and possibly others) - Add optional element --- xep-0388.xml | 520 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 351 insertions(+), 169 deletions(-) diff --git a/xep-0388.xml b/xep-0388.xml index d1e41ed9..eba8a73c 100644 --- a/xep-0388.xml +++ b/xep-0388.xml @@ -12,14 +12,34 @@ 0388 Deferred Standards Track + Council Standards XMPP Core + rfc5802 + XEP-0440 sasl2 &dcridland; + &tmolitor; + &mwild; + + 0.4.0 + 2022-11-16 + tm + +
    +
  • Bump namespace
  • +
  • Add reference to &xep0440; and &rfc5802;
  • +
  • Update security considerations and business rules
  • +
  • Clarify <continue/> and tasks
  • +
  • Add expansion point to inline stream resumption and BIND2 (and possibly others)
  • +
  • Add optional <user-agent/> element
  • +
+
+
0.3.0 2018-10-01 @@ -94,81 +114,161 @@ - -

Servers capable of SASL2 offer a stream feature of <mechanisms/>, qualified by the "urn:xmpp:sasl:1" namespace. This in turn contains one or more <mechanism/> elements in the same namespace, and potentially other elements (for example, the <hostname/> element defined within XEP-0233).

-

Note that SASL2 is impossible for clients to initiate without at least one mechanism being available, and therefore MUST NOT be offered.

+ +

Servers capable of SASL2 offer a stream feature of <authentication/>, qualified by the "urn:xmpp:sasl:2" namespace. This in turn contains one or more <mechanism/> elements in the same namespace, and potentially other elements (for example, the <hostname/> element defined within &xep0233;). The mechanism elements MUST only offer mechanisms the server can offer for the JID provided by the client in the "from" attribute of the stream-header. If that atrribute is omitted or does not contain a recognised bare JID, the server SHOULD only offer mechanisms it can provide independently of the JID. Note that varying responses based on whether an account exists or not may leak the existence of accounts to unauthorized parties. See the security considerations section for more information. If the "from" attribute is not empty and the domain used in this attribute does not match the domain used in the "to" attribute the server SHOULD respond with an invalid-from error as defined in §4.9.3.9 of &rfc6120;.

The feature so advertised, and its child content, SHOULD be stable for the given stream to and from attributes and encryption state, and therefore MAY be cached by clients for later connections.

-

The Service Name used by XMPP is unchanged from RFC 6120.

+

Note that SASL2 is impossible for clients to initiate without at least one mechanism being available, and therefore MUST NOT be offered if not at least one mechanism can be provided.

+

The Service Name used by XMPP is unchanged from &rfc6120;.

+

All servers and clients supporting channel-binding MUST implement &xep0440;.

+

Additional stream features that can be negotiated as part of a successful SASL authentication can be included in the <inline/> element which is an immediate child of <authentication/>.

+ + +]]> + + + + + SCRAM-SHA-1 + SCRAM-SHA-1-PLUS + + + + + + + + + + + + + +]]>

In all cases, both Clients and Servers encode SASL exchanges using Base 64 encoding. This SHOULD NOT include any line wrapping or other whitespace. As the form <element/> is equivalent to <element></element>, these both indicate an empty string. Challenges and responses with no data do not occur in SASL, and so require no special handling. To indicate the absence of an initial response, or the absence of success data, the element is simply not included.

- -

Clients, upon observing this stream feature, initiate the authentication by the use of the <authenticate/> top-level element, within the same namespace. The nature of this element is to inform the server about properties of the final stream state, as well as initiate authentication itself. To achieve the latter, it has a single mandatory attribute of "mechanism", with a string value of a mechanism name offered by the Server in the stream feature, and an optional child element of <initial-response/>, containing a base64-encoded SASL Initial Response.

-

On subsequent connections, if a Client has previously cache the stream feature, the Client MAY choose to send it before seeing the stream features - sending it "pipelined" with the Stream Open tag for example.

+ +

Clients, upon observing this stream feature, initiate the authentication by the use of the <authenticate/> top-level element within the same namespace. The nature of this element is to inform the server about properties of the final stream state, as well as initiate authentication itself. To achieve this, it has a single mandatory attribute of "mechanism", with a string value of a mechanism name offered by the Server in the stream feature and an optional child element of <initial-response/>, containing a base64-encoded SASL Initial Response. If the "mechanism" attribute contains a string not previously announced by the server in in the stream feature, the server MUST fail the authentication.

+

If the stream's from attribute (if present) does not match the non-empty authorization string, the server MUST fail the authentication as defined in Failure.

+

Clients SHOULD also include a <user-agent/> element, informing the server about the connecting client. The 'id' attribute is RECOMMENDED, and if present contains a unique stable identifier for the client installation. The contents of the 'id' attribute MUST be a UUID v4. This allows the server to provide functionality such as deriving stable resource identifiers (see &xep0386;). The child elements <software/> and <device/> MAY be supplied by clients and contain text descriptions of the client software and the device it is installed on. These allow the server to keep the user informed about what devices are connected to their account. Servers MUST NOT expose this information to other entities (such functionality is available in &xep0092; if required).

- Tm9ib2R5IGV2ZXIgZGVjb2RlcyB0aGUgZXhhbXBsZXMu + + + cD10bHMtZXhwb3J0ZXIsLG49dXNlcixyPTEyQzRDRDVDLUUzOEUtNEE5OC04RjZELTE1QzM4RjUxQ0NDNg== + + AwesomeXMPP + Kiva's Phone + ]]>

In order to provide support for other desired stream states beyond authentication, additional child elements are used. For example, a hypothetical XEP-0198 session resumption element might be included, and/or Resource Binding requests.

+ SSBzaG91bGQgbWFrZSB0aGlzIGEgY29tcGV0aXRpb24= + + AwesomeXMPP + Kiva's Phone + -]]> -
- -

Server Challenges MAY then be sent. Each Challenge MUST be responded to by a Client in a Client Response. These are not extensible, and contain the corresponding base64 encoded SASL data:

- - - U28sIG5leHQgRk9TREVNIC0gMjAxOCwgdGhhdCBpcy4uLg== - - - - - Li4uSSdsbCBidXkgYSBiZWVyIGZvciB0aGUgZmlyc3QgcGVyc29uIHdoby4uLg== - ]]>

At any time while authentication is in progress, neither Client nor Server sends any element (including stanzas) or other data except the top-level elements defined herein. Clients MUST NOT send whitespace, and MUST send only <response/> elements as appropriate or an <abort/> element to immediately cause an error. Servers MUST disconnect Clients immediately if any other traffic is received. Servers are similarly REQUIRED to send no whitespace, and only the <response/> and completion elements from the section below.

- + +

Server Challenges MAY then be sent. Each Challenge MUST be responded to by a Client in a Client Response. These are not extensible, and contain the corresponding base64 encoded SASL data:

+ + + cj0xMkM0Q0Q1Qy1FMzhFLTRBOTgtOEY2RC0xNUMzOEY1MUNDQzZhMDkxMTdhNi1hYzUwLTRmMmYtOTNmMS05Mzc5OWMyYmRkZjYscz1RU1hDUitRNnNlazhiZjkyLGk9NDA5Ng== + + + + + Yz1jRDEwYkhNdFpYaHdiM0owWlhJc0xNY29Rdk9kQkRlUGQ0T3N3bG1BV1YzZGcxYTFXaDF0WVBUQndWaWQxMFZVLHI9MTJDNENENUMtRTM4RS00QTk4LThGNkQtMTVDMzhGNTFDQ0M2YTA5MTE3YTYtYWM1MC00ZjJmLTkzZjEtOTM3OTljMmJkZGY2LHA9VUFwbzd4bzZQYTlKK1ZhZWpmei9kRzdCb21VPQ== +]]> + + + + U28sIG5leHQgRk9TREVNIC0gMjAxOCwgdGhhdCBpcy4uLg== + + + + + Li4uSSdsbCBidXkgYSBiZWVyIGZvciB0aGUgZmlyc3QgcGVyc29uIHdoby4uLg== + +]]> +
+

Authentication may complete in one of three ways. It may complete successfully, in which case the client is authenticated. It may also fail, in which case the client is not authenticated and the stream and session state remain entirely unchanged.

Finally, it may have completed successfully, but further interaction is required - for example, a password change or second-factor authentication.

- -

If the Client is now authenticated, the Server sends a <success/> element, which contains contains an <authorization-identity/> element containing the negotiated identity - this is a bare JID, unless resource binding has occurred, in which case it is a full JID.

-

It MAY contain an <additional-data> element, containing additional data from the exchange (task or SASL mechanism) that has just completed.

- + +

If the Client is now authenticated, the Server sends a <success/> element, which contains an <authorization-identity/> element containing the negotiated identity - this is a bare JID, unless resource binding has occurred, in which case it is a full JID.

+

If the <success/> element it the response to a SASL mechanism exchange, it MAY contain an <additional-data> element, containing additional data from the SASL mechanism that has just completed.

+

If the <success/> element is the response to a task exchange initiated by a <continue/> element, it MAY contain any other element defined in a future protocol containing additional data from the task that has just completed

+

If the client requested any stream features inline as part of the SASL negotiation, they are processed by the server at this point.

+ + + + dj1tc1ZIcy9CeklPSERxWGVWSDdFbW1EdTlpZDg9 + + user@example.org + +]]> + ip/AeIOfZXKBV+fW2smE0GUB3I//nnrrLCYkt0Vj juliet@montague.example/Balcony/a987dsh9a87sdh ]]> -

Other extension elements MAY also be contained by the <success/> element.

- +

The results of activating any requested inline stream features are included in the server's <success/> response.

+ SGFkIHlvdSBnb2luZywgdGhlcmUsIGRpZG4ndCBJPw== - juliet@montague.example/Balcony/a987dsh9a87sdh - + juliet@montague.example + ]]>

Any security layer negotiated SHALL take effect after the ">" octet of the closing tag (ie, immediately after "</success>"), if it has not already taken effect at a <continue> - see Continue below.

-

The <success> element is immediately followed by a <features> element containing the applicable stream features of the newly authenticated stream. Note that no stream restart occurs.

+

The <success> element is immediately followed by a <features> element in the "http://etherx.jabber.org/streams" namespace containing the applicable stream features of the newly authenticated stream. Note that no stream restart occurs.

- +

A <failure/> element is used by the server to terminate the authentication attempt. It MAY contain application-specific error codes, and MAY contain a textual error. It MUST contain one of the SASL error codes from RFC 6120 Section 6.5.

+

The server MUST NOT process any inline features requested by the client in a failed authentication request, if any.

+ This is a terrible example. @@ -176,16 +276,16 @@ ]]>
-

A <continue/> element is used to indicate that while the SASL exchange was successful, it is insufficient to allow authentication at this time.

-

This can be used to indicate that the Client needs to perform a Second Factor Authentication ("2FA"), or is required to change password.

+

A <continue/> element is used to indicate that while the SASL exchange was successful, it is insufficient to allow authentication at this time. This can be used to indicate, for example, that the Client needs to perform a Second Factor Authentication ("2FA"), or is required to change password (this list is not meant to be exhaustive in any way).

Such tasks are presented within a <tasks> element, which contains a sequence of <task> elements, each containing a name. 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.

+

Like the <success/> element, the <continue/> element MAY contain an <additional-data/> element containing additional data from the SASL mechanism that has completed.

A client MAY choose any one of the offered tasks; if multiple are required a sequence of <continue> exchanges will occur until all mandatory tasks are complete.

The <continue element therefore always contains a <tasks/> element, as defined above. It MAY contain an <additional-data/> element, as the <success/> element does.

Finally, it MAY contain a <text/> element, which can contain human-readable data explaining the nature of the step required.

+ - SSdtIGJvcmVkIG5vdy4= + SSdtIGJvcmVkIG5vdy4= HOTP-EXAMPLE @@ -195,71 +295,113 @@ ]]>

After the final octet of the first <continue> element, any SASL security layer negotiated in the preceding exchange SHALL be immediately in effect.

-

Clients respond with a <next/> element, which has a single mandatory attribute of "task", containing the selected task name, and contains an OPTIONAL base64 encoded initial response contained in an <initial-response> element.

- - +

Clients respond with a <next/> element, which has a single mandatory attribute of "task", containing the selected task name, and MAY contain any other element as defined in a future protocol defining this task.

+

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. Each task MUST end either by the server sending a <failure/> element, if the task failed, a <continue/> element, if the task was completed successfully and the server requests the client to perform a new task, or a <success/> element, indicating that the task was completed successfully and no further tasks are needed.

+ + + SSd2ZSBydW4gb3V0IG9mIGlkZWFzIGhlcmUu -
- -]]>
+ + + + + + + 94d27acffa2e99a42ba7786162a9e73e7ab17b9d + + + + + + + OTRkMjdhY2ZmYTJlOTlhNDJiYTc3ODYxNjJhOWU3M2U3YWIxN2I5ZAo= + + + + + + + SGFkIHlvdSBnb2luZywgdGhlcmUsIGRpZG4ndCBJPw== + + juliet@montague.example +]]>
- -

This provides pointers and/or clarifications to the Overview in the order and manner defined in RFC 4422, section 4.

- -

The service name SHALL be "xmpp", as defined by RFC 6120.

-
- -

Servers list mechanisms during stream features (See Discovering Support).

-
- - -

Clients initiate using the <authenticate/> top level element (See Initiation.

-
- -

See Challenges and Responses.

-
- -

See Completing Authentication.

-
-
- -

If a Client specifies an authorization string which is non-empty, the identifier is normalized by treating it as a JID, and performing normalization as described in RFC 7622.

-

In general, implementors are advised that a non-empty authorization string MAY be considered an error if the stream's from attribute (if present) does not match.

-
- -

Clients MAY abort unilaterally by sending <abort/> as specified in Client Aborts.

-

Servers MAY abort unliterally by sending <failure/> with the <aborted/> error code as defined in Failure.

-
- -

Security Layers take effect after the SASL mechanism itself (ie, the first negotiation) has completed successfully, after the final octet of the server's <success> or <continue>. See Success and Continue.

-
- -

Option (a) is used - any SASL Security Layer is applied first to data being sent, and TLS applied last.

-
- -

Although the <continue/> concept does use tasks analogous to multiple SASL sequences, only the first SASL mechanism used is considered an authentication, and only the first can negotiate a security layer.

-

In particular, once <success/> has been sent by the server, any further <authenticate/> element MUST result in a stream error.

-
-
+ +

Relative to the SASL profile documented in RFC 6120, this introduces more data unprotected by any security layer negotiated by SASL itself. While no actual exchanges are introduced that are unprotected, the nature of this exchange might allow for (for example) a resource binding extension to be introduced. SASL security layers are sparingly used in the field, however, so this is thought to be a theoretical, rather than practical, concern. TLS, if negotiated before authentication, could mitigate these risks further.

+

As explained in § 13.8.3 of &rfc6120;, servers and clients SHOULD NOT support SASL PLAIN. Usage of PLAIN allows for trivial downgrade atacks by Man-In-The-Middle attackers circumventing any possible channel-binding or mutual authentication and even allowing the attacker to gain access to the cleartext password. If possible, PLAIN should be disabled by default on servers and clients and only be enabled when configured by the admin respective client user (if at all).

+

This protocol makes use of the hint of its identity contained in the stream "from" attribute as defined in &rfc6120; prior to authentication. This value MUST NOT be trusted to contain the real identity of the connecting client. Varying pre-authentication responses (such as supported SASL mechanisms) based on this value may allow unauthorized parties to discover whether an account exists, and even guess at what software might be used with that account (e.g. by observing which SASL mechanisms can be used on this account). Minimizing differences between the default response for unregistered JIDs and registered JIDs, as well as rate-limiting (to prevent enumeration attempts), are possible countermeasures. If the server does not know the client-identity it is RECOMMENDED to randomize the list of provided SASL mechanisms to reduce these risks even further.

+

SASL2 MUST only be used by Clients or offered by Servers after TLS negotiation, see § 5.2 and § 5.3.4 of &rfc6120;.

+

Clients MUST NOT send, and servers MUST NOT process, authentication requests included in the TLS 0-RTT ("early data") extension. Such data is vulnerable to replay attacks, and without adequate protection this could allow an attacker to disrupt established sessions or cause other side-effects depending on the inline features negotiated. This rule may be overridden by later specifications, provided they define appropriate protocols to mitigate these issues. Examples of these attacks and mitigations are discussed in Section 8 of &rfc8446;.

+
+ + +

This provides pointers and/or clarifications to the Overview in the order and manner defined in RFC 4422, section 4.

+ +

The service name SHALL be "xmpp", as defined by RFC 6120.

+
+ +

Servers list mechanisms in the <mechanisms/> list in response to a <request/> by the client. (See Initiation).

+
+ + +

Clients initiate using the <authenticate/> top level element (See Initiation.

+
+ +

See Challenges and Responses.

+
+ +

See Completing Authentication.

+
+
+ +

If a Client specifies an authorization string which is non-empty, the identifier is normalized by treating it as a JID, and performing normalization as described in RFC 7622.

+

Any non-empty authorization string MUST be considered an error if the stream's from attribute (if present) does not match.

+
+ +

Clients MAY abort unilaterally at any time before the authentication completed by sending an <abort/> element. This element MAY contain a <text/> element containing a textual representation of the reason as well as any other element defined in some future protocol.

+

Servers MAY abort unliterally by sending <failure/> with the <aborted/> error code as defined in Failure.

+
+ +

Security Layers take effect after the SASL mechanism itself (ie, the first negotiation) has completed successfully, after the final octet of the server's <success> or <continue>. See Success and Continue.

+
+ +

Option (a) is used - any SASL Security Layer is applied first to data being sent, and TLS applied last.

+
+ +

Although the <continue/> concept does use tasks analogous to multiple SASL sequences, only the first SASL mechanism used is considered an authentication, and only the first can negotiate a security layer.

+

In particular, once <success/> or <continue/> has been sent by the server, any further <authenticate/> element MUST result in a stream error.

+
+
+ + +

This section provides some example flows. It aims to demonstrate the structure of SASL2 negotiation, but it does not definitively describe any of the additional extensions shown here.

+ +

Where no additional features that SASL2 makes available are used, the flow of information is identical to the original SASL profile. This example shows the new syntax and draws the reader's attention to the differences.

+ + - -

This section provides a fictional example. It is important to note that many of the extensions used wihtin this section do not, in fact, exist and therefore are to be avoided.

- -

Where no additional features that SASL2 makes available are used, the flow of information is identical to the original SASL profile. This example shows the new syntax and draws the reader's attention to the differences.

- - + PLAIN SCRAM-SHA-1 - + - + AGFsaWNlQGV4YW1wbGUub3JnCjM0NQ== + + AwesomeXMPP + Kiva's Phone + - + alice@example.org + ]]> -

Use of SASL2 in this simple scenario saves one round-trip (due to the lack of stream restart).

-
- -

Again, this is an equivalent flow to a common SASL1 flow, although using the CRAM-MD5 mechanism which is (thankfully) rarely used in practise.

- Use of SASL2 in this simple scenario saves one round-trip (due to the lack of stream restart).

+
+ +

In this example, multiple potential round-trips are saved by negotiating resource binding and stream management inline.

+ + + - + PLAIN CRAM-MD5 @@ -312,28 +470,34 @@ Client intiates authentication. Here, no initial response is needed, so none is sent. --> - + + + AwesomeXMPP + Kiva's Phone + + - + PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2UucmVzdG9uLm1jaS5uZXQ+ - dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw - + tim@example.org + ]]> -

Use of SASL2 in this simple scenario again simply saves one round-trip.

-
- -

This moves into the deeply hypothetical. A binding extension is posited, alongside an unrealistic 2FA mechanism which somehow mutually authenticates because why not.

- + +

This moves into the deeply hypothetical. A binding extension is posited, alongside an unrealistic 2FA mechanism which somehow mutually authenticates because why not.

+ + + - + BLURDYBLOOP - - + + + + - + SW5pdGlhbCBSZXNwb25zZQ== + + AwesomeXMPP + Kiva's Phone + this-one-please @@ -379,26 +559,26 @@ - + PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2UucmVzdG9uLm1jaS5uZXQ+ - dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw - + QWRkaXRpb25hbCBEYXRh @@ -408,60 +588,49 @@ - - + + VW5yZWFsaXN0aWMgMkZBIElS - - + - - PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2UucmVzdG9uLm1jaS5uZXQ+ - + + + PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2UucmVzdG9uLm1jaS5uZXQ+ + + - + + dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw + + - - + + VW5yZWFsaXN0aWMgMkZBIG11dHVhbCBhdXRoIGRhdGE= - + alice@example.org/this-one-please - - ]]> -

Although the unrealistic 2FA here uses 2 round-trips (real ones will probably use one), the embedding of resource binding as shown here means that a second RTT is saved by SASL2, and there's no net change. A more realistic example would see RTTs saved, and additional negotiations could be added to further reduce RTTs.

-
-
- - -

Relative to the SASL profile documented in RFC 6120, this introduces more data unprotected by any security layer negotiated by SASL itself.

-

While no actual exchanges are introduced that are unprotected, the nature of this exchange might allow for (for example) a resource binding extension to be introduced.

-

SASL security layers are sparingly used in the field, however, so this is thought to be a theoretical, rather than practical, concern.

+

Although the unrealistic 2FA here uses 2 round-trips (real ones will probably use one), the embedding of resource binding as shown here means that a second RTT is saved by SASL2, and there's no net change. A more realistic example would see RTTs saved, and additional negotiations could be added to further reduce RTTs.

+
@@ -476,14 +645,29 @@ - + + + + + + + + + + + + + + + + @@ -493,17 +677,7 @@ - - - - - - - - - - - + @@ -513,13 +687,12 @@ - - - - + + + @@ -539,6 +712,15 @@ + + + + + + + + + @@ -560,7 +742,7 @@ -

The author wishes to share any credit with many members of the community, including Lance Stout, Ralph Meijer, Phil Roberts and Florian Schmaus.

+

The authors wish to share any credit with many members of the community, including Lance Stout, Ralph Meijer, Phil Roberts and Florian Schmaus.