XEP-0178: Best Practices for Use of SASL EXTERNAL with Certificates

Abstract:This document specifies best practices for XMPP usage of the SASL EXTERNAL mechanism in the context of X.509 certificates.
Authors:Peter Saint-Andre, Peter Millard
Copyright:© 1999 - 2010 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status:Active
Type:Informational
Version:1.0
Last Updated:2007-02-15

NOTICE: This Informational specification defines a best practice or protocol profile that has been approved by the XMPP Council and/or the XSF Board of Directors. Implementations are encouraged and the best practice or protocol profile is appropriate for deployment in production systems.


Table of Contents


1. Introduction
2. Client-to-Server Recommendation
3. Server-to-Server Recommendation
4. Security Considerations
5. IANA Considerations
6. XMPP Registrar Considerations
7. Acknowledgements
8. Author Note

Appendices
    A: Document Information
    B: Author Information
    C: Legal Notices
    D: Relation to XMPP
    E: Discussion Venue
    F: Requirements Conformance
    G: Notes
    H: Revision History


1. Introduction

XMPP as specified in RFC 3920 [1] and provisionally clarified in rfc3920bis [2] allows the use of any SASL mechanism (see RFC 4422 [3]) in the authentication of XMPP entities, including the SASL EXTERNAL mechanism. This document specifies a recommended protocol flow for such use in the context of X.509 certificates, specifically when negotiation of TLS is required by a deployment. [4] [5]

2. Client-to-Server Recommendation

As specified in RFC 3920 and provisionally clarified in rfc3920bis, if a JabberID is included in an X.509 certificate, it MUST be encapsulated as an id-on-xmppAddr Object Identifier. Although it is not necessary for an X.509 certificate to include a JabberID, it is RECOMMENDED that client certificates include at least one id-on-xmppAddr OID encapsulating the JabberID of associated user (e.g., "juliet@example.org"), and OPTIONAL for client certificates to include either more than one id-on-xmppAddr or no id-on-xmppAddr. This specification includes recommendations that address all three cases.

The RECOMMENDED protocol flow for client-to-server use of SASL EXTERNAL with end-user certificates is as follows:

  1. Client initiates stream to server.

    <stream:stream 
            xmlns:stream='http://etherx.jabber.org/streams' 
            xmlns='jabber:client' 
            to='example.com' 
            version='1.0'>
          
  2. Server replies with stream header.

    <stream:stream 
            xmlns:stream='http://etherx.jabber.org/streams' 
            xmlns='jabber:client' 
            id='c2s_234' 
            from='example.com' 
            version='1.0'>
          
  3. Server advertises TLS stream feature.

    <stream:features>
      <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'>
        <required/>
      </starttls>
    </stream:features>
          
  4. Client sends STARTTLS command to server.

    <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
          
  5. Server informs client to proceed.

    <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
          
  6. Client presents certificate.

  7. Server and client negotiate TLS and client initiates a new stream header to server.

    <stream:stream 
            xmlns:stream='http://etherx.jabber.org/streams' 
            xmlns='jabber:client' 
            to='example.com' 
            version='1.0'>
          
  8. Server replies with stream header.

    <stream:stream 
            xmlns:stream='http://etherx.jabber.org/streams' 
            xmlns='jabber:client' 
            id='c2s_345' 
            from='example.com' 
            version='1.0'>
          
  9. Server advertises SASL mechanisms. If server expects that client will be able to authenticate and authorize as the identity provided in the presented certificate, then server SHOULD advertize the SASL EXTERNAL mechanism; otherwise, if presented certificate is unacceptable (e.g., because the certificate is expired, not yet valid, or revoked, or because the root certificate was issued by a certification authority that is untrusted), server MUST NOT offer EXTERNAL mechanism.

    <stream:features>
      <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
        <mechanism>EXTERNAL<mechanism>
        <mechanism>DIGEST-MD5<mechanism>
        <mechanism>ANONYMOUS<mechanism>
        <required/>
      </mechanisms>
    </stream:features>
          
  10. Because client presented a certificate, client SHOULD consider EXTERNAL to be its preferred SASL mechanism. If the client certificate includes only one XMPP address and the user wishes to authorize as the identity that has been authenticated by the TLS layer (i.e., the XMPP address that is contained in the client certificate), then the client SHOULD NOT include an authorization identity (i.e., the XML character data for the element SHOULD be "=", indicating an empty response); if the client certificate contains more than one XMPP address or if the user wishes to authorize as another identity, then the client MUST include an authorization identity; if the client certificate contain no XMPP address, then the client SHOULD include an authorization identity (but MAY include no authorzation identity since the client may not even know its identity, instead having it assigned by the server).

    <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='EXTERNAL'>=</auth>
          
  11. Server determines whether to allow authentication and authorization of user.

    1. If the certificate presented by the client contains only one valid XMPP address that corresponds to a registered account on the server and client did not pass an authorization identity in the SASL exchange, then the server SHOULD allow authentication and authorization of that JID. For the purpose of client authentication and authorization with a server, a valid XMPP address is a JID encapsulated as a subjectAltName entity of type otherName with an ASN.1 Object Identifier of "id-on-xmppAddr" as specified in Section 5.1.1. of RFC 3920.

      <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
                
    2. If the certificate contains more than one valid XMPP address that corresponds to a registered account on the server (e.g., because the server offers virtual hosting), then the server SHOULD allow authentication and authorization of the JID specified as the authorization identity.

      <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
                

      If no authorization identity is included, then the server MUST return a SASL failure case of <invalid-authzid/> and close the stream.

      <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
        <invalid-authzid/>
      </failure>
      </stream:stream>
                
    3. If the certificate does not contain an XMPP address, then the server MAY attempt to determine if there is a registered account associated with the user, for example by performing an LDAP lookup based on the Common Name in the certificate; if such a JID mapping is successful and the mapped JID matches the authorization identity provided, then the server SHOULD allow authentication and authorization of that mapped JID.

      <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
                

      If JID mapping is unsuccessful, then the server MUST return a SASL failure case of <not-authorized/> and close the stream.

      <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
        <not-authorized/>
      </failure>
      </stream:stream>
                

      If JID mapping is successful but the mapped JID does not match the authorization identity provided (if any), then the server MUST return a SASL failure case of <invalid-authzid/> and close the stream.

      <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
        <invalid-authzid/>
      </failure>
      </stream:stream>
                
  12. If SASL authentication succeeded, client opens new stream, then client and server proceed with resource binding as described in RFC 3920.

3. Server-to-Server Recommendation

As specified in RFC 3920 and provisionally clarified in rfc3920bis, if a JabberID is included in an X.509 certificate, it MUST be encapsulated as an id-on-xmppAddr Object Identifier. Although it is not necessary for an X.509 certificate to include a JabberID, it is RECOMMENDED that server certificates include the id-on-xmppAddr OID encapsulating the JabberID of the bare XMPP server domain only (e.g., "example.org"). In addition, it is RECOMMENDED in the case of server certificates for the server's hostname to be encapsulated as a subjectAltName extension of type dNSName. Furthermore it is quite common for XMPP servers to also offer associated services as "subdomains" of the server; if a server offers such services then it is RECOMMENDED to either include an id-on-xmppAddr OID for each "subdomain" or to include a dnsName containing the wildcard character '*' applying to the left-most domain name component or component fragment (this is considered to match any single component or component fragment, e.g., *.example.org matches foo.example.org but not bar.foo.example.org, and im*.example.net matches im1.example.net and im2.example.net but not chat.example.net). This specification includes recommendations that address all three cases.

The RECOMMENDED protocol flow for server-to-server use of SASL EXTERNAL with server (domain) certificates is as follows:

  1. Server1 initiates stream to server2.

    <stream:stream 
            xmlns:stream='http://etherx.jabber.org/streams' 
            xmlns='jabber:server' 
            from='conference.example.org' 
            to='example.com' 
            version='1.0'>
          
  2. Server2 replies with stream header.

    <stream:stream 
            xmlns:stream='http://etherx.jabber.org/streams' 
            xmlns='jabber:server' 
            id='s2s_234' 
            from='example.com' 
            to='conference.example.org'
            version='1.0'>
          
  3. Server2 advertises TLS stream feature.

    <stream:features>
      <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'>
        <required/>
      </starttls>
    </stream:features>
          
  4. Server1 sends STARTTLS command to Server2.

    <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
          
  5. Server2 informs Server1 to proceed.

    <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
          
  6. Server1 presents certificate.

  7. Server2 validates certificate.

    1. If certificate is unacceptable (e.g., because the certificate is expired, not yet valid, or revoked), Server2 closes Server1's TCP connection.

    2. Else Server2 completes successful TLS negotiation and Server1 initiates a new stream header to Server2.

      <stream:stream 
              xmlns:stream='http://etherx.jabber.org/streams' 
              xmlns='jabber:server' 
              from='conference.example.org'
              to='example.com' 
              version='1.0'>
                
  8. Server2 replies with stream header.

    <stream:stream 
            xmlns:stream='http://etherx.jabber.org/streams' 
            xmlns='jabber:server' 
            id='s2s_345' 
            from='example.com' 
            to='conference.example.org'
            version='1.0'>
          
  9. Server2 advertises SASL mechanisms. If Server2 expects that Server1 will be able to authenticate and authorize as the identity provided in the certificate that Server1 already provided (e.g., because the two servers share a common root certification authority, Server1's certificate has not been revoked, and the address provided in the 'from' address of Server1's initial stream header matches the authentication identity), then Server2 SHOULD advertize the SASL EXTERNAL mechanism.

    <stream:features>
      <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
        <mechanism>EXTERNAL<mechanism>
        <required/>
      </mechanisms>
    </stream:features>
          
  10. If Server2 advertizes SASL EXTERNAL, Server1 SHOULD consider EXTERNAL to be its preferred SASL mechanism. Server1 SHOULD include an authorization identity (base64-encoded as described in RFC 3920) as the XML character data of the <auth/> element, which SHOULD be the same as the 'from' address on the stream header it sent to Server2.

    <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='EXTERNAL'>Y29uZmVyZW5jZS5leGFtcGxlLm9yZwo=</auth>
          

    (In this case, the authorization identity is "conference.example.org".)

  11. Server2 determines if hostname is valid.

    1. If the authorization identity provided by Server1 matches one of the valid XMPP addresses in the certificate, Server2 SHOULD return success. For the purpose of server authentication with another server, a valid XMPP address is a JID encapsulated as a subjectAltName extension of type otherName with an ASN.1 Object Identifier of "id-on-xmppAddr" or a domain name (which MAY include the wildcard character '*') encapsulated as a subjectAltName extension of type dNSName.

      <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
                
    2. Else server MUST return a <not-authorized/> failure and close the stream.

      <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
        <not-authorized/>
      </failure>
      </stream:stream>
                

4. Security Considerations

This document introduces no security considerations or concerns above and beyond those discussed in RFC 3920.

5. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [7].

6. XMPP Registrar Considerations

This document requires no interaction with the XMPP Registrar [8].

7. Acknowledgements

Thanks to Dave Cridland, Philipp Hancke, Joe Hildebrand, Justin Karneges, Rob Norris, and Matthias Wimmer for their comments.

8. Author Note

Peter Millard, co-author of the initial version of this specification, died on April 26, 2006. The remaining author appreciates his assistance in defining the best practices described herein.


Appendices


Appendix A: Document Information

Series: XEP
Number: 0178
Publisher: XMPP Standards Foundation
Status: Active
Type: Informational
Version: 1.0
Last Updated: 2007-02-15
Approving Body: XMPP Council
Dependencies: XMPP Core
Supersedes: None
Superseded By: None
Short Name: N/A
Source Control: HTML  RSS
This document in other formats: XML  PDF


Appendix B: Author Information

Peter Saint-Andre

Email: stpeter@jabber.org
JabberID: stpeter@jabber.org
URI: https://stpeter.im/

Peter Millard

See Author Note


Appendix C: Legal Notices

Copyright

This XMPP Extension Protocol is copyright © 1999 - 2010 by the XMPP Standards Foundation (XSF).

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.

Disclaimer of 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. ##

Limitation of 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.

IPR 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 <http://xmpp.org/extensions/ipr-policy.shtml> or obtained by writing to XMPP Standards Foundation, 1899 Wynkoop Street, Suite 600, Denver, CO 80202 USA).

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.


Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <http://xmpp.org/about/discuss.shtml> for a complete list.

Errata can be sent to <editor@xmpp.org>.


Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".


Appendix G: Notes

1. RFC 3920: Extensible Messaging and Presence Protocol (XMPP): Core <http://tools.ietf.org/html/rfc3920>.

2. rfc3920bis: proposed revisions to Extensible Messaging and Presence Protocol (XMPP): Core <http://tools.ietf.org/html/draft-ietf-xmpp-3920bis>. (work in progress)

3. RFC 4422: Simple Authentication and Security Layer (SASL) <http://tools.ietf.org/html/rfc4422>.

4. The protocol flows when TLS is not required are more complicated (e.g., alternate flows involving server dialback) and may be described in a future version of this document.

5. This specification focuses on the use of the SASL EXTERNAL mechanism with X.509 certificates. Future specifications may document best practices for use of SASL EXTERNAL outside the context of the X.509 infrastructure, for example via Internet Protocol Security (IPSec) as specified in RFC 4301 [6].

6. RFC 4301: Security Architecture for the Internet Protocol <http://tools.ietf.org/html/rfc4301>.

7. 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 <http://www.iana.org/>.

8. 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 <http://xmpp.org/registrar/>.


Appendix H: Revision History

Note: Older versions of this specification might be available at http://xmpp.org/extensions/attic/

Version 1.0 (2007-02-15)

Per a vote of the XMPP Council, advanced specification to Active.

(psa)

Version 0.7 (2007-02-06)

Clarified that the scope of this specification is limited to X.509 certificates.

(psa)

Version 0.6 (2007-01-29)

Allowed client to not include an authorization identity if the certificate contains no XMPP address (thus depending on the server to assign the identity).

(psa)

Version 0.5 (2007-01-25)

Clarified distinction between authentication and authorization; corrected handling of authorization identities; corrected conditions under which SASL EXTERNAL mechanism is offered; specified recommended formats for client and server certificates.

(psa)

Version 0.4 (2006-11-27)

Modified XMPP address encapsulation methods per rfc3920bis; clarified conditions for certificates to be considered acceptable.

(psa)

Version 0.3 (2006-09-21)

Added TLS and SASL required child elements per rfc3920bis.

(psa)

Version 0.2 (2006-03-09)

Corrected client-server failure case to place error in SASL flow rather than binding flow; added note about non-X.509 usages.

(psa)

Version 0.1 (2006-03-09)

Initial version.

(psa)

Version 0.0.3 (2006-02-10)

Specified inclusion of authorization identity for server-to-server.

(psa/pgm)

Version 0.0.2 (2006-02-10)

Clarified distinction between authentication and authorization.

(psa/pgm)

Version 0.0.1 (2006-02-09)

First draft.

(psa/pgm)

END