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-0158.xml 46KB

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>CAPTCHA Forms</title>
  10. <abstract>This document specifies an XMPP protocol extension that entities may use to discover whether the sender of an XML stanza is a human user or a robot.</abstract>
  12. <number>0158</number>
  13. <status>Draft</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. <spec>XMPP IM</spec>
  19. <spec>XEP-0004</spec>
  20. <spec>XEP-0066</spec>
  21. <spec>XEP-0221</spec>
  22. </dependencies>
  23. <supersedes/>
  24. <supersededby/>
  25. <shortname>captcha</shortname>
  26. <schemaloc>
  27. <url></url>
  28. </schemaloc>
  29. &ianpaterson;
  30. &stpeter;
  31. <revision>
  32. <version>1.0</version>
  33. <date>2008-09-03</date>
  34. <initials>psa</initials>
  35. <remark><p>Per a vote of the XMPP Council, advanced status to Draft; concurrently, the XMPP Registrar issued the urn:xmpp:captcha namespace; also changed element name from challenge to captcha in order to match the namespace name.</p></remark>
  36. </revision>
  37. <revision>
  38. <version>0.11</version>
  39. <date>2008-08-06</date>
  40. <initials>psa</initials>
  41. <remark><p>Further modified examples to track changes to XEP-0231.</p></remark>
  42. </revision>
  43. <revision>
  44. <version>0.10</version>
  45. <date>2008-08-06</date>
  46. <initials>psa</initials>
  47. <remark><p>Modified examples to track changes to XEP-0231; to avoid confusion with cid URIs, changed name of challenge ID form field from cid to challenge.</p></remark>
  48. </revision>
  49. <revision>
  50. <version>0.9</version>
  51. <date>2008-05-12</date>
  52. <initials>psa</initials>
  53. <remark><p>Specified that cid field is required; more clearly defined structure of challenge stanza; added several security considerations; corrected several errors in the text and examples.</p></remark>
  54. </revision>
  55. <revision>
  56. <version>0.8</version>
  57. <date>2008-05-12</date>
  58. <initials>psa</initials>
  59. <remark><p>Moved text regarding labels to new internationalization considerations section; removed necessity that ID of IQ-set shall match ID of challenge, since this is not consistent with existing usage that IDs are generated by the sender of an IQ.</p></remark>
  60. </revision>
  61. <revision>
  62. <version>0.7</version>
  63. <date>2008-04-28</date>
  64. <initials>psa</initials>
  65. <remark><p>Generalized text to cover abuse rather than just spim; modified temporary namespace to adhere to XMPP Registrar procedures; added use case for joining multi-user chat rooms.</p></remark>
  66. </revision>
  67. <revision>
  68. <version>0.6</version>
  69. <date>2007-07-11</date>
  70. <initials>psa/ip</initials>
  71. <remark><p>Moved media element definition to XEP-0221; consistently used the terms sender and challenger rather than client and entity; modified provisional namespaces to adhere to XMPP Registrar policies; completed editorial review.</p></remark>
  72. </revision>
  73. <revision>
  74. <version>0.5</version>
  75. <date>2006-10-30</date>
  76. <initials>ip</initials>
  77. <remark><p>Added reference to SPIM Reporting.</p></remark>
  78. </revision>
  79. <revision>
  80. <version>0.4</version>
  81. <date>2005-09-30</date>
  82. <initials>ip</initials>
  83. <remark><p>Required WAV instead of MP3 for audio CAPTCHAs; minor corrections.</p></remark>
  84. </revision>
  85. <revision>
  86. <version>0.3</version>
  87. <date>2005-09-28</date>
  88. <initials>ip</initials>
  89. <remark><p>Added more CAPTCHA types and the legacy question and answer section.</p></remark>
  90. </revision>
  91. <revision>
  92. <version>0.2</version>
  93. <date>2005-09-14</date>
  94. <initials>ip</initials>
  95. <remark><p>Minor fixes.</p></remark>
  96. </revision>
  97. <revision>
  98. <version>0.1</version>
  99. <date>2005-09-14</date>
  100. <initials>ip</initials>
  101. <remark><p>Initial version.</p></remark>
  102. </revision>
  103. <revision>
  104. <version>0.0.1</version>
  105. <date>2005-09-07</date>
  106. <initials>ip</initials>
  107. <remark><p>First draft.</p></remark>
  108. </revision>
  109. </header>
  110. <section1 topic='Introduction' anchor='intro'>
  111. <p>The appearance of large public IM services based on &xmppcore; and &xmppim; makes it desirable to implement protocols that <em>discourage</em> the sending of large quantities of instant messaging spam (a.k.a. "spim") or, in general, abusive traffic. Abusive stanzas could be generated by XMPP clients connected to legitimate servers or by XMPP servers with virtual clients, where the malicious entities are hosted on networks of "zombie" machines. Such abusive stanas could take many forms; a full taxonomy is outside the scope of this document.</p>
  112. <p>One technique developed to combat abusive messages and behavior via non-XMPP technologies requires humans to be differentiated from bots using a "Completely Automated Public Turing Test to Tell Computers and Humans Apart" or CAPTCHA (see &lt;<link url=''></link>&gt;). These challenge techniques are easily adapted to discourage XMPP abuse. The very occasional inconvenience of responding to a CAPTCHA (e.g., when creating an IM account or sending a message to a new correspondent) is small and perfectly acceptable -- especially when compared to the countless robot-generated interruptions people might otherwise have to filter every day.</p>
  113. <p>An alternative technique to CAPTCHAs requires Desktop PC clients to undertake a <span class='ref'>Hashcash</span> <note>Hashcash &lt;<link url=''></link>&gt;.</note> challenge. These are completely transparent to PC users. They require clients to perform specified CPU-intensive work, making it difficult to send large amounts of abusive traffic.</p>
  114. <p>Both CAPTCHAs and hashcash have been criticized regarding their effectiveness (or lack thereof). Therefore, the challenge protocol specified herein provides a great deal of flexibility, so that challenges can include CAPTCHAs, hashcash, word puzzles, so-called kitten authentication, and any other mechanism that may be developed in the future.</p>
  115. <p>The generic challenge protocol described in this document is designed for incorporation into protocols such as &xep0077;, &xep0045;, &xep0016;, and &xep0159;.</p>
  116. </section1>
  117. <section1 topic='Requirements' anchor='require'>
  118. <section2 topic='Extensibility' anchor='require-extend'>
  119. <p>The CAPTCHAs in most common use today are Optical Character Recognition (OCR) challenges where an image containing deformed text is presented and the human enters the characters they can read. However, if OCR software advances more rapidly than the techniques used to disguise text from Artificial Intelligence (AI) then very different CAPTCHAs will need to be deployed. This protocol must be extensible enough to allow the incorporation of CAPTCHA techniques that may not have been envisaged.</p>
  120. </section2>
  121. <section2 topic='Variety' anchor='require-variety'>
  122. <p>Several common CAPTCHA techniques present major problems to users with disabilities (see &w3turingtest;). Clients running in constrained environments may not be able to perform some challenges (e.g., due to the absence of audio output or a lack of CPU performance). This protocol must allow clients to be offered a choice from a variety of challenges.</p>
  123. </section2>
  124. </section1>
  125. <section1 topic='Protocol' anchor='protocol'>
  126. <section2 topic='Simple Challenge' anchor='protocol-simple'>
  127. <section3 topic='Triggering Stanza' anchor='protocol-trigger'>
  128. <p>A "triggering stanza" is an XMPP &MESSAGE;, &PRESENCE;, or &IQ; stanza that is deemed abusive by the receiving entity (e.g., a client) or an intermediate router (e.g., a server). The entity that generates a triggering stanza is called a "sender".</p>
  129. <example caption='Sender Generates Triggering Stanza'><![CDATA[
  130. <message from=''
  131. to=''
  132. xml:lang='en'
  133. id='spam1'>
  134. <body>Love pills - 75% OFF</body>
  135. <x xmlns='jabber:x:oob'>
  136. <url></url>
  137. </x>
  138. </message>
  139. ]]></example>
  140. </section3>
  141. <section3 topic='Challenge Stanza' anchor='protocol-challenge'>
  142. <p>Upon receiving a triggering stanza, an entity MAY send a "challenge stanza". An entity MUST NOT send a challenge stanza under any other circumstances. The entity that generates the challenge stanza is called the "challenger".</p>
  143. <p>The challange stanza consists of an XMPP &MESSAGE; stanza containing a data form for the sender to fill out, formatted according to &xep0004;, optionally along with a &BODY; and other elements. The following rules apply to the challenge stanza.</p>
  144. <ol>
  145. <li>The challenge stanza MUST include an 'id' attribute set to the challenge ID (i.e., a unique identifier for this challenge within the challenger's application).</li>
  146. <li>The challenge stanza SHOULD include a &BODY; element that provides an explanation of the challenge for clients that do not yet support CAPTCHA forms.</li>
  147. <li>The challenge stanza MAY include a URL (typically a Web page with instructions) using &xep0066; as an alternative for clients that do not yet support CAPTCHA forms.</li>
  148. <li>The 'xml:lang' attribute of the challenge stanza SHOULD be the same as the one received from the sender, if any.</li>
  149. <li>The challenge stanza MUST include a CAPTCHA form, i.e., a data form of type "form" containing one or more challenges. <note>Inclusion of a CAPTCHA form not only makes it possible to flexibly support or require a large number of challenge types, but also enables constrained clients to respond to challenges (e.g., mobile phone clients that cannot present web pages, or clients on XMPP-only networks).</note></li>
  150. <li>The CAPTCHA form MUST include a hidden field named "FORM_TYPE" (in accordance with &xep0068;) whose value MUST be "urn:xmpp:captcha".</li>
  151. <li>The CAPTCHA form MUST include a hidden field named "challenge" set to the challenge ID.</li>
  152. <li>The CAPTCHA form MUST include a hidden field named "from" set to the value of the 'to' attribute from the triggering stanza.</li>
  153. <li>If the triggering stanza included an 'id' attribute, then the CAPTCHA form MUST include a hidden field named "sid" set to that value.</li>
  154. <li>Each of the CAPTCHA form's non-hidden &lt;field/&gt; elements MAY contain a different challenge.</li>
  155. <li>Each CAPTCHA field MAY contain a media element (see &xep0221;) that in turn contains a pointer to media that the sender shall use in solving puzzles, performing optical character recognition, identifying audio or video samples, etc. When the sender replies to a media element via a data form of type "submit", the field type SHOULD be "text-single" (which is the default for data form fields) but MAY in turn include a media element if acceptable to the challenger application.</li>
  156. </ol>
  157. <example caption='Challenger Offers a Choice of Challenges to Sender'><![CDATA[
  158. <message from=''
  159. to=''
  160. xml:lang='en'
  161. id='F3A6292C'>
  162. <body>
  163. Your messages to are being blocked. To unblock
  164. them, visit
  165. </body>
  166. <x xmlns='jabber:x:oob'>
  167. <url></url>
  168. </x>
  169. <captcha xmlns='urn:xmpp:captcha'>
  170. <x xmlns='jabber:x:data' type='form'>
  171. <field type='hidden' var='FORM_TYPE'>
  172. <value>urn:xmpp:captcha</value>
  173. </field>
  174. <field type='hidden' var='from'><value></value></field>
  175. <field type='hidden' var='challenge'><value>F3A6292C</value></field>
  176. <field type='hidden' var='sid'><value>spam1</value></field>
  177. <field var='ocr' label='Enter the text you see'>
  178. <media xmlns='urn:xmpp:media-element'
  179. height='80'
  180. width='290'>
  181. <uri type='image/jpeg'>
  183. </uri>
  184. <uri type='image/jpeg'>
  186. </uri>
  187. </media>
  188. </field>
  189. <field var='picture_recog' label='Identify the picture'>
  190. <media xmlns='urn:xmpp:media-element'
  191. height='150'
  192. width='150'>
  193. <uri type='image/jpeg'>
  195. </uri>
  196. <uri type='image/jpeg'>
  198. </uri>
  199. </media>
  200. </field>
  201. <field var='speech_recog' label='Enter the words you hear'>
  202. <media xmlns='urn:xmpp:media-element'>
  203. <uri type='audio/x-wav'>
  205. </uri>
  206. <uri type='audio/ogg-speex'>
  208. </uri>
  209. </media>
  210. </field>
  211. <field var='video_recog' label='Identity the video'>
  212. <media xmlns='urn:xmpp:media-element'
  213. height='150'
  214. width='150'>
  215. <uri type='video/mpeg'>
  217. </uri>
  218. </media>
  219. </field>
  220. <field label='Type the color of a stop light' type='text-single' var='qa'/>
  221. <field label='93C7A' type='text-single' var='SHA-256'/>
  222. </x>
  223. </captcha>
  224. </message>
  225. ]]></example>
  226. <p>The sender then would retrieve the media data via HTTP or (for the cid: URIs) via XMPP as described in &xep0231;.</p>
  227. </section3>
  228. <section3 topic='Response Stanza' anchor='protocol-response'>
  229. <p>The sender's client SHOULD ignore the challenge stanza in either of the following cases:</p>
  230. <ul>
  231. <li>If it has not recently sent (e.g., in the last two minutes) a stanza to the JID specified in the 'from' field of the form with the 'id' specified in the 'sid' field (or with no 'id' if no 'sid' field is included). <note>Otherwise the user's presence would be disclosed, or a robot might dupe the user into providing answers to other people's challenges!</note></li>
  232. <li>If the 'from' attribute of the challenge stanza does not match the 'from' field of the form. (If the values are different, then they still match if the bare JIDs are the same, or if the 'from' attribute is the domain of the other JID.)</li>
  233. </ul>
  234. <p>Otherwise, if the challenger provided a URL using <cite>Out-of-Band Data</cite>, then the sender's client MAY present the URL to the sender, instead of responding to the CAPTCHA form, in any of the following cases:</p>
  235. <ul>
  236. <li>if it does not understand the CAPTCHA form</li>
  237. <li>if it does not support all of the <em>required</em> challenges (see <link url='#protocol-multiple'>Multiple Challenges</link>)</li>
  238. <li>if it does not support enough of the challenges (see <link url='#protocol-multiple'>Multiple Challenges</link>)</li>
  239. </ul>
  240. <p>Otherwise, the sender's client MUST respond to the challenge.</p>
  241. <p>The sender's client MUST respond with a &notacceptable; error in any of the following cases:</p>
  242. <ul>
  243. <li>if it does not support all of the required challenges (see <link url='#protocol-multiple'>Multiple Challenges</link>)</li>
  244. <li>if it does not support enough of the challenges (see <link url='#protocol-multiple'>Multiple Challenges</link>)</li>
  245. <li>if the sender declines the challenge</li>
  246. </ul>
  247. <example caption='Sender Reports Challenge Not Acceptable'><![CDATA[
  248. <message type='error'
  249. from=''
  250. to=''
  251. xml:lang='en'
  252. id='F3A6292C'>
  253. <error type='modify'>
  254. <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  255. </error>
  256. </message>
  257. ]]></example>
  258. <p>Otherwise, it MUST select one challenge according to the sender's preferences and submit the sender's response form to the challenger.</p>
  259. <example caption='Sender Sends One Response to Challenger'><![CDATA[
  260. <iq type='set'
  261. from=''
  262. to=''
  263. xml:lang='en'
  264. id='z140r0s'>
  265. <captcha xmlns='urn:xmpp:captcha'>
  266. <x xmlns='jabber:x:data' type='submit'>
  267. <field var='FORM_TYPE'>
  268. <value>urn:xmpp:captcha</value>
  269. </field>
  270. <field var='from'><value></value></field>
  271. <field var='challenge'><value>F3A6292C</value></field>
  272. <field var='sid'><value>spam1</value></field>
  273. <field var='ocr'><value>7nHL3</value></field>
  274. </x>
  275. </captcha>
  276. </iq>
  277. ]]></example>
  278. </section3>
  279. <section3 topic='Result Stanza' anchor='protocol-result'>
  280. <p>The challenger SHOULD send a &unavailable; error to the sender if:</p>
  281. <ul>
  282. <li>The challenger did not send the specified challenge. <note>If the challenger is a client then it SHOULD be careful not to leak information about the presence of the sender and reply to potentially bogus challenge responses with exactly the same XML that its server would send if the sender were offline.</note></li>
  283. <li>The sender already submitted its response to this challenge.</li>
  284. <li>The sender took too long to submit its response.</li>
  285. </ul>
  286. <p>Note: This error MAY be sent even in cases where the challenge became unnecessary while the challenger was waiting for the response.</p>
  287. <example caption='Challenger Indicates Challenge Not Found'><![CDATA[
  288. <iq type='error'
  289. from=''
  290. to=''
  291. id='z140r0s'>
  292. <error type='cancel'>
  293. <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  294. </error>
  295. </iq>
  296. ]]></example>
  297. <p>After receiving a correct response to its challenge, the challenger SHOULD inform the sender that it was successful.</p>
  298. <example caption='Challenger Tells Sender it Passed'><![CDATA[
  299. <iq type='result'
  300. from=''
  301. to=''
  302. id='z140r0s'/>
  303. ]]></example>
  304. <p>However, if the sender submits an incorrect response the challenger SHOULD send it a &notacceptable; error with type "cancel": <note>If a large proportion of the responses a server is receiving from another IP are incorrect then it SHOULD inform the administrator of the other server using the protocol specified in &xep0161; or &xep0236;. It SHOULD also automatically block all stanzas from the abusive user, users, server or IP.</note></p>
  305. <example caption='Challenger Tells Sender it Failed'><![CDATA[
  306. <iq type='error'
  307. from=''
  308. to=''
  309. id='z140r0s'>
  310. <error type='cancel'>
  311. <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  312. </error>
  313. </iq>
  314. ]]></example>
  315. </section3>
  316. </section2>
  317. <section2 topic='Multiple Challenges' anchor='protocol-multiple'>
  318. <p>The challenger MAY demand responses to more than one of the challenges it is offering; this is done by including an 'answers' &lt;field/&gt; element in the form, which specifies how many answers the sender needs to include. The challenger also MAY require responses to particular challenges; this is done by including a &lt;required/&gt; element in the compulsory fields.</p>
  319. <example caption='Challenger Sets Multiple Challenges'><![CDATA[
  320. <message from=''
  321. to=''
  322. xml:lang='en'
  323. id='73DE28A2'>
  324. <body>Your messages to are being blocked.
  325. To unblock them, ask to send you a message.</body>
  326. <captcha xmlns='urn:xmpp:captcha'>
  327. <x xmlns='jabber:x:data' type='form'>
  328. <field type='hidden' var='FORM_TYPE'>
  329. <value>urn:xmpp:captcha</value>
  330. </field>
  331. <field type='hidden' var='from'><value></value></field>
  332. <field type='hidden' var='challenge'><value>73DE28A2</value></field>
  333. <field type='hidden' var='sid'><value>spam2</value></field>
  334. <field type='hidden' var='answers'><value>2</value></field>
  335. <field var='ocr' label='Enter the text you see'>
  336. <media xmlns='urn:xmpp:media-element'
  337. height='80'
  338. width='290'>
  339. <uri type='image/jpeg'>
  341. </uri>
  342. <uri type='image/jpeg'>
  344. </uri>
  345. </media>
  346. </field>
  347. <field var='audio_recog' label='Describe the sound you hear'>
  348. <media xmlns='urn:xmpp:media-element'>
  349. <uri type='audio/x-wav'>
  351. </uri>
  352. </media>
  353. </field>
  354. <field label='Type the color of a stop light' type='text-single' var='qa'>
  355. <required/>
  356. </field>
  357. <field label='e03d7' type='text-single' var='SHA-256'/>
  358. </x>
  359. </captcha>
  360. </message>
  361. ]]></example>
  362. <p>If the sender finds the request acceptable, it MUST answer all challenges that include a &lt;required/&gt; element. If the total number of answers was specified and it is greater than the number of &lt;required/&gt; elements then the sender MUST also answer one or more of the challenges without a &lt;required/&gt; element. In the example above, the sender should respond to the 'qa' challenge <em>and</em> one of the other challenges ('ocr', 'audio_recog' or 'SHA-256').</p>
  363. <example caption='Sender Sends Multiple Responses to the Challenger'><![CDATA[
  364. <iq type='set'
  365. from=''
  366. to=''
  367. xml:lang='en'
  368. id='73DE28A2'>
  369. <captcha xmlns='urn:xmpp:captcha'>
  370. <x xmlns='jabber:x:data' type='submit'>
  371. <field var='FORM_TYPE'>
  372. <value>urn:xmpp:captcha</value>
  373. </field>
  374. <field var='from'><value></value></field>
  375. <field var='challenge'><value>73DE28A2</value></field>
  376. <field var='sid'><value>spam2</value></field>
  377. <field var='answers'><value>2</value></field>
  378. <field var='qa'><value>red</value></field>
  379. <field var='SHA-256'><value>innocent@victim.com2450F06C173B05E3</value></field>
  380. </x>
  381. </captcha>
  382. </iq>
  383. ]]></example>
  384. <p>The challenger MAY decide the sender has passed a challenge even if the responses are not all perfectly correct.</p>
  385. </section2>
  386. </section1>
  387. <section1 topic='Extended In-Band Registration' anchor='register'>
  388. <p>This section shows how challenges SHOULD be combined with the existing In-Band Registration protocol according to the rules defined in the Extensibility section of <cite>XEP-0077</cite>.</p>
  389. <p>Note: The &lt;challenge/&gt; wrapper element is not included, because <cite>XEP-0077</cite> specifies that data forms shall be contained as the direct children of the &QUERY; element.</p>
  390. <example caption='Entity Requests Registration Fields from Host'><![CDATA[
  391. <iq type='get' xml:lang='en' id='reg1'>
  392. <query xmlns='jabber:iq:register'/>
  393. </iq>
  394. ]]></example>
  395. <p>Note that the CAPTCHA form MUST be inside the &QUERY; element, and the server's challenge ID is specified within the form:</p>
  396. <example caption='Host Returns Registration and Challenge Fields to Entity'><![CDATA[
  397. <iq type='result' xml:lang='en' id='reg1'>
  398. <query xmlns='jabber:iq:register'>
  399. <x xmlns='jabber:x:data' type='form'>
  400. <field type='hidden' var='FORM_TYPE'>
  401. <value>urn:xmpp:captcha</value>
  402. </field>
  403. <field type='hidden' var='challenge'><value>F3A6292C</value></field>
  404. <field type='hidden' var='sid'><value>reg1</value></field>
  405. <field type='hidden' var='answers'><value>3</value></field>
  406. <field var='ocr' label='Enter the text you see'>
  407. <media xmlns='urn:xmpp:media-element'
  408. height='80'
  409. width='290'>
  410. <uri type='image/jpeg'>
  412. </uri>
  413. </media>
  414. </field>
  415. <field label='93C7A' type='text-single' var='SHA-256'/>
  416. <field type='text-single' var='username'>
  417. <required/>
  418. </field>
  419. <field type='text-private' var='password'>
  420. <required/>
  421. </field>
  422. </x>
  423. <instructions>
  424. To register, visit
  425. </instructions>
  426. <x xmlns='jabber:x:oob'>
  427. <url></url>
  428. </x>
  429. </query>
  430. </iq>
  431. ]]></example>
  432. <p>The server MAY include an &lt;instructions/&gt; element and a URL using <cite>Out-of-Band Data</cite> (e.g., a web page) in the &QUERY; element (see example above). <cite>In-Band Registration</cite> recommends that the challenger SHOULD submit the completed x:data form, however if it does not understand the form, then it MAY present the instructions and the included URL to the user instead of providing the required information in-band.</p>
  433. <example caption='Entity Provides Required Information In-Band'><![CDATA[
  434. <iq type='set' xml:lang='en' id='reg2'>
  435. <query xmlns='jabber:iq:register'>
  436. <x xmlns='jabber:x:data' type='submit'>
  437. <field var='FORM_TYPE'>
  438. <value>urn:xmpp:captcha</value>
  439. </field>
  440. <field var='challenge'><value>F3A6292C</value></field>
  441. <field var='sid'><value>reg1</value></field>
  442. <field var='answers'><value>3</value></field>
  443. <field var='ocr'><value>7nHL3</value></field>
  444. <field var='username'><value>bill</value></field>
  445. <field var='password'><value>Calliope</value></field>
  446. </x>
  447. </query>
  448. </iq>
  449. ]]></example>
  450. </section1>
  451. <section1 topic='Multi-User Chat' anchor='muc'>
  452. <p>A service that hosts multi-user chat rooms in accordance with <cite>XEP-0045</cite> MAY challenge unknown entities that seek to join such rooms or that send messages in such rooms.</p>
  453. <example caption='Sender Attempts to Join Chat Room'><![CDATA[
  454. <presence from=''
  455. to=''/>
  456. ]]></example>
  457. <example caption='Challenger Offers a Choice of Challenges to Sender'><![CDATA[
  458. <message from=''
  459. to=''
  460. id='A4C7303D'>
  461. <body>
  462. Your messages to are being blocked. To unblock
  463. them, visit
  464. </body>
  465. <x xmlns='jabber:x:oob'>
  466. <url></url>
  467. </x>
  468. <captcha xmlns='urn:xmpp:captcha'>
  469. <x xmlns='jabber:x:data' type='form'>
  470. <field type='hidden' var='FORM_TYPE'>
  471. <value>urn:xmpp:captcha</value>
  472. </field>
  473. <field type='hidden' var='from'><value></value></field>
  474. <field type='hidden' var='challenge'><value>A4C7303D</value></field>
  475. <field var='ocr' label='Enter the text you see'>
  476. <media xmlns='urn:xmpp:media-element'
  477. height='80'
  478. width='290'>
  479. <uri type='image/jpeg'>
  481. </uri>
  482. </media>
  483. </field>
  484. <field var='picture_recog' label='Identify the picture'>
  485. <media xmlns='urn:xmpp:media-element'
  486. height='150'
  487. width='150'>
  488. <uri type='image/jpeg'>
  490. </uri>
  491. <uri type='image/jpeg'>
  493. </uri>
  494. </media>
  495. </field>
  496. <field var='speech_recog' label='Enter the words you hear'>
  497. <media xmlns='urn:xmpp:media-element'>
  498. <uri type='audio/x-wav'>
  500. </uri>
  501. <uri type='audio/ogg-speex'>
  503. </uri>
  504. </media>
  505. </field>
  506. <field var='video_recog' label='Identity the video'>
  507. <media xmlns='urn:xmpp:media-element'
  508. height='150'
  509. width='150'>
  510. <uri type='video/mpeg'>
  512. </uri>
  513. </media>
  514. </field>
  515. <field label='Type the color of a stop light' type='text-single' var='qa'/>
  516. <field label='93C7A' type='text-single' var='SHA-256'/>
  517. </x>
  518. </captcha>
  519. </message>
  520. ]]></example>
  521. </section1>
  522. <section1 topic='Challenge Types' anchor='challenge'>
  523. <section2 topic='Introduction' anchor='challenge-intro'>
  524. <p>Entities MUST address the needs of disabled people and CPU-constrained clients by offering senders a reasonable choice of different types of challenges.</p>
  525. <p>Desktop clients running on modern PCs will typically be configured to automatically perform a specified 'SHA-256' Hashcash challenge (see below) whenever it is below a certain level of difficulty, with the result that many people may not even notice challenges most of the time. However, people using CPU-constrained clients (e.g. Web or mobile clients) would notice the performance hit. They might prefer to take a CAPTCHA challenge instead. <note>A CPU-constrained client could ask a faster computer (e.g., its server) to perform a Hashcash challenge for it.</note></p>
  526. <p>Visually disabled people using a CPU-constrained client could configure their client to always present them with an audio CAPTCHA challenge.</p>
  527. <p>Most of the challenges below are language sensitive. However, the evaluation of the OCR and Hashcash responses does not depend on the language the sender is using.</p>
  528. <p>Challenge types are distinguished by the 'var' attribute of each &lt;field/&gt; element. Several types of challenges are described below. More challenges MAY be documented elsewhere and registered with the XMPP Registrar (see <link url='#registrar-formtypes'>Field Standardization</link>).</p>
  529. </section2>
  530. <section2 topic='SHA-256 Hashcash' anchor='challenge-hashcash'>
  531. <p>The SHA-256 Hashcash challenge is transparent to average PC users. It is indicated when the value of the 'var' attribute is 'SHA-256'. It forces clients to perform CPU-intensive work, making it difficult to send large amounts of abusive traffic. This significantly reduces abusive traffic, but alone it will not completely stop abusive stanzas from being sent through large collections of 'zombie' computers. <note>The hope is that the extra CPU usage will often be noticed by the owners of the zombie machines, who will be more likely to fix them.</note></p>
  532. <p>The challenger MUST set the 'label' attribute of the &lt;field/&gt; element to a hexadecimal random number containing a configured number of bits (e.g., 2<span class='super'>20</span> &#8804; label &lt; 2<span class='super'>21</span>).</p>
  533. <p>To pass the test, the sender MUST return a text string that starts with the JID the sender sent the first stanza to (i.e., the stanza that triggered the challenge). The least significant bits of the SHA-256 hash (see &nistfips180-2;) of the string MUST equal the hexadecimal value specified by the challenger (in the 'label' attribute of the &lt;field/&gt; element). For example, if the 'label' attribute is the 20-bit value 'e03d7' then the following string would be correct:</p>
  534. <code>innocent@victim.com2450F06C173B05E3</code>
  535. <p>Note: When configuring the number of bits to be specified by a challenger in the 'label' attribute values, administrators MUST balance the need to make mass abuse as difficult as possible, with the inconvenience that may be caused to the users of less powerful computers. (Most clients will be challenged only very occasionally, so the consumption of 70% of a typical desktop CPU for 4 seconds might be considered appropriate.) Administrators SHOULD increment the configured number of bits from time to time to match increases in the performance of typical desktop PCs. If an administrator notices that abusive robots never attempt the Hashcash challenge, then he SHOULD consider reducing the number of bits, to avoid inconveniencing people unnecessarily.</p>
  536. </section2>
  537. <section2 topic='CAPTCHAs' anchor='challenge-captcha'>
  538. <p>Note: It may be profitable to send abusive stanzas even if less than one percent of CAPTCHA responses are successful. The effectiveness of a CAPTCHA challenge needs to be close to perfect, unless it is used in combination with other anti-abuse techniques.</p>
  539. <p>If a media type is specified (see table below) then the &lt;field/&gt; element MUST contain a &lt;media/&gt; element that includes a &lt;uri/&gt; element of that type. Clients that support the CAPTCHA type MUST be able to play or render the specified MIME-types (see table below). They MAY also support other formats. <note>Audio CAPTCHAs typically require challengers to provide at least the 'audio/x-wav' MIME-type (with the PCM codec) because more efficient patent-free formats are often not supported by constrained clients. It is RECOMMENDED that challengers provide more compact formats (like Ogg Speex or MP3) too.</note></p>
  540. <p>The 'type' attribute of the &lt;field/&gt; element SHOULD be 'text-single', 'text-private', or 'text-multi' (if no 'type' is specified, the default is 'text-single'). <note>The 'boolean' and 'list-single' field types would make it trivial for a robot to provide a correct response at least some of the time.</note> The response MUST be provided in the language specified by the 'xml:lang' attribute of the challenge stanza.</p>
  541. <table caption='CAPTCHAs'>
  542. <tr>
  543. <th>'var'</th>
  544. <th>Name</th>
  545. <th>Media type</th>
  546. <th>MIME-type</th>
  547. <th>Suggested generic instructions *</th>
  548. </tr>
  549. <tr>
  550. <td>audio_recog</td>
  551. <td>Audio Recognition</td>
  552. <td>audio</td>
  553. <td>audio/x-wav</td>
  554. <td>Describe the sound you hear</td>
  555. </tr>
  556. <tr>
  557. <td>ocr **</td>
  558. <td>Optical Character Recognition</td>
  559. <td>image</td>
  560. <td>image/jpeg</td>
  561. <td>Enter the text you see</td>
  562. </tr>
  563. <tr>
  564. <td>picture_q</td>
  565. <td>Picture Question</td>
  566. <td>image</td>
  567. <td>image/jpeg</td>
  568. <td>Answer the question you see</td>
  569. </tr>
  570. <tr>
  571. <td>picture_recog</td>
  572. <td>Picture Recognition</td>
  573. <td>image</td>
  574. <td>image/jpeg</td>
  575. <td>Identify the picture</td>
  576. </tr>
  577. <tr>
  578. <td>qa</td>
  579. <td>Text Question and Answer</td>
  580. <td>-</td>
  581. <td>-</td>
  582. <td>-</td>
  583. </tr>
  584. <tr>
  585. <td>speech_q</td>
  586. <td>Speech Question</td>
  587. <td>audio</td>
  588. <td>audio/x-wav</td>
  589. <td>Answer the question you hear</td>
  590. </tr>
  591. <tr>
  592. <td>speech_recog</td>
  593. <td>Speech Recognition</td>
  594. <td>audio</td>
  595. <td>audio/x-wav</td>
  596. <td>Enter the words you hear</td>
  597. </tr>
  598. <tr>
  599. <td>video_q</td>
  600. <td>Video Question</td>
  601. <td>video</td>
  602. <td>video/mpeg</td>
  603. <td>Answer the question in the video</td>
  604. </tr>
  605. <tr>
  606. <td>video_recog</td>
  607. <td>Video Recognition</td>
  608. <td>video</td>
  609. <td>video/mpeg</td>
  610. <td>Identify the video</td>
  611. </tr>
  612. </table>
  613. <p>* See the <link url='#i18n'>Internationalization Considerations</link> section of this document.</p>
  614. <p>** The image portrays random characters that humans can read but OCR software cannot. <note>See PWNtcha &lt;<link url=''></link>&gt; for some example OCR CAPTCHA images.</note> To pass the challenge, the sender must simply type the characters. The correct answer SHOULD NOT depend on the language specified by the 'xml:lang' attribute of the challenge stanza.</p>
  615. </section2>
  616. </section1>
  617. <section1 topic='Question and Answer for Legacy Clients' anchor='legacy'>
  618. <p>A challenger MAY provide a text question in the &BODY; element of a challenge stanza for clients that do not support CAPTCHA forms. Entities that cannot serve <cite>Out-of-Band Data</cite> URLs MAY use this option to challenge legacy clients.</p>
  619. <!-- It also allows entities to provide a challenge for minimal legacy clients that do not support <cite>Out-of-Band Data</cite> URLs (these don't exist). -->
  620. <p>Note: Robots always attempt the easiest challenge they are offered. So the question MUST be at least as difficult for a robot as the CAPTCHA form.</p>
  621. <p>Note: Even if it provides a text question in the &BODY; element, a challenger MUST always provide a CAPTCHA form.</p>
  622. <example caption='Challenger Includes a Legacy Challenge'><![CDATA[
  623. <message from=''
  624. to=''
  625. xml:lang='en'
  626. id='F3A6292C'>
  627. <body>Your messages to me are being blocked. To unblock them,
  628. reply with the color of a stop light followed by 'F3A6292C'.</body>
  629. <captcha xmlns='urn:xmpp:captcha'>
  630. <x xmlns='jabber:x:data' type='form'>
  631. <field type='hidden' var='FORM_TYPE'>
  632. <value>urn:xmpp:captcha</value>
  633. </field>
  634. <field type='hidden' var='from'><value></value></field>
  635. <field type='hidden' var='challenge'><value>F3A6292C</value></field>
  636. <field type='hidden' var='sid'><value>spam1</value></field>
  637. <field label='Type the color of a stop light' type='text-single' var='qa'/>
  638. <field label='93C7A' type='text-single' var='SHA-256'/>
  639. </x>
  640. </captcha>
  641. </message>
  642. ]]></example>
  643. <p>Legacy clients respond to the challenger using a &MESSAGE; stanza (not an &IQ;).</p>
  644. <example caption='Legacy Sender Responds'><![CDATA[
  645. <message from='' to=''>
  646. <body>red F3A6292C</body>
  647. </message>
  648. ]]></example>
  649. <p>The challenger SHOULD treat the stanza as a normal message (instead of as a response to its challenge) if the legacy client either takes too long to submit it or has already responded to the challenge. The challenger MAY treat the response as a normal message even in cases where the challenge became unnecessary while the challenger was waiting for the response.</p>
  650. <p>Otherwise the challenger MUST report the result of the challenge to the legacy client using a &MESSAGE; stanza (not an &IQ;).</p>
  651. <example caption='Challenger Tells Legacy Sender it Passed'><![CDATA[
  652. <message from='' to=''>
  653. <body>Your message was delivered. Your messages
  654. to me are no longer being blocked.</body>
  655. </message>
  656. ]]></example>
  657. <example caption='Challenger Tells Legacy Sender it Failed'><![CDATA[
  658. <message type='error'
  659. from=''
  660. to=''>
  661. <error type='cancel'>
  662. <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  663. <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>
  664. Your message to me was not delivered.
  665. </text>
  666. </error>
  667. </message>
  668. ]]></example>
  669. </section1>
  670. <section1 topic='Discontinuation Policy' anchor='stop'>
  671. <p>It is RECOMMENDED that entities employ other techniques to combat abusive stanzas in addition to those described in this document (e.g., see <cite>XEP-0161</cite> and &xep0205;).</p>
  672. <p>It is expected that this protocol will be an important and successful tool for discouraging abusive traffic. However, much of its success is dependent on the quality of the CAPTCHAs and other puzzles employed by a particular implementation.</p>
  673. <p>The administrator of an application that functions as a challenger SHOULD discontinue the use of CAPTCHA forms under the following circumstances:</p>
  674. <ul>
  675. <li>If he realises that the challenger's challenges are largely ineffective in combating abusive traffic, and that the reduction in abuse does not compensate for the inconvenience to humans of responding to the challenger's challenges.</li>
  676. <li>If other, <em>more transparent</em>, techniques being employed by the challenger are so successful that challenges are offering only negligible additional protection against abusive traffic.</li>
  677. <li>If the challenger needs no protection at all because it receives only a negligible amount of abusive traffic.</li>
  678. </ul>
  679. </section1>
  680. <section1 topic='Internationalization Considerations' anchor='i18n'>
  681. <p>Each form field SHOULD include a 'label' attribute. If the sender did not include an 'xml:lang' attribute, then the challenger may not know the correct language for the labels. Therefore, depending on user preferences, the client that receives a challenge MAY present generic but localized text instead of label text that would not be understood by the user. Suggested generic text (to be suitably localized) is provided by <link url='#table-1'>Table 1</link> in the <link url='#challenge-captcha'>CAPTCHAs</link> section of this document.</p>
  682. </section1>
  683. <section1 topic='Security Considerations' anchor='sec'>
  684. <p>The use of CAPTCHAs is not a panacea, and should be combined with other anti-abuse mechanisms, such as those described in <cite>XEP-0161</cite> and <cite>XEP-0205</cite>. For example, the task of finding solutions to CAPTCHAs and other computational puzzles is becoming easier for computer programs, and in any case can be farmed out to third parties. Therefore challengers should limit the number of triggering stanzas (e.g., registration attempts, subscription requests, or chatroom joins) allowed per JabberID or IP address during any given time period, and may simply refuse repeated stanzas by terminating an XML stream with a &policy; stream error or returning a &notacceptable; stanza error as appropriate. In addition, a challenger should feel free to deploy additional anti-abuse mechanisms as needed.</p>
  685. </section1>
  686. <section1 topic='IANA Considerations' anchor='iana'>
  687. <p>This document requires no interaction with &IANA;. </p>
  688. </section1>
  689. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  690. <section2 topic='Protocol Namespaces' anchor='ns'>
  691. <p>The &REGISTRAR; includes "urn:xmpp:captcha" in its registry of protocol namespaces (see &NAMESPACES;).</p>
  692. </section2>
  693. <section2 topic='Field Standardization' anchor='registrar-formtypes'>
  694. <section3 topic='CAPTCHA FORM_TYPE' anchor='registrar-formtypes-captcha'>
  695. <p>The <cite>XMPP Registrar</cite> registers following FORM_TYPE. Additional fields might be defined in future submissions.</p>
  696. <code><![CDATA[
  697. <form_type>
  698. <name>urn:xmpp:captcha</name>
  699. <doc>XEP-0158</doc>
  700. <desc>Forms enabling the use of CAPTCHAs.</desc>
  701. <field
  702. var='answers'
  703. type='hidden'
  704. label='number of answers required'/>
  705. <field
  706. var='audio_recog'
  707. type='text-single'
  708. label='text associated with a sound'/>
  709. <field
  710. var='challenge'
  711. type='hidden'
  712. label='challenge ID'/>
  713. <field
  714. var='from'
  715. type='hidden'
  716. label='to attribute of stanza that triggered challenge'/>
  717. <field
  718. var='ocr'
  719. type='text-single'
  720. label='code appearing in an image'/>
  721. <field
  722. var='picture_q'
  723. type='text-single'
  724. label='answer associated with a picture'/>
  725. <field
  726. var='picture_recog'
  727. type='text-single'
  728. label='text associated with a picture'/>
  729. <field
  730. var='qa'
  731. type='text-single'
  732. label='answer to a question'/>
  733. <field
  734. var='SHA-256'
  735. type='text-single'
  736. label='least significant bits of SHA-256 hash of text should equal hexadecimal label'/>
  737. <field
  738. var='sid'
  739. type='hidden'
  740. label='stanza ID'/>
  741. <field
  742. var='speech_q'
  743. type='text-single'
  744. label='answer associated with speech'/>
  745. <field
  746. var='speech_recog'
  747. type='text-single'
  748. label='text associated with speech'/>
  749. <field
  750. var='video_q'
  751. type='text-single'
  752. label='answer associated with a video'/>
  753. <field
  754. var='video_recog'
  755. type='text-single'
  756. label='text associated with a video'/>
  757. </form_type>
  758. ]]></code>
  759. </section3>
  760. <section3 topic='jabber:iq:register FORM_TYPE' anchor='registrar-formtypes-register'>
  761. <p>The <cite>XMPP Registrar</cite> registers the following fields for the existing jabber:iq:register FORM_TYPE. Additional fields might be defined in future submissions.</p>
  762. <code><![CDATA[
  763. <form_type>
  764. <name>jabber:iq:register</name>
  765. <doc>XEP-0077</doc>
  766. <field
  767. var='answers'
  768. type='hidden'
  769. label='number of answers required'/>
  770. <field
  771. var='audio_recog'
  772. type='text-single'
  773. label='text associated with a sound'/>
  774. <field
  775. var='challenge'
  776. type='hidden'
  777. label='challenge ID'/>
  778. <field
  779. var='ocr'
  780. type='text-single'
  781. label='code appearing in an image'/>
  782. <field
  783. var='picture_q'
  784. type='text-single'
  785. label='answer associated with a picture'/>
  786. <field
  787. var='picture_recog'
  788. type='text-single'
  789. label='text associated with a picture'/>
  790. <field
  791. var='qa'
  792. type='text-single'
  793. label='answer to a question'/>
  794. <field
  795. var='SHA-256'
  796. type='text-single'
  797. label='least significant bits of SHA-256 hash of text should equal hexadecimal label'/>
  798. <field
  799. var='sid'
  800. type='hidden'
  801. label='stanza ID'/>
  802. <field
  803. var='speech_q'
  804. type='text-single'
  805. label='answer associated with speech'/>
  806. <field
  807. var='speech_recog'
  808. type='text-single'
  809. label='text associated with speech'/>
  810. <field
  811. var='video_q'
  812. type='text-single'
  813. label='answer associated with a video'/>
  814. <field
  815. var='video_recog'
  816. type='text-single'
  817. label='text associated with a video'/>
  818. </form_type>
  819. ]]></code>
  820. </section3>
  821. </section2>
  822. </section1>
  823. <section1 topic='XML Schema' anchor='schema'>
  824. <code><![CDATA[
  825. <?xml version='1.0' encoding='UTF-8'?>
  826. <xs:schema
  827. xmlns:xs=''
  828. targetNamespace='urn:xmpp:captcha'
  829. xmlns='urn:xmpp:captcha'
  830. elementFormDefault='qualified'>
  831. <xs:annotation>
  832. <xs:documentation>
  833. The protocol documented by this schema is defined in
  834. XEP-0158:
  835. </xs:documentation>
  836. </xs:annotation>
  837. <xs:import namespace='jabber:x:data'
  838. schemaLocation=''/>
  839. <xs:element name='captcha'>
  840. <xs:complexType>
  841. <xs:sequence xmlns:xdata='jabber:x:data'>
  842. <xs:element ref='xdata:x' minOccurs='1' maxOccurs='1'/>
  843. </xs:sequence>
  844. </xs:complexType>
  845. </xs:element>
  846. </xs:schema>
  847. ]]></code>
  848. </section1>
  849. <section1 topic='Open Issues' anchor='open'>
  850. <p>Another protocol could allow users to edit the challenges their server will make on their behalf. For example, the number of SHA-256 bits, a personal or original question and answer, a picture, a video, or a sound recording. Of course Aunt Tillie would typically use this feature only if she was plagued by abusive traffic.</p>
  851. </section1>
  852. </xep>