XEP-0300: Use of Cryptographic Hash Functions in XMPP

Abstract:This document provides recommendations for the use of cryptographic hash functions in XMPP protocol extensions.
Authors:Peter Saint-Andre, Matthew Wild, Kevin Smith
Copyright:© 1999 - 2014 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status:Deferred
Type:Standards Track
Version:0.3
Last Updated:2012-02-08

WARNING: Consideration of this document has been Deferred by the XMPP Standards Foundation. Implementation of the protocol described herein is not recommended.


Table of Contents


1. Introduction
2. Requirements
3. XML Format
4. Hash Functions
    4.1. MD2
    4.2. MD4
    4.3. MD5
    4.4. SHA-0
    4.5. SHA-1
    4.6. SHA-2
    4.7. SHA-3
5. Algorithm Recommendations
6. Determining Support
7. Recommendations for New XMPP Extensions
8. Analysis of Existing XMPP Extensions
    8.1. XEP-0065
    8.2. XEP-0084
    8.3. XEP-0115
    8.4. XEP-0124
    8.5. XEP-0153
    8.6. XEP-0174
    8.7. XEP-0231
    8.8. Recommendations
9. Security Considerations
10. IANA Considerations
11. XMPP Registrar Considerations
    11.1. Protocol Namespaces
    11.2. Protocol Versioning
    11.3. Service Discovery Features
12. XML Schema
13. Acknowledgements

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

Various XMPP extensions make use of cryptographic hash functions, but they do so in different ways (e.g., some define XML elements and some define XML attributes) and often mandate support for different algorithms. The lack of a consistent approach to the use of cryptographic hash functions in XMPP extensions can lead to interoperability problems and security vulnerabilities. Therefore, this document recommends a common approach and XML element that can be re-used in any XMPP protocol extension.

2. Requirements

This extension is designed to meet the following criteria:

Agility
It is absolutely necessary to support more secure cryptographic hash functions as they become available, and to stop supporting less secure functions as they are deprecated.
Security
This document needs to be regularly maintained and revisited so that XMPP protocols are using the most up-to-date security technologies.
Reusability
The extension needs to be reusable in any XMPP protocol.

3. XML Format

This document defines a new XML element that can be used in any XMPP protocol extension. An example follows.

<hash xmlns='urn:xmpp:hashes:1' algo='sha-256'>2XarmwTlNxDAMkvymloX3S5+VbylNrJt/l5QyPa+YoU=</hash>
  

An XMPP protocol can include more than one instance of the <hash/> element, as long as each one has a different value for the 'algo' attribute:

<hash xmlns='urn:xmpp:hashes:1' algo='sha-1'>2AfMGH8O7UNPTvUVAM9aK13mpCY=</hash>
<hash xmlns='urn:xmpp:hashes:1' algo='sha-256'>2XarmwTlNxDAMkvymloX3S5+VbylNrJt/l5QyPa+YoU=</hash>
  

The value of the 'algo' attribute MUST be one of the values from the IANA Hash Function Textual Names Registry [1] maintained by the Internet Assigned Numbers Authority (IANA) [2].

4. Hash Functions

4.1 MD2

The MD2 algorithm is not used in any XMPP protocols and has been deprecated by the IETF (see RFC 6149 [3]).

4.2 MD4

The MD4 algorithm is not used in any XMPP protocols and has been deprecated by the IETF (see RFC 6150 [4]).

4.3 MD5

The MD5 algorithm was commonly used in earlier generations of Internet technologies. As explained in RFC 6151 [5], the MD5 algorithm "is no longer acceptable where collision resistance is required" (such as in digital signatures) and "new protocol designs should not employ HMAC-MD5" either.

The primary use of MD5 in XMPP protocols is SI File Transfer (XEP-0096) [6], which will be obsoleted by Jingle File Transfer (XEP-0234) [7].

4.4 SHA-0

The SHA-0 algorithm was developed by the U.S. National Security Agency and first published in 1993. It was never widely deployed and is not used in any XMPP protocols.

4.5 SHA-1

The SHA-1 algorithm was developed by the U.S. National Security Agency and first published in 1995 to fix problems with SHA-0. The SHA-1 algorithm is currently the most widely-deployed hash function. As described in RFC 4270 [8] in 2005, attacks have been found against the collision resistance property of SHA-1. RFC 6194 [9] notes that as of 2011 no published results indicate improvement upon those attacks. In addition, RFC 6194 notes that "[t]here are no known pre-image or second pre-image attacks that are specific to the full round SHA-1 algorithm". Furthermore, there is no indication that attacks on SHA-1 can be extended to HMAC-SHA-1. Nevertheless, the U.S. National Institute of Standards and Technology (NIST) has recommended that SHA-1 not be used for generating digital signatures after December 31, 2010.

The SHA-1 algorithm is used in a number of XMPP protocols. See Analysis of Existing XMPP Extensions for details.

4.6 SHA-2

The SHA-2 family of algorithms (SHA-224, SHA-256, SHA-384, and SHA-512) was developed by the U.S. National Security Agency and first published in 2001. Because SHA-2 is somewhat similar to SHA-1, it is thought that the security flaws with SHA-1 described above could be extended to SHA-2 (although no such attacks have yet been found on the full-round SHA-2 algorithms).

4.7 SHA-3

The U.S. National Institute of Standards and Technology (NIST) is currently holding a public competition to replace the SHA-1 and SHA-2 functions. The winner and resulting new standard will be announced in 2012. When this "SHA-3" technology is announced, the XSF will update this specification accordingly.

5. Algorithm Recommendations

Support for version 1 of the 'urn:xmpp:hashes' namespace implies the following:

Table 1: Algorithm Recommendations

Algorithm Support
MD2 MUST NOT
MD4 MUST NOT
MD5 MAY
SHA-1 MUST
SHA-256 MUST
SHA-512 SHOULD

These recommendations ought to be reviewed yearly by the XMPP Council [10].

6. Determining Support

If an entity supports the protocol defined herein, it MUST report that by including a Service Discovery (XEP-0030) [11] feature of "urn:xmpp:hashes:1" in response to disco#info requests, along with one service discovery feature for each algorithm it supports:

Example 1. Service discovery information request

<iq from='romeo@montague.lit/orchard'
    id='uw72g176'
    to='juliet@capulet.lit/balcony'
    type='get'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
  

Example 2. Service discovery information response

<iq from='juliet@capulet.lit/balcony'
    id='uw72g176'
    to='romeo@montague.lit/orchard'
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <feature var='urn:xmpp:hashes:1'/>
    <feature var='urn:xmpp:hash-function-text-names:md5'/>
    <feature var='urn:xmpp:hash-function-text-names:sha-1'/>
    <feature var='urn:xmpp:hash-function-text-names:sha-256'/>
  </query>
</iq>
  

In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined in Entity Capabilities (XEP-0115) [12]. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.

7. Recommendations for New XMPP Extensions

The XSF is strongly encouraged to incorporate hash agility into new XMPP extensions that it develops by mandating re-use of the protocol defined in this specification (instead of hash elements or attributes specific to each extension).

8. Analysis of Existing XMPP Extensions

As mentioned, several existing XMPP extensions make use of the SHA-1 algorithm. This section analyzes those extensions. The final subsection provides recommendations.

8.1 XEP-0065

Both SOCKS5 Bytestreams (XEP-0065) [13] and Jingle SOCKS5 Bytestreams Transport Method (XEP-0260) [14] use SHA-1 to hash the Stream ID, Requester's JID, and Target's JID, and this hash can be communicated via the 'dstaddr' attribute. Although this usage is not security-critical, currently it has no agility to specify newer algorithms. Because the hash is communicated by means of an attribute, it cannot directly use the extension defined in this specification.

8.2 XEP-0084

In User Avatar (XEP-0084) [15], the Publish-Subscribe (XEP-0060) [16] ItemId for the metadata node is the SHA-1 hash of the image data for the "image/png" media type. There is no hash agility for this usage. Although attacks against the collision resistance property could potentially result in confusion over the avatar for a user, the fact that avatars cannot be uploaded without authentication as the node owner or authorization as a node publisher reduces the practicality of attacks. In addition, XEP-0084 ought to be updated to specify that avatars must not be compared across JIDs.

8.3 XEP-0115

Entity Capabilities (XEP-0115) [17] typically uses SHA-1 to compute the verification string, however hash agility is supported by use of the 'hash' attribute. Because the hash is communicated by means of an attribute, it cannot directly use the extension defined in this specification.

8.4 XEP-0124

BOSH (XEP-0124) [18] uses SHA-1 to generate the key sequence used to secure sessions that are not protected via SSL/TLS. Because these keys are ephemeral, it is unlikely that an attacker could reproduce or poison the key sequence quickly enough to successfully attack the session. However, attackers can be discouraged more significantly by protecting sessions with SSL/TLS (indeed, it is unclear how widely the key sequence feature is implemented). That said, this use of SHA-1 in BOSH does not support hash agility.

8.5 XEP-0153

vCard-Based Avatars (XEP-0153) [19] is historical but still widely used. Probably it is more valuable to modify XEP-0084 so that it supports hash agility.

8.6 XEP-0174

Link-Local Messaging (XEP-0174) [20] uses SHA-1 to hash the avatar image (i.e., the "phsh" field) advertised in the DNS TXT record for a user, mirroring the usage from XEP-0115. The "hash" field can be used to specify alternative hash algorithms, and thus supports hash agility. However, in practice it is likely that only SHA-1 is implemented. Because the hash is represented in a DNS TXT record, it cannot directly use the extension defined in this specification.

8.7 XEP-0231

Bits of Binary (XEP-0231) [21] supports hash agility through the structure of values for the 'cid' attribute, but does not mandate support for any particular algorithm.

8.8 Recommendations

Of the foregoing, the use in XEP-0115 has the most significant security implications. However, there are other security issues with XEP-0115 that make it likely to be replaced in a more wholesale fashion. Although it would be desirable for all XMPP extensions that use cryptographic hashes to incorporate hash agility, realistically this is difficult to achieve after the fact. For now, the XSF is encouraged to focus on new protocols (e.g., XEP-0234 and a replacement for XEP-0115 if there is consensus to work on the latter) rather than spending effort on migrating its existing uses of SHA-1 to the SHA-2 family of algorithms, and to the SHA-3 family when available. Naturally, these priorities might change if XMPP technologies experience significant attacks on existing extensions that use SHA-1.

9. Security Considerations

This entire document discusses security.

10. IANA Considerations

This document requires no interaction with the IANA. However, it reuses entries from the relevant IANA registry.

11. XMPP Registrar Considerations

11.1 Protocol Namespaces

This specification defines the following XML namespace:

The XMPP Registrar [22] shall include the foregoing namespace in its registry at <http://xmpp.org/registrar/namespaces.html>, as governed by XMPP Registrar Function (XEP-0053) [23].

11.2 Protocol Versioning

If the protocol defined in this specification undergoes a revision that is not fully backwards-compatible with an older version, the XMPP Registrar shall increment the protocol version number found at the end of the XML namespaces defined herein, as described in Section 4 of XEP-0053.

11.3 Service Discovery Features

An entity SHOULD provide one service discovery feature for each algorithm it supports. Ideally these features would be of the form "urn:iana:hash-function-text-names:foo" (where "foo" is the name of an algorithm registered with the IANA); however there is no urn:iana namespace at present. Until there is, we use features of the form "urn:xmpp:hash-function-text-names:foo" instead. Therefore the registry submission is as follows.

Registry Submission

<var>
  <name>urn:xmpp:hash-function-text-names:md5</name>
  <desc>Support for the MD5 hashing algorithm</desc>
  <doc>XEP-0300</doc>
</var>
<var>
  <name>urn:xmpp:hash-function-text-names:sha-1</name>
  <desc>Support for the SHA-1 hashing algorithm</desc>
  <doc>XEP-0300</doc>
</var>
<var>
  <name>urn:xmpp:hash-function-text-names:sha-224</name>
  <desc>Support for the SHA-224 hashing algorithm</desc>
  <doc>XEP-0300</doc>
</var>
<var>
  <name>urn:xmpp:hash-function-text-names:sha-256</name>
  <desc>Support for the SHA-256 hashing algorithm</desc>
  <doc>XEP-0300</doc>
</var>
<var>
  <name>urn:xmpp:hash-function-text-names:sha-384</name>
  <desc>Support for the SHA-384 hashing algorithm</desc>
  <doc>XEP-0300</doc>
</var>
<var>
  <name>urn:xmpp:hash-function-text-names:sha-512</name>
  <desc>Support for the SHA-512 hashing algorithm</desc>
  <doc>XEP-0300</doc>
</var>
    

12. XML Schema

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:xmpp:hashes:1'
    xmlns='urn:xmpp:hashes:1'
    elementFormDefault='qualified'>

  <xs:element name='hash'>
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base='xs:string'>
          <xs:attribute name='algo' type='xs:NCName' use='required'/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

</xs:schema>
  

13. Acknowledgements

Thanks to Dave Cridland, Waqas Hussain, Glenn Maynard, and Remko Tronçon for their input.


Appendices


Appendix A: Document Information

Series: XEP
Number: 0300
Publisher: XMPP Standards Foundation
Status: Deferred
Type: Standards Track
Version: 0.3
Last Updated: 2012-02-08
Approving Body: XMPP Council
Dependencies: XMPP Core
Supersedes: None
Superseded By: None
Short Name: N/A
Source Control: HTML
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/

Matthew Wild

Email: mwild1@gmail.com
JabberID: me@matthewwild.co.uk

Kevin Smith

Email: kevin@kismith.co.uk
JabberID: kevin@doomsong.co.uk


Appendix C: Legal Notices

Copyright

This XMPP Extension Protocol is copyright © 1999 - 2014 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/about-xmpp/xsf/xsf-ipr-policy/> 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 6120) and XMPP IM (RFC 6121) 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. IANA registry of Hash Function Textual Names <http://www.iana.org/assignments/hash-function-text-names>.

2. 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/>.

3. RFC 6149: MD2 to Historic Status <http://tools.ietf.org/html/rfc6149>.

4. RFC 6150: MD4 to Historic Status <http://tools.ietf.org/html/rfc6150>.

5. RFC 6151: Updated Security Considerations for the MD5 Message-Digest and the HMAC-MD5 Algorithms <http://tools.ietf.org/html/rfc6151>.

6. XEP-0096: SI File Transfer <http://xmpp.org/extensions/xep-0096.html>.

7. XEP-0234: Jingle File Transfer <http://xmpp.org/extensions/xep-0234.html>.

8. RFC 4270: Attacks on Cryptographic Hashes in Internet Protocols <http://tools.ietf.org/html/rfc4270>.

9. RFC 6194: Updated Security Considerations for the SHA-0 and SHA-1 Message-Digest Algorithms <http://tools.ietf.org/html/rfc6194>.

10. The XMPP Council is a technical steering committee, authorized by the XSF Board of Directors and elected by XSF members, that approves of new XMPP Extensions Protocols and oversees the XSF's standards process. For further information, see <http://xmpp.org/council/>.

11. XEP-0030: Service Discovery <http://xmpp.org/extensions/xep-0030.html>.

12. XEP-0115: Entity Capabilities <http://xmpp.org/extensions/xep-0115.html>.

13. XEP-0065: SOCKS5 Bytestreams <http://xmpp.org/extensions/xep-0065.html>.

14. XEP-0260: Jingle SOCKS5 Bytestreams Transport Method <http://xmpp.org/extensions/xep-0260.html>.

15. XEP-0084: User Avatar <http://xmpp.org/extensions/xep-0084.html>.

16. XEP-0060: Publish-Subscribe <http://xmpp.org/extensions/xep-0060.html>.

17. XEP-0115: Entity Capabilities <http://xmpp.org/extensions/xep-0115.html>.

18. XEP-0124: Bidirectional-streams Over Synchronous HTTP <http://xmpp.org/extensions/xep-0124.html>.

19. XEP-0153: vCard-Based Avatars <http://xmpp.org/extensions/xep-0153.html>.

20. XEP-0174: Link-Local Messaging <http://xmpp.org/extensions/xep-0174.html>.

21. XEP-0231: Bits of Binary <http://xmpp.org/extensions/xep-0231.html>.

22. 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/>.

23. XEP-0053: XMPP Registrar Function <http://xmpp.org/extensions/xep-0053.html>.


Appendix H: Revision History

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

Version 0.3 (2012-02-08)

Modified XML structure to remove wrapper element; added recommendations for new XMPP extensions; softened recommendations for existing extensions.

(psa)

Version 0.2 (2011-12-05)

Updated to reflect initial analysis of existing XMPP protocol extensions.

(psa)

Version 0.1 (2011-06-29)

Initial published version.

(psa)

Version 0.0.2 (2011-06-22)

Adjusted format to include multiple hashes in one element; modified namespace versioning rules to align with common practice; added service discovery features for various algorithms.

(mw/ks/psa)

Version 0.0.1 (2011-06-16)

Rough draft based on list discussion.

(psa)

END