This document recommends a number of practices that can help discourage denial of service attacks on XMPP-based networks.
WARNING: This Informational document is Experimental. Publication as an XMPP Extension Protocol does not imply approval of this proposal by the XMPP Standards Foundation. Implementation of the best practice or protocol profile described herein is encouraged in exploratory implementations, although production systems should not deploy implementations of this protocol until it advances to a status of Draft.
Series: XEP
Number: 0205
Publisher: XMPP Standards Foundation
Status:
Experimental
Type:
Informational
Version: 0.1
Last Updated: 2007-01-31
Approving Body: XMPP Council
Dependencies: XMPP Core, XMPP IM
Supersedes: None
Superseded By: None
Short Name: N/A
Wiki Page: <http://wiki.jabber.org/index.php/Best Practices to Discourage Denial of Service Attacks (XEP-0205)>
Email:
stpeter@jabber.org
JabberID:
stpeter@jabber.org
This XMPP Extension Protocol is copyright 1999 - 2007 by the XMPP Standards Foundation (XSF) and is in full conformance with the XSF's Intellectual Property Rights Policy <http://www.xmpp.org/extensions/ipr-policy.shtml>. This material may be distributed only subject to the terms and conditions set forth in the Creative Commons Attribution License (<http://creativecommons.org/licenses/by/2.5/>).
The preferred venue for discussion of this document is the Standards discussion list: <http://mail.jabber.org/mailman/listinfo/standards>.
The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.
The following keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".
1. Introduction
2. Potential Attacks
3. Potential Solutions
4. Recommendations
4.1. Simultaneous Connections
4.2. Connection Attempts
4.3. Unauthenticated Connections
4.4. Simultaneous Resources
4.5. Stanza Size
4.6. Bandwidth Limits
4.7. Stanza Limits
4.8. Service Restrictions
5. Implementation Considerations
6. Security Considerations
7. IANA Considerations
8. XMPP Registrar Considerations
9. Acknowledgements
Notes
Revision History
A key factor in the reliability and security of network infrastructure is its resilience in the face of denial of service attacks (see RFC 4732 [1]). Although the existing network of servers and clients that communicate via the Extensible Messaging and Presence Protocol (XMPP; see RFC 3920 [2]) has not yet been subject to such attacks, that is no cause for complacency. Therefore this document specifies a set of best practices that XMPP server implementations and deployments can follow in order to reduce the likelihood of denial of service attacks on the Jabber network.
RFC 4732 defines denial of service as follows:
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.
The authors list a number of attacks, of which the following seem most likely against XMPP systems:
Numerous potential solutions have been suggested to deal with the threat of denial of service attacks against XMPP servers, including the following:
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).
Limiting the number of connection attempts (via the TCP binding specified in RFC 3920 or via the HTTP Binding [6]) 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).
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 and it is instead recommended to limit the number of connections and connection attemps on a per-IP basis.
Disallowing unauthenticated connections from clients and from peer servers; as mentioned below, this is required by RFC 3920.
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.
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).
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".
Limiting or prohibiting the sending of certain stanzas based on payload, type, or other appropriate features.
Restricting access to services (such as multi-user chat and publish-subscribe) that enable traffic amplification.
More strictly limiting the proposed restrictions depending on connection type, authentication type, or user class.
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).
A server implementation SHOULD enable a server administrator to limit the number of connections that it will from a given IP address at any one time. [7] The maximum number of connections per IP address is a matter of deployment policy, and no recommendations are provided herein.
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.
A server implementation SHOULD enable a server administrator to limit the number of connection attempts that it will from a given IP address in a given time period (e.g., one hour). [8] It is RECOMMENDED for a deployment to set the maximum number of connection attempts per IP address to 120 per hour.
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.
In accordance with RFC 3920, a server MUST NOT process XML stanzas from clients that have not provided appropriate authentication credentials, and MUST NOT process XML stanzas from peer servers whose identity it has not either authenticated via SASL or verified via server dialback.
A server implementation MUST enable a server administrator to limit the number of resources it will allow an account to bind at any one time. The allowable range for simultaneous resources MAY vary by server implementation. It is RECOMMENDED for a deployment to set the maximum number of connected resources to a number less than 20.
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 <not-allowed/> stanza error, which in turn SHOULD include an application-specific error condition of <resource-limit-exceeded/>, as shown in the following example:
<iq type='error' id='bind_2'> <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'> <resource>someresource</resource> </bind> <error type='modify'> <not-allowed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> <resource-limit-exceeded xmlns='http://jabber.org/protocol/errors'/> </error> </iq>
A server implementation MUST enable a server administrator to limit the size of stanzas it will accept from a connected client or peer server. It is RECOMMENDED for a deployment to set the upper limit on stanza size to a number in the range of 20 kilobytes and 200 kilobytes.
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 <not-allowed/> stanza error, which in turn SHOULD include an application-specific error condition of <stanza-too-big/>, as shown in the following example:
<message from='shakespeare.lit' to='iago@shakespare.lit/evilos'> <error type='modify'> <not-allowed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> <stanza-too-big xmlns='http://jabber.org/protocol/errors'/> </error> </message>
Note: In the case of a stanza size limit, the server SHOULD NOT include the original stanza.
Alternatively (e.g., if the sender has sent an egregiously large stanza), the server MAY instead return a <policy-violation/> stream error:
<stream:error> <policy-violation xmlns='urn:ietf:params:xml:ns:xmpp-streams'/> <stanza-too-big xmlns='http://jabber.org/protocol/errors'/> </stream:error> </stream:stream>
A server implementation MUST 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.
Bandwidth limits in existing XMPP servers 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.
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:
Such limits and restrictions are a matter of deployment policy, and no recommendations are provided herein.
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.
Such restrictions are a matter of deployment policy, and no recommendations are provided herein (however, see XEP-0045 regarding methods of banning users from multi-user chat rooms and XEP-0060 regarding methods for prohibiting users from interacting with publish-subscribe nodes).
Implementations MAY enable administrators to configurate appropriate exceptions to some of the recommendations specified in this document. Examples include:
This entire document is about security.
This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [13].
The XMPP Registrar [14] shall add <resource-limit-exceeded/> to its registry of application-specific error conditions (see <http://www.xmpp.org/registrar/errors.html>), where the element is qualified by the 'http://jabber.org/protocol/errors' namespace.
The registry submission is as follows:
<condition> <ns>http://jabber.org/protocol/errors</ns> <element>resource-limit-exceeded</element> <desc>the account is not allowed to bind more resources at this time</desc> <doc>XEP-0205</doc> </condition>
Special thanks to Chris Mullins for calling attention to the need for a specification detailing best practices such as those recommended herein. Thanks also to Thiago Camargo, Bruce Campbell, Gustavo Felisberto, Justin Karneges, Pedro Melo, and Michael Vorner for their suggestions.
1. RFC 4732: Internet Denial-of-Service Considerations <http://tools.ietf.org/html/rfc4732>.
2. RFC 3920: Extensible Messaging and Presence Protocol (XMPP): Core <http://tools.ietf.org/html/rfc3920>.
3. Improving TCP's Robustness to Blind In-Window Attacks <http://www.ietf.org/internet-drafts/draft-ietf-ietf-tcpm-tcpsecure-06.txt>. Work in progress.
4. XEP-0045: Multi-User Chat <http://www.xmpp.org/extensions/xep-0045.html>.
5. XEP-0060: Publish-Subscribe <http://www.xmpp.org/extensions/xep-0060.html>.
6. XEP-0124: HTTP Binding <http://www.xmpp.org/extensions/xep-0124.html>.
7. 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.
8. 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.
9. XEP-0008: IQ-Based Avatars <http://www.xmpp.org/extensions/xep-0008.html>.
10. XEP-0047: In-Band Bytestreams <http://www.xmpp.org/extensions/xep-0047.html>.
11. XEP-0077: In-Band Registration <http://www.xmpp.org/extensions/xep-0077.html>.
12. XEP-0138: Stream Compression <http://www.xmpp.org/extensions/xep-0138.html>.
13. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.
14. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <http://www.xmpp.org/registrar/>.
Initial published version.
(psa)Incorporated feedback; specified recommendations regarding bandwidths, payload types, and service access.
(psa)First draft.
(psa)END