No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0115.xml 47KB

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. <!ENTITY ltwarning "<p class='box'>Note: If the four characters '&amp;', 'l', 't', ';' appear consecutively in any of the factors of the verification string S (e.g., a service discovery identity of 'SomeClient&amp;lt;') then that string of characters MUST be treated as literally '&amp;lt;' and MUST NOT be converted to the character '&lt;', because completing such a conversion would open the protocol to trivial attacks.</p>">
  6. ]>
  7. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  8. <xep>
  9. <header>
  10. <title>Entity Capabilities</title>
  11. <abstract>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.</abstract>
  13. <number>0115</number>
  14. <status>Draft</status>
  15. <type>Standards Track</type>
  16. <sig>Standards</sig>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XMPP IM</spec>
  20. <spec>XEP-0030</spec>
  21. </dependencies>
  22. <supersedes/>
  23. <supersededby/>
  24. <shortname>caps</shortname>
  25. <schemaloc>
  26. <url></url>
  27. </schemaloc>
  28. &hildjj;
  29. &stpeter;
  30. &remko;
  31. <author>
  32. <firstname>Jacek</firstname>
  33. <surname>Konieczny</surname>
  34. <email></email>
  35. <jid></jid>
  36. </author>
  37. <revision>
  38. <version>1.5.1</version>
  39. <date>2016-10-06</date>
  40. <initials>egp</initials>
  41. <remark><p>Added registrar consideration about stream features.</p></remark>
  42. </revision>
  43. <revision>
  44. <version>1.5</version>
  45. <date>2008-02-26</date>
  46. <initials>jjh/psa</initials>
  47. <remark>
  48. <ul>
  49. <li>Defined SHA-1 as mandatory to implement</li>
  50. <li>Specified that inclusion of hash attribute is required</li>
  51. <li>Defined the nature of possible preimage attacks</li>
  52. <li>More clearly specified security considerations</li>
  53. <li>More clearly specified implementation notes</li>
  54. <li>Modified generation method to incorporate service discovery extensions</li>
  55. <li>More clearly specified processing method</li>
  56. <li>Clarified meaning and construction of caps node attribute and disco node attribute</li>
  57. <li>Specified that node attribute shall be included in disco#info request for backwards-compatibility</li>
  58. <li>Clarified handling of the legacy format to assist developers</li>
  59. <li>Added service discovery feature for caps optimization to prevent confusion regarding server support of caps vs. caps optimization</li>
  60. </ul>
  61. </remark>
  62. </revision>
  63. <revision>
  64. <version>1.4</version>
  65. <date>2007-08-13</date>
  66. <initials>psa/jk/jjh</initials>
  67. <remark><p>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.</p></remark>
  68. </revision>
  69. <revision>
  70. <version>1.3</version>
  71. <date>2007-04-10</date>
  72. <initials>psa/rt/jjh</initials>
  73. <remark><p>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).</p></remark>
  74. </revision>
  75. <revision>
  76. <version>1.2</version>
  77. <date>2007-02-15</date>
  78. <initials>psa</initials>
  79. <remark><p>Clarified motivation and handling of service discovery requests.</p></remark>
  80. </revision>
  81. <revision>
  82. <version>1.1</version>
  83. <date>2004-10-29</date>
  84. <initials>psa</initials>
  85. <remark><p>Clarified meaning of service discovery results for client#ver and client#ext.</p></remark>
  86. </revision>
  87. <revision>
  88. <version>1.0</version>
  89. <date>2004-08-01</date>
  90. <initials>psa</initials>
  91. <remark><p>Per a vote of the Jabber Council, advanced status to Draft.</p></remark>
  92. </revision>
  93. <revision>
  94. <version>0.7</version>
  95. <date>2004-06-29</date>
  96. <initials>jjh/psa</initials>
  97. <remark><p>Added several items to the Security Considerations; clarified naming requirements regarding 'node', 'ver', and 'ext' attributes.</p></remark>
  98. </revision>
  99. <revision>
  100. <version>0.6</version>
  101. <date>2004-04-25</date>
  102. <initials>psa</initials>
  103. <remark><p>Made a number of editorial adjustments.</p></remark>
  104. </revision>
  105. <revision>
  106. <version>0.5</version>
  107. <date>2004-01-05</date>
  108. <initials>psa</initials>
  109. <remark><p>Specified that the protocol can be used whenever presence is used (e.g., by gateways); improved the XML schema; made several editorial adjustments.</p></remark>
  110. </revision>
  111. <revision>
  112. <version>0.4</version>
  113. <date>2003-09-04</date>
  114. <initials>jjh</initials>
  115. <remark><p>IQ eets must be to a resource, since they are intended to go to a particular session.</p></remark>
  116. </revision>
  117. <revision>
  118. <version>0.3</version>
  119. <date>2003-09-02</date>
  120. <initials>jjh</initials>
  121. <remark><p>Servers MUST strip extras changed to MAY, due to implementer feedback.</p></remark>
  122. </revision>
  123. <revision>
  124. <version>0.2</version>
  125. <date>2003-08-28</date>
  126. <initials>jjh</initials>
  127. <remark><p>Add more clarifying assumptions and requirements, make it clear that clients don't have to send capabilities every time if the server is optimizing.</p></remark>
  128. </revision>
  129. <revision>
  130. <version>0.1</version>
  131. <date>2003-08-27</date>
  132. <initials>jjh</initials>
  133. <remark><p>Initial version.</p></remark>
  134. </revision>
  135. </header>
  136. <section1 topic='Introduction' anchor='intro'>
  137. <section2 topic='Motivation' anchor='motivation'>
  138. <p>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:</p>
  139. <ul>
  140. <li>Showing a different set of icons depending on the capabilities of other entities.</li>
  141. <li>Not sending &xep0071; or other rich content to plaintext clients such as cell phones.</li>
  142. <li>Allowing the initiation of a Voice over IP (VoIP) session only to clients that support &xep0166; and &xep0167;.</li>
  143. <li>Not showing a "Send a File" button if another user's client does not support &xep0096;.</li>
  144. <li>Filtering &xep0060; notifications based on advertised subscriber interests.</li>
  145. </ul>
  146. <p>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 <note>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.</note> 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.</p>
  147. </section2>
  148. <section2 topic='How It Works' anchor='howitworks'>
  149. <p>This section provides a friendly introduction to entity capabilities ("caps").</p>
  150. <p>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 &lt;c/&gt; element with special attributes. As a result, your client receives the following presence packet:</p>
  151. <code><![CDATA[
  152. <presence from='romeo@montague.lit/orchard'>
  153. <c xmlns=''
  154. hash='sha-1'
  155. node=''
  156. ver='QgayPKawpkPSDYmwT/WM94uAlu0='/>
  157. </presence>
  158. ]]></code>
  159. <p>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;).</p>
  160. <p>At this point, your client has no idea what the capabilities are of someone with a verification string 'QgayPKawpkPSDYmwT/WM94uAlu0='. Your client therefore sends a service discovery query to Romeo, asking what his client can do.</p>
  161. <code><![CDATA[
  162. <iq from='juliet@capulet.lit/chamber'
  163. id='disco1'
  164. to='romeo@montague.lit/orchard'
  165. type='get'>
  166. <query xmlns=''
  167. node=''/>
  168. </iq>
  169. ]]></code>
  170. <p>The response is:</p>
  171. <code><![CDATA[
  172. <iq from='romeo@montague.lit/orchard'
  173. id='disco1'
  174. to='juliet@capulet.lit/chamber'
  175. type='result'>
  176. <query xmlns=''
  177. node=''>
  178. <identity category='client' name='Exodus 0.9.1' type='pc'/>
  179. <feature var=''/>
  180. <feature var=''/>
  181. <feature var=''/>
  182. <feature var=''/>
  183. </query>
  184. </iq>
  185. ]]></code>
  186. <p>At this point, your client knows that a contact who advertises a verification string of 'QgayPKawpkPSDYmwT/WM94uAlu0=' supports &xep0045; and the other features returned by Romeo because the contact in fact uses the same version of the same client software as Romeo, with the same enabled features, plugins, presented client name(s), and the like (i.e., the same input to the verification string <link url='#ver-gen'>generation method</link>). <note>The string can be relied upon because of how it is generated and checked, as explained later in this document.</note> Your client remembers this information, so that it does not need to explicitly query the capabilities of a contact with the same verification string. For example, your Nurse may use the same client that Romeo does:</p>
  187. <code><![CDATA[
  188. <presence from='nurse@capulet.lit/chamber'>
  189. <c xmlns=''
  190. hash='sha-1'
  191. node=''
  192. ver='QgayPKawpkPSDYmwT/WM94uAlu0='/>
  193. </presence>
  194. ]]></code>
  195. <p>Therefore you know that she also supports the same features that Romeo does.</p>
  196. <p>On the other hand, for a person with the following presence ...</p>
  197. <code><![CDATA[
  198. <presence from='benvolio@capulet.lit/230193'>
  199. <c xmlns=''
  200. hash='sha-1'
  201. node=''
  202. ver='q07IKJEyjvHSyhy//CH0CxmKi8w='/>
  203. </presence>
  204. ]]></code>
  205. <p>... or the following presence ...</p>
  206. <code><![CDATA[
  207. <presence from='bard@shakespeare.lit/globe'>
  208. <c xmlns=''
  209. hash='sha-1'
  210. node=''
  211. ver='zHyEOgxTrkpSdGcQKH8EFPLsriY='/>
  212. </presence>
  213. ]]></code>
  214. <p>... 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.</p>
  215. </section2>
  216. </section1>
  217. <section1 topic='Assumptions' anchor='assumptions'>
  218. <p>This document makes several assumptions:</p>
  219. <ul>
  220. <li>The identity of the client I am using is of interest to the people in my roster.</li>
  221. <li>Clients for the people on my roster might want to make user interface decisions based on my capabilities.</li>
  222. <li>Members of a community tend to cluster around a small set of clients with a small set of capabilities. More specifically, multiple people in my roster use the same client, and they upgrade versions relatively slowly (commonly a few times a year, perhaps once a week at most, certainly not once a minute).</li>
  223. <li>Some clients are running on networks without server-to-server connectivity enabled and without access to the Internet via HTTP.</li>
  224. <li>Conversations are possible between users who are not on each other's rosters.</li>
  225. <li>Client capabilities may change over the course of a presence session, as features are enabled or disabled.</li>
  226. </ul>
  227. </section1>
  228. <section1 topic='Requirements' anchor='reqs'>
  229. <p>The protocol defined herein addresses the following requirements:</p>
  230. <ol start='1'>
  231. <li>Clients must be able to participate even if they support only &xmppcore;, &xmppim;, and <cite>XEP-0030</cite>.</li>
  232. <li>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.<note>These first two requirements effectively eliminated <cite>XEP-0060</cite> as a possible implementation of entity capabilities.</note></li>
  233. <li>Clients must be able to retrieve information without querying every entity with which they communicate.</li>
  234. <li>Since presence is normally broadcast to many contacts, the byte size of the proposed extension must be as small as possible.</li>
  235. <li>It must be possible to write a XEP-0045 server implementation that passes the given information along.</li>
  236. <li>It must be possible to publish a change in capabilities within a single presence session.</li>
  237. <li>Server infrastructure above and beyond that defined in <cite>XMPP Core</cite> and <cite>XMPP IM</cite> must not be required for this approach to work, although additional server infrastructure may be used for optimization purposes.</li>
  238. <li>The defined mechanism must not be limited to clients but must be usable by servers, components, and other network entities.</li>
  239. </ol>
  240. </section1>
  241. <section1 topic='Protocol' anchor='protocol'>
  242. <p>Entity capabilities are encapsulated in a &lt;c/&gt; element qualified by the '' namespace. The attributes of the &lt;c/&gt; element are as follows.</p>
  243. <table caption='Attributes'>
  244. <tr>
  245. <th>Name</th>
  246. <th>Definition</th>
  247. <th>Inclusion</th>
  248. </tr>
  249. <tr>
  250. <td>ext</td>
  251. <td>A set of nametokens specifying additional feature bundles; this attribute is deprecated (see the <link url='#legacy'>Legacy Format</link> section of this document).</td>
  252. <td>DEPRECATED</td>
  253. </tr>
  254. <tr>
  255. <td>hash</td>
  256. <td>The hashing algorithm used to generate the verification string; see <link url='#security-mti'>Mandatory-to-Implement Technologies</link> regarding supported hashing algorithms.</td>
  257. <td>REQUIRED</td>
  258. </tr>
  259. <tr>
  260. <td>node</td>
  261. <td>A URI that uniquely identifies a software application, typically a URL at the website of the project or company that produces the software. *</td>
  262. <td>REQUIRED</td>
  263. </tr>
  264. <tr>
  265. <td>ver</td>
  266. <td>A string that is used to verify the identity and supported features of the entity. **</td>
  267. <td>REQUIRED</td>
  268. </tr>
  269. </table>
  270. <p>* 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 "" 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).</p>
  271. <p>** 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 <link url='#legacy'>Legacy Format</link>.</p>
  272. </section1>
  273. <section1 topic='Verification String' anchor='ver'>
  274. <section2 topic='Generation Method' anchor='ver-gen'>
  275. <p>In order to help prevent poisoning of entity capabilities information, the value of the verification string MUST be generated according to the following method.</p>
  276. <p>Note: All sorting operations MUST be performed using "i;octet" collation as specified in Section 9.3 of &rfc4790;.</p>
  277. <ol start='1'>
  278. <li>Initialize an empty string S.</li>
  279. <li>Sort the service discovery identities <note>A registry of service discovery identities is located at &DISCOCATEGORIES;.</note> by category and then by type and then by xml:lang (if it exists), formatted as CATEGORY '/' [TYPE] '/' [LANG] '/' [NAME]. <note>The combination of category, type, and xml:lang forms a unique combination, so it is not necessary to also sort by name (the name merely provides some human-readable text associated with a category/type/lang).</note> Note that each slash is included even if the LANG or NAME is not included (in accordance with <cite>XEP-0030</cite>, the category and type MUST be included).</li>
  280. <li>For each identity, append the 'category/type/lang/name' to S, followed by the '&lt;' character.</li>
  281. <li>Sort the supported service discovery features. <note>A registry of service discovery features is located at &DISCOFEATURES;.</note></li>
  282. <li>For each feature, append the feature to S, followed by the '&lt;' character.</li>
  283. <li>If the service discovery information response includes <cite>XEP-0128</cite> data forms, sort the forms by the FORM_TYPE (i.e., by the XML character data of the &lt;value/&gt; element).</li>
  284. <li>For each extended service discovery information form:
  285. <ol start='1'>
  286. <li>Append the XML character data of the FORM_TYPE field's &lt;value/&gt; element, followed by the '&lt;' character.</li>
  287. <li>Sort the fields by the value of the "var" attribute.</li>
  288. <li>For each field other than FORM_TYPE:
  289. <ol start='1'>
  290. <li>Append the value of the "var" attribute, followed by the '&lt;' character.</li>
  291. <li>Sort values by the XML character data of the &lt;value/&gt; element.</li>
  292. <li>For each &lt;value/&gt; element, append the XML character data, followed by the '&lt;' character.</li>
  293. </ol>
  294. </li>
  295. </ol>
  296. </li>
  297. <li>Ensure that S is encoded according to the UTF-8 encoding (&rfc3629;).</li>
  298. <li>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). <note>The OpenSSL command for producing such output with SHA-1 is "echo -n 'S' | openssl dgst -binary -sha1 | openssl enc -nopad -base64".</note></li>
  299. </ol>
  300. &ltwarning;
  301. </section2>
  302. <section2 topic='Simple Generation Example' anchor='ver-gen-simple'>
  303. <p>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 "", "", and "". 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):</p>
  304. <ol start='1'>
  305. <li>
  306. <p>S = ''</p>
  307. </li>
  308. <li>
  309. <p>Only one identity: "client/pc"</p>
  310. </li>
  311. <li>
  312. <p>S = 'client/pc//Exodus 0.9.1&lt;'</p>
  313. </li>
  314. <li>
  315. <p>Sort the features: "", "", "", "".</p>
  316. </li>
  317. <li>
  318. <p>S = 'client/pc//Exodus 0.9.1&lt;;;
  319. <br />;;'</p>
  320. </li>
  321. <li>
  322. <p>ver = QgayPKawpkPSDYmwT/WM94uAlu0=</p>
  323. </li>
  324. </ol>
  325. </section2>
  326. <section2 topic='Complex Generation Example' anchor='ver-gen-complex'>
  327. <p>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 <cite>XEP-0128</cite>.</p>
  328. <code>
  329. &lt;iq from='benvolio@capulet.lit/230193'
  330. id='disco1'
  331. to='juliet@capulet.lit/chamber'
  332. type='result'&gt;
  333. &lt;query xmlns=''
  334. node=''&gt;
  335. &lt;identity xml:lang='en' category='client' name='Psi 0.11' type='pc'/&gt;
  336. &lt;identity xml:lang='el' category='client' name='&#936; 0.11' type='pc'/&gt;
  337. &lt;feature var=''/&gt;
  338. &lt;feature var=''/&gt;
  339. &lt;feature var=''/&gt;
  340. &lt;feature var=''/&gt;
  341. &lt;x xmlns='jabber:x:data' type='result'&gt;
  342. &lt;field var='FORM_TYPE' type='hidden'&gt;
  343. &lt;value&gt;urn:xmpp:dataforms:softwareinfo&lt;/value&gt;
  344. &lt;/field&gt;
  345. &lt;field var='ip_version'&gt;
  346. &lt;value&gt;ipv4&lt;/value&gt;
  347. &lt;value&gt;ipv6&lt;/value&gt;
  348. &lt;/field&gt;
  349. &lt;field var='os'&gt;
  350. &lt;value&gt;Mac&lt;/value&gt;
  351. &lt;/field&gt;
  352. &lt;field var='os_version'&gt;
  353. &lt;value&gt;10.5.1&lt;/value&gt;
  354. &lt;/field&gt;
  355. &lt;field var='software'&gt;
  356. &lt;value&gt;Psi&lt;/value&gt;
  357. &lt;/field&gt;
  358. &lt;field var='software_version'&gt;
  359. &lt;value&gt;0.11&lt;/value&gt;
  360. &lt;/field&gt;
  361. &lt;/x&gt;
  362. &lt;/query&gt;
  363. &lt;/iq&gt;
  364. </code>
  365. <p>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):</p>
  366. <ol start='1'>
  367. <li>
  368. <p>S = ''</p>
  369. </li>
  370. <li>
  371. <p>Two identities: "client/pc/Psi" and "client/pc/&#936;"</p>
  372. </li>
  373. <li>
  374. <p>S = 'client/pc/el/&#936;&#160;0.11&lt;client/pc/en/Psi&#160;0.11&lt;'</p>
  375. </li>
  376. <li>
  377. <p>Sort the features: "",", "", "".</p>
  378. </li>
  379. <li>
  380. <p>
  381. S = 'client/pc/el/&#936;&#160;0.11&lt;client/pc/en/Psi&#160;0.11&lt;;;
  382. <br />;;'.
  383. </p>
  384. </li>
  385. <li>
  386. <p>Sort the extended service discovery forms by FORM_TYPE (there is only one: "urn:xmpp:dataforms:softwareinfo").</p>
  387. </li>
  388. <li>
  389. <p>S = 'client/pc/el/&#936;&#160;0.11&lt;client/pc/en/Psi&#160;0.11&lt;;;
  390. <br />;;urn:xmpp:dataforms:softwareinfo&lt;'</p>
  391. </li>
  392. <li>
  393. <p>Sort the fields by var and append the value(s): "ip_version&lt;ipv4&lt;ipv6", "os&lt;Mac", "os_version&lt;10.5.1", "software&lt;Psi", "software_version&lt;0.11".</p>
  394. </li>
  395. <li>
  396. <p>S = 'client/pc/el/&#936;&#160;0.11&lt;client/pc/en/Psi&#160;0.11&lt;;;
  397. <br />;;urn:xmpp:dataforms:softwareinfo&lt;
  398. <br />ip_version&lt;ipv4&lt;ipv6&lt;os&lt;Mac&lt;os_version&lt;10.5.1&lt;software&lt;Psi&lt;software_version&lt;0.11&lt;'</p>
  399. </li>
  400. <li>
  401. <p>ver = q07IKJEyjvHSyhy//CH0CxmKi8w=</p>
  402. </li>
  403. </ol>
  404. </section2>
  405. <section2 topic='Processing Method' anchor='ver-proc'>
  406. <p>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.</p>
  407. <ol start='1'>
  408. <li>Verify that the &lt;c/&gt; element includes a 'hash' attribute. If it does not, ignore the 'ver' or treat it as generated in accordance with the <link url='#legacy'>Legacy Format</link> (if supported).</li>
  409. <li>If the value of the 'hash' attribute does not match one of the processing application's supported hash functions, do the following:
  410. <ol start='1'>
  411. <li>Send a service discovery information request to the generating entity.</li>
  412. <li>Receive a service discovery information response from the generating entity.</li>
  413. <li>Do not validate or globally cache the verification string as described below; instead, the processing application SHOULD associate the discovered identity+features <em>only</em> with the JabberID of the generating entity.</li>
  414. </ol>
  415. </li>
  416. <li>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:
  417. <ol start='1'>
  418. <li>Send a service discovery information request to the generating entity.</li>
  419. <li>Receive a service discovery information response from the generating entity.</li>
  420. <li>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.</li>
  421. <li>If the response includes more than one service discovery feature with the same XML character data, consider the entire response to be ill-formed.</li>
  422. <li>If the response includes more than one extended service discovery information form with the same FORM_TYPE or the FORM_TYPE field contains more than one &lt;value/&gt; element with different XML character data, consider the entire response to be ill-formed.</li>
  423. <li>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.</li>
  424. <li>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 <link url='#ver-gen'>Generation Method</link>).</li>
  425. <li>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.</li>
  426. <li>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.</li>
  427. </ol>
  428. </li>
  429. </ol>
  430. &ltwarning;
  431. </section2>
  432. </section1>
  433. <section1 topic='Use Cases' anchor='usecases'>
  434. <section2 topic='Advertising Capabilities' anchor='advertise'>
  435. <p>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.</p>
  436. <example caption='Presence with caps'><![CDATA[
  437. <presence>
  438. <c xmlns=''
  439. hash='sha-1'
  440. node=''
  441. ver='QgayPKawpkPSDYmwT/WM94uAlu0='/>
  442. </presence>
  443. ]]></example>
  444. <p>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.</p>
  445. <example caption='Presence with recomputed ver attribute'><![CDATA[
  446. <presence>
  447. <c xmlns=''
  448. hash='sha-1'
  449. node=''
  450. ver='66/0NaeaBKkwk85efJTGmU47vXI='/>
  451. </presence>
  452. ]]></example>
  453. </section2>
  454. <section2 topic="Discovering Capabilities" anchor='discover'>
  455. <p>An application (the "requesting entity") can learn what features another entity supports by sending a disco#info request (see <cite>XEP-0030</cite>) to the entity that generated the caps information (the "generating entity").</p>
  456. <example caption='Disco#info request'><![CDATA[
  457. <iq from='juliet@capulet.lit/balcony'
  458. id='disco1'
  459. to='romeo@montague.lit/orchard'
  460. type='get'>
  461. <query xmlns=''
  462. node=''/>
  463. </iq>
  464. ]]></example>
  465. <p>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 &LOCALFULL;.</p>
  466. <p>Note: The generating entity SHOULD NOT include the "caps node" in the list of entities it returns in its disco#items responses; i.e., the caps node is a kind of virtual or phantom node, not a true items node that is associated with the generating entity for service discovery purposes.</p>
  467. <p>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., "") as provided by the generating entity, the "#" character, and the value of the caps 'ver' attribute (e.g., "QgayPKawpkPSDYmwT/WM94uAlu0=") as provided by the generating entity.</p>
  468. <p>The generating entity then returns all of the capabilities it supports.</p>
  469. <example caption='Disco#info response'><![CDATA[
  470. <iq from='romeo@montague.lit/orchard'
  471. id='disco1'
  472. to='juliet@capulet.lit/balcony'
  473. type='result'>
  474. <query xmlns=''
  475. node=''>
  476. <identity category='client' type='pc'/>
  477. <feature var=''/>
  478. <feature var=''/>
  479. <feature var=''/>
  480. </query>
  481. </iq>
  482. ]]></example>
  483. <p>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.</p>
  484. </section2>
  485. <section2 topic='Stream Feature' anchor='stream'>
  486. <p>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.</p>
  487. <example caption='Stream feature element including capabilities'><![CDATA[
  488. <stream:features>
  489. <c xmlns=''
  490. hash='sha-1'
  491. node=''
  492. ver='ItBTI0XLDFvVxZ72NQElAzKS9sU='/>
  493. </stream:features>
  494. ]]></example>
  495. <p>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 &rfc6120;). 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 <cite>RFC 6120</cite>.</p>
  496. </section2>
  497. </section1>
  498. <section1 topic='Determining Support' anchor='support'>
  499. <p>If an entity supports the entity capabilities protocol, it MUST advertise that fact by returning a feature of <strong>''</strong> in response to a service discovery information request.</p>
  500. <example caption="Service discovery information request"><![CDATA[
  501. <iq from='romeo@montague.lit/orchard'
  502. id='disco2'
  503. to='juliet@capulet.lit/balcony'
  504. type='get'>
  505. <query xmlns=''/>
  506. </iq>
  507. ]]></example>
  508. <example caption="Service discovery information response"><![CDATA[
  509. <iq from='juliet@capulet.lit/balcony'
  510. id='disco2'
  511. to='romeo@montague.lit/orchard'
  512. type='result'>
  513. <query xmlns=''>
  514. ...
  515. <feature var=''/>
  516. ...
  517. </query>
  518. </iq>
  519. ]]></example>
  520. <p>If a server supports the <link url='#impl-optimize'>Caps Optimization</link> functionality, it MUST also return a feature of <strong>''</strong> in response to service discovery information requests.</p>
  521. <example caption="Service discovery information request"><![CDATA[
  522. <iq from='juliet@capulet.lit/balcony'
  523. id='disco3'
  524. to='capulet.lit'
  525. type='get'>
  526. <query xmlns=''/>
  527. </iq>
  528. ]]></example>
  529. <example caption="Service discovery information response"><![CDATA[
  530. <iq from='capulet.lit'
  531. id='disco3'
  532. to='juliet@capulet.lit/balcony'
  533. type='result'>
  534. <query xmlns=''>
  535. ...
  536. <feature var=''/>
  537. ...
  538. </query>
  539. </iq>
  540. ]]></example>
  541. </section1>
  542. <section1 topic='Implementation Notes' anchor='impl'>
  543. <section2 topic='Hashing Algorithm Support' anchor='impl-hash'>
  544. <p>An application SHOULD maintain a list of hashing algorithms it supports, which MUST include the algorithm or algorithms listed in the <link url='#security-mti'>Mandatory-to-Implement Technologies</link> section of this document.</p>
  545. </section2>
  546. <section2 topic='Caching' anchor='impl-cache'>
  547. <p>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.</p>
  548. <p>It is RECOMMENDED for an application to cache associations across presence sessions, since this obviates the need for extensive service discovery requests at the beginning of a session (this is especially helpful in bandwidth-constrained environments).</p>
  549. </section2>
  550. <section2 topic='Directed Presence' anchor='impl-presence'>
  551. <p>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 presence broadcasts. Until and unless capabilities information has been received from another entity, an application MUST assume that the other entity does not support capabilities.</p>
  552. </section2>
  553. <section2 topic='Caps Optimization' anchor='impl-optimize'>
  554. <p>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 (i.e., the &lt;c/&gt; element). 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.</p>
  555. <p>If a connected client determines that its server supports caps optimization, it MAY choose to send the capabilities annotation only on the first presence packet, as well as whenever its capabilities change.</p>
  556. </section2>
  557. </section1>
  558. <section1 topic='Security Considerations' anchor='security'>
  559. <section2 topic='Mandatory-to-Implement Technologies' anchor='security-mti'>
  560. <p>The SHA-1 hashing algorithm is mandatory to implement. All implementations MUST support SHA-1.</p>
  561. <p>An implementation MAY support other algorithms. Any such algorithm SHOULD be registered in the &ianahashes;.</p>
  562. <p>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 <link url='#security-preimage'>Preimage Attacks</link>.</p>
  563. </section2>
  564. <section2 topic='Preimage Attacks' anchor='security-preimage'>
  565. <p>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 <em>possible</em> that the protocol might become subject to preimage attacks if the hash function used is found to be vulnerable to preimage attacks.</p>
  566. <p>In theory, such a preimage attack would take one of the following forms:</p>
  567. <ul>
  568. <li>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").</li>
  569. <li>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").</li>
  570. </ul>
  571. <p>In practice, a preimage attack would need to meet all of the following criteria in order to be effective against the entity capabilities protocol:</p>
  572. <ol start='1'>
  573. <li>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).</li>
  574. <li>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 2<span class='super'>55</span> blocks).</li>
  575. <li>The input message X or S' would need to conform to the structure of S as specified under <link url='#ver'>Verification String</link>, including the order of service discovery identity or identities followed by service discovery features, delimited by the '&lt;' character and sorted using "i;octet" collation.</li>
  576. <li>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.</li>
  577. <li>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 &REGISTRAR;, or both).</li>
  578. </ol>
  579. <p>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.</p>
  580. &ltwarning;
  581. </section2>
  582. <section2 topic='Caps Poisoning' anchor='security-poisoning'>
  583. <p>Adherence to the method defined in the <link url='#ver'>Verification String</link> 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.</p>
  584. <p>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 <link url='#legacy'>Legacy Format</link>), 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.</p>
  585. </section2>
  586. <section2 topic='Information Exposure' anchor='security-exposure'>
  587. <p>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 <link url='#directed'>Directed Presence</link>.</p>
  588. </section2>
  589. </section1>
  590. <section1 topic='IANA Considerations' anchor='iana'>
  591. <p>This document requires no interaction with &IANA;. </p>
  592. </section1>
  593. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  594. <section2 topic='Protocol Namespaces' anchor='ns'>
  595. <p>The &REGISTRAR; includes "" in its registry of protocol namespaces (see &NAMESPACES;).</p>
  596. </section2>
  597. <section2 topic='Service Discovery Features' anchor='registrar-features'>
  598. <p>The XMPP Registrar includes "" and "" in its registry of service discovery features (see &DISCOFEATURES;).</p>
  599. </section2>
  600. <section2 topic='Stream Features' anchor='registrar-stream-features'>
  601. <p>The XMPP Registrar includes "" in its registry of stream features (see &STREAMFEATURES;).</p>
  602. </section2>
  603. </section1>
  604. <section1 topic='XML Schema' anchor='schema'>
  605. <code><![CDATA[
  606. <?xml version='1.0' encoding='UTF-8'?>
  607. <xs:schema
  608. xmlns:xs=''
  609. targetNamespace=''
  610. xmlns=''
  611. elementFormDefault='qualified'>
  612. <xs:annotation>
  613. <xs:documentation>
  614. The protocol documented by this schema is defined in
  615. XEP-0115:
  616. </xs:documentation>
  617. </xs:annotation>
  618. <xs:element name='c'>
  619. <xs:complexType>
  620. <xs:simpleContent>
  621. <xs:extension base='empty'>
  622. <xs:attribute name='ext' type='xs:NMTOKENS' use='optional'/>
  623. <xs:attribute name='hash' type='xs:NMTOKEN' use='required'/>
  624. <xs:attribute name='node' type='xs:string' use='required'/>
  625. <xs:attribute name='ver' type='xs:string' use='required'/>
  626. </xs:extension>
  627. </xs:simpleContent>
  628. </xs:complexType>
  629. </xs:element>
  630. <xs:simpleType name='empty'>
  631. <xs:restriction base='xs:string'>
  632. <xs:enumeration value=''/>
  633. </xs:restriction>
  634. </xs:simpleType>
  635. </xs:schema>
  636. ]]></code>
  637. </section1>
  638. <section1 topic='Legacy Format' anchor='legacy'>
  639. <p>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 &lt;<link url=''></link>&gt;. For backwards-compatibility with the legacy format, the 'node' attribute is REQUIRED and the 'ext' attribute MAY be included.</p>
  640. <p>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.</p>
  641. <p>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.</p>
  642. <p>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.</p>
  643. </section1>
  644. <section1 topic='Acknowledgements' anchor='ack'>
  645. <p>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.</p>
  646. </section1>
  647. </xep>