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-0205.xml 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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>Best Practices to Discourage Denial of Service Attacks</title>
  10. <abstract>This document recommends a number of practices that can help discourage denial of service attacks on XMPP-based networks.</abstract>
  11. &LEGALNOTICE;
  12. <number>0205</number>
  13. <status>Active</status>
  14. <type>Informational</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. <spec>XMPP IM</spec>
  19. </dependencies>
  20. <supersedes/>
  21. <supersededby/>
  22. <shortname>N/A</shortname>
  23. &stpeter;
  24. <revision>
  25. <version>1.0</version>
  26. <date>2009-01-07</date>
  27. <initials>psa</initials>
  28. <remark><p>Per a vote of the XMPP Council, advanced specification to Active; also corrected errors namespace for consistency with XEP-0182.</p></remark>
  29. </revision>
  30. <revision>
  31. <version>0.3</version>
  32. <date>2008-12-19</date>
  33. <initials>psa</initials>
  34. <remark><p>Incorporated Last Call comments: removed paragraph about compression, added paragraph about rate limiting in message or presence amplifiers, corrected simultaneous connections error per revisions to RFC 3920.</p></remark>
  35. </revision>
  36. <revision>
  37. <version>0.2</version>
  38. <date>2007-07-10</date>
  39. <initials>psa</initials>
  40. <remark><p>Add recommendation regarding multiple messages to distinct recipients; removed numerical recommendations since they are a matter of implementation or deployment.</p></remark>
  41. </revision>
  42. <revision>
  43. <version>0.1</version>
  44. <date>2007-01-31</date>
  45. <initials>psa</initials>
  46. <remark><p>Initial published version.</p></remark>
  47. </revision>
  48. <revision>
  49. <version>0.0.2</version>
  50. <date>2007-01-29</date>
  51. <initials>psa</initials>
  52. <remark><p>Incorporated feedback; specified recommendations regarding bandwidths, payload types, and service access.</p></remark>
  53. </revision>
  54. <revision>
  55. <version>0.0.1</version>
  56. <date>2007-01-21</date>
  57. <initials>psa</initials>
  58. <remark><p>First draft.</p></remark>
  59. </revision>
  60. </header>
  61. <section1 topic='Introduction' anchor='intro'>
  62. <p>A key factor in the reliability and security of network infrastructure is its resilience in the face of denial of service attacks (see &rfc4732;). Although the existing network of servers and clients that communicate via the Extensible Messaging and Presence Protocol (&xmppcore;) has not yet been subject to such attacks, that is no cause for complacency. Therefore this document specifies a set of best practices that server implementations and deployments can follow in order to reduce the likelihood of denial of service attacks on the Jabber network.</p>
  63. </section1>
  64. <section1 topic='Potential Attacks' anchor='attacks'>
  65. <p><cite>RFC 4732</cite> defines denial of service as follows:</p>
  66. <p class='indent'>A Denial-of-Service (DoS) attack is an attack in which one or more machines target a victim and attempt to prevent the victim from doing useful work. The victim can be a network server, client or router, a network link or an entire network, an individual Internet user or a company doing business using the Internet, an Internet Service Provider (ISP), country, or any combination of or variant on these.</p>
  67. <p>The authors list a number of attacks, of which the following seem most likely against XMPP systems:</p>
  68. <ol start='1'>
  69. <li>Exploiting poor software quality (e.g., buffer overlow attacks).</li>
  70. <li>Exhausting application or operating system resources (e.g., memory, CPU cycles, disk space, configured maximum simultaneous connections).</li>
  71. <li>Triggering lockouts and quota exhaustion (e.g., quotas associated with the bandwidth limits common in numerous XMPP server implementations.</li>
  72. <li>Hijacking the TCP connection of a client or server (see &tcprobust;).</li>
  73. <li>Attacking the Domain Name System (DNS) infrastructure on which XMPP typically depends.</li>
  74. <li>Poisoning blacklists.</li>
  75. <li>Amplifying network traffic (this could be done through reflectors such as &xep0045; and &xep0060; services).</li>
  76. </ol>
  77. </section1>
  78. <section1 topic='Potential Solutions' anchor='solutions'>
  79. <p>Numerous potential solutions have been suggested to deal with the threat of denial of service attacks against XMPP servers, including the following:</p>
  80. <ol start='1'>
  81. <li><p>Limiting the number of connections that a server will accept from a given IP address at any one time. Such a limit may help to prevent automated processes from exhausting the server's resources (such as available ports or XML parser processing resources).</p></li>
  82. <li><p>Limiting the number of connection attempts (via the TCP binding specified in <cite>RFC 6120</cite> or via the &xep0124;) that a server will accept from a given IP address in a given time period. Such a limit may help to prevent automated processes from exhausting the server's resources (such as available ports or XML parser processing capacity).</p></li>
  83. <li><p>Limiting the number of authentication attempts for a given Jabber ID in a given time period. While such a limit may seem beneficial, in fact it might result in locking out the legitimate owner of a Jabber ID if a malicious entity attempts a large number of illegitimate authentication attempts for the Jabber ID; therefore such a limit is not recommended except as described in Section 6.4.5 of &rfc6120;, and it is instead recommended to limit the number of connections and connection attempts on a per-IP basis.</p></li>
  84. <li><p>Disallowing unauthenticated connections from clients and from peer servers; as mentioned below, this is required by <cite>RFC 6120</cite>.</p></li>
  85. <li><p>Limiting the number of XMPP resource identifiers allowed to an account at any one time. This may help to prevent a rogue account from creating an unlimited number of sessions and therefore exhausting the resources of the server's session manager.</p></li>
  86. <li><p>Limiting the absolute size in bytes of XML stanzas accepted by the server, or of particular aspects of an XML stanza (e.g., attribute values, element names, XML character data). Limits on particular aspects of an XML stanza are probably not needed, as long as it is possible to limit the absolute size of each XML stanza, since such a limit may help to prevent exhaustion of server resources (e.g., XML parser processing capacity).</p></li>
  87. <li><p>Limiting the number of bytes or XML stanzas that a server will accept over a given TCP connection or for a given JabberID in a given time period. Such a limit, which helps to prevent rogue accounts or hijacked clients from flooding the server, is common in existing XMPP server implementations and often goes by the name "karma".</p></li>
  88. <li><p>Limiting the number of XML stanzas that a connected client may send to different recipients in a given time period. Such a limit may help to prevent automated processes (e.g., bots) from sending unsolicited bulk communications (known in the instant messaging domain as "spim").</p></li>
  89. <li><p>Limiting or prohibiting the sending of certain stanzas based on payload, type, or other appropriate features.</p></li>
  90. <li><p>Restricting access to services (such as multi-user chat and publish-subscribe) that enable traffic amplification.</p></li>
  91. <li><p>More strictly limiting the proposed restrictions depending on connection type, authentication type, or user class.</p></li>
  92. </ol>
  93. </section1>
  94. <section1 topic='Recommendations' anchor='rec'>
  95. <p>The following recommendations are presented roughly in order of interaction (e.g., recommendations related to the number of TCP connections or connection attempts are presented before recommendations related to authentication, which are presented before recommendations related to XML stanza handling).</p>
  96. <section2 topic='Simultaneous Connections' anchor='rec-connections'>
  97. <p>A server implementation SHOULD enable a server administrator to limit the number of connections that it will accept from a given IP address at any one time. <note>Alternatively, it is possible to limit the number of connections at the TCP layer rather than at the XMPP application layer. Care must be taken in doing so, since limits at the TCP layer might result in an inability to access non-XMPP services.</note></p>
  98. <p>If an entity attempts to connect but the maximum number of connections has been reached, the receiving server MUST NOT allow the new connection to proceed. There are no XMPP errors associated with this behavior, since it occurs at the binding (TCP or HTTP) level before an XML stream is initiated.</p>
  99. </section2>
  100. <section2 topic='Connection Attempts' anchor='rec-attempts'>
  101. <p>A server implementation SHOULD enable a server administrator to limit the number of connection attempts that it will accept from a given IP address in a given time period (e.g., one hour). <note>Alternatively, it is possible to limit the number of connections at the TCP layer rather than at the XMPP application layer. Care must be taken in doing so, since limits at the TCP layer might result in an inability to access non-XMPP services.</note></p>
  102. <p>If an entity attempts to connect but the maximum number of connection attempts has been reached, the receiving server MUST NOT allow the new connection to proceed. There are no XMPP errors associated with this behavior, since it occurs at the binding (TCP or HTTP) level before an XML stream is initiated.</p>
  103. </section2>
  104. <section2 topic='Unauthenticated Connections' anchor='rec-auth'>
  105. <p>In accordance with <cite>RFC 6120</cite>, a server MUST NOT process XML stanzas (i.e., &MESSAGE;, &PRESENCE;, or &IQ;) from clients that have not yet provided appropriate authentication credentials, and MUST NOT process XML stanzas from peer servers whose identity it has not either authenticated via SASL (see &rfc4422;) or verified via server dialback.</p>
  106. </section2>
  107. <section2 topic='Simultaneous Resources' anchor='rec-resources'>
  108. <p>A server implementation SHOULD enable a server administrator to limit the number of resources it will allow an account to bind at any one time.</p>
  109. <p>If a connected client attempts to bind a resource but has already reached the configured number of allowable resources, the receiving server MUST return a &constraint; stanza error, where the XMPP &ERROR; element SHOULD also include an application-specific error condition of &lt;resource-limit-exceeded/&gt;, as shown in the following example:</p>
  110. <example caption='Resource number limit violation'><![CDATA[
  111. <iq type='error' id='bind_2'>
  112. <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
  113. <resource>someresource</resource>
  114. </bind>
  115. <error type='cancel'>
  116. <resource-constraint xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  117. <resource-limit-exceeded xmlns='urn:xmpperrors'/>
  118. </error>
  119. </iq>
  120. ]]></example>
  121. </section2>
  122. <section2 topic='Stanza Size' anchor='rec-stanzasize'>
  123. <p>A server implementation SHOULD enable a server administrator to limit the size of stanzas it will accept from a connected client or peer server.</p>
  124. <p>If a connected client or peer server sends a stanza that violates the upper limit, the receiving server SHOULD NOT process the stanza and instead SHOULD return a &notallowed; stanza error, where the XMPP &ERROR; element SHOULD also include an application-specific error condition of &lt;stanza-too-big/&gt;, as shown in the following example:</p>
  125. <example caption='Stanza size limit violation: stanza error'><![CDATA[
  126. <message from='shakespeare.lit' to='iago@shakespare.lit/evilos'>
  127. <error type='modify'>
  128. <not-allowed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  129. <stanza-too-big xmlns='urn:xmpp:errors'/>
  130. </error>
  131. </message>
  132. ]]></example>
  133. <p>Note: In the case of a stanza size limit, the server SHOULD NOT include the original payload in the error stanza.</p>
  134. <p>Alternatively (e.g., if the sender has sent a seriously large stanza), the server MAY instead return a &lt;policy-violation/&gt; stream error:</p>
  135. <example caption='Stanza size limit violation: stream error'><![CDATA[
  136. <stream:error>
  137. <policy-violation xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
  138. <stanza-too-big xmlns='urn:xmpp:errors'/>
  139. </stream:error>
  140. </stream:stream>
  141. ]]></example>
  142. </section2>
  143. <section2 topic='Multiple Recipients' anchor='rec-recipients'>
  144. <p>A server implementation SHOULD enable a server administrator to limit the number of XML stanzas that a connected client may send to distinct recipients within a given time period.</p>
  145. <p>If a connected client sends too many stanzas to distinct recipients in a given time period, the receiving server SHOULD NOT process the stanza and instead SHOULD return an &unexpected; stanza error, where the XMPP &ERROR; element SHOULD also include an application-specific error condition of &lt;too-many-stanzas/&gt;, as shown in the following example:</p>
  146. <example caption='Stanza recipients violation: stanza error'><![CDATA[
  147. <message from='iago@shakespeare.lit/evilos' to='juliet@capulet.lit'>
  148. <error type='wait'>
  149. <unexpected-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  150. <too-many-stanzas xmlns='urn:xmpp:errors'/>
  151. </error>
  152. </message>
  153. ]]></example>
  154. </section2>
  155. <section2 topic='Bandwidth Limits' anchor='rec-bandwidth'>
  156. <p>A server implementation SHOULD enable a server administrator to limit the amount of bandwidth it will allow a connected client or peer server to use in a given time period.</p>
  157. <p>Bandwidth limits in existing XMPP server implementations (often called "karma") can be somewhat complex, since they dynamically respond to usage patterns, take into account temporary traffic bursts, enable the server administrator to modify recovery times and penalty lengths, etc. An example of low average bandwidth limits would be 1k-2k per second, of medium limits 4k-6k per second, of high limits 8k-10k per second. For details, see documentation for existing implementations.</p>
  158. </section2>
  159. <section2 topic='Stanza Limits' anchor='rec-stanzas'>
  160. <p>A server implementation SHOULD enable a server administrator to limit the types of stanzas (based on payload etc.) it will allow a connected client send over an active connection. Possible restrictions include:</p>
  161. <ul>
  162. <li>Forbidding XMPP protocol extensions that typically involve the sending of large stanzas, such as &xep0008; and &xep0047;</li>
  163. <li>Prohibiting &xep0077; when directed to the server itself (i.e., disallowing open registration of new accounts).</li>
  164. <li>Limiting the number of roster requests that a user may request in a given time period.</li>
  165. <li>Not supporting offline message storage (or limiting the size of offline storage).</li>
  166. <li>Limiting the number of presence subscription requests that a user may send in a given time period.</li>
  167. <li>Limiting the number of stanzas that a user may generate in a given time period that are intended for unknown or non-existent JIDs, that are intended for JIDs at remote domains, or that are intended for distinct JIDs.</li>
  168. </ul>
  169. </section2>
  170. <section2 topic='Service Restrictions' anchor='rec-services'>
  171. <p>An implementation of a service that enables traffic amplification (e.g., multi-user chat or publish-subscribe) SHOULD enable an administrator of that service to limit (based on JabberID or other characteristics) what entities may send information through the service. (See <cite>XEP-0045</cite> regarding methods of banning users from multi-user chat rooms and <cite>XEP-0060</cite> regarding methods for prohibiting users from interacting with publish-subscribe nodes.)</p>
  172. <p>In fact, the "session manager" of an XMPP presence server also acts as just such an amplifier, since presence information is broadcast to all subscribers. Any such service SHOULD enable an administrator to limit the number of stanzas sent through the service in any given period of time (presence changes in a session manager, presence changes or messages in a chatroom, published items in a pubsub service).</p>
  173. </section2>
  174. </section1>
  175. <section1 topic='Implementation Considerations' anchor='impl'>
  176. <p>Implementations MAY enable administrators to configure appropriate exceptions to some of the recommendations specified in this document. Examples include:</p>
  177. <ul>
  178. <li>Less strict limits for server administrators compared to entities associated with registered accounts, and for entities associated with registered accounts compared to anonymous entities.</li>
  179. <li>Less strict limits for entities that authenticate via strong authentication methods (e.g., TLS + SASL EXTERNAL) compared to entities that authenticate via weaker authentication methods (e.g., TLS + SASL PLAIN or server dialback).</li>
  180. <li>Less strict limits for connections from known IP addresses.</li>
  181. <li>Less strict limits for connections made via the TCP binding compared to connections made via the HTTP binding.</li>
  182. </ul>
  183. </section1>
  184. <section1 topic='Security Considerations' anchor='security'>
  185. <p>This entire document is about security.</p>
  186. </section1>
  187. <section1 topic='IANA Considerations' anchor='iana'>
  188. <p>This document requires no interaction with &IANA;.</p>
  189. </section1>
  190. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  191. <p>The &REGISTRAR; includes &lt;resource-limit-exceeded/&gt; and &lt;too-many-stanzas/&gt; in its registry of application-specific error conditions (see &APPERRORS;), where the element is qualified by the 'urn:xmpp:errors' namespace as described in &xep0182;.</p>
  192. <p>The registry submission is as follows:</p>
  193. <code><![CDATA[
  194. <condition>
  195. <ns>urn:xmpp:errors</ns>
  196. <element>resource-limit-exceeded</element>
  197. <desc>
  198. The account is not allowed to bind more resources at this time.
  199. </desc>
  200. <doc>XEP-0205</doc>
  201. </condition>
  202. <condition>
  203. <ns>urn:xmpp:errors</ns>
  204. <element>too-many-stanzas</element>
  205. <desc>
  206. A connected client has attempted to send multiple stanzas to
  207. too many different intended recipients in a given time period.
  208. </desc>
  209. <doc>XEP-0205</doc>
  210. </condition>
  211. ]]></code>
  212. </section1>
  213. <section1 topic='Acknowledgements' anchor='ack'>
  214. <p>Special thanks to Chris Mullins for calling attention to the need for a specification on this topic. Thanks also to Thiago Camargo, Bruce Campbell, Dave Cridland, Gustavo Felisberto, Justin Karneges, Alexey Melnikov, Pedro Melo, Kevin Smith, Michal Vaner, and Matthew Wild for their suggestions.</p>
  215. </section1>
  216. </xep>