XEP-0185: Dialback Key Generation and Validation

This document explains how to generate and validate the keys used in the XMPP server dialback protocol.


WARNING: This Informational document is Experimental. Publication as an XMPP Extension Protocol does not imply approval of this proposal by the Jabber Software Foundation. Implementation of the best practice or protocol profile described herein is encouraged in exploratory implementations, although production systems should not deploy implementations of this protocol until it advances to a status of Draft.


XEP Information

Status: Experimental
Type: Informational
Number: 0185
Version: 0.2
Last Updated: 2006-05-10
Publishing Organization: Jabber Software Foundation
Approving Body: XMPP Council
Dependencies: XMPP Core
Supersedes: None
Superseded By: None
Short Name: N/A
Wiki Page: <http://wiki.jabber.org/index.php/Dialback Key Generation and Validation (XEP-0185)>

Author Information

Philipp Hancke

Email: fippo@goodadvice.pages.de
JID: fippo@goodadvice.pages.de

Legal Notice

This XMPP Extension Protocol is copyright 1999 - 2006 by the Jabber Software Foundation (JSF) and is in full conformance with the JSF's Intellectual Property Rights Policy <http://www.xmpp.org/extensions/ipr-policy.shtml>. This material may be distributed only subject to the terms and conditions set forth in the Creative Commons Attribution License (<http://creativecommons.org/licenses/by/2.5/>).

Discussion Venue

The preferred venue for discussion of this document is the Standards-JIG discussion list: <http://mail.jabber.org/mailman/listinfo/standards-jig>.

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 Jabber Software 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.

Conformance Terms

The following 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".


Table of Contents

1. Introduction
2. Dialback Explained
3. Example Setup
4. Key Generation and Validation
5. Attacks Against Key Generation Methods
5.1. Hostname of Originating Server Not Considered
5.2. Stream ID Not Considered
5.3. Hostname of the Receiving Server Not Considered
5.4. Shared Secret Not Considered
6. Security Considerations
7. IANA Considerations
8. XMPP Registrar Considerations
Notes
Revision History


1. Introduction

Note: This document describes a protocol or best practice that is intended for addition to the specification that will supersede either RFC 3920 [1] or RFC 3921 [2] within the Internet Standards Process. This document is provided only for the purpose of open community discussion of the potential modification and will be obsoleted as soon as the relevant RFC is published.

RFC 3920 does not specify how to generate the keys used in the server dialback protocol, and why each of the variables used in key generation is crucial for security. This document is provided for discussion purposes and aims at clarifying the key generation and its validation mechanism and to show common attacks on weak mechanisms. It is not meant to supercede the text in RFC 3920.

2. Dialback Explained

The Originating Server, which generates the dialback key, and the Authoritative Server, which validates the dialback key, may reside on different hosts or be running in separate processes. The method used in key generation and validation should not require interactive communication between Originating Server, Authoritative Server and optionally a third party like a database.

The key is generated based on

The last item, a shared secret known to Originating Server and Authoritative Server, is used in a Keyed-Hash Message Authentication Code (HMAC) to generate and validate the dialback keys. This key must either be set up in a configuration option for each host or process or generated as a random string when starting the server. The Keyed-Hash Message Authentication Code (HMAC) [3] recommends that the length of the key should be at least half of the size of the hash function output.

The recommended hash for usage in HMAC is SHA-256 described in Secure Hash Standard [4], hence the secret's length should be at least 128 bits or 16 characters long.

key = HEX( HMAC-SHA256( Secret, { Stream ID, 
           Receiving Server, Originating or Authoritative server } ) ) 
  

To avoid problems of encoding, a hexadecimal representation of the digest algorithm output SHOULD be used.

3. Example Setup

Table 1: Example data used in this document

Originating and Authoritative Server example.com
Receiving Server example.org
Secret thesecret
Stream ID 457F9224A0

4. Key Generation and Validation

This document closely follows the description of the dialback protocol in RFC 3920, but omits steps that are not important for the generation and validation of the dialback keys. For ease of comparison the numbering of the steps is the same as in section 8.3 of RFC 3920.

3. Receiving Server sends a stream header back to the Originating Server, including a unique ID for this interaction:

<stream:stream
  xmlns:stream='http://etherx.jabber.org/streams'
  xmlns='jabber:server'
  xmlns:db='jabber:server:dialback'
  to='example.com'
  from='example.org'
  id='457F9224A0'>
    

The Originating Server now generates a dialback key to be sent to the Receiving Server:

key = HMAC-SHA256( secret, { Receiving server, Originating server, Stream ID})
    = HMAC-SHA256( 'thesecret', { 'example.org', 'example.com', '457F9224A0' })
    = HMAC-SHA256( 'thesecret', { 'example.orgexample.com457F9224A0' })
    = 'a85748c59049b700dfa728da3eae5ea93aac1e0fc89713b490e441486653dd8c'
  

4. The Originating Server sends the generated dialback key to the Receiving Server:

<db:result
  to='example.org'
  from='example.com'>
    a85748c59049b700dfa728da3eae5ea93aac1e0fc89713b490e441486653dd8c
</db:result>
    

8. The Receiving Server sends the Authoritative Server a request for verification of the key:

<db:verify
  to='example.com'
  from='example.org'
  id='457F9224A0'>
    a85748c59049b700dfa728da3eae5ea93aac1e0fc89713b490e441486653dd8c
</db:verify>
    

The Authoritative Server calculates the valid key for this verify request, using data supplied in the packet and the secret shared with the Originating Server.

key = HMAC-SHA256( secret, { Receiving Server, Authoritative Server, Stream ID })
    = HMAC-SHA256( 'thesecret', { 'example.org', 'example.com', '457F9224A0' })
    = HMAC-SHA256( 'thesecret', { 'example.orgexample.com457F9224A0' })
    = 'a85748c59049b700dfa728da3eae5ea93aac1e0fc89713b490e441486653dd8c'
    

9. The Authoritative Server compares this value to the key contained in the verification requests and informs the Originating Server of the result, in our example a success:

<db:verify
  to='example.org'
  from='example.com'
  id='457F9224A0'
  type='valid'/>
    

5. Attacks Against Key Generation Methods

This section contains attack scenarios that illustrate why each of the factors used in key generation is important.

An attacker will assume the role of the Originating Server and try to send a dialback key that the Authoritative Server acknowledges as valid. If this is successful, the attacker is allowed to send packets for the hostname of the Authoritative Server.

In each subsection, the example hash method, which uses the SHA1 algorithm as described in RFC 3174 [5] for simplicity, ignores one of the variables,

and it is shown how an attacker might exploit this behavior to get a valid result from the Authoritative Server.

5.1 Hostname of Originating Server Not Considered

This subsection demonstrates what can happen if the key generation method ignores the hostname of the Originating Server, e.g. for the hash function

key = SHA1({ Secret, Receiving Server, Stream ID })
    

The dialback keys generated for the originating domains 'example.com' and 'example.net' are the same, which might disclose that the secret used to generate the keys for these domains is equal. An attacker cannot exploit this any further.

<db:verify
  to='example.com'
  from='example.org'
  id='457F9224A0'> 
    807ccee5541ed9332559513797df75c1dd18ae8e
</db:verify>
    

This key is generated using:

SHA1('thesecretexample.org457F9224A0') = 
	    '807ccee5541ed9332559513797df75c1dd18ae8e'
    

5.2 Stream ID Not Considered

This subsection demonstrates a replay attack that is possible if the key generation method ignores the Stream ID, e.g. for the hash function

key = SHA1({ Secret, Receiving Server, Originating Server })
    

If the attacker is able to obtain a single valid dialback key exchanged between the two domains, this key can be used to validate any stream.

<db:verify
  to='example.com'
  from='example.org'
  id='457F9224A0'> 
    14cbd71d0f127be89b7004c2242424918d8fad95
</db:verify>
    

This key is generated using the empty string instead of the id:

SHA1('thesecretexample.orgexample.com') = 
	    '14cbd71d0f127be89b7004c2242424918d8fad95'
    

This key is also valid for

<db:verify
  to='example.com'
  from='example.org'
  id='anyidyouwant'>
    14cbd71d0f127be89b7004c2242424918d8fad95
</db:verify>
    

5.3 Hostname of the Receiving Server Not Considered

This subsection demonstrates against a key generation method that ignores the hostname of the receiving server, e.g. for the hash function

key = SHA1({ Secret, Originating Server, Stream ID })
    

The attacker can use a dialback key and stream ID we have sent a domain under his control.

<db:verify
  to='example.com'
  from='example.org'
  id='457F9224A0'> 
    c04ca426a81b3fa04bd4a9df2e24482372b4b874
</db:verify>
    

This key is generated using:

SHA1('thesecretexample.com457F9224A0') = 
	    'c04ca426a81b3fa04bd4a9df2e24482372b4b874'
    

5.4 Shared Secret Not Considered

If the key generation method does not take into account a shared secret in the Authoritative Servers network or if this secret is disclosed and the key generation method is known, an attacker can generate valid dialback keys.

key = SHA1({ Receiving Server, Originating Server, Stream ID })
    

In both cases the attacker is able to generate an arbitrary number of dialback keys.

<db:verify
  to='example.com'
  from='example.org'
  id='457F9224A0'> 
    30e59d3ee62926a29f012822769e58e67571d750
</db:verify>
    

This key is generated using:

SHA1('example.orgexample.com457F9224A0') = 
	    '30e59d3ee62926a29f012822769e58e67571d750'
    

6. Security Considerations

This document introduces no security considerations or concerns above and beyond those discussed in RFC3920, but describes what might happen if the security considerations are ignored.

7. IANA Considerations

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

8. XMPP Registrar Considerations

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


Notes

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

2. RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://www.ietf.org/rfc/rfc3921.txt>.

3. The Keyed-Hash Message Authentication Code (HMAC): Federal Information Processing Standards Publication 198 <http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf>.

4. Secure Hash Standard: Federal Information Processing Standards Publication 180-2 <http://csrc.nist.gov/publications/fips/fips180-2/fips186-2withchangenotice.pdf>.

5. RFC 3174: US Secure Hash Algorithm 1 (SHA1) <http://www.ietf.org/rfc/rfc3174.txt>.

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

7. 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 Jabber Software Foundation. For further information, see <http://www.xmpp.org/registrar/>.


Revision History

Version 0.2 (2006-05-10)

Clarified and corrected roles of originating and receiving servers; updated recommendation and main example to use HMAC-SHA256 for key generation.

(ph)

Version 0.1 (2006-04-11)

Initial version.

(psa)

Version 0.0.1 (2006-03-30)

First draft.

(ph)


END