%ents; ]>
Entity Capabilities This document defines an XMPP protocol extension for broadcasting and dynamically discovering client, device, or generic entity capabilities. In order to minimize network impact, the transport mechanism is standard XMPP presence broadcast (thus forestalling the need for polling related to service discovery data), the capabilities information can be cached either within a session or across sessions. and the format has been kept as small as possible. &LEGALNOTICE; 0115 Draft Standards Track Standards XMPP Core XMPP IM XEP-0030 caps http://www.xmpp.org/schemas/caps.xsd &hildjj; &stpeter; &remko; Jacek Konieczny jajcus@jajcus.net jajcus@jabber.bnet.pl 1.5pre18 in progress, last updated 2008-01-29 jjh/psa
  • Defined SHA-1 as mandatory to implement
  • Specified that inclusion of hash attribute is required
  • Defined the nature of possible preimage attacks
  • More clearly specified security considerations
  • More clearly specified implementation notes
  • Modified generation method to incorporate service discovery extensions
  • More clearly specified processing method
  • Clarified meaning and construction of caps node attribute and disco node attribute
  • Specified that node attribute shall be included in disco#info request for backwards-compatibility
  • Clarified handling of the legacy format to assist developers
  • Added service discovery feature for caps optimization to prevent confusion regarding server support of caps vs. caps optimization
1.4 2007-08-13 psa/jk/jjh

In response to persistent security concerns over caps poisoning, redefined ver attribute to be a hash of the service discovery identity and features in a way that is backwards-compatible with the legacy format.

1.3 2007-04-10 psa/rt/jjh

Added developer-friendly introduction; specified that ext names must be stable across application versions; further clarified examples; added stream feature use case; removed message example (send directed presence instead).

1.2 2007-02-15 psa

Clarified motivation and handling of service discovery requests.

1.1 2004-10-29 psa

Clarified meaning of service discovery results for client#ver and client#ext.

1.0 2004-08-01 psa

Per a vote of the Jabber Council, advanced status to Draft.

0.7 2004-06-29 jjh/psa

Added several items to the Security Considerations; clarified naming requirements regarding 'node', 'ver', and 'ext' attributes.

0.6 2004-04-25 psa

Made a number of editorial adjustments.

0.5 2004-01-05 psa

Specified that the protocol can be used whenever presence is used (e.g., by gateways); improved the XML schema; made several editorial adjustments.

0.4 2003-09-04 jjh

IQ eets must be to a resource, since they are intended to go to a particular session.

0.3 2003-09-02 jjh

Servers MUST strip extras changed to MAY, due to implementer feedback.

0.2 2003-08-28 jjh

Add more clarifying assumptions and requirements, make it clear that clients don't have to send capabilities every time if the server is optimizing.

0.1 2003-08-27 jjh

Initial version.

It is often desirable for an XMPP application (commonly but not necessarily a client) to take different actions depending on the capabilities of another application from which it receives presence information. Examples include:

  • Showing a different set of icons depending on the capabilities of other entities.
  • Not sending &xep0071; or other rich content to plaintext clients such as cell phones.
  • Allowing the initiation of a Voice over IP (VoIP) session only to clients that support &xep0166; and &xep0167;.
  • Not showing a "Send a File" button if another user's client does not support &xep0096;.
  • Filtering &xep0060; notifications based on advertised subscriber interests.

In the past, after logging in some Jabber clients sent one &xep0030; and one &xep0092; request to each entity from which they received presence. That "disco/version flood" resulted in an excessive use of bandwidth and was impractical on a larger scale, particularly for users with large rosters. Therefore this document defines a more robust and scalable solution: namely, a presence-based mechanism Entity capabilities is not limited to clients, and can be used by any entity that exchanges presence with another entity, e.g., a gateway. However, this specification mainly uses the example of clients. for exchanging information about entity capabilities. Clients should not engage in the older "disco/version flood" behavior and instead should use Entity Capabilities as specified herein.

This section provides a friendly introduction to entity capabilities ("caps").

Imagine that you are a Shakespearean character named Juliet and one of your contacts, a handsome fellow named Romeo, becomes available. His client wants to publish its capabilities, and does this by adding to its presence packets a <c/> element with special attributes. As a result, your client receives the following presence packet:

]]>

The 'node' attribute represents the client software Romeo is using. The 'ver' attribute is a specially-constructed string (called a "verification string") that represents the entity's service discovery identity (category and type as registered at &DISCOCATEGORIES;, as well as, optionally, xml:lang and name) and supported features (as registered at &DISCOFEATURES; as well as, optionally, extended service discovery information data registered at &FORMTYPES;).

At this point, your client has no idea what the capabilities are of someone with a version string 'SrFo9ar2CCk2EnOH4q4QANeuxLQ='. Your client therefore sends a service discovery query to Romeo, asking what his client can do.

]]>

The response is:

]]>

At this point, your client knows that anyone advertising a version string of 'SrFo9ar2CCk2EnOH4q4QANeuxLQ=' has a client that can do &xep0045; and the other features returned by Romeo's client (the string can be relied upon because of how it is generated and checked, as explained later in this document). Your client remembers this information, so that it does not need to explicitly query the capabilities of a contact with the same version string. For example, your Nurse may use the same client that Romeo does:

]]>

Therefore you know that she also supports the same features that Romeo does.

On the other hand, for a person with the following presence ...

]]>

... or the following presence ...

]]>

... you have no information about what this contact's client is capable of unless you have cached previous entity capabilities information; therefore you need to query for capabilities explicitly again via service discovery.

This document makes several assumptions:

The protocol defined herein addresses the following requirements:

  1. Clients must be able to participate even if they support only &xmppcore;, &xmppim;, and XEP-0030.
  2. Clients must be able to participate even if they are on networks without connectivity to other XMPP servers, services offering specialized XMPP extensions, or HTTP servers.These first two requirements effectively eliminated XEP-0060 as a possible implementation of entity capabilities.
  3. Clients must be able to retrieve information without querying every entity with which they communicate.
  4. Since presence is normally broadcasted to many contacts, the byte size of the proposed extension must be as small as possible.
  5. It must be possible to write a XEP-0045 server implementation that passes the given information along.
  6. It must be possible to publish a change in capabilities within a single presence session.
  7. Server infrastructure above and beyond that defined in XMPP Core and XMPP IM must not be required for this approach to work, although additional server infrastructure may be used for optimization purposes.
  8. The defined mechanism must not be limited to clients but must be usable be servers, components, and other network entities.

Entity capabilities are encapsulated in a <c/> element qualified by the 'http://jabber.org/protocol/caps' namespace. The attributes of the <c/> element are as follows.

Name Definition Inclusion
ext A set of nametokens specifying additional feature bundles; this attribute is deprecated (see the Legacy Format section of this document). DEPRECATED
hash The hashing algorithm used to generate the verification string; see Mandatory-to-Implement Technologies regarding supported hashing algorithms. REQUIRED
node A URI that uniquely identifies a software application, typically a URL at the website of the project or company that produces the software. * REQUIRED
ver A string that is used to verify the identity and supported features of the entity. ** REQUIRED

* Note: It is RECOMMENDED for the value of the 'node' attribute to be an HTTP URL at which a user could find further information about the software product, such as "http://psi-im.org" for the Psi client; this enables a processing application to also determine a unique string for the generating application, which it could maintain in a list of known software implementations (e.g., associating the name received via the disco#info reply with the URL found in the caps data).

** Note: Before version 1.4 of this specification, the 'ver' attribute was used to specify the released version of the software; while the values of the 'ver' attribute that result from use of the algorithm specified herein are backwards-compatible, applications SHOULD appropriately handle the Legacy Format.

In order to help prevent poisoning of entity capabilities information, the value of the verification string MUST be generated according to the following method.

Note: All sorting operations MUST be performed using "i;octet" collation as specified in Section 9.3 of &rfc4790;.

  1. Initialize an empty string S.
  2. Sort the service discovery identities A registry of service discovery identities is located at &DISCOCATEGORIES;. by category and then by type (if it exists) and then by xml:lang (if it exists), formatted as CATEGORY '/' [TYPE] '/' [LANG] '/' [NAME]. Note that each slash is included even if the TYPE, LANG, or NAME is not included.
  3. For each identity, append the 'category/type/lang/name' to S, followed by the '<' character.
  4. Sort the supported service discovery features. A registry of service discovery features is located at &DISCOFEATURES;.
  5. For each feature, append the feature to S, followed by the '<' character.
  6. If the service discovery information response includes XEP-0128 data forms, sort the forms by the FORM_TYPE (i.e., by the XML character data of the <value/> element).
  7. For each extended service discovery information form:
    1. Append the XML character data of the FORM_TYPE field's <value/> element, followed by the '<' character.
    2. Sort the fields by the value of the "var" attribute.
    3. For each field:
      1. Append the value of the "var" attribute, followed by the '<' character.
      2. Sort values by the XML character data of the <value/> element.
      3. For each <value/> element, append the XML character data, followed by the '<' character.
  8. Ensure that S is encoded according to the UTF-8 encoding (&rfc3269;).
  9. Compute the verification string by hashing S using the algorithm specified in the 'hash' attribute (e.g., SHA-1 as defined in &rfc3174;). The hashed data MUST be generated with binary output and encoded using Base64 as specified in Section 4 of &rfc4648; (note: the Base64 output MUST NOT include whitespace and MUST set padding bits to zero). The OpenSSL command for producing such output with SHA-1 is "echo -n 'S' | openssl dgst -binary -sha1 | openssl enc -nopad -base64".

Consider an entity whose category is "client", whose service discovery type is "pc", whose service discovery name is "Exodus 0.9.1", and whose supported features are "http://jabber.org/protocol/disco#info", "http://jabber.org/protocol/disco#items", and "http://jabber.org/protocol/muc". Using the SHA-1 algorithm, the verification string would be generated as follows:

  1. S = ''
  2. Only one identity: "client/pc"
  3. S = 'client/pc//Exodus 0.9.1<'
  4. Sort the features: "http://jabber.org/protocol/disco#info", "http://jabber.org/protocol/disco#items", "http://jabber.org/protocol/muc".
  5. S = 'client/pc//Exodus 0.9.1<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<'
  6. ver = SrFo9ar2CCk2EnOH4q4QANeuxLQ=

Consider a more complex example, where the entity includes several identities (with the service discovery name in different languages) as well as extended information formatted according to XEP-0128.

<iq from='benvolio@capulet.lit/230193'> id='disco1' to='juliet@capulet.lit/chamber' type='result'> <query xmlns='http://jabber.org/protocol/disco#info' node='http://psi-im.org#8lu+88MRxmKM7yO3MEzY7YmTsWs='> <identity xml:lang='en' category='client' name='Psi 0.9.1' type='pc'/> <identity xml:lang='el' category='client' name='Ψ 0.9.1' type='pc'/> <feature var='http://jabber.org/protocol/disco#info'/> <feature var='http://jabber.org/protocol/disco#items'/> <feature var='http://jabber.org/protocol/muc'/> <x xmlns='jabber:x:data' type='result'> <field var='FORM_TYPE' type='hidden'> <value>urn:xmpp:dataforms:softwareinfo</value> </field> <field var='ip_version'> <value>ipv4</value> <value>ipv6</value> </field> <field var='os'> <value>Mac</value> </field> <field var='os_version'> <value>10.5.1</value> </field> <field var='software'> <value>Psi</value> </field> <field var='software_version'> <value>0.11</value> </field> </x> </query> </iq>

Using the SHA-1 algorithm, the verification string would be generated as follows (note: line breaks in the verification string are included only for the purposes of readability):

  1. S = ''
  2. Two identities: "client/pc/Psi" and "client/pc/Ψ"
  3. S = 'client/pc/el/Ψ 0.9.1<client/pc/en/Psi 0.9.1<'
  4. Sort the features: "http://jabber.org/protocol/caps", http://jabber.org/protocol/disco#info", "http://jabber.org/protocol/disco#items", "http://jabber.org/protocol/muc".
  5. S = 'client/pc/el/Ψ 0.9.1<client/pc/en/Psi 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info
    <http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc'.
  6. Sort the extended service discovery forms by FORM_TYPE (there is only one: "urn:xmpp:dataforms:softwareinfo").
  7. S = 'client/pc/el/Ψ 0.9.1<client/pc/en/Psi 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info
    <http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<urn:xmpp:dataforms:softwareinfo<'
  8. Sort the fields by var and append the value(s): "ip_version<ipv4<ipv6", "os<Mac", "os_version<10.5.1", "software<Psi", "software_version<0.11".
  9. S = 'client/pc/el/Ψ 0.9.1<client/pc/en/Psi 0.9.1<http://jabber.org/protocol/caps
    <http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc
    <urn:xmpp:dataforms:softwareinfo<ip_version<ipv4<ipv6<os<Mac<os_version<10.5.1<software<Psi<software_version<0.11<'
  10. ver = 8lu+88MRxmKM7yO3MEzY7YmTsWs=

When an entity receives a value of the 'ver' attribute that appears to be a verification string generated in accordance with the generation method defined in this specification, it MUST process the 'ver' according to the following method.

  1. Verify that the <c/> element includes a 'hash' attribute. If it does not, ignore the 'ver' or treat it as generated in accordance with the Legacy Format (if supported).
  2. If the value of the 'hash' attribute does not match one of the processing application's supported hash functions, do the following:
    1. Send a service discovery information request to the generating entity.
    2. Receive a service discovery information response from the generating entity.
    3. Do not validate or globally cache the verification string as described below; instead, the processing application SHOULD associate the discovered identity+features only with the JabberID of the generating entity.
  3. If the value of the 'hash' attribute matches one of the processing application's supported hash functions, validate the verification string by doing the following:
    1. Send a service discovery information request to the generating entity.
    2. Receive a service discovery information response from the generating entity.
    3. If the response includes more than one service discovery identity with the same category/type/lang/name, consider the entire response to be ill-formed.
    4. If the response includes more than one service discovery feature with the same XML character data, consider the entire response to be ill-formed.
    5. If the response includes more than one extended service discovery information form with the same FORM_TYPE, consider the entire response to be ill-formed.
    6. If the response includes an extended service discovery information form where the FORM_TYPE field is not of type "hidden" or the form does not include a FORM_TYPE field, ignore the form but continue processing.
    7. If the response is considered well-formed, reconstruct the hash by using the service discovery information response to generate a local hash in accordance with the Generation Method).
    8. If the values of the received and reconstructed hashes match, the processing application MUST consider the result to be valid and SHOULD globally cache the result for all JabberIDs with which it communicates.
    9. If the values of the received and reconstructed hashes do not match, the processing application MUST consider the result to be invalid and MUST NOT globally cache the verification string; however, it SHOULD check the service discovery identity and supported features of another generating entity who advertises that value.

Each time a generating entity sends presence, it annotates that presence with an entity identifier ('node' attribute) and identity and feature identifier ('ver' attribute). So that servers can remember the last presence for use in responding to probes, a client SHOULD include entity capabilities with every presence notification it sends.

]]>

If the supported features change during a generating entity's presence session (e.g., a user installs an updated version of a client plugin), the application MUST recompute the verification string and SHOULD send a new presence broadcast.

]]>

An application (the "requesting entity") can learn what features another entity supports by sending a disco#info request (see XEP-0030) to the entity that generated the caps information (the "generating entity").

]]>

The disco#info request is sent by the requesting entity to the generating entity. The value of the 'to' attribute MUST be the exact JID of the generating entity, which in the case of a client will be the full JID (&FULLJID;).

The disco 'node' attribute MUST be included for backwards-compatibility. The value of the 'node' attribute SHOULD be generated by concatenating the value of the caps 'node' attribute (e.g., "http://code.google.com/p/exodus") as provided by the generating entity, the "#" character, and the value of the caps 'ver' attribute (e.g., "SrFo9ar2CCk2EnOH4q4QANeuxLQ=") as provided by the generating entity.

The generating entity then returns all of the capabilities it supports.

node='http://code.google.com/p/exodus#SrFo9ar2CCk2EnOH4q4QANeuxLQ='> ]]>

Note: If the generating entity incorporated multiple identities with different xml:lang values in its verification string, it MUST return all of the identities even if the request specified a particular xml:lang.

A server MAY include its entity capabilities in a stream feature element so that connecting clients and peer servers do not need to send service discovery requests each time they connect.

]]>

When a connected client or peer server sends a service discovery information request to determine the entity capabilities of a server that advertises capabilities via the stream feature, the requesting entity MUST send the disco#info request to the server's JID as provided in the 'from' attribute of the response stream header (the 'from' attribute was recommended by &rfc3920; and is required by &rfc3920bis;). To enable this functionality, a server that advertises support for entity capabilities MUST provide a 'from' address in its response stream headers, in accordance with rfc3920bis.

If an entity supports the entity capabilities protocol, it MUST advertise that fact by returning a feature of 'http://jabber.org/protocol/caps' in response to a service discovery information request.

]]> ... ... ]]>

If a server supports the Server Optimization functionality, it MUST also return a feature of 'http://jabber.org/protocol/caps#optimize' in response to service discovery information requests.

]]> ... ... ]]>

An application SHOULD maintain a list of hashing algorithms it supports, which MUST include the algorithm or algorithms listed in the Mandatory-to-Implement Technologies section of this document.

It is RECOMMENDED for an application that processes entity capabilities information to cache associations between the verification string and discovered identity+features within the scope of one presence session. This obviates the need for extensive service discovery requests within a session.

It is OPTIONAL for an application to cache associates across presence sessions. However, since this obviates the need for extensive service discovery requests at the beginning of a session, such caching is strongly encouraged, especially in bandwidth-constrained environments.

If two entities exchange messages but they do not normally exchange presence (i.e., via presence subscription), the entities MAY choose to send directed presence to each other, where the presence information SHOULD be annotated with the same capabilities information as each entity sends in broadcasted presence. Until and unless capabilities information has not been received from another entity, an application MUST assume that the other entity does not support capabilities.

A server that is managing an connected client's presence session MAY optimize presence notification traffic sent through the server by stripping off redundant capabilities annotations. Because of this, receivers of presence notifications MUST NOT expect an annotation on every presence notification they receive. If the server performs caps optimization, it MUST ensure that the first presence notification each subscriber receives contains the annotation. The server MUST also ensure that any changes in the caps information (e.g., an updated 'ver' attribute) are sent to all subscribers.

If a connected client determines that its server supports caps optimization, MAY choose to send the capabilities annotation only on the first presence packet, as well as whenever its capabilities change.

The SHA-1 hashing algorithm is mandatory to implement. All implementations MUST support SHA-1.

An implementation MAY support other algorithms. Any such algorithm SHOULD be registered in the &ianahashes;.

In the future, the &COUNCIL; may, at its discretion, modify the mandatory-to-implement hashing algorithm if it determines that SHA-1 has become practically vulnerable to Preimage Attacks.

As described in &rfc4270;, protocols that use the output of hash functions such as MD5 or SHA-1 can be vulnerable to collision attacks or preimage attacks or both. Because of how the hash output is used in entity capabilities, the protocol will not be subject to collision attacks even if the hash function used is found to be vulnerable to collision attacks. However, it is possible that the protocol might become subject to preimage attacks if the hash function used is found to be vulnerable to preimage attacks.

In theory, such a preimage attack would take one of the following forms:

  • Given knowledge of a particular value V of the 'ver' attribute, an attacker can find an input message X such that hash(X) yields V (this is known as a "first preimage attack").
  • Given knowledge of a particular value S used as the input message to the hash function, an attacker can find a value S' that yields V (this is known as a "second preimage attack").

In practice, a preimage attack would need to meet all of the following criteria in order to be effective against the entity capabilities protocol:

  1. The hashing algorithm used would need to be found not only theoretically but practically vulnerable to first or second preimage attacks (e.g., this is not yet true of the MD5 or SHA-1 algorithms, but may become true in the future).
  2. An attacker would need to find an input message X or S' that matches the hash V for a particular value of V or S, which may not be practical given that (a) the values of S used as input to the hash function in entity capabilities are relatively short and (b) cryptanalysis to date indicates that existing hash functions may not be vulnerable to preimage attacks except in the case of relatively long input messages (on the order of 255 blocks).
  3. The input message X or S' would need to conform to the structure of S as specified under Verification String, including the order of service discovery identity or identities followed by service discovery features, delimited by the '<' character and sorted using "i;octet" collation.
  4. The input messsage X or S' would need to make it seem as if a desirable feature (e.g., end-to-end encryption) is not supported by other entities that advertise the same hash V even though the feature is indeed supported (i.e., the attacker would need to return a set of service discovery identities and features that match X or S', and have that set be plausible for an entity that communicates via XMPP), or make it seem as if an undesirable feature is supported even though the feature is not supported.
  5. The attacker would need to propagate the hash V before some other entity with the true input message S could broadcast presence with the relevant entity capabilities data and provide the true service discovery response (thus the attacker might need to subvert the development process of a particular software project or subvert the namespace issuance process of the ®ISTRAR;, or both).

It currently seems extremely unlikely that an attacker could meet all of the foregoing conditions in the foreseeable future. However, the XMPP Council shall continue to monitor the state of cryptanalysis regarding the mandatory-to-implement hash function as well as the possibility that any vulnerabilities in that function might lead to practical threats against the entity capabilities protocol. If and when it becomes practical (or even possible) to launch effective preimage attacks against the entity capabilities protocol, the XMPP Council shall consider updating this specification to change the mandatory-to-implement hashing algorithm to a safer technology.

Adherence to the method defined in the Verification String section of this document for both generation and processing of the 'ver' attribute helps to guard against poisoning of entity capabilities information by malicious or improperly implemented entities.

If the value of the 'ver' attribute is a verification string as defined herein (i.e., if the 'ver' attribute is not generated according to the Legacy Format), inclusion of the 'hash' attribute is REQUIRED. Knowing explicitly that the value of the 'ver' attribute is a verification string enables the recipient to avoid spurious notification of invalid or poisoned hashes.

Use of entity capabilities might make it easier for an attacker to launch certain application-specific attacks, since the attacker could more easily determine the type of client being used as well as its capabilities. However, since most clients respond to Service Discovery and Software Version requests without performing access control checks, there is no new vulnerability. Entities that wish to restrict access to capabilities information SHOULD use &xep0016; to define appropriate communications blocking (e.g., an entity MAY choose to allow IQ requests only from "trusted" entities, such as those with whom it has a presence subscription of "both"); note, however, that such restrictions may be incompatible with the recommendation regarding Directed Presence.

This document requires no interaction with &IANA;.

The ®ISTRAR; includes 'http://jabber.org/protocol/caps' in its registry of protocol namespaces (see &NAMESPACES;).

The XMPP Registrar shall include "http://jabber.org/protocol/caps#optimize" in its registry of service discovery features (see &DISCOFEATURES;).

The protocol documented by this schema is defined in XEP-0115: http://www.xmpp.org/extensions/xep-0115.html ]]>

Before Version 1.4 of this specification, the 'ver' attribute was generated differently, the 'ext' attribute was used more extensively, and the 'hash' attribute was absent. For historical purposes, Version 1.3 of this specification is archived at <http://www.xmpp.org/extensions/attic/xep-0115-1.3.html>. For backwards-compatibility with the legacy format, the 'node' attribute is REQUIRED and the 'ext' attribute MAY be included.

An application can determine if the legacy format is in use by checking for the presence of the 'hash' attribute, which is REQUIRED in the current format.

If a caps-processing application supports the legacy format, it SHOULD check the 'node', 'ver', and 'ext' combinations as specified in the archived version 1.3 of this specification, and MAY cache the results.

If a caps-processing application does not support the legacy format, it SHOULD ignore the 'ver' value entirely (since the value cannot be verified) and SHOULD NOT cache it, since the application cannot validate the identity and features by checking the hash.

Thanks to Rachel Blackman, Dave Cridland, Richard Dobson, Olivier Goffart, Sergei Golovan, Justin Karneges, Ralph Meijer, Ian Paterson, Kevin Smith, Tomasz Sterna, Michal Vaner, and Matt Yacobucci for comments and suggestions.