idnits 2.17.1 draft-ietf-xmpp-3920bis-18.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- == There are 1 instance of lines with non-RFC3849-compliant IPv6 addresses in the document. If these are example addresses, they should be changed. -- The draft header indicates that this document obsoletes RFC3920, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 8200 has weird spacing: '...equence xmlns...' == Line 8201 has weird spacing: '...s:group ref=...' == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). -- The document date (October 25, 2010) is 4926 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '3' on line 490 -- Looks like a reference, but probably isn't: '1' on line 962 -- Looks like a reference, but probably isn't: '23' on line 6324 -- Looks like a reference, but probably isn't: '32' on line 6331 ** Obsolete normative reference: RFC 2560 (ref. 'OCSP') (Obsoleted by RFC 6960) ** Obsolete normative reference: RFC 3447 (ref. 'PKIX-ALGO') (Obsoleted by RFC 8017) ** Obsolete normative reference: RFC 793 (ref. 'TCP') (Obsoleted by RFC 9293) ** Obsolete normative reference: RFC 5246 (ref. 'TLS') (Obsoleted by RFC 8446) == Outdated reference: A later version (-14) exists of draft-saintandre-tls-server-id-check-10 -- Possible downref: Non-RFC (?) normative reference: ref. 'UCS2' -- Possible downref: Non-RFC (?) normative reference: ref. 'UNICODE' -- Possible downref: Non-RFC (?) normative reference: ref. 'X509' -- Possible downref: Non-RFC (?) normative reference: ref. 'XML' ** Obsolete normative reference: RFC 3023 (ref. 'XML-MEDIA') (Obsoleted by RFC 7303) -- Possible downref: Non-RFC (?) normative reference: ref. 'XML-NAMES' == Outdated reference: A later version (-09) exists of draft-ietf-xmpp-address-06 -- Obsolete informational reference (is this intentional?): RFC 2831 (ref. 'DIGEST-MD5') (Obsoleted by RFC 6331) -- Obsolete informational reference (is this intentional?): RFC 2616 (ref. 'HTTP') (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) -- Obsolete informational reference (is this intentional?): RFC 5226 (ref. 'IANA-GUIDE') (Obsoleted by RFC 8126) == Outdated reference: A later version (-10) exists of draft-ietf-tsvwg-iana-ports-08 -- Obsolete informational reference (is this intentional?): RFC 3501 (ref. 'IMAP') (Obsoleted by RFC 9051) -- Obsolete informational reference (is this intentional?): RFC 3920 (Obsoleted by RFC 6120) -- Obsolete informational reference (is this intentional?): RFC 3921 (Obsoleted by RFC 6121) -- Obsolete informational reference (is this intentional?): RFC 4013 (ref. 'SASLPREP') (Obsoleted by RFC 7613) == Outdated reference: A later version (-20) exists of draft-ietf-xmpp-3921bis-16 Summary: 5 errors (**), 0 flaws (~~), 9 warnings (==), 19 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 XMPP P. Saint-Andre 3 Internet-Draft Cisco 4 Obsoletes: 3920 (if approved) October 25, 2010 5 Intended status: Standards Track 6 Expires: April 28, 2011 8 Extensible Messaging and Presence Protocol (XMPP): Core 9 draft-ietf-xmpp-3920bis-18 11 Abstract 13 The Extensible Messaging and Presence Protocol (XMPP) is an 14 application profile of the Extensible Markup Language (XML) that 15 enables the near-real-time exchange of structured yet extensible data 16 between any two or more network entities. This document defines 17 XMPP's core protocol methods: setup and teardown of XML streams, 18 channel encryption, authentication, error handling, and communication 19 primitives for messaging, network availability ("presence"), and 20 request-response interactions. 22 Status of this Memo 24 This Internet-Draft is submitted in full conformance with the 25 provisions of BCP 78 and BCP 79. 27 Internet-Drafts are working documents of the Internet Engineering 28 Task Force (IETF). Note that other groups may also distribute 29 working documents as Internet-Drafts. The list of current Internet- 30 Drafts is at http://datatracker.ietf.org/drafts/current/. 32 Internet-Drafts are draft documents valid for a maximum of six months 33 and may be updated, replaced, or obsoleted by other documents at any 34 time. It is inappropriate to use Internet-Drafts as reference 35 material or to cite them other than as "work in progress." 37 This Internet-Draft will expire on April 28, 2011. 39 Copyright Notice 41 Copyright (c) 2010 IETF Trust and the persons identified as the 42 document authors. All rights reserved. 44 This document is subject to BCP 78 and the IETF Trust's Legal 45 Provisions Relating to IETF Documents 46 (http://trustee.ietf.org/license-info) in effect on the date of 47 publication of this document. Please review these documents 48 carefully, as they describe your rights and restrictions with respect 49 to this document. Code Components extracted from this document must 50 include Simplified BSD License text as described in Section 4.e of 51 the Trust Legal Provisions and are provided without warranty as 52 described in the Simplified BSD License. 54 Table of Contents 56 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 9 57 1.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 9 58 1.2. History . . . . . . . . . . . . . . . . . . . . . . . . 9 59 1.3. Functional Summary . . . . . . . . . . . . . . . . . . . 9 60 1.4. Terminology . . . . . . . . . . . . . . . . . . . . . . 11 61 1.5. Acknowledgements . . . . . . . . . . . . . . . . . . . . 12 62 1.6. Discussion Venue . . . . . . . . . . . . . . . . . . . . 13 63 2. Architecture . . . . . . . . . . . . . . . . . . . . . . . . 13 64 2.1. Global Addresses . . . . . . . . . . . . . . . . . . . . 13 65 2.2. Presence . . . . . . . . . . . . . . . . . . . . . . . . 14 66 2.3. Persistent Streams . . . . . . . . . . . . . . . . . . . 14 67 2.4. Structured Data . . . . . . . . . . . . . . . . . . . . 14 68 2.5. Distributed Network of Clients and Servers . . . . . . . 14 69 3. TCP Binding . . . . . . . . . . . . . . . . . . . . . . . . . 16 70 3.1. Scope . . . . . . . . . . . . . . . . . . . . . . . . . 16 71 3.2. Hostname Resolution . . . . . . . . . . . . . . . . . . 16 72 3.2.1. Preferred Process: SRV Lookup . . . . . . . . . . . 17 73 3.2.2. Fallback Processes . . . . . . . . . . . . . . . . . 18 74 3.2.3. When Not to Use SRV . . . . . . . . . . . . . . . . 18 75 3.2.4. Use of SRV Records with Add-On Services . . . . . . 18 76 3.3. Reconnection . . . . . . . . . . . . . . . . . . . . . . 19 77 3.4. Reliability . . . . . . . . . . . . . . . . . . . . . . 19 78 4. XML Streams . . . . . . . . . . . . . . . . . . . . . . . . . 19 79 4.1. Stream Fundamentals . . . . . . . . . . . . . . . . . . 19 80 4.2. Stream Negotiation . . . . . . . . . . . . . . . . . . . 22 81 4.2.1. Basic Concepts . . . . . . . . . . . . . . . . . . . 22 82 4.2.2. Stream Features Format . . . . . . . . . . . . . . . 23 83 4.2.3. Restarts . . . . . . . . . . . . . . . . . . . . . . 25 84 4.2.4. Resending Features . . . . . . . . . . . . . . . . . 25 85 4.2.5. Completion of Stream Negotiation . . . . . . . . . . 25 86 4.2.6. Determination of Addresses . . . . . . . . . . . . . 26 87 4.2.7. Flow Chart . . . . . . . . . . . . . . . . . . . . . 27 88 4.3. Directionality . . . . . . . . . . . . . . . . . . . . . 29 89 4.4. Closing a Stream . . . . . . . . . . . . . . . . . . . . 30 90 4.5. Handling of Silent Peers . . . . . . . . . . . . . . . . 31 91 4.5.1. Dead Connection . . . . . . . . . . . . . . . . . . 31 92 4.5.2. Broken Stream . . . . . . . . . . . . . . . . . . . 32 93 4.5.3. Idle Peer . . . . . . . . . . . . . . . . . . . . . 32 94 4.5.4. Use of Checking Methods . . . . . . . . . . . . . . 32 95 4.6. Stream Attributes . . . . . . . . . . . . . . . . . . . 33 96 4.6.1. from . . . . . . . . . . . . . . . . . . . . . . . . 33 97 4.6.2. to . . . . . . . . . . . . . . . . . . . . . . . . . 34 98 4.6.3. id . . . . . . . . . . . . . . . . . . . . . . . . . 36 99 4.6.4. xml:lang . . . . . . . . . . . . . . . . . . . . . . 36 100 4.6.5. version . . . . . . . . . . . . . . . . . . . . . . 38 101 4.6.6. Summary of Stream Attributes . . . . . . . . . . . . 39 102 4.7. Namespaces . . . . . . . . . . . . . . . . . . . . . . . 40 103 4.7.1. Streams Namespace . . . . . . . . . . . . . . . . . 40 104 4.7.2. Content Namespace . . . . . . . . . . . . . . . . . 40 105 4.7.3. Other Namespaces . . . . . . . . . . . . . . . . . . 41 106 4.7.4. Namespace Declarations and Prefixes . . . . . . . . 42 107 4.7.5. Mandatory-to-Implement Content Namespaces . . . . . 42 108 4.8. Stream Errors . . . . . . . . . . . . . . . . . . . . . 43 109 4.8.1. Rules . . . . . . . . . . . . . . . . . . . . . . . 44 110 4.8.1.1. Stream Errors Are Unrecoverable . . . . . . . . . 44 111 4.8.1.2. Stream Errors Can Occur During Setup . . . . . . 44 112 4.8.1.3. Stream Errors When the Host is Unspecified or 113 Unknown . . . . . . . . . . . . . . . . . . . . . 45 114 4.8.1.4. Where Stream Errors Are Sent . . . . . . . . . . 46 115 4.8.2. Syntax . . . . . . . . . . . . . . . . . . . . . . . 46 116 4.8.3. Defined Stream Error Conditions . . . . . . . . . . 47 117 4.8.3.1. bad-format . . . . . . . . . . . . . . . . . . . 47 118 4.8.3.2. bad-namespace-prefix . . . . . . . . . . . . . . 48 119 4.8.3.3. conflict . . . . . . . . . . . . . . . . . . . . 49 120 4.8.3.4. connection-timeout . . . . . . . . . . . . . . . 49 121 4.8.3.5. host-gone . . . . . . . . . . . . . . . . . . . . 50 122 4.8.3.6. host-unknown . . . . . . . . . . . . . . . . . . 51 123 4.8.3.7. improper-addressing . . . . . . . . . . . . . . . 51 124 4.8.3.8. internal-server-error . . . . . . . . . . . . . . 52 125 4.8.3.9. invalid-from . . . . . . . . . . . . . . . . . . 52 126 4.8.3.10. invalid-namespace . . . . . . . . . . . . . . . . 52 127 4.8.3.11. invalid-xml . . . . . . . . . . . . . . . . . . . 53 128 4.8.3.12. not-authorized . . . . . . . . . . . . . . . . . 54 129 4.8.3.13. not-well-formed . . . . . . . . . . . . . . . . . 54 130 4.8.3.14. policy-violation . . . . . . . . . . . . . . . . 55 131 4.8.3.15. remote-connection-failed . . . . . . . . . . . . 55 132 4.8.3.16. reset . . . . . . . . . . . . . . . . . . . . . . 56 133 4.8.3.17. resource-constraint . . . . . . . . . . . . . . . 56 134 4.8.3.18. restricted-xml . . . . . . . . . . . . . . . . . 57 135 4.8.3.19. see-other-host . . . . . . . . . . . . . . . . . 57 136 4.8.3.20. system-shutdown . . . . . . . . . . . . . . . . . 58 137 4.8.3.21. undefined-condition . . . . . . . . . . . . . . . 59 138 4.8.3.22. unsupported-encoding . . . . . . . . . . . . . . 59 139 4.8.3.23. unsupported-feature . . . . . . . . . . . . . . . 60 140 4.8.3.24. unsupported-stanza-type . . . . . . . . . . . . . 60 141 4.8.3.25. unsupported-version . . . . . . . . . . . . . . . 61 142 4.8.4. Application-Specific Conditions . . . . . . . . . . 62 143 4.9. Simplified Stream Examples . . . . . . . . . . . . . . . 63 145 5. STARTTLS Negotiation . . . . . . . . . . . . . . . . . . . . 65 146 5.1. Fundamentals . . . . . . . . . . . . . . . . . . . . . . 66 147 5.2. Support . . . . . . . . . . . . . . . . . . . . . . . . 66 148 5.3. Stream Negotiation Rules . . . . . . . . . . . . . . . . 66 149 5.3.1. Mandatory-to-Negotiate . . . . . . . . . . . . . . . 66 150 5.3.2. Restart . . . . . . . . . . . . . . . . . . . . . . 66 151 5.3.3. Data Formatting . . . . . . . . . . . . . . . . . . 66 152 5.3.4. Order of TLS and SASL Negotiations . . . . . . . . . 67 153 5.3.5. TLS Renegotiation . . . . . . . . . . . . . . . . . 67 154 5.3.6. TLS Extensions . . . . . . . . . . . . . . . . . . . 68 155 5.4. Process . . . . . . . . . . . . . . . . . . . . . . . . 68 156 5.4.1. Exchange of Stream Headers and Stream Features . . . 68 157 5.4.2. Initiation of STARTTLS Negotiation . . . . . . . . . 69 158 5.4.2.1. STARTTLS Command . . . . . . . . . . . . . . . . 69 159 5.4.2.2. Failure Case . . . . . . . . . . . . . . . . . . 69 160 5.4.2.3. Proceed Case . . . . . . . . . . . . . . . . . . 70 161 5.4.3. TLS Negotiation . . . . . . . . . . . . . . . . . . 70 162 5.4.3.1. Rules . . . . . . . . . . . . . . . . . . . . . . 70 163 5.4.3.2. TLS Failure . . . . . . . . . . . . . . . . . . . 71 164 5.4.3.3. TLS Success . . . . . . . . . . . . . . . . . . . 71 165 6. SASL Negotiation . . . . . . . . . . . . . . . . . . . . . . 73 166 6.1. Fundamentals . . . . . . . . . . . . . . . . . . . . . . 73 167 6.2. Support . . . . . . . . . . . . . . . . . . . . . . . . 73 168 6.3. Stream Negotiation Rules . . . . . . . . . . . . . . . . 73 169 6.3.1. Mandatory-to-Negotiate . . . . . . . . . . . . . . . 73 170 6.3.2. Restart . . . . . . . . . . . . . . . . . . . . . . 73 171 6.3.3. Mechanism Preferences . . . . . . . . . . . . . . . 73 172 6.3.4. Mechanism Offers . . . . . . . . . . . . . . . . . . 74 173 6.3.5. Data Formatting . . . . . . . . . . . . . . . . . . 75 174 6.3.6. Security Layers . . . . . . . . . . . . . . . . . . 75 175 6.3.7. Simple User Name . . . . . . . . . . . . . . . . . . 75 176 6.3.8. Authorization Identity . . . . . . . . . . . . . . . 76 177 6.3.9. Realms . . . . . . . . . . . . . . . . . . . . . . . 76 178 6.3.10. Round Trips . . . . . . . . . . . . . . . . . . . . 76 179 6.4. Process . . . . . . . . . . . . . . . . . . . . . . . . 77 180 6.4.1. Exchange of Stream Headers and Stream Features . . . 77 181 6.4.2. Initiation . . . . . . . . . . . . . . . . . . . . . 78 182 6.4.3. Challenge-Response Sequence . . . . . . . . . . . . 79 183 6.4.4. Abort . . . . . . . . . . . . . . . . . . . . . . . 79 184 6.4.5. SASL Failure . . . . . . . . . . . . . . . . . . . . 80 185 6.4.6. SASL Success . . . . . . . . . . . . . . . . . . . . 81 186 6.5. SASL Errors . . . . . . . . . . . . . . . . . . . . . . 82 187 6.5.1. aborted . . . . . . . . . . . . . . . . . . . . . . 82 188 6.5.2. account-disabled . . . . . . . . . . . . . . . . . . 82 189 6.5.3. credentials-expired . . . . . . . . . . . . . . . . 83 190 6.5.4. encryption-required . . . . . . . . . . . . . . . . 83 191 6.5.5. incorrect-encoding . . . . . . . . . . . . . . . . . 83 192 6.5.6. invalid-authzid . . . . . . . . . . . . . . . . . . 84 193 6.5.7. invalid-mechanism . . . . . . . . . . . . . . . . . 84 194 6.5.8. malformed-request . . . . . . . . . . . . . . . . . 84 195 6.5.9. mechanism-too-weak . . . . . . . . . . . . . . . . . 85 196 6.5.10. not-authorized . . . . . . . . . . . . . . . . . . . 85 197 6.5.11. temporary-auth-failure . . . . . . . . . . . . . . . 85 198 6.5.12. transition-needed . . . . . . . . . . . . . . . . . 86 199 6.6. SASL Definition . . . . . . . . . . . . . . . . . . . . 86 200 7. Resource Binding . . . . . . . . . . . . . . . . . . . . . . 87 201 7.1. Fundamentals . . . . . . . . . . . . . . . . . . . . . . 87 202 7.2. Support . . . . . . . . . . . . . . . . . . . . . . . . 88 203 7.3. Stream Negotiation Rules . . . . . . . . . . . . . . . . 88 204 7.3.1. Mandatory-to-Negotiate . . . . . . . . . . . . . . . 88 205 7.3.2. Restart . . . . . . . . . . . . . . . . . . . . . . 88 206 7.4. Advertising Support . . . . . . . . . . . . . . . . . . 88 207 7.5. Generation of Resource Identifiers . . . . . . . . . . . 89 208 7.6. Server-Generated Resource Identifier . . . . . . . . . . 89 209 7.6.1. Success Case . . . . . . . . . . . . . . . . . . . . 89 210 7.6.2. Error Cases . . . . . . . . . . . . . . . . . . . . 90 211 7.6.2.1. Resource Constraint . . . . . . . . . . . . . . . 90 212 7.6.2.2. Not Allowed . . . . . . . . . . . . . . . . . . . 90 213 7.7. Client-Submitted Resource Identifier . . . . . . . . . . 90 214 7.7.1. Success Case . . . . . . . . . . . . . . . . . . . . 90 215 7.7.2. Error Cases . . . . . . . . . . . . . . . . . . . . 91 216 7.7.2.1. Bad Request . . . . . . . . . . . . . . . . . . . 91 217 7.7.2.2. Conflict . . . . . . . . . . . . . . . . . . . . 92 218 7.7.3. Retries . . . . . . . . . . . . . . . . . . . . . . 93 219 8. XML Stanzas . . . . . . . . . . . . . . . . . . . . . . . . . 94 220 8.1. Common Attributes . . . . . . . . . . . . . . . . . . . 94 221 8.1.1. to . . . . . . . . . . . . . . . . . . . . . . . . . 94 222 8.1.1.1. Client-to-Server Streams . . . . . . . . . . . . 94 223 8.1.1.2. Server-to-Server Streams . . . . . . . . . . . . 95 224 8.1.2. from . . . . . . . . . . . . . . . . . . . . . . . . 96 225 8.1.2.1. Client-to-Server Streams . . . . . . . . . . . . 96 226 8.1.2.2. Server-to-Server Streams . . . . . . . . . . . . 97 227 8.1.3. id . . . . . . . . . . . . . . . . . . . . . . . . . 97 228 8.1.4. type . . . . . . . . . . . . . . . . . . . . . . . . 97 229 8.1.5. xml:lang . . . . . . . . . . . . . . . . . . . . . . 98 230 8.2. Basic Semantics . . . . . . . . . . . . . . . . . . . . 99 231 8.2.1. Message Semantics . . . . . . . . . . . . . . . . . 99 232 8.2.2. Presence Semantics . . . . . . . . . . . . . . . . . 99 233 8.2.3. IQ Semantics . . . . . . . . . . . . . . . . . . . . 99 234 8.3. Stanza Errors . . . . . . . . . . . . . . . . . . . . . 101 235 8.3.1. Rules . . . . . . . . . . . . . . . . . . . . . . . 102 236 8.3.2. Syntax . . . . . . . . . . . . . . . . . . . . . . . 102 237 8.3.3. Defined Conditions . . . . . . . . . . . . . . . . . 104 238 8.3.3.1. bad-request . . . . . . . . . . . . . . . . . . . 104 239 8.3.3.2. conflict . . . . . . . . . . . . . . . . . . . . 104 240 8.3.3.3. feature-not-implemented . . . . . . . . . . . . . 105 241 8.3.3.4. forbidden . . . . . . . . . . . . . . . . . . . . 105 242 8.3.3.5. gone . . . . . . . . . . . . . . . . . . . . . . 106 243 8.3.3.6. internal-server-error . . . . . . . . . . . . . . 107 244 8.3.3.7. item-not-found . . . . . . . . . . . . . . . . . 107 245 8.3.3.8. jid-malformed . . . . . . . . . . . . . . . . . . 108 246 8.3.3.9. not-acceptable . . . . . . . . . . . . . . . . . 108 247 8.3.3.10. not-allowed . . . . . . . . . . . . . . . . . . . 109 248 8.3.3.11. not-authorized . . . . . . . . . . . . . . . . . 109 249 8.3.3.12. payment-required . . . . . . . . . . . . . . . . 110 250 8.3.3.13. policy-violation . . . . . . . . . . . . . . . . 110 251 8.3.3.14. recipient-unavailable . . . . . . . . . . . . . . 111 252 8.3.3.15. redirect . . . . . . . . . . . . . . . . . . . . 112 253 8.3.3.16. registration-required . . . . . . . . . . . . . . 112 254 8.3.3.17. remote-server-not-found . . . . . . . . . . . . . 113 255 8.3.3.18. remote-server-timeout . . . . . . . . . . . . . . 114 256 8.3.3.19. resource-constraint . . . . . . . . . . . . . . . 114 257 8.3.3.20. service-unavailable . . . . . . . . . . . . . . . 115 258 8.3.3.21. subscription-required . . . . . . . . . . . . . . 115 259 8.3.3.22. undefined-condition . . . . . . . . . . . . . . . 116 260 8.3.3.23. unexpected-request . . . . . . . . . . . . . . . 117 261 8.3.4. Application-Specific Conditions . . . . . . . . . . 118 262 8.4. Extended Content . . . . . . . . . . . . . . . . . . . . 119 263 9. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 122 264 9.1. Client-to-Server Examples . . . . . . . . . . . . . . . 122 265 9.1.1. TLS . . . . . . . . . . . . . . . . . . . . . . . . 122 266 9.1.2. SASL . . . . . . . . . . . . . . . . . . . . . . . . 124 267 9.1.3. Resource Binding . . . . . . . . . . . . . . . . . . 126 268 9.1.4. Stanza Exchange . . . . . . . . . . . . . . . . . . 127 269 9.1.5. Close . . . . . . . . . . . . . . . . . . . . . . . 127 270 9.2. Server-to-Server Examples . . . . . . . . . . . . . . . 128 271 9.2.1. TLS . . . . . . . . . . . . . . . . . . . . . . . . 128 272 9.2.2. SASL . . . . . . . . . . . . . . . . . . . . . . . . 129 273 9.2.3. Stanza Exchange . . . . . . . . . . . . . . . . . . 130 274 9.2.4. Close . . . . . . . . . . . . . . . . . . . . . . . 131 275 10. Server Rules for Processing XML Stanzas . . . . . . . . . . . 131 276 10.1. In-Order Processing . . . . . . . . . . . . . . . . . . 131 277 10.2. General Considerations . . . . . . . . . . . . . . . . . 133 278 10.3. No 'to' Address . . . . . . . . . . . . . . . . . . . . 134 279 10.3.1. Message . . . . . . . . . . . . . . . . . . . . . . 134 280 10.3.2. Presence . . . . . . . . . . . . . . . . . . . . . . 134 281 10.3.3. IQ . . . . . . . . . . . . . . . . . . . . . . . . . 134 282 10.4. Remote Domain . . . . . . . . . . . . . . . . . . . . . 135 283 10.4.1. Existing Stream . . . . . . . . . . . . . . . . . . 135 284 10.4.2. No Existing Stream . . . . . . . . . . . . . . . . . 135 285 10.4.3. Error Handling . . . . . . . . . . . . . . . . . . . 136 286 10.5. Local Domain . . . . . . . . . . . . . . . . . . . . . . 136 287 10.5.1. Mere Domain . . . . . . . . . . . . . . . . . . . . 136 288 10.5.2. Domain with Resource . . . . . . . . . . . . . . . . 136 289 10.5.3. Localpart at Domain . . . . . . . . . . . . . . . . 136 290 10.5.3.1. No Such User . . . . . . . . . . . . . . . . . . 137 291 10.5.3.2. Bare JID . . . . . . . . . . . . . . . . . . . . 137 292 10.5.3.3. Full JID . . . . . . . . . . . . . . . . . . . . 137 293 11. XML Usage . . . . . . . . . . . . . . . . . . . . . . . . . . 138 294 11.1. Restrictions . . . . . . . . . . . . . . . . . . . . . . 138 295 11.2. XML Namespace Names and Prefixes . . . . . . . . . . . . 138 296 11.3. Well-Formedness . . . . . . . . . . . . . . . . . . . . 139 297 11.4. Validation . . . . . . . . . . . . . . . . . . . . . . . 139 298 11.5. Inclusion of XML Declaration . . . . . . . . . . . . . . 140 299 11.6. Character Encoding . . . . . . . . . . . . . . . . . . . 140 300 11.7. Whitespace . . . . . . . . . . . . . . . . . . . . . . . 140 301 11.8. XML Versions . . . . . . . . . . . . . . . . . . . . . . 141 302 12. Internationalization Considerations . . . . . . . . . . . . . 141 303 13. Security Considerations . . . . . . . . . . . . . . . . . . . 141 304 13.1. Fundamentals . . . . . . . . . . . . . . . . . . . . . . 141 305 13.2. Threat Model . . . . . . . . . . . . . . . . . . . . . . 142 306 13.3. Order of Layers . . . . . . . . . . . . . . . . . . . . 143 307 13.4. Confidentiality and Integrity . . . . . . . . . . . . . 143 308 13.5. Peer Entity Authentication . . . . . . . . . . . . . . . 144 309 13.6. Strong Security . . . . . . . . . . . . . . . . . . . . 144 310 13.7. Certificates . . . . . . . . . . . . . . . . . . . . . . 144 311 13.7.1. Certificate Generation . . . . . . . . . . . . . . . 145 312 13.7.1.1. General Considerations . . . . . . . . . . . . . 145 313 13.7.1.2. Server Certificates . . . . . . . . . . . . . . . 146 314 13.7.1.3. Client Certificates . . . . . . . . . . . . . . . 148 315 13.7.1.4. XmppAddr Identifier Type . . . . . . . . . . . . 148 316 13.7.2. Certificate Validation . . . . . . . . . . . . . . . 149 317 13.7.2.1. Server Certificates . . . . . . . . . . . . . . . 149 318 13.7.2.2. Client Certificates . . . . . . . . . . . . . . . 149 319 13.7.2.3. Checking of Certificates in Long-Lived Streams . 150 320 13.7.2.4. Use of Certificates in XMPP Extensions . . . . . 151 321 13.8. Mandatory-to-Implement Technologies . . . . . . . . . . 151 322 13.9. Technology Reuse . . . . . . . . . . . . . . . . . . . . 152 323 13.9.1. Use of base64 in SASL . . . . . . . . . . . . . . . 152 324 13.9.2. Use of DNS . . . . . . . . . . . . . . . . . . . . . 153 325 13.9.3. Use of Hash Functions . . . . . . . . . . . . . . . 153 326 13.9.4. Use of SASL . . . . . . . . . . . . . . . . . . . . 153 327 13.9.5. Use of TLS . . . . . . . . . . . . . . . . . . . . . 154 328 13.9.6. Use of UTF-8 . . . . . . . . . . . . . . . . . . . . 155 329 13.9.7. Use of XML . . . . . . . . . . . . . . . . . . . . . 155 330 13.10. Information Leaks . . . . . . . . . . . . . . . . . . . 155 331 13.10.1. IP Addresses . . . . . . . . . . . . . . . . . . . . 155 332 13.10.2. Presence Information . . . . . . . . . . . . . . . . 155 333 13.11. Directory Harvesting . . . . . . . . . . . . . . . . . . 156 334 13.12. Denial of Service . . . . . . . . . . . . . . . . . . . 156 335 13.13. Firewalls . . . . . . . . . . . . . . . . . . . . . . . 158 336 13.14. Interdomain Federation . . . . . . . . . . . . . . . . . 158 337 13.15. Non-Repudiation . . . . . . . . . . . . . . . . . . . . 158 338 14. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 159 339 14.1. XML Namespace Name for TLS Data . . . . . . . . . . . . 159 340 14.2. XML Namespace Name for SASL Data . . . . . . . . . . . . 159 341 14.3. XML Namespace Name for Stream Errors . . . . . . . . . . 159 342 14.4. XML Namespace Name for Resource Binding . . . . . . . . 160 343 14.5. XML Namespace Name for Stanza Errors . . . . . . . . . . 160 344 14.6. GSSAPI Service Name . . . . . . . . . . . . . . . . . . 160 345 14.7. Port Numbers and Service Names . . . . . . . . . . . . . 160 346 15. Conformance Requirements . . . . . . . . . . . . . . . . . . 161 347 16. References . . . . . . . . . . . . . . . . . . . . . . . . . 170 348 16.1. Normative References . . . . . . . . . . . . . . . . . . 170 349 16.2. Informative References . . . . . . . . . . . . . . . . . 173 350 Appendix A. XML Schemas . . . . . . . . . . . . . . . . . . . . 178 351 A.1. Streams Namespace . . . . . . . . . . . . . . . . . . . 178 352 A.2. Stream Error Namespace . . . . . . . . . . . . . . . . . 180 353 A.3. STARTTLS Namespace . . . . . . . . . . . . . . . . . . . 182 354 A.4. SASL Namespace . . . . . . . . . . . . . . . . . . . . . 183 355 A.5. Resource Binding Namespace . . . . . . . . . . . . . . . 185 356 A.6. Stanza Error Namespace . . . . . . . . . . . . . . . . . 185 357 Appendix B. Contact Addresses . . . . . . . . . . . . . . . . . 187 358 Appendix C. Account Provisioning . . . . . . . . . . . . . . . . 187 359 Appendix D. Differences from RFC 3920 . . . . . . . . . . . . . 187 360 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 189 362 1. Introduction 364 1.1. Overview 366 The Extensible Messaging and Presence Protocol (XMPP) is an 367 application profile of the Extensible Markup Language [XML] that 368 enables the near-real-time exchange of structured yet extensible data 369 between any two or more network entities. This document defines 370 XMPP's core protocol methods: setup and teardown of XML streams, 371 channel encryption, authentication, error handling, and communication 372 primitives for messaging, network availability ("presence"), and 373 request-response interactions. 375 1.2. History 377 The basic syntax and semantics of XMPP were developed originally 378 within the Jabber open-source community, mainly in 1999. In late 379 2002, the XMPP Working Group was chartered with developing an 380 adaptation of the core Jabber protocol that would be suitable as an 381 IETF instant messaging (IM) and presence technology in accordance 382 with [IMP-REQS]. In October 2004, [RFC3920] and [RFC3921] were 383 published, representing the most complete definition of XMPP at that 384 time. 386 Since 2004 the Internet community has gained extensive implementation 387 and deployment experience with XMPP, including formal 388 interoperability testing carried out under the auspices of the XMPP 389 Standards Foundation (XSF). This document incorporates comprehensive 390 feedback from software developers and service providers, including a 391 number of backward-compatible modifications summarized under 392 Appendix D. As a result, this document reflects the rough consensus 393 of the Internet community regarding the core features of XMPP 1.0, 394 thus obsoleting RFC 3920. 396 1.3. Functional Summary 398 This non-normative section provides a developer-friendly, functional 399 summary of XMPP; refer to the sections that follow for a normative 400 definition of XMPP. 402 The purpose of XMPP is to enable the exchange of relatively small 403 pieces of structured data (called "XML stanzas") over a network 404 between any two (or more) entities. XMPP is typically implemented 405 using a distributed client-server architecture, wherein a client 406 needs to connect to a server in order to gain access to the network 407 and thus be allowed to exchange XML stanzas with other entities 408 (which can be associated with other servers). The process whereby a 409 client connects to a server, exchanges XML stanzas, and ends the 410 connection is: 412 1. Determine the hostname and port at which to connect 413 2. Open a Transmission Control Protocol [TCP] connection 414 3. Open an XML stream over TCP 415 4. Negotiate Transport Layer Security [TLS] for channel encryption 416 (recommended) 417 5. Authenticate using a Simple Authentication and Security Layer 418 [SASL] mechanism 419 6. Bind a resource to the stream 420 7. Exchange an unbounded number of XML stanzas with other entities 421 on the network 422 8. Close the XML stream 423 9. Close the TCP connection 425 Within XMPP, one server can optionally connect to another server to 426 enable inter-domain or inter-server communication. For this to 427 happen, the two servers need to negotiate a connection between 428 themselves and then exchange XML stanzas; the process for doing so 429 is: 431 1. Determine the hostname and port at which to connect 432 2. Open a TCP connection 433 3. Open an XML stream 434 4. Negotiate TLS for channel encryption (recommended) 435 5. Authenticate using a Simple Authentication and Security Layer 436 [SASL] mechanism * 437 6. Exchange an unbounded number of XML stanzas both directly for the 438 servers and indirectly on behalf of entities associated with each 439 server (e.g., connected clients) 440 7. Close the XML stream 441 8. Close the TCP connection 443 * Implementation Note: At the time of writing, most deployed 444 servers use the Server Dialback protocol [XEP-0220] to provide 445 weak identity verification instead of using SASL to provide strong 446 authentication, especially in cases where SASL negotiation would 447 not result in strong authentication anyway (e.g., because TLS 448 negotiation was not mandated by the peer server, or because the 449 PKIX certificate presented by the peer server during TLS 450 negotiation is self-signed and has not been previously accepted); 451 for details, see [XEP-0220]. 453 This document specifies how clients connect to servers and specifies 454 the basic semantics of XML stanzas. However, this document does not 455 define the "payloads" of the XML stanzas that might be exchanged once 456 a connection is successfully established; instead, those payloads are 457 defined by various XMPP extensions. For example, [XMPP-IM] defines 458 extensions for basic instant messaging and presence functionality. 459 In addition, various specifications produced in the XSF's XEP series 460 [XEP-0001] define extensions for a wide range of applications. 462 1.4. Terminology 464 The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 465 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 466 "OPTIONAL" in this document are to be interpreted as described in 467 [KEYWORDS]. 469 Certain security-related terms are to be understood in the sense 470 defined in [SEC-TERMS]; such terms include, but are not limited to, 471 "assurance", "attack", "authentication", "authorization", 472 "certificate", "certification authority", "certification path", 473 "confidentiality", "credential", "downgrade", "encryption", 474 "fingerprint", "hash value", "identity", "integrity", "signature", 475 "security perimeter", "self-signed certificate", "sign", "spoof", 476 "tamper", "trust", "trust anchor", "trust chain", "validate", 477 "verify". 479 Certain terms related to certificates, domains, and application 480 service identity are to be understood in the sense defined in 481 [TLS-CERTS]; these include, but are not limited to, "PKIX 482 certificate", "source domain", "derived domain", and the identifier 483 types "CN-ID", "DNS-ID", and "SRV-ID". 485 Other security-related terms are to be understood in the sense 486 defined in the referenced specifications (for example, "denial of 487 service" as described in [DOS]). 489 The term "whitespace" is used to refer to any character that matches 490 production [3] content of [XML], i.e., any instance of SP, HT, CR, or 491 LF. 493 We define the following terms with regard to XML stanzas or parts 494 thereof: 496 deliver: for a server, to pass the data to a connected client 498 ignore: for a client or server, to discard the data without 499 acting upon it, presenting it a human user, or returning an 500 error to the sender 502 route: for a server, to pass the data to a remote server for 503 subsequent delivery 505 In examples, lines have been wrapped for improved readability, 506 "[...]" means elision, and the following prepended strings are used 507 (these prepended strings are not to be sent over the wire): 509 o C: = a client 510 o E: = any XMPP entity 511 o I: = an initiating entity 512 o P: = a peer server 513 o R: = a receiving entity 514 o S: = a server 515 o S1: = server1 516 o S2: = server2 518 Readers need to be aware that the examples are not exhaustive and 519 that, in examples for some protocol flows, the alternate steps shown 520 would not necessarily be triggered by the exact data sent in the 521 previous step; in all cases the protocol definitions specified in 522 this document or in normatively referenced documents rule over any 523 examples provided here. 525 Following the "XML Notation" used in [IRI] to represent characters 526 that cannot be rendered in ASCII-only documents, some examples in 527 this document use the form "&#x...." as a notational device to 528 represent [UNICODE] characters (e.g., the string "ř" stands 529 for the Unicode character LATIN SMALL LETTER R WITH CARON); this form 530 is definitely not to be sent over the wire in XMPP systems. 532 In adherence to the convention used in [URI] to represent Uniform 533 Resource Indentifiers, XMPP addresses in running text are enclosed 534 between '<' and '>' (despite the fact that natively they are not 535 URIs). 537 1.5. Acknowledgements 539 This document is an update to, and derived from, RFC 3920. This 540 document would have been impossible without the work of the 541 contributors and commenters acknowledged there. 543 Hundreds of people have provided implementation feedback, bug 544 reports, requests for clarification, and suggestions for improvement 545 since publication of RFC 3920. Although the document editor has 546 endeavored to address all such feedback, he is solely responsible for 547 any remaining errors and ambiguities. 549 Special thanks are due to Kevin Smith, Matthew Wild, Dave Cridland, 550 Philipp Hancke, Waqas Hussain, Florian Zeitz, Ben Campbell, Jehan 551 Pages, Paul Aurich, Justin Karneges, Kurt Zeilenga, Simon Josefsson, 552 Ralph Meijer, Curtis King, and others for their comments during 553 Working Group Last Call. 555 The Working Group chairs were Ben Campbell and Joe Hildebrand. 557 The responsible Area Director was Gonzalo Camarillo. 559 1.6. Discussion Venue 561 The document editor and the broader XMPP developer community welcome 562 discussion and comments related to the topics presented in this 563 document. The primary and preferred venue is the 564 mailing list, for which archives and subscription information are 565 available at . Related 566 discussions often occur on the mailing list, for 567 which archives and subscription information are available at 568 . 570 2. Architecture 572 XMPP provides a technology for the asynchronous, end-to-end exchange 573 of structured data by means of direct, persistent XML streams among a 574 distributed network of globally-addressable, presence-aware clients 575 and servers. Because this architectural style involves ubiquitous 576 knowledge of network availability and a conceptually unlimited number 577 of concurrent information transactions in the context of a given 578 client-to-server or server-to-server session, we label it 579 "Availability for Concurrent Transactions" (ACT) to distinguish it 580 from the "Representational State Transfer" [REST] architectural style 581 familiar from the World Wide Web. Although the architecture of XMPP 582 is similar in important ways to that of email (see [EMAIL-ARCH]), it 583 introduces several modifications to facilitate communication in close 584 to real time. The salient features of this ACTive architectural 585 style are as follows. 587 2.1. Global Addresses 589 As with email, XMPP uses globally-unique addresses (based on the 590 Domain Name System) in order to route and deliver messages over the 591 network. All XMPP entities are addressable on the network, most 592 particularly clients and servers but also various additional services 593 that can be accessed by clients and servers. In general, server 594 addresses are of the form (e.g., ), 595 accounts hosted at a server are of the form 596 (e.g., ), and a particular connected device or 597 resource that is currently authorized for interaction on behalf of an 598 account is of the form (e.g., 599 ). For historical reasons, XMPP 600 addresses are often called Jabber IDs or JIDs. Because the formal 601 specification of the XMPP address format depends on 602 internationalization technologies that are in flux at the time of 603 writing, the format is defined in [XMPP-ADDR] instead of this 604 document. 606 2.2. Presence 608 XMPP includes the ability for an entity to advertise its network 609 availability or "presence" to other entities. Such availability for 610 communication is signalled end-to-end via dedicated communication 611 primitives in XMPP (the stanza). Although knowledge of 612 network availability is not strictly necessary for the exchange of 613 XMPP messages, it facilitates real-time interaction because the 614 originator of a message can know before initiating communication that 615 the intended recipient is online and available. End-to-end presence 616 is defined in [XMPP-IM]. 618 2.3. Persistent Streams 620 Availability for communication is also built into a point-to-point 621 "hop" through the use of persistent XML streams over long-lived TCP 622 connections. These "always-on" client-to-server or server-to-server 623 streams enable each party to push data to the other party at any time 624 for immediate routing or delivery. XML streams are defined under 625 Section 4. 627 2.4. Structured Data 629 The basic protocol data unit in XMPP is not an XML stream (which 630 simply provides the transport for point-to-point communication) but 631 an XML "stanza", which is essentially a fragment of XML that is sent 632 over a stream. The root element of a stanza includes routing 633 attributes (such as "from" and "to" addresses) and the child elements 634 of the stanza contain a payload for delivery to the intended 635 recipient. XML stanzas are defined under Section 8. 637 2.5. Distributed Network of Clients and Servers 639 In practice, XMPP consists of a network of clients and servers that 640 inter-communicate (however, communication between any two given 641 deployed servers is strictly OPTIONAL). Thus, for example, the user 642 associated with the server 643 might be able to exchange messages, presence, and other structured 644 data with the user associated with the server 645 . This pattern is familiar from messaging protocols 646 that make use of global addresses, such as the email network (see 647 [SMTP] and [EMAIL-ARCH]). As a result, end-to-end communication in 648 XMPP is logically peer-to-peer but physically client-to-server-to- 649 server-to-client, as illustrated in the following diagram. 651 example.net ---------------- im.example.com 652 | | 653 | | 654 romeo@example.net juliet@im.example.com 656 Figure 1: Distributed Client-Server Architecture 658 Informational Note: Architectures that employ XML streams 659 (Section 4) and XML stanzas (Section 8) but that establish peer- 660 to-peer connections directly between clients using technologies 661 based on [LINKLOCAL] have been deployed, but such architectures 662 are not defined in this specification and are best described as 663 "XMPP-like"; for details, see [XEP-0174]. In addition, XML 664 streams can be established end-to-end over any reliable transport, 665 including extensions to XMPP itself; however, such methods are out 666 of scope for this specification. 668 The following paragraphs describe the responsibilities of clients and 669 servers on the network. 671 A client is an entity that establishes an XML stream with a server by 672 authenticating using the credentials of a local account and that then 673 completes resource binding (Section 7) in order to enable delivery of 674 XML stanzas between the server and the client over the negotiated 675 stream. The client then uses XMPP to communicate with its server, 676 other clients, and any other entities on the network, where the 677 server is responsible for delivering stanzas to local entities or 678 routing them to remote entities. Multiple clients can connect 679 simultaneously to a server on behalf of the same local account, where 680 each client is differentiated by the resourcepart of an XMPP address 681 (e.g., vs. 682 ), as defined under [XMPP-ADDR] and 683 Section 7. 685 A server is an entity whose primary responsibilities are to: 687 o Manage XML streams (Section 4) with local clients and deliver XML 688 stanzas (Section 8) to those clients over the negotiated streams; 689 this includes responsibility for ensuring that a client 690 authenticates with the server before being granted access to the 691 XMPP network. 693 o Subject to local service policies on server-to-server 694 communication, manage XML streams (Section 4) with remote servers 695 and route XML stanzas (Section 8) to those servers over the 696 negotiated streams. 698 Depending on the application, the secondary responsibilities of an 699 XMPP server can include: 701 o Storing data that is used by clients (e.g., contact lists for 702 users of XMPP-based instant messaging and presence applications as 703 defined in [XMPP-IM]); in this case, the relevant XML stanza is 704 handled directly by the server itself on behalf of the client and 705 is not routed to a remote server or delivered to a local entity. 707 o Hosting local services that also use XMPP as the basis for 708 communication but that provide additional functionality beyond 709 that defined in this document or in [XMPP-IM]; examples include 710 multi-user conferencing services as specified in [XEP-0045] and 711 publish-subscribe services as specified in [XEP-0060]. 713 3. TCP Binding 715 3.1. Scope 717 As XMPP is defined in this specification, an initiating entity 718 (client or server) MUST open a Transmission Control Protocol [TCP] 719 connection to the receiving entity (server) before it negotiates XML 720 streams with the receiving entity. The parties then maintain that 721 TCP connection for as long as the XML streams are in use. The rules 722 specified in the following sections apply to the TCP binding. 724 Informational Note: There is no necessary coupling of XML streams 725 to TCP, and other transports are possible. For example, two 726 entities could connect to each other by means of [HTTP] as 727 specified in [XEP-0124] and [XEP-0206]. However, this 728 specification defines only a binding of XMPP to TCP. 730 3.2. Hostname Resolution 732 Because XML streams are sent over TCP, the initiating entity needs to 733 determine the IPv4 or IPv6 address (and port) of the receiving 734 entity's "origin domain" before it can attempt to connect to the XMPP 735 network. 737 3.2.1. Preferred Process: SRV Lookup 739 The preferred process for hostname resolution is to use [DNS-SRV] 740 records as follows: 742 1. The initiating entity constructs a DNS SRV query whose inputs 743 are: 744 * a Service of "xmpp-client" (for client-to-server connections) 745 or "xmpp-server" (for server-to-server connections) 746 * a Proto of "tcp" 747 * a Name corresponding to the "origin domain" of the XMPP 748 service to which the initiating entity wishes to connect 749 (e.g., "example.net" or "im.example.com") 751 2. The resulting is a query such as "_xmpp-client._tcp.example.net." 752 or "_xmpp-server._tcp.im.example.com.". 754 3. If a response is received, it will contain one or more 755 combinations of a port and hostname, each of which is weighted 756 and prioritized as described in [DNS-SRV]. However, if the 757 result of the SRV lookup is a single resource record with a 758 Target of ".", i.e. the root domain, then the initiating entity 759 MUST abort SRV processing at this point (but SHOULD attempt the 760 fallback process described in the next section). 762 4. The initiating entity chooses at least one of the returned 763 hostnames to resolve (following the rules in [DNS-SRV]), which it 764 does by using a DNS "A" or "AAAA" lookup on the hostname; this 765 will result in an IPv4 or IPv6 address. 767 5. The initiating entity uses the IP address(es) from the first 768 successfully resolved hostname (with the corresponding port 769 number returned by the SRV lookup) as the connection address for 770 the receiving entity. 772 6. If the initiating entity fails to connect using that IP address 773 but the "A" or "AAAA" lookup returned more than one IP address, 774 then the initiating entity uses the next resolved IP address for 775 that hostname as the connection address. 777 7. If the initiating entity fails to connect using all resolved IP 778 addresses for a given hostname, then it repeats the process of 779 resolution and connection for the next hostname returned by the 780 SRV lookup. 782 8. If the initiating entity fails to connect using any hostname 783 returned by the SRV lookup, then it can either abort the 784 connection attempt or use the fallback process described in the 785 next section. 787 3.2.2. Fallback Processes 789 The fallback process SHOULD be a normal "A" or "AAAA" address record 790 resolution to determine the IPv4 or IPv6 address of the origin 791 domain, where the port used is the "xmpp-client" port of 5222 for 792 client-to-server connections or the "xmpp-server" port 5269 for 793 server-to-server connections. 795 For client-to-server connections, the fallback MAY be a [DNS-TXT] 796 lookup for alternative connection methods, for example as described 797 in [XEP-0156]. 799 3.2.3. When Not to Use SRV 801 If the initiating entity has been explicitly configured to associate 802 a particular hostname (and potentially port) with the origin domain 803 of the receiving entity (say, to "hardcode" an association from an 804 origin domain of example.net to a configured hostname of 805 webcm.example.com:80), the initiating entity SHOULD use the 806 configured name instead of performing the preferred SRV resolution 807 process on the origin name. 809 3.2.4. Use of SRV Records with Add-On Services 811 Many XMPP servers are implemented in such a way that they can host 812 add-on services (beyond those defined in this specification and 813 [XMPP-IM]) at DNS domain names that typically are "subdomains" of the 814 main XMPP service (e.g., conference.example.net for a [XEP-0045] 815 service associated with the example.net XMPP service) or "subdomains" 816 of the first-level domain of the underlying service (e.g., 817 muc.example.com for a [XEP-0045] service associated with the 818 im.example.com XMPP service). If an entity associated with a remote 819 XMPP server wishes to use such an add-on service, it would generate 820 an appropriate XML stanza and the remote server would attempt to 821 resolve the add-on service's DNS domain name via an SRV lookup on 822 resource records such as "_xmpp-server._tcp.conference.example.net." 823 or "_xmpp-server._tcp.muc.example.com.". Therefore if the 824 administrators of an XMPP service wish to enable entities associated 825 with remote servers to access such add-on services, they need to 826 advertise the appropriate "_xmpp-server" SRV records in addition to 827 the "_xmpp-server" record for their main XMPP service. In case SRV 828 records are not available, the fallback methods described under 829 Section 3.2.2 can be used to resolve the DNS domain names of add-on 830 services. 832 3.3. Reconnection 834 It can happen that an XMPP server goes offline while servicing TCP 835 connections from local clients and from other servers. Because the 836 number of such connections can be quite large, the reconnection 837 algorithm employed by entities that seek to reconnect can have a 838 significant impact on software and network performance. If an entity 839 chooses to reconnect, the following guidelines are RECOMMENDED: 841 o The number of seconds that expire before an entity first seeks to 842 reconnect SHOULD be an unpredictable number between 0 and 60 843 (e.g., so that all clients do not attempt to reconnect exactly 30 844 seconds after being disconnected). 846 o If the first reconnection attempt does not succeed, an entity 847 SHOULD back off increasingly on the time between subsequent 848 reconnection attempts (e.g., in accordance with "truncated binary 849 exponential backoff" as described in [ETHERNET]). 851 3.4. Reliability 853 The use of long-lived TCP connections in XMPP implies that the 854 sending of XML stanzas over XML streams can be unreliable, since the 855 parties to a long-lived TCP connection might not discover a 856 connectivity disruption in a timely manner. At the XMPP application 857 layer, long connectivity disruptions can result in undelivered 858 stanzas. Although the core XMPP technology defined in this 859 specification does not contain features to overcome this lack of 860 reliability, there exist XMPP extensions for doing so (e.g., 861 [XEP-0198]). 863 4. XML Streams 865 4.1. Stream Fundamentals 867 Two fundamental concepts make possible the rapid, asynchronous 868 exchange of relatively small payloads of structured information 869 between XMPP entities: XML streams and XML stanzas. These terms are 870 defined as follows. 872 Definition of XML Stream: An XML stream is a container for the 873 exchange of XML elements between any two entities over a network. 874 The start of an XML stream is denoted unambiguously by an opening 875 "stream header" (i.e., an XML tag with appropriate 876 attributes and namespace declarations), while the end of the XML 877 stream is denoted unambiguously by a closing XML tag. 878 During the life of the stream, the entity that initiated it can 879 send an unbounded number of XML elements over the stream, either 880 elements used to negotiate the stream (e.g., to complete TLS 881 negotiation (Section 5) or SASL negotiation (Section 6)) or XML 882 stanzas. The "initial stream" is negotiated from the initiating 883 entity (typically a client or server) to the receiving entity 884 (typically a server), and can be seen as corresponding to the 885 initiating entity's "connection to" or "session with" the 886 receiving entity. The initial stream enables unidirectional 887 communication from the initiating entity to the receiving entity; 888 in order to enable exchange of stanzas from the receiving entity 889 to the initiating entity, the receiving entity MUST negotiate a 890 stream in the opposite direction (the "response stream"). 892 Definition of XML Stanza: An XML stanza is the basic unit of meaning 893 in XMPP. Only a first-level , , or 894 element qualified by the content namespace is an XML stanza. By 895 contrast, a first-level XML element sent for any other purpose is 896 not an XML stanza (stream errors, stream features, TLS-related 897 elements, SASL-related elements, etc.). An XML stanza typically 898 contains one or more child elements (with accompanying attributes, 899 elements, and XML character data) as necessary in order to convey 900 the desired information, which MAY be qualified by any XML 901 namespace (see [XML-NAMES] as well as Section 8.4 in this 902 specification). 904 Consider the example of a client's connection to a server. The 905 client initiates an XML stream by sending a stream header to the 906 server, optionally preceded by an XML declaration specifying the XML 907 version and the character encoding supported (see Section 11.5 and 908 Section 11.6). Subject to local policies and service provisioning, 909 the server then replies with a second XML stream back to the client, 910 again optionally preceded by an XML declaration. Once the client has 911 completed SASL negotiation (Section 6) and resource binding 912 (Section 7), the client can send an unbounded number of XML stanzas 913 over the stream. When the client desires to close the stream, it 914 simply sends a closing tag to the server as further 915 described under Section 4.4. 917 In essence, then, one XML stream functions as an envelope for the XML 918 stanzas sent during a session and another XML stream functions as an 919 envelope for the XML stanzas received during a session. We can 920 represent this in a simplistic fashion as follows. 922 +--------------------+--------------------+ 923 | INITIAL STREAM | RESPONSE STREAM | 924 +--------------------+--------------------+ 925 | | | 926 |--------------------|--------------------| 927 | | | 928 |--------------------|--------------------| 929 | | | 930 | | | 931 | | | 932 |--------------------|--------------------| 933 | | | 934 | | | 935 | | | 936 |--------------------|--------------------| 937 | | | 939 | | | 940 | | | 941 |--------------------|--------------------| 942 | | | 944 | | | 945 | | | 946 |--------------------|--------------------| 947 | [ ... ] | | 948 |--------------------|--------------------| 949 | | [ ... ] | 950 |--------------------|--------------------| 951 | | | 952 |--------------------|--------------------| 953 | | | 954 +--------------------+--------------------+ 956 Figure 2: A Simplistic View of Two Streams 958 Those who are accustomed to thinking of XML in a document-centric 959 manner might find the following analogies useful: 961 o The two XML streams are like two "documents" (matching production 962 [1] content of [XML]) that are built up through the accumulation 963 of XML stanzas. 964 o The root element is like the "document entity" for each 965 "document" (as described in Section 4.8 of [XML]). 966 o The XML stanzas sent over the streams are like "fragments" of the 967 "documents" (as described in [XML-FRAG]). 969 However, these analogies are merely that, because XMPP does not deal 970 in documents and fragments but in streams and stanzas. 972 The remainder of this section defines the following aspects of XML 973 streams: 975 o The stream negotation process 976 o How to close a stream 977 o How to handle peers that are silent 978 o The XML attributes of a stream 979 o The XML namespaces of a stream 981 4.2. Stream Negotiation 983 4.2.1. Basic Concepts 985 Because the receiving entity for a stream acts as a gatekeeper to the 986 domains it services, it imposes certain conditions for connecting as 987 a client or as a peer server. At a minimum, the initiating entity 988 needs to authenticate with the receiving entity before it is allowed 989 to send stanzas to the receiving entity, typically using SASL as 990 described under Section 6. However, the receiving entity can 991 consider conditions other than authentication to be mandatory, such 992 as encryption using TLS as described under Section 5. The receiving 993 entity informs the initiating entity about such conditions by 994 communicating "stream features": the set of particular protocol 995 interactions that are mandatory for the initiating entity to complete 996 before the receiving entity will accept XML stanzas from the 997 initiating entity (e.g., authentication), as well as any protocol 998 interactions that are voluntary but that might improve the handling 999 of an XML stream (e.g., establishment of application-layer 1000 compression as described in [XEP-0138]). 1002 The existence of conditions for connecting implies that streams need 1003 to be negotiated. The order of layers (TCP, then TLS, then SASL, 1004 then XMPP; see Section 13.3) implies that stream negotiation is a 1005 multi-stage process. Further structure is imposed by two factors: 1006 (1) a given stream feature might be offered only to certain entities 1007 or only after certain other features have been negotiated (e.g., 1008 resource binding is offered only after SASL authentication), and (2) 1009 stream features can be either mandatory-to-negotiate or voluntary-to- 1010 negotiate. Finally, for security reasons the parties to a stream 1011 need to discard knowledge that they gained during the negotiation 1012 process after successfully completing the protocol interactions 1013 defined for certain features (e.g., TLS in all cases and SASL in the 1014 case when a security layer might be established, as defined in the 1015 specification for the relevant SASL mechanism); this is done by 1016 flushing the old stream context and exchanging new stream headers 1017 over the existing TCP connection. 1019 4.2.2. Stream Features Format 1021 If the initiating entity includes the 'version' attribute set to a 1022 value of at least "1.0" in the initial stream header, after sending 1023 the response stream header the receiving entity MUST send a 1024 child element (prefixed by the streams namespace prefix) 1025 to the initiating entity in order to announce any conditions for 1026 continuation of the stream negotiation process. Each condition takes 1027 the form of a child element of the element, qualified by 1028 a namespace that is different from the streams namespace and the 1029 content namespace. The element can contain one child, 1030 contain multiple children, or be empty. 1032 Implementation Note: The order of child elements contained in any 1033 given element is not significant. 1035 If a particular stream feature is or can be mandatory-to-negotiate, 1036 the definition of that feature needs to do one of the following: 1038 1. Declare that the feature is always mandatory-to-negotiate (e.g., 1039 this is true of resource binding for XMPP clients); or 1041 2. Specify a way for the receiving entity to flag the feature as 1042 mandatory-to-negotiate for this interaction (e.g., this is done 1043 for TLS by including an empty element in the 1044 advertisement for that stream feature); it is RECOMMENDED that 1045 stream feature definitions for mandatory-to-negotiate features do 1046 so by including an empty element as is done for TLS. 1048 Informational Note: Because there is no generic format for 1049 indicating that a feature is mandatory-to-negotiate, it is 1050 possible that a feature which is not understood by the initiating 1051 entity might be considered mandatory-to-negotiate by the receiving 1052 entity, resulting in failure of the stream negotiation process. 1053 Although such an outcome would be undesirable, the working group 1054 deemed it rare enough that a generic format was not needed. 1056 For security reasons, certain stream features necessitate the 1057 initiating entity to send a new initial stream header upon successful 1058 negotiation of the feature (e.g., TLS in all cases and SASL in the 1059 case when a security layer might be established). If this is true of 1060 a given stream feature, the definition of that feature needs to 1061 declare that a stream restart is expected after negotiation of the 1062 feature. 1064 A element that contains at least one mandatory-to- 1065 negotiate feature indicates that the stream negotiation is not 1066 complete and that the initiating entity MUST negotiate further 1067 features. 1069 R: 1070 1071 1072 1073 1075 A element MAY contain more than one mandatory feature. 1076 This means that the initiating entity can choose among the mandatory 1077 features. For example, perhaps a future technology will perform 1078 roughly the same function as TLS, so the receiving entity might 1079 advertise support for both TLS and the future technology. 1081 A element that contains both mandatory and voluntary 1082 features indicates that the negotiation is not complete but that the 1083 initiating entity MAY complete the voluntary feature(s) before it 1084 attempts to negotiate the mandatory feature(s). 1086 R: 1087 1088 1089 zlib 1090 lzw 1091 1092 1094 A element that contains only voluntary features indicates 1095 that the stream negotiation is complete and that the initiating 1096 entity is cleared to send XML stanzas, but that the initiating entity 1097 MAY negotiate further features if desired. 1099 R: 1100 1101 zlib 1102 lzw 1103 1104 1106 An empty element indicates that the stream negotiation is 1107 complete and that the initiating entity is cleared to send XML 1108 stanzas. 1110 R: 1112 4.2.3. Restarts 1114 On successful negotiation of a feature that necessitates a stream 1115 restart, both parties MUST consider the previous stream to be 1116 replaced but MUST NOT terminate the underlying TCP connection; 1117 instead, the parties MUST reuse the existing connection, which might 1118 be in a new state (e.g., encrypted as a result of TLS negotiation). 1119 The initiating entity then MUST send a new initial stream header, 1120 which SHOULD be preceded by an XML declaration as described under 1121 Section 11.5. When the receiving entity receives the new initial 1122 stream header, it MUST generate a new stream ID (instead of re-using 1123 the old stream ID) before sending a new response stream header (which 1124 SHOULD be preceded by an XML declaration as described under 1125 Section 11.5). 1127 4.2.4. Resending Features 1129 The receiving entity MUST send an updated list of stream features to 1130 the initiating entity after a stream restart, and MAY do so after 1131 completing negotiation of a stream feature that does not require a 1132 stream restart. The list of updated features MAY be empty if there 1133 are no further features to be advertised or MAY include any 1134 combination of features. 1136 4.2.5. Completion of Stream Negotiation 1138 The receiving entity indicates completion of the stream negotiation 1139 process by sending to the initiating entity either an empty 1140 element or a element that contains only 1141 voluntary features. After doing so, the receiving entity MAY send an 1142 empty element (e.g., after negotiation of such voluntary 1143 features) but MUST NOT send additional stream features to the 1144 initiating entity (if the receiving entity has new features to offer, 1145 preferably limited to mandatory-to-negotiate or security-critical 1146 features, it can simply close the stream using a stream 1147 error and then advertise the new features when the initiating entity 1148 reconnects, preferably closing existing streams in a staggered way so 1149 that not all of the initiating entities reconnect at once). Once 1150 stream negotiation is complete, the initiating entity is cleared to 1151 send XML stanzas over the stream for as long as the stream is 1152 maintained by both parties. 1154 Informational Note: Resource binding as specified under Section 7 1155 is an historical exception to the foregoing rule, since it is 1156 mandatory-to-negotiate for clients but uses XML stanzas for 1157 negotiation purposes. 1159 The initiating entity MUST NOT attempt to send XML stanzas 1160 (Section 8) to entities other than itself (i.e., the client's 1161 connected resource or any other authenticated resource of the 1162 client's account) or the server to which it is connected until stream 1163 negotiation has been completed. Even if the initiating entity does 1164 attempt to do so, the receiving entity MUST NOT accept such stanzas 1165 and MUST return a stream error. This rule applies 1166 to XML stanzas only (i.e., , , and 1167 elements qualified by the content namespace) and not to XML elements 1168 used for stream negotiation (e.g., elements used to complete TLS 1169 negotiation (Section 5) or SASL negotiation (Section 6)). 1171 4.2.6. Determination of Addresses 1173 After the parties to an XML stream have completed the appropriate 1174 aspects of stream negotiation (typically SASL negotiation (Section 6) 1175 and, for client-to-server streams, resource binding (Section 7)) the 1176 receiving entity for a stream MUST determine the initiating entity's 1177 JID. 1179 For client-to-server communication, the client's bare JID 1180 () MUST be the authorization identity (as 1181 defined by [SASL]), either (1) as directly communicated by the client 1182 during SASL negotiation (Section 6) or (2) as derived by the server 1183 from the authentication identity if no authorization identity was 1184 specified during SASL negotiation. The resourcepart of the full JID 1185 () MUST be the resource negotiated 1186 by the client and server during resource binding (Section 7). A 1187 client MUST NOT attempt to guess at its JID but instead MUST consider 1188 its JID to be whatever the server returns to it during resource 1189 binding. The server MUST ensure that the resulting JID (including 1190 localpart, domainpart, resourcepart, and separator characters) 1191 conforms to the canonical format for XMPP addresses defined in 1192 [XMPP-ADDR]; to meet this restriction, the server MAY replace the JID 1193 sent by the client with the canonicalized JID as determined by the 1194 server and communicate that JID to the client during resource 1195 binding. 1197 For server-to-server communication, the initiating server's JID 1198 () MUST be the authorization identity (as defined by 1199 [SASL]), either (1) as directly communicated by the initiating server 1200 during SASL negotiation (Section 6) or (2) as derived by the 1201 receiving server from the authentication identity if no authorization 1202 identity was specified during SASL negotiation; in the absence of 1203 SASL negotiation, the receiving server MAY consider the authorization 1204 identity to be an identity negotiated within the relevant 1205 verification protocol (e.g., the 'from' attribute of the 1206 element in Server Dialback [XEP-0220]). 1208 Security Note: Because it is possible for a third party to tamper 1209 with information that is sent over the stream before a security 1210 layer such as TLS is successfully negotiated, it is advisable for 1211 the receiving server to treat any such unprotected information 1212 with caution. 1214 4.2.7. Flow Chart 1216 We summarize the foregoing rules in the following non-normative flow 1217 chart for the stream negotiation process, presented from the 1218 perspective of the initiating entity. 1220 +------------+ 1221 | open TCP | 1222 | connection | 1223 +------------+ 1224 | 1225 v 1226 +---------------+ 1227 | send initial |<-------------------------+ 1228 | stream header | ^ 1229 +---------------+ | 1230 | | 1231 v | 1232 +------------------+ | 1233 | receive response | | 1234 | stream header | | 1235 +------------------+ | 1236 | | 1237 v | 1238 +----------------+ | 1239 | receive stream | | 1240 +------------------>| features | | 1241 ^ +----------------+ | 1242 | | | 1243 | v | 1244 | +<-----------------+ | 1245 | | | 1246 | {empty?} ----> {all voluntary?} ----> {some mandatory?} | 1247 | | no | no | | 1248 | | yes | yes | yes | 1249 | | v v | 1250 | | +---------------+ +----------------+ | 1251 | | | MAY negotiate | | MUST negotiate | | 1252 | | | any or none | | one feature | | 1253 | | +---------------+ +----------------+ | 1254 | | | | | 1255 | v v | | 1256 | +----------+ +-----------+ | | 1257 | | process |<-----| negotiate | | | 1258 | | complete | no | a feature | | | 1259 | +----------+ +-----------+ | | 1260 | | | | 1261 | yes | | | 1262 | v v | 1263 | +--------->+<---------+ | 1264 | | | 1265 | v | 1266 +<-------------------------- {restart mandatory?} ------------>+ 1267 no yes 1268 Figure 3: Stream Negotiation Flow Chart 1270 4.3. Directionality 1272 An XML stream is always unidirectional, by which is meant that XML 1273 stanzas can be sent in only one direction over the stream (either 1274 from the initiating entity to the receiving entity or from the 1275 receiving entity to the initiating entity). 1277 Depending on the type of session that has been negotiated and the 1278 nature of the entities involved, the entities might use: 1280 o Two streams over a single TCP connection; this is typical for 1281 client-to-server sessions, and a server MUST allow a client to use 1282 the same TCP connection for both streams. 1284 o Two streams over two TCP connections, where one TCP connection is 1285 used for the stream in which stanzas are sent from the initiating 1286 entity to the receiving entity and the other TCP connection is 1287 used for the stream in which stanzas are sent from the receiving 1288 entity to the initiating entity; this is typical for server-to- 1289 server sessions. 1291 o Multiple streams over two or more TCP connections. This approach 1292 is sometimes used for server-to-server communication between two 1293 large XMPP service providers; however, this can make it difficult 1294 to maintain coherence of data received over multiple streams in 1295 situations described under Section 10.1, which is why a server MAY 1296 return a stream error to a remote server that attempts 1297 to negotiate more than one stream (as described under 1298 Section 4.8.3.3). 1300 This concept of directionality applies only to stanzas and explicitly 1301 does not apply to other first-level children of the stream root, such 1302 as elements used for TLS negotiation, SASL negotiation, Server 1303 Dialback [XEP-0220], and Stream Management [XEP-0198]. 1305 During establishment of a server-to-server session, while completing 1306 STARTTLS negotiation (Section 5) and SASL negotiation (Section 6) two 1307 servers would use one TCP connection, but after the stream 1308 negotiation process is done that original TCP connection would be 1309 used only for the initiating server to send XML stanzas to the 1310 receiving server. In order for the receiving server to send XML 1311 stanzas to the initiating server, the receiving server would need to 1312 reverse the roles and negotiate an XML stream from the receiving 1313 server to the initiating server over a separate TCP connection. 1315 Implementation Note: For historical reasons, a server-to-server 1316 session always uses two TCP connections. While that approach 1317 remains the standard behavior described in this document, 1318 extensions such as [XEP-0288] enable servers to negotiate the use 1319 of a single TCP connection for bidirectional stanza exchange. 1321 Informational Note: Although XMPP developers sometimes apply the 1322 terms "unidirectional" and "bidirectional" to the underlying TCP 1323 connection (e.g., calling the TCP connection for a client-to- 1324 server session "bidirectional" and the TCP connection for a 1325 server-to-server session "unidirectional"), strictly speaking a 1326 stream is always unidirectional (because the initiating entity and 1327 receiving entity always have a minimum of two streams, one in each 1328 direction) and a TCP connection is always bidirectional (because 1329 TCP traffic can be sent in both directions). Directionality 1330 applies to the application-layer traffic sent over the TCP 1331 connection, not to the transport-layer traffic sent over the TCP 1332 connection itself. 1334 4.4. Closing a Stream 1336 An XML stream between two entities can be closed at any time, either 1337 because a specific stream error has occurred or in the absence of an 1338 error (e.g., when a client simply ends its session). 1340 A stream is closed by sending a closing tag. 1342 S: 1344 The entity that sends the closing stream tag SHOULD behave as 1345 follows: 1347 1. Wait for the other party to also close its stream before 1348 terminating the underlying TCP connection (this gives the other 1349 party an opportunity to finish transmitting any data in the 1350 opposite direction before the TCP connection is terminated). 1352 2. Refrain from initiating the sending of further data over that 1353 stream but continue to process data sent by the other entity 1354 (and, if necessary, react to such data). 1356 3. Consider both streams to be void if the other party does not send 1357 its closing stream tag within a reasonable amount of time (where 1358 the definition of "reasonable" is a matter of implementation or 1359 deployment). 1361 4. After receiving a reciprocal closing stream tag from the other 1362 party or waiting a reasonable amount of time with no response, 1363 MUST terminate the underlying TCP connection. 1365 4.5. Handling of Silent Peers 1367 When an entity that is a party to a stream has not received any XMPP 1368 traffic from its stream peer for some period of time, the peer might 1369 appear to be silent. There are several reasons why this might 1370 happen: 1372 1. The underlying TCP connection is dead. 1374 2. The XML stream is broken despite the fact that the underlying TCP 1375 connection is alive. 1377 3. The peer is idle and simply has not sent any XMPP traffic over 1378 its XML stream to the entity. 1380 These three conditions are best handled separately, as described in 1381 the following sections. 1383 Implementation Note: For the purpose of handling silent peers, we 1384 treat a two unidirectional TCP connections as conceptually 1385 equivalent to a single bidirectional TCP connection (see 1386 Section 4.3); however, implementers need to be aware that, in the 1387 case of two unidirectional TCP connections, responses to traffic 1388 at the XMPP application layer will come back from the peer on the 1389 second TCP connection. In addition, the use of multiple streams 1390 in each direction (which is a common deployment choice for server- 1391 to-server connectivity among large XMPP service providers) further 1392 complicates application-level checking of XMPP streams and their 1393 underlying TCP connections, because there is no necessary 1394 correlation between any given initial stream and any given 1395 response stream. 1397 4.5.1. Dead Connection 1399 If the underlying TCP connection is dead, stream-level checks (e.g., 1400 [XEP-0199] and [XEP-0198]) are ineffective. Therefore it is 1401 unnecessary to close the stream with or without an error, and it is 1402 appropriate instead to simply terminate the TCP connection. 1404 One common method for checking the TCP connection is to send a space 1405 character (U+0020) between XML stanzas, which is allowed for XML 1406 streams as described under Section 11.7; the sending of such a space 1407 character is properly called a "whitespace keepalive" (the term 1408 "whitespace ping" is often used, despite the fact that it is not a 1409 ping since no "pong" is possible). 1411 4.5.2. Broken Stream 1413 Even if the underlying TCP connection is alive, the peer might never 1414 respond to XMPP traffic that the entity sends, whether normal stanzas 1415 or specialized stream-checking traffic such as the application-level 1416 pings defined in [XEP-0199] or the more comprehensive Stream 1417 Management protocol defined in [XEP-0198]. In this case, it is 1418 appropriate for the entity to close a broken stream using the 1419 stream error described under Section 4.8.3.4. 1421 4.5.3. Idle Peer 1423 Even if the underlying TCP connection is alive and the stream is not 1424 broken, the peer might have sent no stanzas for a certain period of 1425 time. In this case, the peer SHOULD close the stream using the 1426 handshake described under Section 4.4. If the idle peer does not 1427 close the stream, the other party MAY either close the stream using 1428 the handshake described under Section 4.4 or return a stream error 1429 (e.g., if the entity has reached a limit on 1430 the number of open TCP connections or if the 1431 connection has exceeded a local timeout policy). However, consistent 1432 with the order of layers (specified under Section 13.3), the other 1433 party is advised to verify that the underlying TCP connection is 1434 alive and the stream is unbroken (as described above) before 1435 concluding that the peer is idle. Furthermore, it is preferable to 1436 be liberal in accepting idle peers, since experience has shown that 1437 doing so improves the reliability of communication over XMPP networks 1438 and that it is typically more efficient to maintain a stream between 1439 two servers than to aggressively timeout such a stream. 1441 4.5.4. Use of Checking Methods 1443 Implementers are advised to support whichever stream-checking and 1444 connection-checking methods they deem appropriate, but to carefully 1445 weigh the network impact of such methods against the benefits of 1446 discovering broken streams and dead TCP connections in a timely 1447 manner. The length of time between the use of any particular check 1448 is very much a matter of local service policy and depends strongly on 1449 the network environment and usage scenarios of a given deployment and 1450 connection type; at the time of writing, it is RECOMMENDED that any 1451 such check be performed not more than once every 5 minutes and that, 1452 ideally, such checks will be initiated by clients rather than 1453 servers. Those who implement XMPP software and deploy XMPP services 1454 are encouraged to seek additional advice regarding appropriate timing 1455 of stream-checking and connection-checking methods, particularly when 1456 power-constrained devices are being used (e.g., in mobile 1457 environments). 1459 4.6. Stream Attributes 1461 The attributes of the root element are defined in the 1462 following sections. 1464 Security Note: Until and unless the confidentiality and integrity 1465 of a stream header is ensured via Transport Layer Security as 1466 described under Section 5, the attributes provided in a stream 1467 header could be tampered with by an attacker. 1469 Implementation Note: The attributes of the root element 1470 are not prepended by a namespace prefix because, as explained in 1471 [XML-NAMES], "[d]efault namespace declarations do not apply 1472 directly to attribute names; the interpretation of unprefixed 1473 attributes is determined by the element on which they appear." 1475 4.6.1. from 1477 The 'from' attribute communicates an XMPP identity of the entity 1478 sending the stream element. 1480 For initial stream headers in client-to-server communication, if the 1481 client knows the XMPP identity of the principal controlling the 1482 client (typically an account name of the form 1483 ), then it SHOULD include the 'from' attribute 1484 and set its value to that identity once the stream is in a state in 1485 which it is willing to perform authentication, e.g. once TLS has been 1486 negotiated. However, because the client might not know the XMPP 1487 identity of the principal controlling the entity (e.g., because the 1488 XMPP identity is assigned at a level other than the XMPP application 1489 layer, as in the General Security Service Application Program 1490 Interface [GSS-API]), inclusion of the 'from' address is OPTIONAL. 1492 Security Note: Including the XMPP identity before the stream is 1493 protected via TLS can expose that identity to eavesdroppers. 1495 I: 1496 1504 For initial stream headers in server-to-server communication, a 1505 server MUST include the 'from' attribute and MUST set the value to 1506 the domainpart of the 'from' attribute of the stanza that caused the 1507 stream to be established (because the initiating entity might have 1508 more than one XMPP identity, e.g., in the case of a server that 1509 provides virtual hosting, it will need to choose an identity that is 1510 associated with this stream). 1512 I: 1513 1521 For response stream headers in both client-to-server and server-to- 1522 server communication, the receiving entity MUST include the 'from' 1523 attribute and MUST set the value to one of the receiving entity's 1524 hostnames (which MAY be a hostname other than that specified in the 1525 'to' attribute of the initial stream header; see Section 4.8.1.3 and 1526 Section 4.8.3.6). 1528 R: 1529 1538 Whether or not the 'from' attribute is included, each entity MUST 1539 verify the identity of the other entity before exchanging XML stanzas 1540 with it, as described under Section 13.5. 1542 Interoperability Note: It is possible that implementations based 1543 on [RFC3920] will not include the 'from' address on stream 1544 headers; an entity SHOULD be liberal in accepting such stream 1545 headers. 1547 4.6.2. to 1549 For initial stream headers in both client-to-server and server-to- 1550 server communication, the initiating entity MUST include the 'to' 1551 attribute and MUST set its value to a hostname that the initiating 1552 entity knows or expects the receiving entity to service. (The same 1553 information can be provided in other ways, such as a server name 1554 indication during TLS negotiation as described in [TLS-EXT].) 1556 I: 1557 1565 For response stream headers in client-to-server communication, if the 1566 client included a 'from' attribute in the initial stream header then 1567 the server MUST include a 'to' attribute in the response stream 1568 header and MUST set its value to the bare JID specified in the 'from' 1569 attribute of the initial stream header. If the client did not 1570 include a 'from' attribute in the initial stream header then the 1571 server MUST NOT include a 'to' attribute in the response stream 1572 header. 1574 R: 1575 1584 For response stream headers in server-to-server communication, the 1585 receiving entity MUST include a 'to' attribute in the response stream 1586 header and MUST set its value to the hostname specified in the 'from' 1587 attribute of the initial stream header. 1589 R: 1590 1599 Whether or not the 'to' attribute is included, each entity MUST 1600 verify the identity of the other entity before exchanging XML stanzas 1601 with it, as described under Section 13.5. 1603 Interoperability Note: It is possible that implementations based 1604 on [RFC3920] will not include the 'to' address on stream headers; 1605 an entity SHOULD be liberal in accepting such stream headers. 1607 4.6.3. id 1609 The 'id' attribute communicates a unique identifier for the stream, 1610 called a "stream ID". The stream ID MUST be generated by the 1611 receiving entity when it sends a response stream header and MUST BE 1612 unique within the receiving application (normally a server). 1614 Security Note: The stream ID MUST be both unpredictable and non- 1615 repeating because it can be security-critical when re-used by an 1616 authentication mechanisms, as is the case for Server Dialback 1617 [XEP-0220] and the "XMPP 0.9" authentication mechanism used before 1618 RFC 3920 defined the use of SASL in XMPP; for recommendations 1619 regarding randomness for security purposes, see [RANDOM]. 1621 For initial stream headers, the initiating entity MUST NOT include 1622 the 'id' attribute; however, if the 'id' attribute is included, the 1623 receiving entity MUST ignore it. 1625 For response stream headers, the receiving entity MUST include the 1626 'id' attribute. 1628 R: 1629 1638 Interoperability Note: In RFC 3920, the text regarding inclusion 1639 of the 'id' attribute was ambiguous, leading some implementations 1640 to leave the attribute off the response stream header. 1642 4.6.4. xml:lang 1644 The 'xml:lang' attribute communicates an entity's preferred or 1645 default language for any human-readable XML character data to be sent 1646 over the stream (an XML stanza can also possess an 'xml:lang' 1647 attribute, as discussed under Section 8.1.5). The syntax of this 1648 attribute is defined in Section 2.12 of [XML]; in particular, the 1649 value of the 'xml:lang' attribute MUST conform to the NMTOKEN 1650 datatype (as defined in Section 2.3 of [XML]) and MUST conform to the 1651 language identifier format defined in [LANGTAGS]. 1653 For initial stream headers, the initiating entity SHOULD include the 1654 'xml:lang' attribute. 1656 I: 1657 1665 For response stream headers, the receiving entity MUST include the 1666 'xml:lang' attribute. The following rules apply: 1668 o If the initiating entity included an 'xml:lang' attribute in its 1669 initial stream header and the receiving entity supports that 1670 language in the human-readable XML character data that it 1671 generates and sends to the initiating entity (e.g., in the 1672 element for stream and stanza errors), the value of the 'xml:lang' 1673 attribute MUST be the identifier for the initiating entity's 1674 preferred language (e.g., "de-CH"). 1675 o If the receiving entity supports a language that closely matches 1676 the initiating entity's preferred language (e.g., "de" instead of 1677 "de-CH"), then the value of the 'xml:lang' attribute SHOULD be the 1678 identifier for the matching language (e.g., "de") but MAY be the 1679 identifier for the default language of the receiving entity (e.g., 1680 "en"). 1681 o If the receiving entity does not support the initiating entity's 1682 preferred language or a closely matching language (or if the 1683 initiating entity did not include the 'xml:lang' attribute in its 1684 initial stream header), then the value of the 'xml:lang' attribute 1685 MUST be the identifier for the default language of the receiving 1686 entity (e.g., "en"). 1688 R: 1689 1698 If the initiating entity included the 'xml:lang' attribute in its 1699 initial stream header, the receiving entity SHOULD remember that 1700 value as the default xml:lang for all stanzas sent by the initiating 1701 entity over the current stream. As described under Section 8.1.5, 1702 the initiating entity MAY include the 'xml:lang' attribute in any XML 1703 stanzas it sends over the stream. If the initiating entity does not 1704 include the 'xml:lang' attribute in any such stanza, the receiving 1705 entity SHOULD add the 'xml:lang' attribute to the stanza, where the 1706 value of the attribute MUST be the identifier for the language 1707 preferred by the initiating entity (even if the receiving entity does 1708 not support that language for human-readable XML character data it 1709 generates and sends to the initiating entity, such as in stream or 1710 stanza errors). If the initiating entity includes the 'xml:lang' 1711 attribute in any such stanza, the receiving entity MUST NOT modify or 1712 delete it. 1714 4.6.5. version 1716 The inclusion of the version attribute set to a value of at least 1717 "1.0" signals support for the stream-related protocols defined in 1718 this specification, including TLS negotiation (Section 5), SASL 1719 negotiation (Section 6), stream features (Section 4.2.2), and stream 1720 errors (Section 4.8). 1722 The version of XMPP specified in this specification is "1.0"; in 1723 particular, XMPP 1.0 encapsulates the stream-related protocols as 1724 well as the basic semantics of the three defined XML stanza types 1725 (, , and ). 1727 The numbering scheme for XMPP versions is ".". The 1728 major and minor numbers MUST be treated as separate integers and each 1729 number MAY be incremented higher than a single digit. Thus, "XMPP 1730 2.4" would be a lower version than "XMPP 2.13", which in turn would 1731 be lower than "XMPP 12.3". Leading zeros (e.g., "XMPP 6.01") MUST be 1732 ignored by recipients and MUST NOT be sent. 1734 The major version number will be incremented only if the stream and 1735 stanza formats or obligatory actions have changed so dramatically 1736 that an older version entity would not be able to interoperate with a 1737 newer version entity if it simply ignored the elements and attributes 1738 it did not understand and took the actions defined in the older 1739 specification. 1741 The minor version number will be incremented only if significant new 1742 capabilities have been added to the core protocol (e.g., a newly 1743 defined value of the 'type' attribute for message, presence, or IQ 1744 stanzas). The minor version number MUST be ignored by an entity with 1745 a smaller minor version number, but MAY be used for informational 1746 purposes by the entity with the larger minor version number (e.g., 1747 the entity with the larger minor version number would simply note 1748 that its correspondent would not be able to understand that value of 1749 the 'type' attribute and therefore would not send it). 1751 The following rules apply to the generation and handling of the 1752 'version' attribute within stream headers: 1754 1. The initiating entity MUST set the value of the 'version' 1755 attribute in the initial stream header to the highest version 1756 number it supports (e.g., if the highest version number it 1757 supports is that defined in this specification, it MUST set the 1758 value to "1.0"). 1760 2. The receiving entity MUST set the value of the 'version' 1761 attribute in the response stream header to either the value 1762 supplied by the initiating entity or the highest version number 1763 supported by the receiving entity, whichever is lower. The 1764 receiving entity MUST perform a numeric comparison on the major 1765 and minor version numbers, not a string match on 1766 ".". 1768 3. If the version number included in the response stream header is 1769 at least one major version lower than the version number included 1770 in the initial stream header and newer version entities cannot 1771 interoperate with older version entities as described, the 1772 initiating entity SHOULD generate an 1773 stream error. 1775 4. If either entity receives a stream header with no 'version' 1776 attribute, the entity MUST consider the version supported by the 1777 other entity to be "0.9" and SHOULD NOT include a 'version' 1778 attribute in the response stream header. 1780 4.6.6. Summary of Stream Attributes 1782 The following table summarizes the attributes of the root 1783 element. 1785 +----------+--------------------------+-------------------------+ 1786 | | initiating to receiving | receiving to initiating | 1787 +----------+--------------------------+-------------------------+ 1788 | to | JID of receiver | JID of initiator | 1789 | from | JID of initiator | JID of receiver | 1790 | id | ignored | stream identifier | 1791 | xml:lang | default language | default language | 1792 | version | XMPP 1.0+ supported | XMPP 1.0+ supported | 1793 +----------+--------------------------+-------------------------+ 1795 Figure 4: Stream Attributes 1797 4.7. Namespaces 1799 Readers are referred to the specification of XML namespaces 1800 [XML-NAMES] for a full understanding of the concepts used in this 1801 section, especially the concept of a "default namespace" as provided 1802 in Section 3 and Section 6.2 of that specification. 1804 4.7.1. Streams Namespace 1806 The root element ("stream header") MUST be qualified by the 1807 namespace 'http://etherx.jabber.org/streams' (the "streams 1808 namespace"). If this rule is violated, the entity that receives the 1809 offending stream header MUST return a stream error to the sending 1810 entity, which SHOULD be (although some existing 1811 implementations send instead). 1813 4.7.2. Content Namespace 1815 An entity MAY declare a "content namespace" as the default namespace 1816 for data sent over the stream (i.e., data other than elements 1817 qualified by the streams namespace). If so, (1) the content 1818 namespace MUST be other than the streams namespace, and (2) the 1819 content namespace MUST be the same for the initial stream and the 1820 response stream so that both streams are qualified consistently. The 1821 content namespace applies to all first-level child elements sent over 1822 the stream unless explicitly qualified by another namespace (i.e., 1823 the content namespace is the default namespace). 1825 Alternatively (i.e., instead of declaring the content namespace as 1826 the default namespace), an entity MAY explicitly qualify the 1827 namespace for each first-level child element of the stream, using so- 1828 called "prefix-free canonicalization". These two styles are shown in 1829 the following examples. 1831 When a content namespace is declared as the default namespace, in 1832 rough outline a stream will look something like the following. 1834 1841 1842 foo 1843 1844 1846 When a content namespace is not declared as the default namespace and 1847 so-called "prefix-free canonicalization" is used instead, in rough 1848 outline a stream will look something like the following. 1850 1856 1857 foo 1858 1859 1861 Historically, most XMPP implementations have used the content- 1862 namespace-as-default-namespace style rather than the prefix-free 1863 canonicalization style for stream headers; however, both styles are 1864 acceptable since they are semantically equivalent. 1866 4.7.3. Other Namespaces 1868 Either party to a stream MAY send data qualified by namespaces other 1869 than the content namespace and the streams namespace. For example, 1870 this is how data related to TLS negotiation and SASL negotiation are 1871 exchanged, as well as XMPP extensions such as Server Dialback 1872 [XEP-0220] and Stream Management [XEP-0198]. 1874 Interoperability Note: For historical reasons, some server 1875 implementations expect a declaration of the 'jabber:server: 1876 dialback' namespace on server-to-server streams; for details, see 1877 [XEP-0220]. 1879 4.7.4. Namespace Declarations and Prefixes 1881 Because the content namespace is other than the streams namespace, if 1882 a content namespace is declared as the default namespace then the 1883 following statements are true: 1885 1. The stream header needs to contain a namespace declaration for 1886 both the content namespace and the streams namespace. 1888 2. The streams namespace declaration needs to include a namespace 1889 prefix for the streams namespace. 1891 Interoperability Note: For historical reasons, an implementation 1892 MAY accept only the prefix 'stream' for the streams namespace 1893 (resulting in prefixed names such as and ). If an entity receives a stream header with a streams 1895 namespace prefix it does not accept, it MUST return a stream error 1896 to the sending entity, which SHOULD be 1897 (although some existing implementations send 1898 instead). 1900 An implementation MUST NOT generate namespace prefixes for elements 1901 qualified by the content namespace if the content namespace is 1902 'jabber:client' or 'jabber:server'. 1904 Namespaces declared in a stream header MUST apply only to that stream 1905 (e.g., the 'jabber:server:dialback' namespace used in Server Dialback 1906 [XEP-0220]). In particular, because XML stanzas intended for routing 1907 or delivery over streams with other entities will lose the namespace 1908 context declared in the header of the stream in which those stanzas 1909 originated, namespaces for extended content within such stanzas MUST 1910 NOT be declared in that stream header (see also Section 8.4). If 1911 either party to a stream declares such namespaces, the other party to 1912 the stream SHOULD close the stream with a stream error of . In any case, an entity MUST ensure that such namespaces 1914 are properly declared (according to this section) when routing or 1915 delivering stanzas originating from such a stream over streams with 1916 other entities. 1918 4.7.5. Mandatory-to-Implement Content Namespaces 1920 XMPP as defined in this specification uses two content namespaces: 1921 'jabber:client' and 'jabber:server'. These namespaces are nearly 1922 identical but are used in different contexts (client-to-server 1923 communication for 'jabber:client' and server-to-server communication 1924 for 'jabber:server'). The only difference between the two is that 1925 the 'to' and 'from' attributes are OPTIONAL on stanzas sent over XML 1926 streams qualified by the 'jabber:client' namespace, whereas they are 1927 REQUIRED on stanzas sent over XML streams qualified by the 'jabber: 1928 server' namespace. Support for these content namespaces implies 1929 support for the common attributes (Section 8.1) and basic semantics 1930 (Section 8.2) of all three core stanza types (message, presence, and 1931 IQ). 1933 An implementation MAY support content namespaces other than 'jabber: 1934 client' or 'jabber:server'. However, because such namespaces would 1935 define applications other than XMPP, they are to be defined in 1936 separate specifications. 1938 An implementation MAY refuse to support any other content namespaces 1939 as default namespaces. If an entity receives a first-level child 1940 element qualified by a content namespace it does not support, it MUST 1941 return an stream error. 1943 Client implementations MUST support the 'jabber:client' content 1944 namespace as a default namespace. 1946 Server implementations MUST support as default namespaces both the 1947 'jabber:client' content namespace (when the stream is used for 1948 communication between a client and a server) and the 'jabber:server' 1949 content namespace (when the stream is used for communication between 1950 two servers). 1952 Implementation Note: Because a client sends stanzas over a stream 1953 whose content namespace is 'jabber:client', if the server to which 1954 the client is connected needs to route a client-generated stanza 1955 to another server then it MUST "re-scope" the stanza so that its 1956 content namespace is 'jabber:server' (i.e., it MUST NOT send a 1957 stanza qualified by the 'jabber:client' namespace over a stream 1958 whose content namespace is 'jabber:server'). Similarly, a routing 1959 server MUST "re-scope" a stanza received over a server-to-server 1960 stream (whose content namespace is 'jabber:server') so that the 1961 stanza is qualified by the 'jabber:client' namespace before 1962 sending it over a client-to-server stream (whose content namespace 1963 is 'jabber:client'). 1965 4.8. Stream Errors 1967 The root stream element MAY contain an child element that is 1968 prefixed by the streams namespace prefix. The error child SHALL be 1969 sent by a compliant entity if it perceives that a stream-level error 1970 has occurred. 1972 4.8.1. Rules 1974 The following rules apply to stream-level errors. 1976 4.8.1.1. Stream Errors Are Unrecoverable 1978 Stream-level errors are unrecoverable. Therefore, if an error occurs 1979 at the level of the stream, the entity that detects the error MUST 1980 send an element with an appropriate child element that 1981 specifies the error condition and immediately close the stream as 1982 described under Section 4.4. 1984 C: No closing tag! 1986 S: 1987 1989 1990 1992 The entity that generates the stream error then shall close the 1993 stream as explained under Section 4.4. 1995 C: 1997 4.8.1.2. Stream Errors Can Occur During Setup 1999 If the error is triggered by the initial stream header, the receiving 2000 entity MUST still send the opening tag, include the 2001 element as a child of the stream element, and send the closing 2002 tag (preferably all at the same time). 2004 C: 2005 2013 S: 2014 2022 2023 2025 2026 2028 4.8.1.3. Stream Errors When the Host is Unspecified or Unknown 2030 If the initiating entity provides no 'to' attribute or provides an 2031 unknown host in the 'to' attribute and the error occurs during stream 2032 setup, the value of the 'from' attribute returned by the receiving 2033 entity in the stream header sent before closing the stream MUST be 2034 either an authoritative hostname for the receiving entity or the 2035 empty string. 2037 C: 2038 2046 S: 2047 2055 2056 2058 2059 2061 4.8.1.4. Where Stream Errors Are Sent 2063 When two TCP connections are used between the initiating entity and 2064 the receiving entity (one in each direction) rather than using a 2065 single bidirectional connection, the following rules apply: 2067 o Stream-level errors related to the initial stream are returned by 2068 the receiving entity on the response stream via the same TCP 2069 connection. 2071 o Stanza errors triggered by outbound stanzas sent from the 2072 initiating entity over the initial stream via the same TCP 2073 connection are returned by the receiving entity on the response 2074 stream via the other, return TCP connection (since they are 2075 inbound stanzas from the perspective of the initiating entity). 2077 4.8.2. Syntax 2079 The syntax for stream errors is as follows, where "defined-condition" 2080 is a placeholder for one of the conditions defined under 2081 Section 4.8.3 and XML data shown within the square brackets '[' and 2082 ']' is OPTIONAL. 2084 2085 2086 [ 2088 [ ... descriptive text ... ] 2089 ] 2090 [application-specific condition element] 2091 2093 The element: 2095 o MUST contain a child element corresponding to one of the defined 2096 stream error conditions (Section 4.8.3); this element MUST be 2097 qualified by the 'urn:ietf:params:xml:ns:xmpp-streams' namespace. 2099 o MAY contain a child element containing XML character data 2100 that describes the error in more detail; this element MUST be 2101 qualified by the 'urn:ietf:params:xml:ns:xmpp-streams' namespace 2102 and SHOULD possess an 'xml:lang' attribute specifying the natural 2103 language of the XML character data. 2105 o MAY contain a child element for an application-specific error 2106 condition; this element MUST be qualified by an application- 2107 defined namespace, and its structure is defined by that namespace 2108 (see Section 4.8.4). 2110 The element is OPTIONAL. If included, it MUST be used only 2111 to provide descriptive or diagnostic information that supplements the 2112 meaning of a defined condition or application-specific condition. It 2113 MUST NOT be interpreted programmatically by an application. It MUST 2114 NOT be used as the error message presented to a human user, but MAY 2115 be shown in addition to the error message associated with the defined 2116 condition element (and, optionally, the application-specific 2117 condition element). 2119 4.8.3. Defined Stream Error Conditions 2121 The following stream-level error conditions are defined. 2123 4.8.3.1. bad-format 2125 The entity has sent XML that cannot be processed. 2127 (In the following example, the client sends an XMPP message that is 2128 not well-formed XML, which alternatively might trigger a stream error.) 2130 C: 2131 No closing tag! 2132 2134 S: 2135 2137 2138 2140 This error MAY be used instead of the more specific XML-related 2141 errors, such as , , , , and . However, the 2143 more specific errors are RECOMMENDED. 2145 4.8.3.2. bad-namespace-prefix 2147 The entity has sent a namespace prefix that is unsupported, or has 2148 sent no namespace prefix on an element that needs such a prefix (see 2149 Section 11.2). 2151 (In the following example, the client specifies a namespace prefix of 2152 "foobar" for the XML streams namespace.) 2154 C: 2155 2162 S: 2163 2171 2172 2174 2175 2177 4.8.3.3. conflict 2179 The server either (1) is closing the existing stream for this entity 2180 because a new stream has been initiated that conflicts with the 2181 existing stream, or (2) is refusing a new stream for this entity 2182 because allowing the new stream would conflict with an existing 2183 stream (e.g., because the server allows only a certain number of 2184 connections from the same IP address or allows only one server-to- 2185 server stream for a given domain pair as a way of helping to ensure 2186 in-order processing as described under Section 10.1). 2188 C: 2189 2196 S: 2197 2205 2206 2208 2209 2211 If a client receives a stream error, during the resource 2212 binding aspect of its reconnection attempt it MUST NOT blindly 2213 request the resourcepart it used during the former session but 2214 instead MUST choose a different resourcepart; details are provided 2215 under Section 7. 2217 4.8.3.4. connection-timeout 2219 One party is closing the stream because it has reason to believe that 2220 the other party has permanently lost the ability to communicate over 2221 the stream. The lack of ability to communicate can be discovered 2222 using various methods, such as whitespace keepalives as specified 2223 under Section 4.4, XMPP-level pings as defined in [XEP-0199], and 2224 XMPP Stream Management as defined in [XEP-0198]. 2226 P: 2227 2229 2230 2232 Interoperability Note: RFC 3920 specified that the stream error is to be used if the peer has not generated 2234 any traffic over the stream for some period of time. That 2235 behavior is no longer recommended; instead, the error SHOULD be 2236 used only if the connected client or peer server has not responded 2237 to data sent over the stream. 2239 4.8.3.5. host-gone 2241 The value of the 'to' attribute provided in the initial stream header 2242 corresponds to a hostname that is no longer serviced by the receiving 2243 entity. 2245 (In the following example, the peer specifies a 'to' address of 2246 "foo.im.example.com" when connecting to the "im.example.com" server, 2247 but the server no longer hosts a service at that address.) 2249 P: 2250 2257 S: 2258 2266 2267 2269 2270 2272 4.8.3.6. host-unknown 2274 The value of the 'to' attribute provided in the initial stream header 2275 does not correspond to a hostname that is serviced by the receiving 2276 entity. 2278 (In the following example, the peer specifies a 'to' address of 2279 "example.org" when connecting to the "im.example.com" server, but the 2280 server knows nothing of that address.) 2282 P: 2283 2290 S: 2291 2299 2300 2302 2303 2305 4.8.3.7. improper-addressing 2307 A stanza sent between two servers lacks a 'to' or 'from' attribute, 2308 the 'from' or 'to' attribute has no value, or the value is not a 2309 valid XMPP address. 2311 (In the following example, the peer sends a stanza without a 'to' 2312 address over a server-to-server stream.) 2313 P: 2314 Wherefore art thou? 2315 2317 S: 2318 2320 2321 2323 4.8.3.8. internal-server-error 2325 The server has experienced a misconfiguration or an otherwise- 2326 undefined internal error that prevents it from servicing the stream. 2328 S: 2329 2331 2332 2334 4.8.3.9. invalid-from 2336 The JID or hostname provided in a 'from' address is not a valid JID 2337 or does not match an authorized JID or validated domain as negotiated 2338 between servers via SASL or Server Dialback, or as negotiated between 2339 a client and a server via authentication and resource binding. 2341 (In the following example, a peer that has authenticated only as 2342 "example.net" attempts to send a stanza from an address at 2343 "example.org".) 2345 P: 2346 Neither, fair saint, if either thee dislike. 2347 2349 S: 2350 2352 2353 2355 4.8.3.10. invalid-namespace 2357 The streams namespace name is something other than 2358 "http://etherx.jabber.org/streams" (see Section 11.2) or the content 2359 namespace is not supported (e.g., something other than "jabber: 2360 client" or "jabber:server"). 2362 (In the following example, the client specifies a namespace of 2363 'http://wrong.namespace.example.org/' for the stream.) 2365 C: 2366 2373 S: 2374 2382 2383 2385 2386 2388 4.8.3.11. invalid-xml 2390 The entity has sent invalid XML over the stream to a server that 2391 performs validation (see Section 11.4). 2393 (In the following example, the peer attempts to send an IQ stanza of 2394 type "subscribe" but the XML schema defines no such value for the 2395 'type' attribute.) 2397 P: 2401 2402 2404 S: 2405 2407 2408 2410 4.8.3.12. not-authorized 2412 The entity has attempted to send XML stanzas before the stream has 2413 been authenticated, or otherwise is not authorized to perform an 2414 action related to stream negotiation; the receiving entity MUST NOT 2415 process the offending stanza before sending the stream error. 2417 (In the following example, the client attempts to send XML stanzas 2418 before authenticating with the server.) 2420 C: 2421 2428 S: 2429 2439 Wherefore art thou? 2440 2442 S: 2443 2445 2446 2448 4.8.3.13. not-well-formed 2450 The initiating entity has sent XML that violates the well-formedness 2451 rules of [XML] or [XML-NAMES]. 2453 (In the following example, the client sends an XMPP message that is 2454 not namespace-well-formed.) 2455 C: 2456 What is this foo? 2457 2459 S: 2460 2462 2463 2465 Interoperability Note: In RFC 3920, the name of this error 2466 condition was "xml-not-well-formed" instead of "not-well-formed". 2467 The name was changed because the element name violates the constraint from Section 3 of [XML] that 2469 "names beginning with a match to (('X'|'x')('M'|'m')('L'|'l')) are 2470 reserved for standardization in this or future versions of this 2471 specification". 2473 4.8.3.14. policy-violation 2475 The entity has violated some local service policy (e.g., the stanza 2476 exceeds a configured size limit); the server MAY choose to specify 2477 the policy in the element or in an application-specific 2478 condition element. 2480 (In the following example, the client sends an XMPP message that is 2481 too large according to the server's local service policy.) 2483 C: 2484 [ ... the-emacs-manual ... ] 2485 2487 S: 2488 2490 2491 2493 S: 2495 4.8.3.15. remote-connection-failed 2497 The server is unable to properly connect to a remote entity that is 2498 needed for authentication or authorization, such as a remote 2499 authentication database. 2501 C: 2502 2509 S: 2510 2518 2519 2521 2522 2524 4.8.3.16. reset 2526 The server is closing the stream because it has new (typically 2527 security-critical) features to offer, because the keys or 2528 certificates used to establish a secure context for the stream have 2529 expired or have been revoked during the life of the stream 2530 (Section 13.7.2.3), because the TLS sequence number has wrapped 2531 (Section 5.3.5), etc. 2533 S: 2534 2536 2537 2539 4.8.3.17. resource-constraint 2541 The server lacks the system resources necessary to service the 2542 stream. 2544 C: 2545 2552 S: 2553 2561 2562 2564 2565 2567 4.8.3.18. restricted-xml 2569 The entity has attempted to send restricted XML features such as a 2570 comment, processing instruction, DTD subset, or XML entity reference 2571 (see Section 11.1). 2573 (In the following example, the client sends an XMPP message 2574 containing an XML comment.) 2576 C: 2577 2578 This message has no subject. 2579 2581 S: 2582 2584 2585 2587 4.8.3.19. see-other-host 2589 The server will not provide service to the initiating entity but is 2590 redirecting traffic to another host; the XML character data of the 2591 element returned by the server MUST specify the 2592 alternate hostname or IP address at which to connect, which MUST be a 2593 valid domainpart or a domainpart plus port number (separated by the 2594 ':' character in the form "domainpart:port"). If the domainpart is 2595 the same as the source domain, derived domain, or resolved IP address 2596 to which the initiating entity originally connected (differing only 2597 by the port number), then the initiating entity SHOULD simply attempt 2598 to reconnect at that address. Otherwise, the initiating entity MUST 2599 resolve the hostname specified in the element as 2600 described under Section 3.2. 2602 C: 2603 2610 S: 2611 2619 2620 2622 [2001:41D0:1:A49b::1]:9222 2623 2624 2625 2627 4.8.3.20. system-shutdown 2629 The server is being shut down and all active streams are being 2630 closed. 2632 S: 2633 2635 2636 2638 4.8.3.21. undefined-condition 2640 The error condition is not one of those defined by the other 2641 conditions in this list; this error condition SHOULD be used only in 2642 conjunction with an application-specific condition. 2644 S: 2645 2647 2648 2649 2651 4.8.3.22. unsupported-encoding 2653 The initiating entity has encoded the stream in an encoding that is 2654 not supported by the server (see Section 11.6) or has otherwise 2655 improperly encoded the stream (e.g., by violating the rules of the 2656 [UTF-8] encoding). 2658 (In the following example, the client attempts to encode data using 2659 UTF-16 instead of UTF-8.) 2661 C: 2662 2669 S: 2670 2679 2681 2682 2684 4.8.3.23. unsupported-feature 2686 The receiving entity has advertised a mandatory stream feature that 2687 the initiating entity does not support, and has offered no other 2688 mandatory feature alongside the unsupported feature. 2690 (In the following example, the receiving entity requires negotiation 2691 of an example feature but the initiating entity does not support the 2692 feature.) 2694 R: 2695 2696 2697 2698 2700 I: 2701 2703 2704 2706 4.8.3.24. unsupported-stanza-type 2708 The initiating entity has sent a first-level child of the stream that 2709 is not supported by the server, either because the receiving entity 2710 does not understand the namespace or because the receiving entity 2711 does not understand the element name for the applicable namespace 2712 (which might be the content namespace declared as the default 2713 namespace). 2715 (In the following example, the client attempts to send a first-level 2716 child element of qualified by the 'jabber:client' 2717 namespace, but the schema for that namespace defines no such 2718 element.) 2719 C: 2720 2721 2722 2723 Soliloquy 2724 2725 To be, or not to be: that is the question: 2726 Whether 'tis nobler in the mind to suffer 2727 The slings and arrows of outrageous fortune, 2728 Or to take arms against a sea of troubles, 2729 And by opposing end them? 2730 2731 2733 tag:denmark.example,2003:entry-32397 2734 2003-12-13T18:30:02Z 2735 2003-12-13T18:30:02Z 2736 2737 2738 2739 2741 S: 2742 2744 2745 2747 4.8.3.25. unsupported-version 2749 The value of the 'version' attribute provided by the initiating 2750 entity in the stream header specifies a version of XMPP that is not 2751 supported by the server. 2753 C: 2754 2761 S: 2762 2771 2773 2774 2776 4.8.4. Application-Specific Conditions 2778 As noted, an application MAY provide application-specific stream 2779 error information by including a properly-namespaced child in the 2780 error element. The application-specific element SHOULD supplement or 2781 further qualify a defined element. Thus the element will 2782 contain two or three child elements. 2784 C: 2785 2786 My keyboard layout is: 2788 QWERTYUIOP{}| 2789 ASDFGHJKL:" 2790 ZXCVBNM<>? 2791 2792 2794 S: 2795 2797 2798 Some special application diagnostic information! 2799 2800 2801 2802 2804 4.9. Simplified Stream Examples 2806 This section contains two simplified examples of a stream-based 2807 connection between a client and a server; these examples are included 2808 for the purpose of illustrating the concepts introduced thus far. 2810 A basic connection: 2812 C: 2813 2821 S: 2822 2831 [ ... channel encryption ... ] 2833 [ ... authentication ... ] 2835 [ ... resource binding ... ] 2837 C: 2840 Art thou not Romeo, and a Montague? 2841 2843 S: 2846 Neither, fair saint, if either thee dislike. 2847 2849 C: 2851 S: 2852 A connection gone bad: 2854 C: 2855 2863 S: 2864 2873 [ ... channel encryption ... ] 2875 [ ... authentication ... ] 2877 [ ... resource binding ... ] 2879 C: 2882 No closing tag! 2883 2885 S: 2886 2888 2889 2891 More detailed examples are provided under Section 9. 2893 5. STARTTLS Negotiation 2894 5.1. Fundamentals 2896 XMPP includes a method for securing the stream from tampering and 2897 eavesdropping. This channel encryption method makes use of the 2898 Transport Layer Security [TLS] protocol, specifically a "STARTTLS" 2899 extension that is modelled after similar extensions for the [IMAP], 2900 [POP3], and [ACAP] protocols as described in [USINGTLS]. The XML 2901 namespace name for the STARTTLS extension is 2902 'urn:ietf:params:xml:ns:xmpp-tls'. 2904 5.2. Support 2906 Support for STARTTLS is REQUIRED in XMPP client and server 2907 implementations. An administrator of a given deployment MAY specify 2908 that TLS is obligatory for client-to-server communication, server-to- 2909 server communication, or both. An initiating entity SHOULD use TLS 2910 to secure its stream with the receiving entity before proceeding with 2911 SASL authentication. 2913 5.3. Stream Negotiation Rules 2915 5.3.1. Mandatory-to-Negotiate 2917 If the receiving entity advertises only the STARTTLS feature or if 2918 the receiving entity includes the child element as 2919 explained under Section 5.4.1, the parties MUST consider TLS as 2920 mandatory-to-negotiate. If TLS is mandatory-to-negotiate, the 2921 receiving entity SHOULD NOT advertise support for any stream feature 2922 except STARTTLS during the initial stage of the stream negotiation 2923 process, because further stream features might depend on prior 2924 negotiation of TLS given the order of layers in XMPP (e.g., the 2925 particular SASL mechanisms offered by the receiving entity will 2926 likely depend on whether TLS has been negotiated). 2928 5.3.2. Restart 2930 After TLS negotiation, the parties MUST restart the stream. 2932 5.3.3. Data Formatting 2934 During STARTTLS negotiation, the entities MUST NOT send any 2935 whitespace as separators between XML elements (i.e., from the last 2936 character of the element qualified by the 2937 'urn:ietf:params:xml:ns:xmpp-tls' namespace at depth=1 of the stream 2938 as sent by the initiating entity, until the last character of the 2939 element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' 2940 namespace at depth=1 of the stream as sent by the receiving entity). 2941 This prohibition helps to ensure proper security layer byte 2942 precision. Any such whitespace shown in the STARTTLS examples 2943 provided in this document is included only for the sake of 2944 readability. 2946 5.3.4. Order of TLS and SASL Negotiations 2948 If the initiating entity chooses to use TLS, STARTTLS negotiation 2949 MUST be completed before proceeding to SASL negotiation (Section 6); 2950 this order of negotiation is necessary to help safeguard 2951 authentication information sent during SASL negotiation, as well as 2952 to make it possible to base the use of the SASL EXTERNAL mechanism on 2953 a certificate (or other credentials) provided during prior TLS 2954 negotiation. 2956 5.3.5. TLS Renegotiation 2958 The TLS protocol allows either party in a TLS-protected channel to 2959 initiate a new handshake that establishes new cryptographic 2960 parameters (see [TLS-NEG]). The cases most commonly mentioned are: 2962 1. Refreshing encryption keys. 2964 2. Wrapping the TLS sequence number as explained in Section 6.1 of 2965 [TLS]. 2967 3. Protecting client credentials by completing server authentication 2968 first and then completing client authentication over the 2969 protected channel. 2971 Because it is relatively inexpensive to establish streams in XMPP, 2972 for the first two cases it is preferable to use an XMPP stream reset 2973 (as described under Section 4.8.3.16) instead of performing TLS 2974 renegotiation. 2976 The third case has improved security characteristics when the TLS 2977 client (which might be an XMPP server) presents credentials to the 2978 TLS server. If communicating such credentials to an unauthenticated 2979 server might leak private information, it can be appropriate to 2980 complete TLS negotiation for the purpose of server authentication and 2981 then attempt TLS renegotiation for the purpose of client 2982 authentication with the TLS server. 2984 However, the third case is sufficiently rare that XMPP entities 2985 SHOULD NOT blindly attempt TLS renegotiation. 2987 If an entity that does not support TLS renegotiation detects a 2988 renegotiation attempt, then it MUST immediately close the underlying 2989 TCP connection without returning a stream error (since the violation 2990 has occurred at the TLS layer, not the XMPP layer; see Section 13.3). 2992 If an entity that supports TLS renegotiation detects a TLS 2993 renegotiation attempt that does not use the TLS Renegotiation 2994 Extension [TLS-NEG], then it MUST immediately close the underlying 2995 TCP connection without returning a stream error (since the violation 2996 has occurred at the TLS layer, not the XMPP layer; see Section 13.3). 2998 Support for TLS renegotiation is strictly OPTIONAL. However, 2999 implementations that support TLS renegotiation MUST implement and use 3000 the TLS Renegotiation Extension [TLS-NEG]. 3002 5.3.6. TLS Extensions 3004 Either party to a stream MAY include any TLS extension during the TLS 3005 negotiation itself. This is a matter for the TLS layer, not the XMPP 3006 layer. 3008 5.4. Process 3010 5.4.1. Exchange of Stream Headers and Stream Features 3012 The initiating entity resolves the hostname of the receiving entity 3013 as specified under Section 3, opens a TCP connection to the 3014 advertised port at the resolved IP address, and sends an initial 3015 stream header to the receiving entity; if the initiating entity is 3016 capable of STARTTLS negotiation, it MUST include the 'version' 3017 attribute set to a value of at least "1.0" in the initial stream 3018 header. 3020 I: 3028 The receiving entity MUST send a response stream header to the 3029 initiating entity over the TCP connection opened by the initiating 3030 entity; if the receiving entity is capable of STARTTLS negotiation, 3031 it MUST include the 'version' attribute set to a value of at least 3032 "1.0" in the response stream header. 3034 R: element qualified by the 3047 'urn:ietf:params:xml:ns:xmpp-tls' namespace. 3049 If the receiving entity considers STARTTLS negotiation to be 3050 mandatory, the element SHOULD contain an empty 3051 child element. 3053 R: 3054 3055 3056 3057 3059 5.4.2. Initiation of STARTTLS Negotiation 3061 5.4.2.1. STARTTLS Command 3063 In order to begin the STARTTLS negotiation, the initiating entity 3064 issues the STARTTLS command (i.e., a element qualified by 3065 the 'urn:ietf:params:xml:ns:xmpp-tls' namespace) to instruct the 3066 receiving entity that it wishes to begin a STARTTLS negotiation to 3067 secure the stream. 3069 I: 3071 The receiving entity MUST reply with either a element 3072 (proceed case) or a element (failure case) qualified by 3073 the 'urn:ietf:params:xml:ns:xmpp-tls' namespace. 3075 5.4.2.2. Failure Case 3077 If the failure case occurs, the receiving entity MUST return a 3078 element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' 3079 namespace and close the XML stream. 3081 R: 3083 R: 3085 Causes for the failure case include but are not limited to: 3087 1. The initiating entity has sent a malformed STARTTLS command. 3089 2. The receiving entity did not offer the STARTTLS feature in its 3090 stream features. 3092 3. The receiving entity cannot complete STARTTLS negotiation because 3093 of an internal error. 3095 Informational Note: STARTTLS failure is not triggered by TLS 3096 errors such as bad_certificate or handshake_failure, which are 3097 generated and handled during the TLS negotiation itself as 3098 described in [TLS]. 3100 If the failure case occurs, the initiating entity MAY attempt to 3101 reconnect as explained under Section 3.3. 3103 5.4.2.3. Proceed Case 3105 If the proceed case occurs, the receiving entity MUST return a 3106 element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' 3107 namespace. 3109 R: 3111 The receiving entity MUST consider the TLS negotiation to have begun 3112 immediately after sending the closing '>' character of the 3113 element to the initiating entity. The initiating entity MUST 3114 consider the TLS negotiation to have begun immediately after 3115 receiving the closing '>' character of the element from 3116 the receiving entity. 3118 The entities now proceed to TLS negotiation as explained in the next 3119 section. 3121 5.4.3. TLS Negotiation 3123 5.4.3.1. Rules 3125 In order to complete TLS negotiation over the TCP connection, the 3126 entities MUST follow the process defined in [TLS]. 3128 The following rules apply: 3130 1. The entities MUST NOT send any further XML data until the TLS 3131 negotiation is complete. 3133 2. When using any of the mandatory-to-implement cipher suites 3134 specified under Section 13.8, the receiving entity MUST present a 3135 certificate. 3137 3. So that mutual authentication will be possible, the receiving 3138 entity SHOULD send a certificate request to the initiating entity 3139 and the initiating entity SHOULD send a certificate (if 3140 available) to the receiving entity. 3142 4. The initiating entity MUST validate the certificate to determine 3143 if the TLS negotiation will succeed; see Section 13.7.2 regarding 3144 certificate validation procedures. 3146 5. The receiving entity SHOULD choose which certificate to present 3147 based on the 'to' attribute of the initial stream header. 3149 6. Following successful TLS negotiation, all further data 3150 transmitted by either party MUST be encrypted. 3152 Security Note: See Section 13.8 regarding ciphers that MUST be 3153 supported for TLS; naturally, other ciphers MAY be supported as 3154 well. 3156 5.4.3.2. TLS Failure 3158 If the TLS negotiation results in failure, the receiving entity MUST 3159 terminate the TCP connection. 3161 The receiving entity MUST NOT send a closing tag before 3162 terminating the TCP connection, since the receiving entity and 3163 initiating entity MUST consider the original stream to be replaced 3164 upon failure of the TLS negotiation. 3166 The initiating entity MAY attempt to reconnect as explained under 3167 Section 3.3, with or without attempting TLS negotiation (in 3168 accordance with local service policy, user-configured preferences, 3169 etc.). 3171 5.4.3.3. TLS Success 3173 If the TLS negotiation is successful, then the entities MUST proceed 3174 as follows. 3176 1. The initiating entity MUST discard any information transmitted in 3177 layers above TCP that it obtained from the receiving entity in an 3178 insecure manner before TLS took effect (e.g., the receiving 3179 entity's 'from' address or the stream ID and stream features 3180 received from the receiving entity). 3182 2. The receiving entity MUST discard any information transmitted in 3183 layers above TCP that it obtained from the initiating entity in 3184 an insecure manner before TLS took effect (e.g., the initiating 3185 entity's 'from' address). 3187 3. The initiating entity MUST send a new initial stream header to 3188 the receiving entity over the encrypted connection. 3190 I: 3198 Implementation Note: The initiating entity MUST NOT send a 3199 closing tag before sending the new initial stream 3200 header, since the receiving entity and initiating entity MUST 3201 consider the original stream to be replaced upon success of the 3202 TLS negotiation. 3204 4. The receiving entity MUST respond with a new response stream 3205 header over the encrypted connection (for which it MUST generate 3206 a new stream ID instead of re-using the old stream ID). 3208 R: 3223 3224 EXTERNAL 3225 PLAIN 3226 3227 3229 6. SASL Negotiation 3231 6.1. Fundamentals 3233 XMPP includes a method for authenticating a stream by means of an 3234 XMPP-specific profile of the Simple Authentication and Security Layer 3235 protocol (see [SASL]). SASL provides a generalized method for adding 3236 authentication support to connection-based protocols, and XMPP uses 3237 an XML namespace profile of SASL that conforms to the profiling 3238 requirements of [SASL]. The XML namespace name for the SASL 3239 extension is 'urn:ietf:params:xml:ns:xmpp-sasl'. 3241 6.2. Support 3243 Support for SASL negotiation is REQUIRED in XMPP client and server 3244 implementations. 3246 6.3. Stream Negotiation Rules 3248 6.3.1. Mandatory-to-Negotiate 3250 The parties to a stream MUST consider SASL as mandatory-to-negotiate. 3252 6.3.2. Restart 3254 After SASL negotiation, the parties MUST restart the stream. 3256 6.3.3. Mechanism Preferences 3258 Any entity that will act as a SASL client or a SASL server MUST 3259 maintain an ordered list of its preferred SASL mechanisms according 3260 to the client or server, where the list is ordered according to local 3261 policy or user configuration (which SHOULD be in order of perceived 3262 strength to enable the strongest authentication possible). A server 3263 MUST offer and a client MUST try SASL mechanisms in preference order. 3264 For example, if the server offers the ordered list "PLAIN SCRAM-SHA-1 3265 GSSAPI" or "SCRAM-SHA-1 GSSAPI PLAIN" but the client's ordered list 3266 is "GSSAPI SCRAM-SHA-1", the client MUST try GSSAPI first and then 3267 SCRAM-SHA-1 but MUST never try PLAIN (since PLAIN is not on its 3268 list). 3270 6.3.4. Mechanism Offers 3272 If the receiving entity considers TLS negotiation (Section 5) to be 3273 mandatory before it will accept authentication with a particular SASL 3274 mechanism, it MUST NOT advertise that mechanism in its list of 3275 available SASL mechanisms before TLS negotiation has been completed. 3277 The receiving entity SHOULD offer the SASL EXTERNAL mechanism if both 3278 of the following conditions hold: 3280 1. During TLS negotiation the initiating entity presented a 3281 certificate that is acceptable to the receiving entity for 3282 purposes of strong identity verification in accordance with local 3283 service policies (e.g., because said certificate is unexpired, is 3284 unrevoked, and is anchored to a root trusted by the receiving 3285 entity). 3287 2. The receiving entity expects that the initiating entity will be 3288 able to authenticate and authorize as the identity provided in 3289 the certificate; in the case of a server-to-server stream, the 3290 receiving entity might have such an expectation because a DNS 3291 domain name presented in the initiating entity's certificate 3292 matches the domain referenced in the 'from' attribute of the 3293 initial stream header, where the matching rules of [TLS-CERTS] 3294 apply; in the case of a client-to-server stream, the receiving 3295 entity might have such an expectation because the bare JID 3296 presented in the initiating entity's certificate matches a user 3297 account that is registered with the server or because other 3298 information contained in the initiating entity's certificate 3299 matches that of an entity that has permission to use the server 3300 for access to an XMPP network. 3302 However, the receiving entity MAY offer the SASL EXTERNAL mechanism 3303 under other circumstances, as well. 3305 When the receiving entity offers the SASL EXTERNAL mechanism, the 3306 receiving entity SHOULD list the EXTERNAL mechanism first among its 3307 offered SASL mechanisms and the initiating entity SHOULD attempt SASL 3308 negotiation using the EXTERNAL mechanism first (this preference will 3309 tend to increase the likelihood that the parties can negotiate mutual 3310 authentication). 3312 Section 13.8 specifies SASL mechanisms that MUST be supported; 3313 naturally, other SASL mechanisms MAY be supported as well. 3315 Informational Note: Best practices for the use of SASL in the 3316 context of XMPP are described in [XEP-0175] for the ANONYMOUS 3317 mechanism and in [XEP-0178] for the EXTERNAL mechanism. 3319 6.3.5. Data Formatting 3321 The following data formatting rules apply to the SASL negotiation: 3323 1. During SASL negotiation, the entities MUST NOT send any 3324 whitespace as separators between XML elements (i.e., from the 3325 last character of the element qualified by the 3326 'urn:ietf:params:xml:ns:xmpp-sasl' namespace at depth=1 of the 3327 stream as sent by the initiating entity, until the last character 3328 of the element qualified by the 3329 'urn:ietf:params:xml:ns:xmpp-sasl' namespace at depth=1 of the 3330 stream as sent by the receiving entity). This prohibition helps 3331 to ensure proper security layer byte precision. Any such 3332 whitespace shown in the SASL examples provided in this document 3333 is included only for the sake of readability. 3335 2. Any XML character data contained within the XML elements MUST be 3336 encoded using base64, where the encoding adheres to the 3337 definition in Section 4 of [BASE64] and where the padding bits 3338 are set to zero. 3340 3. As formally specified in the XML schema for the 3341 'urn:ietf:params:xml:ns:xmpp-sasl' namespace under Appendix A.4, 3342 the receiving entity MAY include one or more application-specific 3343 child elements inside the element to provide 3344 information that might be needed by the initiating entity in 3345 order to complete successful SASL negotiation using one or more 3346 of the offered mechanisms; however, the syntax and semantics of 3347 all such elements are out of scope for this specification. 3349 6.3.6. Security Layers 3351 Upon successful SASL negotiation that involves negotiation of a 3352 security layer, both the initiating entity and the receiving MUST 3353 discard any application-layer state (i.e, state from the XMPP layer, 3354 excluding state from the TLS negotiation or SASL negotiation). 3356 6.3.7. Simple User Name 3358 Some SASL mechanisms (e.g., CRAM-MD5, DIGEST-MD5, and SCRAM) specify 3359 that the authentication identity used in the context of such 3360 mechanisms is a "simple user name" combined with a password (see 3361 Section 2 of [SASL] as well as [SASLPREP]). The exact form of the 3362 simple user name in any particular mechanism or deployment thereof is 3363 a local matter, and a simple user name does not necessarily map to an 3364 application identifier such as a JID or JID component (e.g., a 3365 localpart). However, in the absence of local information provided by 3366 the server, an XMPP client SHOULD assume that the authentication 3367 identity for such a SASL mechanism is the combination of a user name 3368 and password, where the simple user name is the localpart of the 3369 user's JID. 3371 6.3.8. Authorization Identity 3373 An authorization identity is an optional identity specified by the 3374 initiating entity; in client-to-server streams it is typically used 3375 by an administrator to perform some management task on behalf of 3376 another user, whereas in server-to-server streams it is typically 3377 used to specify a particular application at a service (e.g., a multi- 3378 user chat server at conference.example.com that is hosted by the 3379 example.com XMPP service). If the initiating entity wishes to act on 3380 behalf of another entity and the selected SASL mechanism supports 3381 transmission of an authorization identity, the initiating entity 3382 SHOULD provide an authorization identity during SASL negotiation. If 3383 the initiating entity does not wish to act on behalf of another 3384 entity, it SHOULD NOT provide an authorization identity. 3386 In the case of client-to-server communication, the value of an 3387 authorization identity MUST be a bare JID () 3388 and not a full JID (). 3390 In the case of server-to-server communication, the value of an 3391 authorization identity MUST be a domainpart only (). 3393 If the initiating entity provides an authorization identity during 3394 SASL negotiation, the receiving entity is responsible for verifying 3395 that the initiating entity is in fact allowed to assume the specified 3396 authorization identity; if not, the receiving entity MUST return an 3397 SASL error as described under Section 6.5.6. 3399 6.3.9. Realms 3401 The receiving entity MAY include a realm when negotiating certain 3402 SASL mechanisms. If the receiving entity does not communicate a 3403 realm, the initiating entity MUST NOT assume that any realm exists. 3404 The realm MUST be used only for the purpose of authentication; in 3405 particular, an initiating entity MUST NOT attempt to derive an XMPP 3406 hostname from the realm information provided by the receiving entity. 3408 6.3.10. Round Trips 3410 [SASL] specifies that a using protocol such as XMPP can define two 3411 methods by which the protocol can save round trips where allowed for 3412 the SASL mechanism: 3414 1. When the SASL client (the XMPP "initiating entity") requests an 3415 authentication exchange, it can include "initial response" data 3416 with its request if appropriate for the SASL mechanism in use. 3417 In XMPP this is done by including the initial response as the XML 3418 character data of the element. 3420 2. At the end of the authentication exchange, the SASL server (the 3421 XMPP "receiving entity") can include "additional data with 3422 success" if appropriate for the SASL mechanism in use. In XMPP 3423 this is done by including the additional data as the XML 3424 character data of the element. 3426 For the sake of protocol efficiency, it is REQUIRED for clients and 3427 servers to support these methods and RECOMMENDED to use them; however 3428 clients and servers MUST support the less efficient modes as well. 3430 6.4. Process 3432 The process for SASL negotiation is as follows. 3434 6.4.1. Exchange of Stream Headers and Stream Features 3436 If SASL negotiation follows successful STARTTLS negotiation 3437 (Section 5), then the SASL negotiation occurs over the encrypted 3438 stream that has already been negotiated. If not, the initiating 3439 entity resolves the hostname of the receiving entity as specified 3440 under Section 3, opens a TCP connection to the advertised port at the 3441 resolved IP address, and sends an initial stream header to the 3442 receiving entity; if the initiating entity is capable of SASL 3443 negotiation, it MUST include the 'version' attribute set to a value 3444 of at least "1.0" in the initial stream header. 3446 I: 3454 The receiving entity MUST send a response stream header to the 3455 initiating entity (for which it MUST generate a new stream ID instead 3456 of re-using the old stream ID); if the receiving entity is capable of 3457 SASL negotiation, it MUST include the 'version' attribute set to a 3458 value of at least "1.0" in the response stream header. 3460 R: element qualified by the 3473 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; typically the only case 3474 in which support for SASL negotiation would not be advertised here is 3475 before STARTTLS negotiation when TLS is required. 3477 The element MUST contain one child element 3478 for each authentication mechanism the receiving entity offers to the 3479 initiating entity. The order of elements in the XML 3480 indicates the preference order of the SASL mechanisms according to 3481 the receiving entity; however the initiating entity MUST maintain its 3482 own preference order independent of the preference order of the 3483 receiving entity. 3485 R: 3486 3487 EXTERNAL 3488 PLAIN 3489 3490 3492 6.4.2. Initiation 3494 In order to begin the SASL negotiation, the initiating entity sends 3495 an element qualified by the 3496 'urn:ietf:params:xml:ns:xmpp-sasl' namespace and includes an 3497 appropriate value for the 'mechanism' attribute, thus starting the 3498 handshake for that particular authentication mechanism. This element 3499 MAY contain XML character data (in SASL terminology, the "initial 3500 response") if the mechanism supports or requires it; if the 3501 initiating entity needs to send a zero-length initial response, it 3502 MUST transmit the response as a single equals sign character ("="), 3503 which indicates that the response is present but contains no data. 3505 I: AGp1bGlldAByMG0zMG15cjBtMzA= 3508 If the initiating entity subsequently sends another element 3509 (even if the ongoing authentication handshake has not yet completed), 3510 the server SHOULD discard the ongoing handshake and begin a new 3511 handshake for the subsequently requested SASL mechanism. 3513 6.4.3. Challenge-Response Sequence 3515 If necessary, the receiving entity challenges the initiating entity 3516 by sending a element qualified by the 3517 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY 3518 contain XML character data (which MUST be generated in accordance 3519 with the definition of the SASL mechanism chosen by the initiating 3520 entity). 3522 The initiating entity responds to the challenge by sending a 3523 element qualified by the 3524 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY 3525 contain XML character data (which MUST be generated in accordance 3526 with the definition of the SASL mechanism chosen by the initiating 3527 entity). 3529 If necessary, the receiving entity sends more challenges and the 3530 initiating entity sends more responses. 3532 This series of challenge/response pairs continues until one of three 3533 things happens: 3535 o The initiating entity aborts the handshake for this authentication 3536 mechanism. 3537 o The receiving entity reports failure of the handshake. 3538 o The receiving entity reports success of the handshake. 3540 These scenarios are described in the following sections. 3542 6.4.4. Abort 3544 The initiating entity aborts the handshake for this authentication 3545 mechanism by sending an element qualified by the 3546 'urn:ietf:params:xml:ns:xmpp-sasl' namespace. 3548 I: 3550 Upon receiving an element, the receiving entity MUST return 3551 a element qualified by the 3552 'urn:ietf:params:xml:ns:xmpp-sasl' namespace and containing an 3553 child element. 3555 R: 3556 3557 3559 6.4.5. SASL Failure 3561 The receiving entity reports failure of the handshake for this 3562 authentication mechanism by sending a element qualified by 3563 the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace (the particular 3564 cause of failure MUST be communicated in an appropriate child element 3565 of the element as defined under Section 6.5). 3567 R: 3568 3569 3571 Where appropriate for the chosen SASL mechanism, the receiving entity 3572 SHOULD allow a configurable but reasonable number of retries (at 3573 least 2 and no more than 5); this enables the initiating entity 3574 (e.g., an end-user client) to tolerate incorrectly-provided 3575 credentials (e.g., a mistyped password) without being forced to 3576 reconnect. 3578 If the initiating entity attempts a reasonable number of retries with 3579 the same SASL mechanism and all attempts fail, it MAY fall back to 3580 the next mechanism in its ordered list by sending a new 3581 request to the receiving entity, this starting a new handshake for 3582 that authentication mechanism. If all handshakes fail and there are 3583 no remaining mechanisms in the initiating entity's list of supported 3584 and acceptable mechanisms, the initiating entity SHOULD simply close 3585 the stream. 3587 If the initiating entity exceeds the number of retries, the receiving 3588 entity MUST return a stream error, which SHOULD be (although some existing implementations send instead). 3592 Implementation Note: For server-to-server streams, if the 3593 receiving entity cannot offer the SASL EXTERNAL mechanism or any 3594 other SASL mechanism based on the security context established 3595 during TLS negotiation, the receiving entity MAY attempt to 3596 complete weak identity verification using the Server Dialback 3597 protocol [XEP-0220]; however, if according to local service 3598 policies weak identity verification is insufficient then the 3599 receiving entity SHOULD instead close the stream with a stream error. 3602 6.4.6. SASL Success 3604 The receiving entity reports success of the handshake by sending a 3605 element qualified by the 3606 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY 3607 contain XML character data (in SASL terminology, "additional data 3608 with success") if the chosen SASL mechanism supports or requires it; 3609 if the receiving entity needs to send additional data of zero length, 3610 it MUST transmit the data as a single equals sign character ("="). 3612 R: 3614 Informational Note: The authorization identity communicated during 3615 SASL negotiation is used to determine the canonical address for 3616 the initiating client according to the receiving server, as 3617 described under Section 4.2.6. 3619 Upon receiving the element, the initiating entity MUST 3620 initiate a new stream over the existing TCP connection by sending a 3621 new initial stream header to the receiving entity. 3623 I: tag before sending the new initial stream header, since 3633 the receiving entity and initiating entity MUST consider the 3634 original stream to be replaced upon sending or receiving the 3635 element. 3637 Upon receiving the new initial stream header from the initiating 3638 entity, the receiving entity MUST respond by sending a new response 3639 stream header to the initiating entity (for which it MUST generate a 3640 new stream ID instead of re-using the old stream ID). 3642 R: 3651 The receiving entity MUST also send stream features, containing any 3652 further available features or containing no features (via an empty 3653 element). 3655 R: 3656 3657 3659 6.5. SASL Errors 3661 The syntax of SASL errors is as follows, where "defined-condition" is 3662 one of the SASL-related error conditions defined in the following 3663 sections and XML data shown within the square brackets '[' and ']' is 3664 OPTIONAL. 3666 3667 3668 [ 3669 OPTIONAL descriptive text 3670 ] 3671 3673 Inclusion of a defined condition is REQUIRED. 3675 Inclusion of the element is OPTIONAL, and can be used to 3676 provide application-specific information about the error condition, 3677 which information MAY be displayed to a human but only as a 3678 supplement to the defined condition. 3680 6.5.1. aborted 3682 The receiving entity acknowledges an element sent by the 3683 initiating entity; sent in reply to the element. 3685 I: 3687 R: 3688 3689 3691 6.5.2. account-disabled 3693 The account of the initiating entity has been temporarily disabled; 3694 sent in reply to an element (with or without initial response 3695 data) or a element. 3697 I: AGp1bGlldAByMG0zMG15cjBtMzA= 3700 R: 3701 3702 Call 212-555-1212 for assistance. 3703 3705 6.5.3. credentials-expired 3707 The authentication failed because the initiating entity provided 3708 credentials that have expired; sent in reply to a element 3709 or an element with initial response data. 3711 I: 3712 [ ... ] 3713 3715 R: 3716 3717 3719 6.5.4. encryption-required 3721 The mechanism requested by the initiating entity cannot be used 3722 unless the underlying stream is encrypted; sent in reply to an 3723 element (with or without initial response data). 3725 I: AGp1bGlldAByMG0zMG15cjBtMzA= 3728 R: 3729 3730 3732 6.5.5. incorrect-encoding 3734 The data provided by the initiating entity could not be processed 3735 because the [BASE64] encoding is incorrect (e.g., because the 3736 encoding does not adhere to the definition in Section 4 of [BASE64]); 3737 sent in reply to a element or an element with 3738 initial response data. 3740 I: [ ... ] 3743 R: 3744 3746 3748 6.5.6. invalid-authzid 3750 The authzid provided by the initiating entity is invalid, either 3751 because it is incorrectly formatted or because the initiating entity 3752 does not have permissions to authorize that ID; sent in reply to a 3753 element or an element with initial response data. 3755 I: 3756 [ ... ] 3757 3759 R: 3760 3761 3763 6.5.7. invalid-mechanism 3765 The initiating entity did not provide a mechanism or requested a 3766 mechanism that is not supported by the receiving entity; sent in 3767 reply to an element. 3769 I: 3772 R: 3773 3774 3776 6.5.8. malformed-request 3778 The request is malformed (e.g., the element includes initial 3779 response data but the mechanism does not allow that, or the data sent 3780 violates the syntax for the specified SASL mechanism); sent in reply 3781 to an , , , or element. 3783 (In the following example, the XML character data of the 3784 element contains more than 255 UTF-8-encoded Unicode characters and 3785 therefore violates the "token" production for the SASL ANONYMOUS 3786 mechanism as specified in [ANONYMOUS].) 3788 I: [ ... some-long-token ... ] 3791 R: 3792 3793 3795 6.5.9. mechanism-too-weak 3797 The mechanism requested by the initiating entity is weaker than 3798 server policy permits for that initiating entity; sent in reply to an 3799 element (with or without initial response data). 3801 I: AGp1bGlldAByMG0zMG15cjBtMzA= 3804 R: 3805 3806 3808 6.5.10. not-authorized 3810 The authentication failed because the initiating entity did not 3811 provide proper credentials or the receiving entity has detected an 3812 attack but wishes to disclose as little information as possible to 3813 the attacker; sent in reply to a element or an 3814 element with initial response data. 3816 I: 3817 [ ... ] 3818 3820 R: 3821 3822 3824 Security Note: This error condition includes but is not limited to 3825 the case of incorrect credentials or a nonexistent username. In 3826 order to discourage directory harvest attacks, no differentiation 3827 is made between incorrect credentials and a nonexistent username. 3829 6.5.11. temporary-auth-failure 3831 The authentication failed because of a temporary error condition 3832 within the receiving entity, and it is advisable for the initiating 3833 entity to try again later; sent in reply to an element or a 3834 element. 3836 I: 3837 [ ... ] 3838 3840 R: 3841 3842 3844 6.5.12. transition-needed 3846 The authentication failed because the mechanism cannot be used until 3847 the initiating entity provides (for one time only) a plaintext 3848 password so that the receiving entity can build a hashed password for 3849 use in future authentication attempts; sent in reply to an 3850 element with or without initial response data. 3852 I: [ ... ] 3855 R: 3856 3857 3859 Security Note: An XMPP client MUST treat a 3860 SASL error with extreme caution, SHOULD NOT provide a plaintext 3861 password over an XML stream that is not encrypted via Transport 3862 Layer Security, and MUST warn a human user before allowing the 3863 user to provide a plaintext password over an unencrypted 3864 connection. Even so, the attacker could be located on the server, 3865 attempting to capture the plaintext password. 3867 6.6. SASL Definition 3869 The profiling requirements of [SASL] require that the following 3870 information be supplied by the definition of a using protocol. 3872 service name: "xmpp" 3873 initiation sequence: After the initiating entity provides an opening 3874 XML stream header and the receiving entity replies in kind, the 3875 receiving entity provides a list of acceptable authentication 3876 methods. The initiating entity chooses one method from the list 3877 and sends it to the receiving entity as the value of the 3878 'mechanism' attribute possessed by an element, optionally 3879 including an initial response to avoid a round trip. 3880 exchange sequence: Challenges and responses are carried through the 3881 exchange of elements from receiving entity to 3882 initiating entity and elements from initiating entity 3883 to receiving entity. The receiving entity reports failure by 3884 sending a element and success by sending a 3885 element; the initiating entity aborts the exchange by sending an 3886 element. Upon successful negotiation, both sides 3887 consider the original XML stream to be closed and new stream 3888 headers are sent by both entities. 3890 security layer negotiation: The security layer takes effect 3891 immediately after sending the closing '>' character of the 3892 element for the receiving entity, and immediately after 3893 receiving the closing '>' character of the element for 3894 the initiating entity. The order of layers is first [TCP], then 3895 [TLS], then [SASL], then XMPP. 3896 use of the authorization identity: The authorization identity can be 3897 used in XMPP to denote the non-default of a 3898 client; an empty string is equivalent to an absent authorization 3899 identity. 3901 7. Resource Binding 3903 7.1. Fundamentals 3905 After a client authenticates with a server, it MUST bind a specific 3906 resource to the stream so that the server can properly address the 3907 client. That is, there MUST be an XMPP resource associated with the 3908 bare JID () of the client, so that the address 3909 for use over that stream is a full JID of the form 3910 (including the resourcepart). This 3911 ensures that the server can deliver XML stanzas to and receive XML 3912 stanzas from the client in relation to entities other than the server 3913 itself or the client's account, as explained under Section 10 (the 3914 client could exchange stanzas with the server itself or the client's 3915 account before binding a resource since the full JID is needed only 3916 for addressing outside the context of the stream negotiated between 3917 the client and the server, but this is not commonly done). 3919 After a client has bound a resource to the stream, it is referred to 3920 as a "connected resource". A server SHOULD allow an entity to 3921 maintain multiple connected resources simultaneously, where each 3922 connected resource is associated with a distinct XML stream and 3923 differentiated from the other connected resources by a distinct 3924 resourcepart. 3926 Security Note: A server SHOULD enable the administrator of an XMPP 3927 service to limit the number of connected resources in order to 3928 prevent certain denial of service attacks as described under 3929 Section 13.12. 3931 If, before completing the resource binding step, the client attempts 3932 to send an XML stanza to an entity other than the server itself or 3933 the client's account, the server MUST NOT process the stanza and MUST 3934 return a stream error to the client. 3936 The XML namespace name for the resource binding extension is 3937 'urn:ietf:params:xml:ns:xmpp-bind'. 3939 7.2. Support 3941 Support for resource binding is REQUIRED in XMPP client and server 3942 implementations. 3944 7.3. Stream Negotiation Rules 3946 7.3.1. Mandatory-to-Negotiate 3948 The parties to a stream MUST consider resource binding as mandatory- 3949 to-negotiate. 3951 7.3.2. Restart 3953 After resource binding, the parties MUST NOT restart the stream. 3955 7.4. Advertising Support 3957 Upon sending a new response stream header to the client after 3958 successful SASL negotiation, the server MUST include a 3959 element qualified by the 'urn:ietf:params:xml:ns:xmpp-bind' namespace 3960 in the stream features it presents to the client. 3962 The server MUST NOT include the resource binding stream feature until 3963 after the client has authenticated, typically by means of successful 3964 SASL negotiation. 3966 S: 3975 S: 3976 3977 3979 Upon being informed that resource binding is mandatory, the client 3980 MUST bind a resource to the stream as described in the following 3981 sections. 3983 7.5. Generation of Resource Identifiers 3985 A resourcepart MUST at a minimum be unique among the connected 3986 resources for that . Enforcement of this 3987 policy is the responsibility of the server. 3989 Security Note: A resourcepart can be security-critical. For 3990 example, if a malicious entity can guess a client's resourcepart 3991 then it might be able to determine if the client (and therefore 3992 the controlling principal) is online or offline, thus resulting in 3993 a presence leak as described under Section 13.10.2. To prevent 3994 that possibility, a client can either (1) generate a random 3995 resourcepart on its own or (2) ask the server to generate a 3996 resourcepart on its behalf, which MUST be random (see [RANDOM]). 3997 One method for ensuring that the resourcepart is random is to 3998 generate a Universally Unique Identifier (UUID) as specified in 3999 [UUID]. 4001 7.6. Server-Generated Resource Identifier 4003 A server MUST be able to generate an XMPP resourcepart on behalf of a 4004 client. 4006 7.6.1. Success Case 4008 A client requests a server-generated resourcepart by sending an IQ 4009 stanza of type "set" (see Section 8.2.3) containing an empty 4010 element qualified by the 'urn:ietf:params:xml:ns:xmpp-bind' 4011 namespace. 4013 C: 4014 4015 4017 Once the server has generated an XMPP resourcepart for the client, it 4018 MUST return an IQ stanza of type "result" to the client, which MUST 4019 include a child element that specifies the full JID for the 4020 connected resource as determined by the server. 4022 S: 4023 4024 4025 juliet@im.example.com/4db06f06-1ea4-11dc-aca3-000bcd821bfb 4026 4027 4028 4030 7.6.2. Error Cases 4032 When a client asks the server to generate a resourcepart during 4033 resource binding, the following stanza error conditions are defined 4034 (and others not specified here are possible; see under Section 8.3): 4036 o The account has reached a limit on the number of simultaneous 4037 connected resources allowed. 4038 o The client is otherwise not allowed to bind a resource to the 4039 stream. 4041 7.6.2.1. Resource Constraint 4043 If the account has reached a limit on the number of simultaneous 4044 connected resources allowed, the server MUST return a stanza error. 4047 S: 4048 4049 4051 4052 4054 7.6.2.2. Not Allowed 4056 If the client is otherwise not allowed to bind a resource to the 4057 stream, the server MUST return a stanza error. 4059 S: 4060 4061 4063 4064 4066 7.7. Client-Submitted Resource Identifier 4068 Instead of asking the server to generate a resourcepart on its 4069 behalf, a client MAY attempt to submit a resourcepart that it has 4070 generated or that the controlling user has provided. 4072 7.7.1. Success Case 4074 A client asks its server to accept a client-submitted resourcepart by 4075 sending an IQ stanza of type "set" containing a element with 4076 a child element containing non-zero-length XML character 4077 data. 4079 C: 4080 4081 balcony 4082 4083 4085 The server SHOULD accept the client-submitted resourcepart. It does 4086 so by returning an IQ stanza of type "result" to the client, 4087 including a child element that specifies the full JID for the 4088 connected resource and contains without modification the client- 4089 submitted text. 4091 S: 4092 4093 juliet@im.example.com/balcony 4094 4095 4097 Alternatively, in accordance with local service policies the server 4098 MAY refuse the client-submitted resourcepart and override it with a 4099 resourcepart that the server generates. 4101 S: 4102 4103 4104 juliet@im.example.com/balcony 4db06f06-1ea4-11dc-aca3-000bcd821bfb 4105 4106 4107 4109 7.7.2. Error Cases 4111 When a client attempts to submit its own XMPP resourcepart during 4112 resource binding, the following stanza error conditions are defined 4113 in addition to those described under Section 7.6.2 (and others not 4114 specified here are possible; see under Section 8.3): 4116 o The provided resourcepart cannot be processed by the server. 4117 o The provided resourcepart is already in use. 4119 7.7.2.1. Bad Request 4121 If the provided resourcepart cannot be processed by the server (e.g. 4122 because it is of zero length or because it is not in accordance with 4123 the Resourceprep profile of stringprep specified in [XMPP-ADDR]), the 4124 server MAY return a stanza error (but SHOULD instead 4125 apply the Resourceprep profile or otherwise process the resourcepart 4126 so that it is in conformance). 4128 S: 4129 4130 4131 4132 4134 7.7.2.2. Conflict 4136 If there is a currently-connected client whose session has the 4137 resourcepart being requested by the newly-connecting client, the 4138 server MUST do one of the following (which of these the server does 4139 is a matter for implementation or local service policy, although 4140 suggestions are provided below). 4142 1. Override the resourcepart provided by the newly-connecting client 4143 with a server-generated resourcepart. 4145 This behavior is encouraged, because it simplifies the resource 4146 binding process for client implementations. 4148 2. Disallow the resource binding attempt of the newly-connecting 4149 client and maintain the session of the currently-connected 4150 client. 4152 This behavior is neither encouraged nor discouraged, despite the 4153 fact that it was implicitly encouraged in RFC 3920; however, note 4154 that handling of the error described below is 4155 unevenly supported among existing client implementations, which 4156 often treat it as an authentication error and have been observed 4157 to discard cached credentials when receiving it. 4159 3. Terminate the session of the currently-connected client and allow 4160 the resource binding attempt of the newly-connecting client. 4162 Although this was the traditional behavior of early XMPP server 4163 implementations, it is now discouraged because it can lead to a 4164 neverending cycle of two clients effectively disconnecting each 4165 other; however, note that this behavior can be appropriate in 4166 some deployment scenarios or if the server knows that the 4167 currently-connected client has a dead connection or broken stream 4168 as described under Section 4.5. 4170 If the server follows behavior #1, it returns an stanza of type 4171 "result" to the newly-connecting client, where the child of 4172 the element contains XML character data that indicates the 4173 full JID of the client, including the resourcepart that was generated 4174 by the server. 4176 S: 4177 4178 4179 juliet@im.example.com/balcony 4db06f06-1ea4-11dc-aca3-000bcd821bfb 4180 4181 4182 4184 If the server follows behavior #2, it sends a stanza 4185 error in response to the resource binding attempt of the newly- 4186 connecting client but maintains the XML stream so that the newly- 4187 connecting client has an opportunity to negotiate a non-conflicting 4188 resourcepart (i.e., the newly-connecting client needs to choose a 4189 different resourcepart before making another attempt to bind a 4190 resource). 4192 S: 4193 4194 4195 4196 4198 If the server follows behavior #3, it sends a stream 4199 error to the currently-connected client and returns an IQ stanza of 4200 type "result" (indicating success) in response to the resource 4201 binding attempt of the newly-connecting client. 4203 S: 4204 4205 4206 juliet@im.example.com/balcony 4207 4208 4209 4211 7.7.3. Retries 4213 If an error occurs when a client submits a resourcepart, the server 4214 SHOULD allow a configurable but reasonable number of retries (at 4215 least 5 and no more than 10); this enables the client to tolerate 4216 incorrectly-provided resourceparts (e.g., bad data formats or 4217 duplicate text strings) without being forced to reconnect. 4219 After the client has reached the retry limit, the server MUST return 4220 a stream error to the client. 4222 8. XML Stanzas 4224 After a client and a server (or two servers) have completed stream 4225 negotiation, either party can send XML stanzas. Three kinds of XML 4226 stanza are defined for the 'jabber:client' and 'jabber:server' 4227 namespaces: , , and . In addition, there 4228 are five common attributes for these stanza types. These common 4229 attributes, as well as the basic semantics of the three stanza types, 4230 are defined in this specification; more detailed information 4231 regarding the syntax of XML stanzas for instant messaging and 4232 presence applications is provided in [XMPP-IM], and for other 4233 applications in the relevant XMPP extension specifications. 4235 Support for the XML stanza syntax and semantics defined in this 4236 specification is REQUIRED in XMPP client and server implementations. 4238 Security Note: A server MUST NOT process a partial stanza and MUST 4239 NOT attach meaning to the transmission timing of any part of a 4240 stanza (before receipt of the close tag). 4242 8.1. Common Attributes 4244 The following five attributes are common to message, presence, and IQ 4245 stanzas. 4247 8.1.1. to 4249 The 'to' attribute specifies the JID of the intended recipient for 4250 the stanza. 4252 4253 Art thou not Romeo, and a Montague? 4254 4256 For information about server processing of inbound and outbound XML 4257 stanzas based on the 'to' address, refer to Section 10. 4259 8.1.1.1. Client-to-Server Streams 4261 The following rules apply to inclusion of the 'to' attribute in 4262 stanzas sent from the client to the server over an XML stream 4263 qualified by the 'jabber:client' namespace. 4265 1. A stanza with a specific intended recipient (e.g., a conversation 4266 partner, a remote service, the server itself, even another 4267 resource associated with the user's bare JID) MUST possess a 'to' 4268 attribute whose value is an XMPP address. 4270 2. A stanza sent from a client to a server for direct processing by 4271 the server as described in [XMPP-IM] for rosters (e.g., presence 4272 sent to the server for broadcasting to other entities) MUST NOT 4273 possess a 'to' attribute. 4275 The following rules apply to inclusion of the 'to' attribute in 4276 stanzas sent from the server to the client over an XML stream 4277 qualified by the 'jabber:client' namespace. 4279 1. If the server has received the stanza from another connected 4280 client or from another server, the server MUST NOT modify the 4281 'to' address before delivering the stanza to the client. 4283 2. If the server has itself generated the stanza (e.g., a response 4284 to an IQ stanza of type "get" or "set", even if the stanza did 4285 not include a 'to' address), the stanza MAY include a 'to' 4286 address, which MUST be the full JID of the client; however, if 4287 the stanza does not include a 'to' address then the client MUST 4288 treat it as if the 'to' address were included with a value of the 4289 client's full JID. 4291 Implementation Note: It is the server's responsibility to deliver 4292 only stanzas that are addressed to the client's full JID or the 4293 user's bare JID; thus there is no need for the client to check the 4294 'to' address of incoming stanzas. However, if the client does 4295 check the 'to' address then it is suggested to check at most the 4296 bare JID portion (not the full JID), since the 'to' address might 4297 be the user's bare JID, the client's current full JID, or even a 4298 full JID with a different resourcepart (e.g., in the case of so- 4299 called "offline messages" as described in [XEP-0160]). 4301 8.1.1.2. Server-to-Server Streams 4303 The following rules apply to inclusion of the 'to' attribute in the 4304 context of XML streams qualified by the 'jabber:server' namespace 4305 (i.e., server-to-server streams). 4307 1. A stanza MUST possess a 'to' attribute whose value is an XMPP 4308 address; if a server receives a stanza that does not meet this 4309 restriction, it MUST generate an stream 4310 error. 4312 2. The domainpart of the JID contained in the stanza's 'to' 4313 attribute MUST match the hostname of the receiving server (or any 4314 validated domain thereof) as communicated via SASL negotiation 4315 (see Section 6), Server Dialback (see [XEP-0220]), or similar 4316 means; if a server receives a stanza that does not meet this 4317 restriction, it MUST generate a or 4318 stream error. 4320 8.1.2. from 4322 The 'from' attribute specifies the JID of the sender. 4324 4326 Art thou not Romeo, and a Montague? 4327 4329 8.1.2.1. Client-to-Server Streams 4331 The following rules apply to the 'from' attribute in the context of 4332 XML streams qualified by the 'jabber:client' namespace (i.e., client- 4333 to-server streams). 4335 1. When the server receives an XML stanza from a client, the server 4336 MUST add a 'from' attribute to the stanza or override the 'from' 4337 attribute specified by the client, where the value of the 'from' 4338 attribute is the full JID () 4339 determined by the server for the connected resource that 4340 generated the stanza (see Section 4.2.6), or the bare JID 4341 () in the case of subscription-related 4342 presence stanzas (see [XMPP-IM]). 4344 2. When the server generates a stanza from the server itself for 4345 delivery to the client, the stanza MUST include a 'from' 4346 attribute whose value is the bare JID (i.e., ) of the 4347 server as agreed upon during stream negotiation (e.g., based on 4348 the 'to' attribute of the initial stream header). 4350 3. When the server generates a stanza from the server for delivery 4351 to the client on behalf of the account of the connected client 4352 (e.g., in the context of data storage services provided by the 4353 server on behalf of the client), the stanza MUST either (a) not 4354 include a 'from' attribute or (b) include a 'from' attribute 4355 whose value is the account's bare JID (). 4357 4. A server MUST NOT send to the client a stanza without a 'from' 4358 attribute if the stanza was not generated by the server (e.g., if 4359 it was generated by another client or another server); therefore, 4360 when a client receives a stanza that does not include a 'from' 4361 attribute, it MUST assume that the stanza is from the user's 4362 account on the server. 4364 8.1.2.2. Server-to-Server Streams 4366 The following rules apply to the 'from' attribute in the context of 4367 XML streams qualified by the 'jabber:server' namespace (i.e., server- 4368 to-server streams). 4370 1. A stanza MUST possess a 'from' attribute whose value is an XMPP 4371 address; if a server receives a stanza that does not meet this 4372 restriction, it MUST generate an stream 4373 error. 4375 2. The domainpart of the JID contained in the stanza's 'from' 4376 attribute MUST match the hostname of the sending server (or any 4377 validated domain thereof) as communicated via SASL negotiation 4378 (see Section 6), Server Dialback (see [XEP-0220]), or similar 4379 means; if a server receives a stanza that does not meet this 4380 restriction, it MUST generate an stream error. 4382 Enforcement of these rules helps to prevent certain denial of service 4383 attacks as described under Section 13.12. 4385 8.1.3. id 4387 The 'id' attribute is used by the entity that generates a stanza 4388 ("the originating entity") to track any response or error stanza that 4389 it might receive in relation to the generated stanza from another 4390 entity (such as an intermediate server or the intended recipient). 4392 It is up to the originating entity whether the value of the 'id' 4393 attribute will be unique only within its current stream or unique 4394 globally. 4396 For and stanzas, it is RECOMMENDED for the 4397 originating entity to include an 'id' attribute; for stanzas, 4398 it is REQUIRED. 4400 If the generated stanza includes an 'id' attribute then it is 4401 REQUIRED for the response or error stanza to also include an 'id' 4402 attribute, where the value of the 'id' attribute MUST match that of 4403 the generated stanza. 4405 The semantics of IQ stanzas impose additional restrictions; see 4406 Section 8.2.3. 4408 8.1.4. type 4410 The 'type' attribute specifies the purpose or context of the message, 4411 presence, or IQ stanza. The particular allowable values for the 4412 'type' attribute vary depending on whether the stanza is a message, 4413 presence, or IQ stanza. The defined values for message and presence 4414 stanzas are specific to instant messaging and presence applications 4415 and therefore are defined in [XMPP-IM], whereas the values for IQ 4416 stanzas specify the role of an IQ stanza in a structured request- 4417 response exchange and therefore are specified under Section 8.2.3. 4418 The only 'type' value common to all three stanzas is "error"; see 4419 Section 8.3. 4421 8.1.5. xml:lang 4423 A stanza SHOULD possess an 'xml:lang' attribute (as defined in 4424 Section 2.12 of [XML]) if the stanza contains XML character data that 4425 is intended to be presented to a human user (as explained in 4426 [CHARSETS], "internationalization is for humans"). The value of the 4427 'xml:lang' attribute specifies the default language of any such 4428 human-readable XML character data. 4430 4431 dnd 4432 Wooing Juliet 4433 4435 The value of the 'xml:lang' attribute MAY be overridden by the 'xml: 4436 lang' attribute of a specific child element. 4438 4439 dnd 4440 Wooing Juliet 4441 Dvořím se Julii 4442 4450 dnd 4451 Wooing Juliet 4452 4454 S: 4457 dnd 4458 Wooing Juliet 4459 4461 If an inbound stanza received by a client or server does not possess 4462 an 'xml:lang' attribute, an implementation MUST assume that the 4463 default language is that specified for the stream as defined under 4464 Section 4.6.4. 4466 The value of the 'xml:lang' attribute MUST conform to the NMTOKEN 4467 datatype (as defined in Section 2.3 of [XML]) and MUST conform to the 4468 format defined in [LANGTAGS]. 4470 A server MUST NOT modify or delete 'xml:lang' attributes on stanzas 4471 it receives from other entities. 4473 8.2. Basic Semantics 4475 8.2.1. Message Semantics 4477 The stanza can be seen as a "push" mechanism whereby one 4478 entity pushes information to another entity, similar to the 4479 communications that occur in a system such as email. All message 4480 stanzas SHOULD possess a 'to' attribute that specifies the intended 4481 recipient of the message; upon receiving such a stanza, a server 4482 SHOULD route or deliver it to the intended recipient (see Section 10 4483 for general routing and delivery rules related to XML stanzas). 4485 8.2.2. Presence Semantics 4487 The stanza can be seen as a specialized broadcast or 4488 "publish-subscribe" mechanism, whereby multiple entities receive 4489 information (in this case, network availability information) about an 4490 entity to which they have subscribed. In general, a publishing 4491 entity (client) SHOULD send a presence stanza with no 'to' attribute, 4492 in which case the server to which the entity is connected SHOULD 4493 broadcast that stanza to all subscribed entities. However, a 4494 publishing entity MAY also send a presence stanza with a 'to' 4495 attribute, in which case the server SHOULD route or deliver that 4496 stanza to the intended recipient. See Section 10 for general routing 4497 and delivery rules related to XML stanzas, and [XMPP-IM] for rules 4498 specific to presence applications. 4500 8.2.3. IQ Semantics 4502 Info/Query, or IQ, is a request-response mechanism, similar in some 4503 ways to the Hypertext Transfer Protocol [HTTP]. The semantics of IQ 4504 enable an entity to make a request of, and receive a response from, 4505 another entity. The data content of the request and response is 4506 defined by the schema or other structural definition associated with 4507 the XML namespace that qualifies the direct child element of the IQ 4508 element (see Section 8.4), and the interaction is tracked by the 4509 requesting entity through use of the 'id' attribute. Thus, IQ 4510 interactions follow a common pattern of structured data exchange such 4511 as get/result or set/result (although an error can be returned in 4512 reply to a request if appropriate): 4514 Requesting Responding 4515 Entity Entity 4516 ---------- ---------- 4517 | | 4518 | | 4519 | [ ... payload ... ] | 4520 | | 4521 | -------------------------> | 4522 | | 4523 | | 4524 | [ ... payload ... ] | 4525 | | 4526 | <------------------------- | 4527 | | 4528 | | 4529 | [ ... payload ... ] | 4530 | | 4531 | -------------------------> | 4532 | | 4533 | | 4534 | [ ... condition ... ] | 4535 | | 4536 | <------------------------- | 4537 | | 4539 Figure 5: Semantics of IQ Stanzas 4541 To enforce these semantics, the following rules apply: 4543 1. The 'id' attribute is REQUIRED for IQ stanzas. 4545 2. The 'type' attribute is REQUIRED for IQ stanzas. The value MUST 4546 be one of the following (if the value is other than one of the 4547 following strings, the recipient or an intermediate router MUST 4548 return a stanza error of ): 4549 * get -- The stanza requests information, inquires about what 4550 data is needed in order to complete further operations, etc. 4552 * set -- The stanza provides data that is needed for an 4553 operation to be completed, sets new values, replaces existing 4554 values, etc. 4556 * result -- The stanza is a response to a successful get or set 4557 request. 4559 * error -- The stanza reports an error that has occurred 4560 regarding processing or delivery of a previously-sent get or 4561 set request (see Section 8.3). 4563 3. An entity that receives an IQ request of type "get" or "set" MUST 4564 reply with an IQ response of type "result" or "error". The 4565 response MUST preserve the 'id' attribute of the request (or be 4566 empty if the generated stanza did not include an 'id' attribute). 4568 4. An entity that receives a stanza of type "result" or "error" MUST 4569 NOT respond to the stanza by sending a further IQ response of 4570 type "result" or "error"; however, the requesting entity MAY send 4571 another request (e.g., an IQ of type "set" to provide obligatory 4572 information discovered through a get/result pair). 4574 5. An IQ stanza of type "get" or "set" MUST contain exactly one 4575 child element, which specifies the semantics of the particular 4576 request. 4578 6. An IQ stanza of type "result" MUST include zero or one child 4579 elements. 4581 7. An IQ stanza of type "error" MAY include the child element 4582 contained in the associated "get" or "set" and MUST include an 4583 child; for details, see Section 8.3. 4585 8.3. Stanza Errors 4587 Stanza-related errors are handled in a manner similar to stream 4588 errors (Section 4.8). Unlike stream errors, stanza errors are 4589 recoverable; therefore they do not result in termination of the XML 4590 stream and underlying TCP connection. Instead, the entity that 4591 discovers the error condition returns an error stanza, which is a 4592 stanza that: 4594 o is of the same kind (message, presence, or IQ) as the generated 4595 stanza that triggered the error 4597 o has a 'type' attribute set to a value of "error" 4599 o swaps the 'from' and 'to' addresses of the generated stanza 4601 o mirrors the 'id' attribute (if any) of the generated stanza that 4602 triggered the error 4604 o contains an child element that specifies the error 4605 condition and therefore provides a hint regarding actions that the 4606 sender can take to remedy the error (if possible) 4608 8.3.1. Rules 4610 The following rules apply to stanza errors: 4612 1. The receiving or processing entity that detects an error 4613 condition in relation to a stanza SHOULD return an error stanza 4614 (and MUST do so for IQ stanzas). 4616 2. The error stanza MUST simply swap the 'from' and 'to' addresses 4617 from the generated stanza. 4619 3. If the generated stanza was or and 4620 included an 'id' attribute then it is REQUIRED for the error 4621 stanza to also include an 'id' attribute. If the generated 4622 stanza was then the error stanza MUST include an 'id' 4623 attribute. In all cases, the value of the 'id' attribute MUST 4624 match that of the generated stanza (or be empty if the generated 4625 stanza did not include an 'id' attribute). 4627 4. An error stanza MUST contain an child element. 4629 5. The entity that returns an error stanza MAY pass along its JID to 4630 the sender of the generated stanza (e.g., for diagnostic or 4631 tracking purposes) through the addition of a 'by' attribute to 4632 the child element. 4634 6. The entity that returns an error stanza MAY include the original 4635 XML sent so that the sender can inspect and, if necessary, 4636 correct the XML before attempting to resend (however, this is a 4637 courtesy only and the originating entity MUST NOT depend on 4638 receiving the original payload). 4640 7. An child MUST NOT be included if the 'type' attribute 4641 has a value other than "error" (or if there is no 'type' 4642 attribute). 4644 8. An entity that receives an error stanza MUST NOT respond to the 4645 stanza with a further error stanza; this helps to prevent 4646 looping. 4648 8.3.2. Syntax 4650 The syntax for stanza-related errors is as follows, where XML data 4651 shown within the square brackets '[' and ']' is OPTIONAL, 'intended- 4652 recipient' is the JID of the entity to which the original stanza was 4653 addressed, and 'sender' is the JID of the originating entity. 4655 4656 [OPTIONAL to include sender XML here] 4657 4659 4660 [ 4662 OPTIONAL descriptive text 4663 ] 4664 [OPTIONAL application-specific condition element] 4665 4666 4668 The "stanza-kind" MUST be one of message, presence, or iq. 4670 The "error-type" MUST be one of the following: 4672 o auth -- retry after providing credentials 4673 o cancel -- do not retry (the error cannot be remedied) 4674 o continue -- proceed (the condition was only a warning) 4675 o modify -- retry after changing the data sent 4676 o wait -- retry after waiting (the error is temporary) 4678 The "defined-condition" MUST correspond to one of the stanza error 4679 conditions defined under Section 8.3.3. 4681 The element: 4683 o MUST contain a defined condition element. 4685 o MAY contain a child element containing XML character data 4686 that describes the error in more detail; this element MUST be 4687 qualified by the 'urn:ietf:params:xml:ns:xmpp-stanzas' namespace 4688 and SHOULD possess an 'xml:lang' attribute specifying the natural 4689 language of the XML character data. 4691 o MAY contain a child element for an application-specific error 4692 condition; this element MUST be qualified by an application- 4693 specific namespace that defines the syntax and semantics of the 4694 element. 4696 The element is OPTIONAL. If included, it MUST be used only 4697 to provide descriptive or diagnostic information that supplements the 4698 meaning of a defined condition or application-specific condition. It 4699 MUST NOT be interpreted programmatically by an application. It MUST 4700 NOT be used as the error message presented to a human user, but MAY 4701 be shown in addition to the error message associated with the defined 4702 condition element (and, optionally, the application-specific 4703 condition element). 4705 Interoperability Note: The syntax defined in [RFC3920] included a 4706 legacy 'code' attribute, whose semantics have been replaced by the 4707 defined condition elements; information about mapping defined 4708 condition elements to values of the legacy 'code' attribute can be 4709 found in [XEP-0086]. 4711 8.3.3. Defined Conditions 4713 The following conditions are defined for use in stanza errors. 4715 8.3.3.1. bad-request 4717 The sender has sent a stanza containing XML that does not conform to 4718 the appropriate schema or that cannot be processed (e.g., an IQ 4719 stanza that includes an unrecognized value of the 'type' attribute, 4720 or an element that is qualified by a recognized namespace but that 4721 violates the defined syntax for the element); the associated error 4722 type SHOULD be "modify". 4724 C: 4728 4729 4731 S: 4735 4736 4737 4738 4740 8.3.3.2. conflict 4742 Access cannot be granted because an existing resource exists with the 4743 same name or address; the associated error type SHOULD be "cancel". 4745 C: 4746 4747 balcony 4748 4749 4751 S: 4752 4753 4754 4755 4757 8.3.3.3. feature-not-implemented 4759 The feature represented in the XML stanza is not implemented by the 4760 intended recipient or an intermediate server and therefore the stanza 4761 cannot be processed (e.g., the entity understands the namespace but 4762 does not recognize the element name); the associated error type 4763 SHOULD be "cancel" or "modify". 4765 C: 4769 4770 4771 4772 4774 E: 4778 4779 4781 4784 4785 4787 8.3.3.4. forbidden 4789 The requesting entity does not possess the necessary permissions to 4790 perform the action; the associated error type SHOULD be "auth". 4792 C: 4796 4797 4799 E: 4804 4805 4806 4807 4809 8.3.3.5. gone 4811 The recipient or server can no longer be contacted at this address, 4812 typically on a permanent basis (as opposed to the error 4813 condition, which is used for temporary addressing failures); the 4814 associated error type SHOULD be "cancel" and the error stanza SHOULD 4815 include a new address (if available) as the XML character data of the 4816 element (which MUST be a Uniform Resource Identifier [URI] or 4817 Internationalized Resource Identifier [IRI] at which the entity can 4818 be contacted, typically an XMPP IRI as specified in [XMPP-URI]). 4820 C: 4825 Thy lips are warm. 4826 4828 S: 4833 4835 4836 xmpp:romeo@afterlife.example.net 4837 4838 4839 4841 8.3.3.6. internal-server-error 4843 The server could not process the stanza because of a misconfiguration 4844 or an otherwise-undefined internal server error; the associated error 4845 type SHOULD be "cancel". 4847 C: 4851 4852 4854 E: 4859 4860 4862 4863 4865 8.3.3.7. item-not-found 4867 The addressed JID or item requested cannot be found; the associated 4868 error type SHOULD be "cancel". 4870 C: 4874 S: 4878 4879 4880 4881 4883 Security Note: An application MUST NOT return this error if doing 4884 so would provide information about the intended recipient's 4885 network availability to an entity that is not authorized to know 4886 such information; instead it MUST return a 4887 stanza error. 4889 8.3.3.8. jid-malformed 4891 The sending entity has provided (e.g., during resource binding) or 4892 communicated (e.g., in the 'to' address of a stanza) an XMPP address 4893 or aspect thereof that does not adhere to the syntax defined in 4894 [XMPP-ADDR]; the associated error type SHOULD be "modify". 4896 C: 4900 4901 4903 E: 4908 4910 4912 4913 4915 Implementation Note: Enforcement of the format for XMPP localparts 4916 is primarily the responsibility of the service at which the 4917 associated account or entity is located (e.g., the example.com 4918 service is responsible for returning errors 4919 related to all JIDs of the form ), whereas 4920 enforcement of the format for XMPP domainparts is primarily the 4921 responsibility of the service that seeks to route a stanza to the 4922 service identified by that domainpart (e.g., the example.org 4923 service is responsible for returning errors 4924 related to stanzas that users of that service have to tried send 4925 to JIDs of the form ). However, any entity 4926 that detects a malformed JID MAY return this error. 4928 8.3.3.9. not-acceptable 4930 The recipient or server understands the request but cannot process it 4931 because the request does not meet criteria defined by the recipient 4932 or server (e.g., a request to subscribe to information that does not 4933 simultaneously include configuration parameters needed by the 4934 recipient); the associated error type SHOULD be "modify". 4936 C: 4937 [ ... the-emacs-manual ... ] 4938 4940 S: 4941 4942 4944 4945 4947 8.3.3.10. not-allowed 4949 The recipient or server does not allow any entity to perform the 4950 action (e.g., sending to entities at a blacklisted domain); the 4951 associated error type SHOULD be "cancel". 4953 C: 4957 4958 4960 E: 4965 4966 4967 4968 4970 8.3.3.11. not-authorized 4972 The sender needs to provide credentials before being allowed to 4973 perform the action, or has provided improper credentials; the 4974 associated error type SHOULD be "auth". 4976 C: 4980 4981 4983 E: 4987 4988 4989 4990 4992 8.3.3.12. payment-required 4994 The requesting entity is not authorized to access the requested 4995 service because payment is necessary; the associated error type 4996 SHOULD be "auth". 4998 C: 5002 5003 5004 5005 5007 E: 5011 5012 5014 5015 5017 8.3.3.13. policy-violation 5019 The entity has violated some local service policy (e.g., a message 5020 contains words that are prohibited by the service); the server MAY 5021 choose to specify the policy in the element or in an 5022 application-specific condition element; the associated error type 5023 SHOULD be "modify" or "wait" depending on the policy being violated. 5025 (In the following example, the client sends an XMPP message that is 5026 too large according to the server's local service policy.) 5028 C: 5031 %#&@^!!! 5032 5034 S: 5037 5038 5040 5041 5043 8.3.3.14. recipient-unavailable 5045 The intended recipient is temporarily unavailable, undergoing 5046 maintenance, etc.; the associated error type SHOULD be "wait". 5048 C: 5052 5053 5055 E: 5059 5060 5062 5063 5065 Security Note: An application MUST NOT return this error if doing 5066 so would provide information about the intended recipient's 5067 network availability to an entity that is not authorized to know 5068 such information; instead it MUST return a 5069 stanza error. 5071 8.3.3.15. redirect 5073 The recipient or server is redirecting requests for this information 5074 to another entity, typically in a temporary fashion (as opposed to 5075 the error condition, which is used for permanent addressing 5076 failures); the associated error type SHOULD be "modify" and the error 5077 stanza SHOULD contain the alternate address in the XML character data 5078 of the element (which MUST be a URI or IRI at which the 5079 entity can be contacted, typically an XMPP IRI as specified in 5080 [XMPP-URI]). 5082 C: 5086 5087 5089 E: 5094 5095 5096 xmpp:characters@conference.example.org 5097 5098 5099 5101 8.3.3.16. registration-required 5103 The requesting entity is not authorized to access the requested 5104 service because prior registration is necessary; the associated error 5105 type SHOULD be "auth". 5107 C: 5111 5112 5114 E: 5118 5119 5121 5122 5124 8.3.3.17. remote-server-not-found 5126 A remote server or service specified as part or all of the JID of the 5127 intended recipient does not exist or cannot be resolved (e.g., there 5128 is no _xmpp-server._tcp DNS SRV record, the A or AAAA fallback 5129 resolution fails, or A/AAAA lookup succeeds but there is no response 5130 on the IANA-registered port 5269); the associated error type SHOULD 5131 be "cancel". 5133 C: 5138 yt? 5139 5141 E: 5146 5147 5149 5150 5152 8.3.3.18. remote-server-timeout 5154 A remote server or service specified as part or all of the JID of the 5155 intended recipient (or needed to fulfill a request) was resolved but 5156 communications could not be established within a reasonable amount of 5157 time (e.g., an XML stream cannot be established at the resolved IP 5158 address and port, or an XML stream can be established but stream 5159 negotiation fails because of problems with TLS, SASL, Server 5160 Dialback, etc.); the associated error type SHOULD be "wait". 5162 C: 5167 yt? 5168 5170 E: 5175 5176 5178 5179 5181 8.3.3.19. resource-constraint 5183 The server or recipient is busy or lacks the system resources 5184 necessary to service the request; the associated error type SHOULD be 5185 "wait". 5187 C: 5191 5192 5193 5194 5196 E: 5200 5201 5203 5204 5206 8.3.3.20. service-unavailable 5208 The server or recipient does not currently provide the requested 5209 service; the associated error type SHOULD be "cancel". 5211 C: 5213 Hello? 5214 5216 S: 5218 5219 5221 5222 5224 Security Note: An application MUST return a 5225 stanza error instead of or if sending one of the latter errors would provide 5227 information about the intended recipient's network availability to 5228 an entity that is not authorized to know such information. 5230 8.3.3.21. subscription-required 5232 The requesting entity is not authorized to access the requested 5233 service because a prior subscription is necessary; the associated 5234 error type SHOULD be "auth". 5236 C: 5241 ACT II, SCENE II 5242 help, I forgot my lines! 5243 5245 E: 5250 5251 5253 5254 5256 8.3.3.22. undefined-condition 5258 The error condition is not one of those defined by the other 5259 conditions in this list; any error type can be associated with this 5260 condition, and it SHOULD be used only in conjunction with an 5261 application-specific condition. 5263 C: 5267 My lord, dispatch; read o'er these articles. 5268 5269 5272 5274 S: 5278 5282 5285 5286 5287 5289 5290 5293 5294 5295 5297 8.3.3.23. unexpected-request 5299 The recipient or server understood the request but was not expecting 5300 it at this time (e.g., the request was out of order); the associated 5301 error type SHOULD be "wait" or "modify". 5303 C: 5307 5308 5311 5312 5314 E: 5318 5319 5321 5323 5324 5326 8.3.4. Application-Specific Conditions 5328 As noted, an application MAY provide application-specific stanza 5329 error information by including a properly-namespaced child within the 5330 error element. Typically, the application-specific element 5331 supplements or further qualifies a defined element. Thus, the 5332 element will contain two or three child elements. 5334 5335 5336 5337 5338 5339 5340 5341 5342 5344 5346 [ ... application-specific information ... ] 5347 5348 5349 5350 5352 An entity that receives an application-specific error condition it 5353 does not understand MUST ignore that condition but appropriately 5354 process the rest of the error stanza. 5356 8.4. Extended Content 5358 Although the message, presence, and IQ stanzas provide basic 5359 semantics for messaging, availability, and request-response 5360 interactions, XMPP uses XML namespaces (see [XML-NAMES]) to extend 5361 the basic stanza syntax for the purpose of providing additional 5362 functionality. 5364 A message or presence stanza MAY contain one or more optional child 5365 elements specifying content that extends the meaning of the message 5366 (e.g., an XHTML-formatted version of the message body as described in 5367 [XEP-0071]), and an IQ stanza of type "get" or "set" MUST contain one 5368 such child element. Such a child element MAY have any name and MUST 5369 possess a namespace declaration (other than "jabber:client", "jabber: 5370 server", or "http://etherx.jabber.org/streams") that defines the data 5371 contained within the child element. Such a child element is called 5372 an "extension element". An extension element can be included either 5373 at the direct child level of the stanza or in any mix of levels. 5375 Similarly, "extension attributes" are allowed. That is: a stanza 5376 itself (i.e., the , , and elements 5377 qualified by the "jabber:client" or "jabber:server" content 5378 namespace) and any child element of such a stanza (whether an 5379 extension element or a child element qualified by the content 5380 namespace) MAY also include one or more attributes qualified by XML 5381 namespaces other than the content namespace or the reserved 5382 "http://www.w3.org/XML/1998/namespace" namespace (including the so- 5383 called "empty namespace" if the attribute is not prefixed; see 5384 [XML-NAMES]). 5386 Interoperability Note: For the sake of backward compatibility and 5387 maximum interoperability, an entity that generates a stanza SHOULD 5388 NOT include such attributes in the stanza itself or in child 5389 elements of the stanza that are qualified by the content 5390 namespaces "jabber:client" or "jabber:server" (e.g., the 5391 child of the stanza). 5393 An extension element or extension attribute is said to be "extended 5394 content" and the namespace name for such an element or attribute is 5395 said to be an "extended namespace". 5397 Informational Note: Although extended namespaces for XMPP are 5398 commonly defined by the XMPP Standards Foundation (XSF) and by the 5399 IETF, no specification or IETF standards action is required to 5400 define extended namespaces, and any individual or organization is 5401 free to define XMPP extensions. 5403 To illustrate these concepts, several examples follow. 5405 The following stanza contains one direct child element whose extended 5406 namespace is 'jabber:iq:roster': 5408 5411 5412 5414 The following stanza contains two direct child elements with two 5415 different extended namespaces. 5417 5418 5422 5423 sha1-hash-of-image 5424 5425 5427 The following stanza contains two child elements, one of which is 5428 qualified by the "jabber:client" or "jabber:server" content namespace 5429 and one of which is qualified by an extended namespace; the extension 5430 element in turn contains a child element that is qualified by a 5431 different extended namespace. 5433 5434 Hello? 5435 5436 5437

Hello? 5438 5439 5440 5442 It is conventional in the XMPP community for implementations to not 5443 generate namespace prefixes for elements that are qualified by 5444 extended namespaces (outside the XMPP community, this convention is 5445 sometimes called "prefix-free canonicalization"). However, if an 5446 implementation generates such namespace prefixes then it MUST include 5447 the namespace declaration in the stanza itself or a child element of 5448 the stanza, not in the stream header (see Section 4.7.3). 5450 Routing entities (typically servers) SHOULD try to maintain prefixes 5451 when serializing XML stanzas for processing, but receiving entities 5452 MUST NOT depend on the prefix strings to have any particular value. 5454 Support for any given extended namespace is OPTIONAL on the part of 5455 any implementation. If an entity does not understand such a 5456 namespace, the entity's expected behavior depends on whether the 5457 entity is (1) the recipient or (2) a server that is routing or 5458 delivering the stanza to the recipient. 5460 If a recipient receives a stanza that contains an element or 5461 attribute it does not understand, it MUST NOT attempt to process that 5462 XML data and instead MUST proceed as follows. 5464 o If an entity receives a message stanza whose only child element is 5465 qualified by a namespace it does not understand, then depending on 5466 the XMPP application it MUST either ignore the entire stanza or 5467 return a stanza error, which SHOULD be . 5469 o If an entity receives a presence stanza whose only child element 5470 is qualified by a namespace it does not understand, then it MUST 5471 ignore the child element by treating the presence stanza as if it 5472 contained no child element. 5474 o If an entity receives a message or presence stanza that contains 5475 XML data qualified by a namespace it does not understand, then it 5476 MUST ignore the portion of the stanza qualified by the unknown 5477 namespace. 5479 o If an entity receives an IQ stanza of type "get" or "set" 5480 containing a child element qualified by a namespace it does not 5481 understand, then the entity MUST return an IQ stanza of type 5482 "error" with an error condition of . 5484 If a server handles a stanza that is intended for delivery to another 5485 entity and that contains a child element it does not understand, it 5486 MUST route the stanza unmodified to a remote server or deliver the 5487 stanza unmodified to a connected client associated with a local 5488 account. 5490 9. Examples 5492 The examples in this section further illustrate the protocols defined 5493 in this specification. 5495 9.1. Client-to-Server Examples 5497 The following examples show the XMPP data flow for a client 5498 negotiating an XML stream with a server, exchanging XML stanzas, and 5499 closing the negotiated stream. The server is "im.example.com", the 5500 server requires use of TLS, the client authenticates via the SASL 5501 SCRAM-SHA-1 mechanism as , and the client 5502 binds a client-submitted resource to the stream. It is assumed that 5503 before sending the initial stream header, the client has already 5504 resolved an SRV record of _xmpp-client._tcp.im.example.com and has 5505 opened a TCP connection to the advertised port at the resolved IP 5506 address. 5508 9.1.1. TLS 5510 Step 1: Client initiates stream to server: 5512 C: 5520 Step 2: Server responds by sending a response stream header to 5521 client: 5523 S: 5536 5537 5538 5539 5541 Step 4: Client sends STARTTLS command to server: 5543 C: 5545 Step 5: Server informs client that it is allowed to proceed: 5547 S: 5549 Step 5 (alt): Server informs client that STARTTLS negotiation has 5550 failed and closes both XML stream and TCP connection: 5552 S: 5554 S: 5556 Step 6: Client and server attempt to complete TLS negotiation over 5557 the existing TCP connection (see [TLS] for details). 5559 Step 7: If TLS negotiation is successful, client initiates a new 5560 stream to server: 5562 C: 5570 Step 7 (alt): If TLS negotiation is unsuccessful, server closes TCP 5571 connection. 5573 9.1.2. SASL 5575 Step 8: Server responds by sending a stream header to client along 5576 with any available stream features: 5578 S: 5588 5589 SCRAM-SHA-1-PLUS 5590 SCRAM-SHA-1 5591 PLAIN 5592 5593 5595 Step 9: Client selects an authentication mechanism, in this case 5596 SCRAM-SHA-1, including initial response data: 5598 C: 5600 biwsbj1qdWxpZXQscj1vTXNUQUF3QUFBQU1BQUFBTlAwVEFBQUFBQUJQVTBBQQ== 5601 5603 The decoded base64 data is 5604 "n,,n=juliet,r=oMsTAAwAAAAMAAAANP0TAAAAAABPU0AA". 5606 Step 10: Server sends a challenge: 5608 S: 5609 cj1vTXNUQUF3QUFBQU1BQUFBTlAwVEFBQUFBQUJQVTBBQWUxMjQ2OTViLTY5Y 5610 TktNGRlNi05YzMwLWI1MWIzODA4YzU5ZSxzPU5qaGtZVE0wTURndE5HWTBaaT 5611 AwTmpkbUxUa3hNbVV0TkRsbU5UTm1ORE5rTURNeixpPTQwOTY= 5612 5614 The decoded base64 data is "r=oMsTAAwAAAAMAAAANP0TAAAAAABPU0AAe124695 5615 b-69a9-4de6-9c30- 5616 b51b3808c59e,s=NjhkYTM0MDgtNGY0Zi00NjdmLTkxMmUtNDlmNTNmNDNkMDMz,i=409 5617 6" (line breaks not included in actual data). 5619 Step 11: Client sends a response: 5621 C: 5622 Yz1iaXdzLHI9b01zVEFBd0FBQUFNQUFBQU5QMFRBQUFBQUFCUFUwQUFlMTI0N 5623 jk1Yi02OWE5LTRkZTYtOWMzMC1iNTFiMzgwOGM1OWUscD1VQTU3dE0vU3ZwQV 5624 RCa0gyRlhzMFdEWHZKWXc9 5625 5627 The decoded base64 data is "c=biws, r=oMsTAAwAAAAMAAAANP0TAAAAAABPU0A 5628 Ae124695b-69a9-4de6-9c30-b51b3808c59e, p=UA57tM/ 5629 SvpATBkH2FXs0WDXvJYw=" (line breaks not included in actual data). 5631 Step 12: Server informs client of success, including additional data 5632 with success: 5634 S: 5635 dj1wTk5ERlZFUXh1WHhDb1NFaVc4R0VaKzFSU289 5636 5638 The decoded base64 data is "v=pNNDFVEQxuXxCoSEiW8GEZ+1RSo=". 5640 Step 12 (alt): Server returns error to client: 5642 S: 5643 5644 5646 Step 13: Client initiates a new stream to server: 5648 C: 5670 S: 5671 5672 5674 Upon being informed that resource binding is mandatory, the client 5675 needs to bind a resource to the stream; here we assume that the 5676 client submits a human-readable text string. 5678 Step 15: Client binds a resource: 5680 C: 5681 5682 balcony 5683 5684 5686 Step 16: Server accepts submitted resourcepart and informs client of 5687 successful resource binding: 5689 S: 5690 5691 5692 juliet@im.example.com/balcony 5693 5694 5695 5697 Step 16 (alt): Server returns error to client: 5699 S: 5700 5701 5702 5703 5705 9.1.4. Stanza Exchange 5707 Now the client is allowed to send XML stanzas over the negotiated 5708 stream. 5710 C: 5715 Art thou not Romeo, and a Montague? 5716 5718 If necessary, sender's server negotiates XML streams with intended 5719 recipient's server (see Section 9.2). 5721 The intended recipient replies and the message is delivered to the 5722 client. 5724 E: 5729 Neither, fair saint, if either thee dislike. 5730 5732 The client can subsequently send and receive an unbounded number of 5733 subsequent XML stanzas over the stream. 5735 9.1.5. Close 5737 Desiring to send no further messages, the client closes the stream 5738 but waits for incoming data from the server. 5740 C: 5742 Consistent with Section 4.4, the server might send additional data 5743 and then closes the stream as well. 5745 S: 5747 The client now terminates the underlying TCP connection. 5749 9.2. Server-to-Server Examples 5751 The following examples show the data flow for a server negotiating an 5752 XML stream with another server, exchanging XML stanzas, and closing 5753 the negotiated stream. The initiating server ("Server1") is 5754 im.example.com; the receiving server ("Server2") is example.net and 5755 it requires use of TLS; im.example.com presents a certificate and 5756 authenticates via the SASL EXTERNAL mechanism. It is assumed that 5757 before sending the initial stream header, Server1 has already 5758 resolved an SRV record of _xmpp-server._tcp.example.net and has 5759 opened a TCP connection to the advertised port at the resolved IP 5760 address. Note how Server1 declares the content namespace "jabber: 5761 server" as the default namespace and uses prefixes for stream-related 5762 elements, whereas Server2 uses prefix-free canonicalization. 5764 9.2.1. TLS 5766 Step 1: Server1 initiates stream to Server2: 5768 S1: 5775 Step 2: Server2 responds by sending a response stream header to 5776 Server1: 5778 S2: 5785 Step 3: Server2 sends stream features to Server1 (only the STARTTLS 5786 extension at this point): 5788 S2: 5789 5790 5791 5792 5794 Step 4: Server1 sends the STARTTLS command to Server2: 5796 S1: 5798 Step 5: Server2 informs Server1 that it is allowed to proceed: 5800 S2: 5802 Step 5 (alt): Server2 informs Server1 that STARTTLS negotiation has 5803 failed and closes stream: 5805 S2: 5807 S2: 5809 Step 6: Server1 and Server2 attempt to complete TLS negotiation via 5810 TCP (see [TLS] for details). 5812 Step 7: If TLS negotiation is successful, Server1 initiates a new 5813 stream to Server2: 5815 S1: 5822 Step 7 (alt): If TLS negotiation is unsuccessful, Server2 closes TCP 5823 connection. 5825 9.2.2. SASL 5827 Step 8: Server2 sends a response stream header to Server1 along with 5828 available stream features (including a preference for the SASL 5829 EXTERNAL mechanism): 5831 S2: 5838 S2: 5839 5840 EXTERNAL 5841 5843 5845 Step 9: Server1 selects the EXTERNAL mechanism (including an empty 5846 response of "="): 5848 S1: = 5851 Step 10: Server2 returns success: 5853 S2: 5855 Step 10 (alt): Server2 informs Server1 of failed authentication: 5857 S2: 5858 5859 5861 S2: 5863 Step 11: Server1 initiates a new stream to Server2: 5865 S1: 5872 Step 12: Server2 responds by sending a stream header to Server1 along 5873 with any additional features (or, in this case, an empty features 5874 element): 5876 S2: 5883 S2: 5885 9.2.3. Stanza Exchange 5887 Now Server1 is allowed to send XML stanzas to Server2 over the 5888 negotiated stream from im.example.com to example.net; here we assume 5889 that the transferred stanzas are those shown earlier for client-to- 5890 server communication, albeit over a server-to-server stream qualified 5891 by the 'jabber:server' namespace. 5893 Server1 sends XML stanza to Server2: 5895 S1: 5900 Art thou not Romeo, and a Montague? 5901 5903 9.2.4. Close 5905 Desiring to send no further messages, Server1 closes the stream. (In 5906 practice, the stream would most likely remain open for some time, 5907 since Server1 and Server2 do not immediately know if the stream will 5908 be needed for further communication.) 5910 S1: 5912 Consistent with the recommended stream closing handshake, Server2 5913 closes the stream as well: 5915 S2: 5917 Server1 now terminates the underlying TCP connection. 5919 10. Server Rules for Processing XML Stanzas 5921 Each server implementation will contain its own logic for processing 5922 stanzas it receives. Such logic determines whether the server needs 5923 to route a given stanza to another domain, deliver it to a local 5924 entity (typically a connected client associated with a local 5925 account), or handle it directly within the server itself. This 5926 section provides general rules for processing XML stanzas. However, 5927 particular XMPP applications MAY specify delivery rules that modify 5928 or supplement the following rules (e.g., a set of delivery rules for 5929 instant messaging and presence applications is defined in [XMPP-IM]). 5931 10.1. In-Order Processing 5933 An XMPP server MUST ensure in-order processing of the stanzas and 5934 other XML elements it receives over a given stream from a connected 5935 client or remote server (for purposes of this section we describe 5936 such a stream as an "input stream", in contrast to an "output stream" 5937 that a server would use to deliver data to a connected client or to 5938 route data to a remote server). 5940 In-order processing applies (a) to any XML elements used to negotiate 5941 and manage XML streams, and (b) to all uses of XML stanzas, including 5942 but not limited to the following: 5944 1. Stanzas sent by a client to its server or to its own bare JID for 5945 direct processing by the server (e.g., in-order processing of a 5946 roster get and initial presence as described in [XMPP-IM]). 5948 2. Stanzas sent by a connected client and intended for delivery to 5949 another entity associated with a local domain (e.g., stanzas 5950 addressed from to 5951 ). The server MUST ensure that it delivers 5952 stanzas addressed to the intended recipient in the order it 5953 receives them over the input stream from the sending client, 5954 treating stanzas addressed to the bare JID and the full JID of 5955 the intended recipient as equivalent for delivery purposes. 5957 3. Stanzas sent by a connected client and intended for delivery to 5958 an entity located at a remote domain (e.g., stanzas addressed 5959 from to ). The 5960 routing server MUST ensure that it routes stanzas addressed to 5961 the intended recipient in the order it receives them over the 5962 input stream from the sending client, treating stanzas addressed 5963 to the bare JID and the full JID of the intended recipient as 5964 equivalent for routing purposes. To help ensure in-order 5965 processing, the routing server MUST route such stanzas over a 5966 single output stream to the remote domain, rather than sending 5967 some stanzas over one server-to-server stream and other stanzas 5968 over another server-to-server stream. 5970 4. Stanzas routed from one server to another server for delivery to 5971 an entity associated with the remote domain (e.g., stanzas 5972 addressed from to and 5973 routed by over a server-to-server stream to 5974 ). The delivering server MUST ensure that it 5975 delivers stanzas to the intended recipient in the order it 5976 receives them over the input stream from the routing server, 5977 treating stanzas addressed to the bare JID and the full JID of 5978 the intended recipient as equivalent for delivery purposes. 5980 5. Stanzas sent by one server to another server for direct 5981 processing by the server that is hosting the remote domain (e.g., 5982 stanzas addressed from to ). 5984 If the server's processing of a particular request could have an 5985 effect on its processing of subsequent data it might receive over 5986 that input stream (e.g., enforcement of communication policies), it 5987 MUST suspend processing of subsequent data until it has processed the 5988 request. 5990 In-order processing applies only to a single input stream. Therefore 5991 a server is not responsible for ensuring the coherence of data it 5992 receives across multiple input streams associated with the same local 5993 account (e.g., stanzas received over two different input streams from 5994 and ) 5995 or the same remote domain (e.g., two different input streams 5996 negotiated by a remote domain; however, a server MAY return a 5997 stream error to a remote server that attempts to negotiate 5998 more than one stream, as described under Section 4.8.3.3). 6000 10.2. General Considerations 6002 At high level, there are three primary considerations at play in 6003 server processing of XML stanzas, which sometimes are at odds but 6004 need to be managed in a consistent way: 6006 1. It is good to deliver a stanza to the intended recipient if 6007 possible. 6009 2. If a stanza cannot be delivered, it is helpful to inform the 6010 sender. 6012 3. It is bad to facilitate directory harvesting attacks 6013 (Section 13.11) and presence leaks (Section 13.10.2). 6015 With regarding to possible delivery-related attacks, the following 6016 points need to be kept in mind: 6018 1. From the perspective of an attacker, there is little if any 6019 effective difference between the server's (i) delivering the 6020 stanza or storing it offline for later delivery (see [XMPP-IM]) 6021 and (ii) silently ignoring it (because an error is not returned 6022 immediately in any of those cases); therefore, in scenarios where 6023 a server delivers a stanza or places the stanza into offline 6024 storage for later delivery, it needs to silently ignore the 6025 stanza if that account does not exist. 6027 2. How a server processes stanzas sent to the bare JID 6028 has implications for directory harvesting. 6030 3. How a server processes stanzas sent to a full JID has 6031 implications for presence leaks. However, the attack is less 6032 direct here (because the attacker needs to try many different 6033 resources in an attempt to find the one resource that matches) so 6034 it is of somewhat lesser concern. 6036 Naturally, presence is not leaked if the entity to which a user's 6037 server returns an error already knows the user's presence or is 6038 authorized to do so (e.g., by means of a presence subscription or 6039 directed presence), and a server does not enable a directory 6040 harvesting attack if it returns an error to an entity that already 6041 knows if a user exists (e.g., because the entity is in the user's 6042 contact list); these matters are discussed more fully in [XMPP-IM]. 6044 10.3. No 'to' Address 6046 If the stanza possesses no 'to' attribute, the server MUST handle it 6047 directly on behalf of the entity that sent it, where the meaning of 6048 "handle it directly" depends on whether the stanza is message, 6049 presence, or IQ. Because all stanzas received from other servers 6050 MUST possess a 'to' attribute, this rule applies only to stanzas 6051 received from a local entity (typically a client) that is connected 6052 to the server. 6054 10.3.1. Message 6056 If the server receives a message stanza with no 'to' attribute, it 6057 MUST treat the message as if the 'to' address were the bare JID 6058 of the sending entity. 6060 10.3.2. Presence 6062 If the server receives a presence stanza with no 'to' attribute, it 6063 MUST broadcast it to the entities that are subscribed to the sending 6064 entity's presence, if applicable ([XMPP-IM] defines the semantics of 6065 such broadcasting for presence applications). 6067 10.3.3. IQ 6069 If the server receives an IQ stanza with no 'to' attribute, it MUST 6070 process the stanza on behalf of the account from which received the 6071 stanza, as follows: 6073 1. If the IQ stanza is of type "get" or "set" and the server 6074 understands the namespace that qualifies the payload, the server 6075 MUST handle the stanza on behalf of the sending entity or return 6076 an appropriate error to the sending entity. Although the meaning 6077 of "handle" is determined by the semantics of the qualifying 6078 namespace, in general the server will respond to the IQ stanza of 6079 type "get" or "set" by returning an appropriate IQ stanza of type 6080 "result" or "error", responding as if the server were the bare 6081 JID of the sending entity. As an example, if the sending entity 6082 sends an IQ stanza of type "get" where the payload is qualified 6083 by the 'jabber:iq:roster' namespace (as described in [XMPP-IM]), 6084 then the server will return the roster associated with the 6085 sending entity's bare JID to the particular resource of the 6086 sending entity that requested the roster. 6088 2. If the IQ stanza is of type "get" or "set" and the server does 6089 not understand the namespace that qualifies the payload, the 6090 server MUST return an error to the sending entity, which MUST be 6091 . 6093 3. If the IQ stanza is of type "error" or "result", the server MUST 6094 handle the error or result in accordance with the payload of the 6095 associated IQ stanza or type "get" of "set" (if there is no such 6096 associated stanza, the server MUST ignore the error or result 6097 stanza). 6099 10.4. Remote Domain 6101 If the domainpart of the JID contained in the 'to' attribute does not 6102 match one of the configured hostnames of the server, the server 6103 SHOULD attempt to route the stanza to the remote domain (subject to 6104 local service provisioning and security policies regarding inter- 6105 domain communication, since such communication is optional for any 6106 given deployment). As described in the following sections, there are 6107 two possible cases. 6109 Security Note: These rules apply only client-to-server streams. 6110 As described under Section 8.1.1.2, a server MUST NOT accept a 6111 stanza over a server-to-server stream if the domainpart of the JID 6112 in the 'to' attribute does not match a hostname serviced by the 6113 receiving server. 6115 10.4.1. Existing Stream 6117 If a server-to-server stream already exists between the two domains, 6118 the sender's server will attempt to route the stanza to the 6119 authoritative server for the remote domain over the existing stream. 6121 10.4.2. No Existing Stream 6123 If there exists no server-to-server stream between the two domains, 6124 the sender's server will proceed as follows: 6126 1. Resolve the hostname of the remote domain, as described under 6127 Section 13.9.2). 6129 2. Negotiate a server-to-server stream between the two domains (as 6130 defined under Section 5 and Section 6). 6132 3. Route the stanza to the authoritative server for the remote 6133 domain over the newly-established stream. 6135 10.4.3. Error Handling 6137 If routing of a stanza to the intended recipient's server is 6138 unsuccessful, the sender's server MUST return an error to the sender. 6139 If resolution of the remote domain is unsuccessful, the stanza error 6140 MUST be . If resolution succeeds but 6141 streams cannot be negotiated, the stanza error MUST be . 6144 If stream negotiation with the intended recipient's server is 6145 successful but the remote server cannot deliver the stanza to the 6146 recipient, the remote server MUST return an appropriate error to the 6147 sender by way of the sender's server. 6149 10.5. Local Domain 6151 If the hostname of the domainpart of the JID contained in the 'to' 6152 attribute matches one of the configured hostnames of the server, the 6153 server MUST first determine if the hostname is serviced by the server 6154 itself or by a specialized local service. If the latter, the server 6155 MUST route the stanza to that service. If the former, the server 6156 MUST proceed as follows. 6158 10.5.1. Mere Domain 6160 If the JID contained in the 'to' attribute is of the form , 6161 then the server MUST either (a) handle the stanza as appropriate for 6162 the stanza kind or (b) return an error stanza to the sender. 6164 10.5.2. Domain with Resource 6166 If the JID contained in the 'to' attribute is of the form 6167 , then the server MUST either (a) handle the 6168 stanza as appropriate for the stanza kind or (b) return an error 6169 stanza to the sender. 6171 10.5.3. Localpart at Domain 6173 An address of this type is normally associated with an account on the 6174 server. The following rules provide some general guidelines; more 6175 detailed rules in the context of instant messaging and presence 6176 applications are provided in [XMPP-IM]. 6178 10.5.3.1. No Such User 6180 If there is no local account associated with the 6181 , how the stanza is processed depends on the 6182 stanza type. 6184 o For a message stanza, the server MUST either (a) silently ignore 6185 the stanza or (b) return a stanza error to 6186 the sender. 6188 o For a presence stanza, the server SHOULD ignore the stanza (or 6189 behave as described in [XMPP-IM]). 6191 o For an IQ stanza, the server MUST return a 6192 stanza error to the sender. 6194 10.5.3.2. Bare JID 6196 If the JID contained in the 'to' attribute is of the form 6197 , how the stanza is processed depends on the 6198 stanza type. 6200 o For a message stanza, if there exists at least one connected 6201 resource for the account the server SHOULD deliver it to at least 6202 one of the connected resources. If there exists no connected 6203 resource, the server MUST either (a) store the message offline for 6204 delivery when the account next has a connected resource or (b) 6205 return a stanza error. 6207 o For a presence stanza, if there exists at least one connected 6208 resource that has sent initial presence (i.e., has a "presence 6209 session" as defined in [XMPP-IM]), the server SHOULD deliver it to 6210 such resources. If there exists no connected resource, the server 6211 SHOULD ignore the stanza (or behave as described in [XMPP-IM]). 6213 o For an IQ stanza, the server MUST handle it directly on behalf of 6214 the intended recipient. 6216 10.5.3.3. Full JID 6218 If the JID contained in the 'to' attribute is of the form 6219 and there is no connected 6220 resource that exactly matches the full JID, the stanza SHOULD be 6221 processed as if the JID were of the form . 6223 If the JID contained in the 'to' attribute is of the form 6224 and there is a connected resource 6225 that exactly matches the full JID, the server MUST deliver the stanza 6226 to that connected resource. 6228 11. XML Usage 6230 11.1. Restrictions 6232 XMPP defines a class of data objects called XML streams as well as 6233 the behavior of computer programs that process XML streams. XMPP is 6234 an application profile or restricted form of the Extensible Markup 6235 Language [XML], and a complete XML stream (including start and end 6236 stream tags) is a conforming XML document. 6238 However, XMPP does not deal with XML documents but with XML streams. 6239 Because XMPP does not require the parsing of arbitrary and complete 6240 XML documents, there is no requirement that XMPP needs to support the 6241 full feature set of [XML]. Furthermore, XMPP uses XML to define 6242 protocol data structures and extensions for the purpose of structured 6243 interactions between network entities and therefore adheres to the 6244 recommendations provided in [XML-GUIDE] regarding restrictions on the 6245 use of XML in IETF protocols. As a result, the following features of 6246 XML are prohibited in XMPP: 6248 o comments (as defined in Section 2.5 of [XML]) 6249 o processing instructions (Section 2.6 therein) 6250 o internal or external DTD subsets (Section 2.8 therein) 6251 o internal or external entity references (Section 4.2 therein) with 6252 the exception of the predefined entities (Section 4.6 therein) 6254 An XMPP implementation MUST behave as follows with regard to these 6255 features: 6257 1. An XMPP implementation MUST NOT inject characters matching such 6258 features into an XML stream. 6260 2. If an XMPP implementation receives characters matching such 6261 features over an XML stream, it MUST return a stream error, which 6262 SHOULD be (although some existing 6263 implementations send instead). 6265 11.2. XML Namespace Names and Prefixes 6267 XML namespaces (see [XML-NAMES]) are used within XMPP streams to 6268 create strict boundaries of data ownership. The basic function of 6269 namespaces is to separate different vocabularies of XML elements that 6270 are structurally mixed together. Ensuring that XMPP streams are 6271 namespace-aware enables any allowable XML to be structurally mixed 6272 with any data element within XMPP. XMPP-specific rules for XML 6273 namespace names and prefixes are defined under Section 4.7 for XML 6274 streams and Section 8.4 for XML stanzas. 6276 11.3. Well-Formedness 6278 There are two varieties of well-formedness: 6280 o "XML-well-formedness" in accordance with the definition of "well- 6281 formed" from Section 2.1 of [XML]. 6282 o "Namespace-well-formedness" in accordance with the definition of 6283 "namespace-well-formed" from Section 7 of [XML-NAMES]. 6285 The following rules apply. 6287 An XMPP entity MUST NOT generate data that is not XML-well-formed. 6288 An XMPP entity MUST NOT accept data that is not XML-well-formed; 6289 instead it MUST return a stream error and close 6290 the stream over which the data was received. 6292 An XMPP entity MUST NOT generate data that is not namespace-well- 6293 formed. An XMPP entity MUST NOT accept data that is not namespace- 6294 well-formed (in particular, an XMPP server MUST NOT route or deliver 6295 data that is not namespace-well-formed); instead it MUST return 6296 either a stanza error of or a stream error of (where it is preferable to return a stream error 6298 because accepting such data can open an entity to certain denial of 6299 service attacks). 6301 Interoperability Note: Because these restrictions were 6302 underspecified in [RFC3920], it is possible that implementations 6303 based on that specification will send data that does not comply 6304 with these restrictions. 6306 11.4. Validation 6308 A server is not responsible for ensuring that XML data delivered to a 6309 client or routed to another server is valid, in accordance with the 6310 definition of "valid" provided in Section 2.8 of [XML]. An 6311 implementation MAY choose to accept or provide only data that has 6312 been explicitly validated against the schemas provided in this 6313 document, but such behavior is OPTIONAL. A client SHOULD NOT rely on 6314 the ability to send data that does not conform to the schemas, and 6315 SHOULD ignore any non-conformant elements or attributes on the 6316 incoming XML stream. 6318 Informational Note: The terms "valid" and "well-formed" are 6319 distinct in XML. 6321 11.5. Inclusion of XML Declaration 6323 Before sending a stream header, an implementation SHOULD send an XML 6324 declaration (matching production [23] content of [XML]). 6325 Applications MUST follow the rules provided in [XML] regarding the 6326 format of the XML declaration and the circumstances under which the 6327 XML declaration is included. 6329 Because external markup declarations are prohibited in XMPP (as 6330 described under Section 11.1), the standalone document declaration 6331 (matching production [32] content of [XML]) would have no meaning and 6332 therefore SHOULD NOT be included in an XML declaration sent over an 6333 XML stream. If an XMPP entity receives an XML declaration containing 6334 a standalone document declaration set to a value of "no", the entity 6335 MUST either ignore the standalone document declaration or return a 6336 stream error (which SHOULD be ). 6338 11.6. Character Encoding 6340 Implementations MUST support the UTF-8 transformation of Universal 6341 Character Set [UCS2] characters, as needed for conformance with 6342 [CHARSETS] and as defined in [UTF-8]. Implementations MUST NOT 6343 attempt to use any other encoding. If one party to an XML stream 6344 detects that the other party has attempted to send XML data with an 6345 encoding other than UTF-8, it MUST return a stream error, which 6346 SHOULD be (although some existing 6347 implementations send instead). 6349 Implementation Note: Because it is mandatory for an XMPP 6350 implementation to support all and only the UTF-8 encoding and 6351 because UTF-8 always has the same byte order, an implementation 6352 MUST NOT send a byte order mark ("BOM") at the beginning of the 6353 data stream. If an entity receives the [UNICODE] character U+FEFF 6354 anywhere in an XML stream (including as the first character of the 6355 stream), it MUST interpret that character as a zero width no-break 6356 space, not as a byte order mark. 6358 11.7. Whitespace 6360 Except where explicitly disallowed (e.g., during TLS negotiation 6361 (Section 5) and SASL negotiation (Section 6)), either entity MAY send 6362 whitespace as separators between XML stanzas or between any other 6363 first-level elements sent over the stream. One common use for 6364 sending such whitespace is explained under Section 4.4. 6366 11.8. XML Versions 6368 XMPP is an application profile of XML 1.0. A future version of XMPP 6369 might be defined in terms of higher versions of XML, but this 6370 specification defines XMPP only in terms of XML 1.0. 6372 12. Internationalization Considerations 6374 As specified under Section 11.6, XML streams MUST be encoded in 6375 UTF-8. 6377 As specified under Section 4.6, an XML stream SHOULD include an 'xml: 6378 lang' attribute specifying the default language for any XML character 6379 data that is intended to be presented to a human user. As specified 6380 under Section 8.1.5, an XML stanza SHOULD include an 'xml:lang' 6381 attribute if the stanza contains XML character data that is intended 6382 to be presented to a human user. A server SHOULD apply the default 6383 'xml:lang' attribute to stanzas it routes or delivers on behalf of 6384 connected entities, and MUST NOT modify or delete 'xml:lang' 6385 attributes on stanzas it receives from other entities. 6387 Internationalization of XMPP addresses is specified in [XMPP-ADDR]. 6389 13. Security Considerations 6391 13.1. Fundamentals 6393 XMPP technologies are typically deployed using a decentralized 6394 client-server architecture. As a result, several paths are possible 6395 when two XMPP entities need to communicate: 6397 1. Both entities are servers. In this case, the entities can 6398 establish a direct server-to-server stream between themselves. 6400 2. One entity is a server and the other entity is a client whose 6401 account is hosted on that server. In this case, the entities can 6402 establish a direct client-to-server stream between themselves. 6404 3. Both entities are clients whose accounts are hosted on the same 6405 server. In this case, the entities cannot establish a direct 6406 stream between themselves, but there is only one intermediate 6407 entity between them, whose policies they might understand and in 6408 which they might have some level of trust (e.g., the server might 6409 require the use of Transport Layer Security for all client 6410 connections). 6412 4. Both entities are clients but their accounts are hosted on 6413 different servers. In this case, the entities cannot establish a 6414 direct stream between themselves and there are two intermediate 6415 entities between them; each client might have some trust in the 6416 server that hosts its account but might know nothing about the 6417 policies of the server to which the other client connects. 6419 This specification covers only the security of a direct XML stream 6420 between two servers or between a client and a server (cases #1 and 6421 #2), where each stream can be considered a single "hop" along a 6422 communication path. The goal of security for a multi-hop path (cases 6423 #3 and #4), although very desirable, is out of scope for this 6424 specification. 6426 In accordance with [SEC-GUIDE], this specification covers 6427 communication security (confidentiality, data integrity, and peer 6428 entity authentication), non-repudiation, and systems security 6429 (unauthorized usage, inappropriate usage, and denial of service). We 6430 also discuss common security issues such as information leaks, 6431 firewalls, and directory harvesting, as well as best practices 6432 related to the re-use of technologies such as base64, DNS, 6433 cryptographic hash functions, SASL, TLS, UTF-8, and XML. 6435 13.2. Threat Model 6437 The threat model for XMPP is in essence the standard "Internet Threat 6438 Model" described in [SEC-GUIDE]. Attackers are assumed to be 6439 interested in and capable of launching the following attacks against 6440 unprotected XMPP systems: 6442 o Eavesdropping 6443 o Sniffing passwords 6444 o Breaking passwords through dictionary attacks 6445 o Discovering usernames through directory harvesting attacks 6446 o Replaying, inserting, deleting, or modifying stanzas 6447 o Spoofing users 6448 o Gaining unauthorized entry to a server or account 6449 o Using a server or account inappropriately 6450 o Denying service to other entities 6451 o Subverting communication streams through man-in-the-middle attacks 6452 o Gaining control over on-path servers 6454 Where appropriate, the following sections describe methods for 6455 protecting against these threats. 6457 13.3. Order of Layers 6459 The order of layers in which protocols MUST be stacked is as follows: 6461 1. TCP 6462 2. TLS 6463 3. SASL 6464 4. XMPP 6466 This order has important security characteristics, as described 6467 throughout these security considerations. 6469 Within XMPP, XML stanzas are ordered on top of XML streams, as 6470 described under Section 4. 6472 13.4. Confidentiality and Integrity 6474 The use of Transport Layer Security (TLS) with non-null cipher suites 6475 provides a reliable mechanism for the ensuring the confidentiality 6476 and integrity of data exchanged between a client and a server or 6477 between two servers. Therefore TLS helps to protect against 6478 eavesdropping, password sniffing, man-in-the-middle attacks, and 6479 stanza replays, insertion, deletion, and modification over an XML 6480 stream. XMPP clients and servers MUST support TLS as defined under 6481 Section 5. 6483 Informational Note: The confidentiality and integrity of a stream 6484 can be ensured by methods other than TLS, e.g. by means of a SASL 6485 mechanism that involves negotiation of a security layer. 6487 Security Note: The use of TLS in XMPP applies to a single stream. 6488 Because XMPP is typically deployed using a distributed client- 6489 server architecture (as explained under Section 2.5), a stanza 6490 might traverse multiple streams, and not all of those streams 6491 might be TLS-protected. For example, a stanza sent from a client 6492 with a session at one server (e.g., ) 6493 and intended for delivery to a client with a session at another 6494 server (e.g., ) will traverse three 6495 streams: the stream from the sender's client to its server, the 6496 stream from the sender's server to the recipient's server, and the 6497 stream from the recipient's server to the recipient's client. 6498 Furthermore, the stanza will be processed as cleartext within the 6499 sender's server and the recipient's server. Therefore, even if 6500 the stream from the sender's client to its server is protected, 6501 the confidentiality and integrity of a stanza sent over that 6502 protected stream cannot be guaranteed when the stanza is processed 6503 by the sender's server, sent from the sender's server to the 6504 recipient's server, processed by the recipient's server, or sent 6505 from the recipient's server to the recipient's client. Only a 6506 robust technology for end-to-end encryption could ensure the 6507 confidentiality and integrity of a stanza as it traverses all of 6508 the "hops" along a communication path (e.g., a technology that 6509 meets the requirements defined in [E2E-REQS]). Unfortunately, the 6510 XMPP community has so far failed to produce an end-to-end 6511 encryption technology that might be suitable for widespread 6512 implementation and deployment, and definition of such a technology 6513 is out of scope for this document. 6515 13.5. Peer Entity Authentication 6517 The use of the Simple Authentication and Security Layer (SASL) for 6518 authentication provides a reliable mechanism for peer entity 6519 authentication. Therefore SASL helps to protect against user 6520 spoofing, unauthorized usage, and man-in-the middle attacks. XMPP 6521 clients and servers MUST support SASL as defined under Section 6. 6523 13.6. Strong Security 6525 [STRONGSEC] defines "strong security" and its importance to 6526 communication over the Internet. For the purpose of XMPP 6527 communication over client-to-server and server-to-server streams, the 6528 term "strong security" refers to the use of security technologies 6529 that provide both mutual authentication and integrity checking (e.g., 6530 a combination of TLS encryption and SASL authentication using 6531 appropriate SASL mechanisms). In particular, when using certificate- 6532 based authentication to provide strong security, a trust chain SHOULD 6533 be established out-of-band, although a shared certification authority 6534 signing certificates could allow a previously unknown certificate to 6535 establish trust in-band. See the next section regarding certificate 6536 validation procedures. 6538 Implementations MUST support strong security. Service provisioning 6539 SHOULD use strong security. 6541 The initial stream and the response stream MUST be secured 6542 separately, although security in both directions MAY be established 6543 via mechanisms that provide mutual authentication. 6545 13.7. Certificates 6547 Channel encryption of an XML stream using Transport Layer Security as 6548 described under Section 5, and in some cases also authentication as 6549 described under Section 6, is commonly based on a digital certificate 6550 presented by the receiving entity (or, in the case of mutual 6551 authentication, both the receiving entity and the initiating entity). 6552 This section describes best practices regarding the generation of 6553 digital certificates to be presented by XMPP entities and the 6554 verification of digital certificates presented by XMPP entities. 6556 In general, the following sections rely on and extend the rules and 6557 guidelines provided in the [PKIX] profile of [X509], and in 6558 [TLS-CERTS]. The reader is referred to those specifications for a 6559 detailed understanding of PKIX certificates and their use in TLS. 6561 13.7.1. Certificate Generation 6563 13.7.1.1. General Considerations 6565 The following rules apply to public key certificates that are issued 6566 to XMPP entities: 6568 1. The certificate MUST conform to [PKIX]. 6570 2. The certificate MUST NOT contain a basicConstraints extension 6571 with the cA boolean set to TRUE. 6573 3. The subject field MUST NOT be null. 6575 4. The hash algorithm for the signature SHOULD be SHA-256 as defined 6576 by [PKIX-ALGO]. 6578 5. The certificate SHOULD include an Authority Information Access 6579 (AIA) extension that specifies the address of an Online 6580 Certificate Status Protocol [OCSP] responder. 6582 The following rules apply to issuers of XMPP certificates: 6584 1. The certificate MUST conform to [PKIX]. 6586 2. The certificate MUST contain a keyUsage extension with the 6587 digitalSignature bit set. 6589 3. The subject field MUST NOT be null. 6591 4. The hash algorithm for the signature SHOULD be SHA-256 as defined 6592 by [PKIX-ALGO]. 6594 5. For issuers of public key certificates, the issuer's certificate 6595 MUST contain a basicConstraints extension with the cA boolean set 6596 to TRUE. 6598 6. For issuers of access certificates, the issuer's certificate MUST 6599 NOT contain a basicConstraints extension with the cA boolean set 6600 to TRUE. 6602 13.7.1.2. Server Certificates 6604 13.7.1.2.1. Rules 6606 In a digital certificate to be presented by an XMPP server (i.e., a 6607 SERVER CERTIFICATE), it is RECOMMENDED for the certificate to include 6608 one or more JIDs (i.e., domainparts) associated with domains serviced 6609 at the server. The rules and guidelines defined in [TLS-CERTS] apply 6610 to XMPP server certificates, with the following supplemental rules 6611 for XMPP: 6613 o Support for the DNS-ID identifier type [PKIX] is REQUIRED in XMPP 6614 client and server software implementations. Certification 6615 authorities that issue XMPP-specific certificates MUST support the 6616 DNS-ID identifier type. Service providers SHOULD include the 6617 DNS-ID identifier type in certificate requests. 6619 o Support for the SRV-ID identifier type [PKIX-SRV] is REQUIRED for 6620 XMPP client and server software implementations (XMPP client 6621 implementations need to support only the "_xmpp-client" service 6622 type, whereas XMPP server implementations need to support both the 6623 "_xmpp-client" and "_xmpp-server" service types). Certification 6624 authorities that issue XMPP-specific certificates SHOULD support 6625 the SRV-ID identifier type. Service providers SHOULD include the 6626 SRV-ID identifier type in certificate requests. 6628 o Support for the XmppAddr identifier type (specified under 6629 Section 13.7.1.4) is encouraged in XMPP client and server software 6630 implementations for the sake of backward-compatibility, but is no 6631 longer encouraged in certificates issued by certification 6632 authorities or requested by service providers. 6634 13.7.1.2.2. Examples 6636 For our first (relatively simple) example, consider a company called 6637 "Example Products, Inc." It hosts an XMPP service at 6638 "im.example.com" (i.e., user addresses at the service are of the form 6639 "user@im.example.com"), and SRV lookups for the xmpp-client and xmpp- 6640 server services at "im.example.com" yield one machine, called 6641 "x.example.com", as follows: 6643 _xmpp-client._tcp.im.example.com. 400 IN SRV 20 0 5222 x.example.com 6644 _xmpp-server._tcp.im.example.com. 400 IN SRV 20 0 5269 x.example.com 6646 The certificate presented by x.example.com contains the following 6647 representations: 6649 o An otherName type of SRVName (id-on-dnsSRV) containing an 6650 IA5String (ASCII) string of: "_xmpp-client.im.example.com" 6652 o An otherName type of SRVName (id-on-dnsSRV) containing an 6653 IA5String (ASCII) string of: "_xmpp-server.im.example.com" 6655 o A dNSName containing an ASCII string of "im.example.com" 6657 o An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 6658 string of: "im.example.com" 6660 o A CN containing an ASCII string of "Example Products, Inc." 6662 For our second (more complex) example, consider an ISP called 6663 "Example Internet Services". It hosts an XMPP service at 6664 "example.net" (i.e., user addresses at the service are of the form 6665 "user@example.net"), but SRV lookups for the xmpp-client and xmpp- 6666 server services at "example.net" yield two machines ("x1.example.net" 6667 and "x2.example.net"), as follows: 6669 _xmpp-client._tcp.example.net. 68400 IN SRV 20 0 5222 x1.example.net. 6670 _xmpp-client._tcp.example.net. 68400 IN SRV 20 0 5222 x2.example.net. 6671 _xmpp-server._tcp.example.net. 68400 IN SRV 20 0 5269 x1.example.net. 6672 _xmpp-server._tcp.example.net. 68400 IN SRV 20 0 5269 x2.example.net. 6674 Example Internet Services also hosts chatrooms at chat.example.net, 6675 and provides an xmpp-server SRV record for that service as well (thus 6676 enabling entity from remote domains to access that service). It also 6677 might provide other such services in the future, so it wishes to 6678 represent a wildcard in its certificate to handle such growth. 6680 The certificate presented by either x1.example.net or x2.example.net 6681 contains the following representations: 6683 o An otherName type of SRVName (id-on-dnsSRV) containing an 6684 IA5String (ASCII) string of: "_xmpp-client.example.net" 6686 o An otherName type of SRVName (id-on-dnsSRV) containing an 6687 IA5String (ASCII) string of: "_xmpp-server.example.net" 6689 o An otherName type of SRVName (id-on-dnsSRV) containing an 6690 IA5String (ASCII) string of: "_xmpp-server.chat.example.net" 6692 o A dNSName containing an ASCII string of "example.net" 6694 o A dNSName containing an ASCII string of "*.example.net" 6695 o An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 6696 string of: "example.net" 6698 o An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 6699 string of: "chat.example.net" 6701 o A CN containing an ASCII string of "Example Internet Services" 6703 13.7.1.3. Client Certificates 6705 In a digital certificate to be presented by an XMPP client controlled 6706 by a human user (i.e., a CLIENT CERTIFICATE), it is RECOMMENDED for 6707 the certificate to include one or more JIDs associated with an XMPP 6708 user. If included, a JID MUST be represented as an XmppAddr as 6709 specified under Section 13.7.1.4. 6711 13.7.1.4. XmppAddr Identifier Type 6713 The XmppAddr identifier type is a UTF8String within an otherName 6714 entity inside the subjectAltName, using the [ASN.1] Object Identifier 6715 "id-on-xmppAddr" specified below. 6717 id-pkix OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) 6718 dod(6) internet(1) security(5) mechanisms(5) pkix(7) } 6720 id-on OBJECT IDENTIFIER ::= { id-pkix 8 } -- other name forms 6722 id-on-xmppAddr OBJECT IDENTIFIER ::= { id-on 5 } 6724 XmppAddr ::= UTF8String 6726 As an alternative to the "id-on-xmppAddr" notation, this Object 6727 Identifier MAY be represented in dotted display format (i.e., 6728 "1.3.6.1.5.5.7.8.5") or in the Uniform Resource Name notation 6729 specified in [URN-OID] (i.e., "urn:oid:1.3.6.1.5.5.7.8.5"). 6731 Thus for example the JID as included in a 6732 certificate could be formatted in any of the following three ways: 6734 id-on-xmppAddr: 6735 subjectAltName=otherName:id-on-xmppAddr;UTF8:juliet@im.example.com 6737 dotted display format: subjectAltName=otherName: 6738 1.3.6.1.5.5.7.8.5;UTF8:juliet@im.example.com 6740 URN notation: subjectAltName=otherName:urn:oid: 6741 1.3.6.1.5.5.7.8.5;UTF8:juliet@im.example.com 6743 Use of the "id-on-xmppAddr" format is RECOMMENDED in the generation 6744 of certificates, but all three formats MUST be supported for the 6745 purpose of certificate validation. 6747 The "id-on-xmppAddr" object identifier MAY be used on conjuction with 6748 the extended key usage extension specified in Section 4.2.1.12 of 6749 [PKIX] in order to explicitly define and limit the intended use of a 6750 certificate to the XMPP network. 6752 13.7.2. Certificate Validation 6754 When an XMPP entity is presented with a server certificate or client 6755 certificate by a peer for the purpose of encryption or authentication 6756 of XML streams as described under Section 5 and Section 6, the entity 6757 MUST attempt to validate the certificate to determine if the 6758 certificate will be considered a TRUSTED CERTIFICATE, i.e., a 6759 certificate that is acceptable for encryption and/or authentication 6760 in accordance with the XMPP entity's local service policies or 6761 configured settings. 6763 For both server certificates and client certificates, the validating 6764 entity MUST attempt to verify the integrity of the certificate, MUST 6765 attempt to verify that the certificate has been properly signed by 6766 the issuing Certificate Authority, MUST attempt to validate the full 6767 certification path, and MUST support certificate revocation messages. 6768 An implementation MUST enable a human user to view information about 6769 the certification path. 6771 If these validation attempts fail, either entity MAY choose to 6772 unilaterally terminate the session. 6774 The following sections describe certificate validation rules for 6775 server-to-server and client-to-server streams. 6777 13.7.2.1. Server Certificates 6779 For server certificates, the rules and guidelines defined in 6780 [TLS-CERTS] apply, with the proviso that the XmppAddr identifier 6781 specified under Section 13.7.1.4 is allowed as a reference 6782 identifier. 6784 13.7.2.2. Client Certificates 6786 When an XMPP server validates a certificate presented by a client, 6787 there are three possible cases, as discussed in the following 6788 sections. 6790 13.7.2.2.1. Case #1 6792 If the client certificate appears to be certified by a certification 6793 path terminating in a trust anchor (as described in Section 6.1 of 6794 [PKIX]), the server MUST check the certificate for any instances of 6795 the XmppAddr as described under Section 13.7.1.4. There are three 6796 possible sub-cases: 6798 Sub-Case #1: The server finds one XmppAddr for which the domainpart 6799 of the represented JID matches one of the configured hostnames of 6800 the server; the server SHOULD use this represented JID as the 6801 validated identity of the client. 6803 Sub-Case #2: The server finds more than one XmppAddr for which the 6804 domainpart of the represented JID matches one of the configured 6805 hostnames of the server; the server SHOULD use one of these 6806 represented JIDs as the validated identity of the client, choosing 6807 among them according to local service policies or based on the 6808 'to' address of the initial stream header. 6810 Sub-Case #3: The server finds no XmppAddrs, or finds at least one 6811 XmppAddr but the domainpart of the represented JID does not match 6812 one of the configured hostnames of the server; the server MUST NOT 6813 use the represented JID (if any) as the validated identity of the 6814 client but instead MUST either validate the identity of the client 6815 using other means. 6817 13.7.2.2.2. Case #2 6819 If the client certificate is certified by a Certificate Authority not 6820 known to the server, the server MUST proceed as under Case #1, Sub- 6821 Case #3. 6823 13.7.2.2.3. Case #3 6825 If the client certificate is self-signed, the server MUST proceed as 6826 under Case #1, Sub-Case #3. 6828 13.7.2.3. Checking of Certificates in Long-Lived Streams 6830 Because XMPP uses long-lived XML streams, it is possible that a 6831 certificate presented during stream negotiation might expire or be 6832 revoked while the stream is still live (this is especially relevant 6833 in the context of server-to-server streams). Therefore, each party 6834 to a long-lived stream SHOULD: 6836 1. Cache the expiration date of the certificate presented by the 6837 other party and any certificates on which that certificate 6838 depends (such as a root or intermediate certificate for a 6839 certification authority), and close the stream when any such 6840 certificate expires, with a stream error of 6841 (Section 4.8.3.16). 6843 2. Periodically query the Online Certificate Status Protocol [OCSP] 6844 responder listed in the Authority Information Access (AIA) 6845 extension of the certificate presented by the other party and any 6846 certificates on which that certificate depends (such as a root or 6847 intermediate certificate for a certification authority), and 6848 close the stream if any such certificate has been revoked, with a 6849 stream error of (Section 4.8.3.16). 6851 After the stream is closed, the initiating entity from the closed 6852 stream will need to re-connect and the receiving entity will need to 6853 authenticate the initiating entity based on whatever certificate it 6854 presents during negotiation of the new stream. 6856 13.7.2.4. Use of Certificates in XMPP Extensions 6858 Certificates MAY be used in extensions to XMPP for the purpose of 6859 application-layer encryption or authentication above the level of XML 6860 streams (e.g., for end-to-end encryption). Such extensions will 6861 define their own certificate handling rules, which at a minimum 6862 SHOULD be consistent with the rules defined in this specification but 6863 MAY specify additional rules. 6865 13.8. Mandatory-to-Implement Technologies 6867 At a minimum, all implementations MUST support the following 6868 technologies: 6870 for authentication only: the SASL Salted Challenge Response 6871 mechanism [SCRAM], in particular the SCRAM-SHA-1 variant 6872 (REQUIRED) and SCRAM-SHA-1-PLUS variant (RECOMMENDED if channel 6873 binding is possible); although the SASL PLAIN mechanism [PLAIN] 6874 can also be used for authentication only, such usage is strongly 6875 discouraged 6877 for confidentiality only: TLS (using the 6878 TLS_RSA_WITH_AES_128_CBC_SHA cipher) 6880 for both confidentiality and authentication with passwords: TLS plus 6881 SCRAM-SHA-1 (REQUIRED) or SCRAM-SHA-1-PLUS (RECOMMENDED); 6882 alternatively, TLS plus SASL PLAIN (but see further security 6883 considerations under Section 13.9.4) 6885 for both confidentiality and authentication without passwords: TLS 6886 plus the SASL EXTERNAL mechanism (see Appendix A of [SASL]) using 6887 the TLS_RSA_WITH_AES_128_CBC_SHA cipher supporting peer 6888 certificates (clients SHOULD support this, and servers MUST) 6890 Naturally, implementations MAY support other ciphers with TLS and MAY 6891 support other SASL mechanisms. 6893 Interoperability Note: The use of the SCRAM-SHA-1 or SASL-SCRAM- 6894 SHA-1-PLUS mechanism replaces the SASL DIGEST-MD5 mechanism as 6895 XMPP's mandatory-to-implement password-based method for 6896 authentication only, and the use of TLS plus either of those SCRAM 6897 variants or TLS plus PLAIN replaces TLS plus DIGEST-MD5. For 6898 backward-compatibility with existing deployed infrastructure, 6899 implementations are encouraged to continue supporting the DIGEST- 6900 MD5 mechanism as specified in [DIGEST-MD5], however there are 6901 known interoperability issues with DIGEST-MD5 that make it 6902 impractical in the long term. The use of the SCRAM-SHA-1 and 6903 SCRAM-SHA-1-PLUS mechanisms is strongly preferred over the SASL 6904 PLAIN mechanism because of their superior security properties, and 6905 PLAIN is intended to be a fallback only for implementations that 6906 do not yet support SCRAM. For important security considerations 6907 related to these SASL mechanisms, see Section 13.9.4 and also 6908 refer to [SCRAM] and [PLAIN]. 6910 13.9. Technology Reuse 6912 13.9.1. Use of base64 in SASL 6914 Both the client and the server MUST verify any base64 data received 6915 during SASL negotiation (Section 6). An implementation MUST reject 6916 (not ignore) any characters that are not explicitly allowed by the 6917 base64 alphabet; this helps to guard against creation of a covert 6918 channel that could be used to "leak" information. 6920 An implementation MUST NOT break on invalid input and MUST reject any 6921 sequence of base64 characters containing the pad ('=') character if 6922 that character is included as something other than the last character 6923 of the data (e.g., "=AAA" or "BBBB=CCC"); this helps to guard against 6924 buffer overflow attacks and other attacks on the implementation. 6926 While base 64 encoding visually hides otherwise easily recognized 6927 information (such as passwords), it does not provide any 6928 computational confidentiality. 6930 All uses of base 64 encoding MUST follow the definition in Section 4 6931 of [BASE64] and padding bits MUST be set to zero. 6933 13.9.2. Use of DNS 6935 XMPP typically relies on the Domain Name System (specifically 6936 [DNS-SRV] records) to resolve a fully qualified domain name to an IP 6937 address before a client connects to a server or before a peer server 6938 connects to another server. Before attempting to negotiate an XML 6939 stream, the initiating entity MUST NOT proceed until it has resolved 6940 the DNS domain name of the peer server as specified under Section 3 6941 (although it is not necessary to resolve the DNS domain name before 6942 each connection attempt, because DNS resolution results can be 6943 temporarily cached in accordance with time-to-live values). However, 6944 in the absence of a secure DNS option (e.g., as provided by 6945 [DNSSEC]), a malicious attacker with access to the DNS server data, 6946 or able to cause spoofed answers to be cached in a recursive 6947 resolver, can potentially cause the initiating entity to connect to 6948 any XMPP server chosen by the attacker. Deployment and validation of 6949 server certificates helps to prevent such attacks. 6951 13.9.3. Use of Hash Functions 6953 XMPP itself does not directly mandate the use of any particular hash 6954 function. However, technologies on which XMPP depends (e.g., TLS and 6955 particular SASL mechanisms), as well as various XMPP extensions, 6956 might make use of hash functions. Those who implement XMPP 6957 technologies or who develop XMPP extensions are advised to closely 6958 monitor the state of the art regarding attacks against cryptographic 6959 hashes in Internet protocols as they relate to XMPP. For helpful 6960 guidance, refer to [HASHES]. 6962 13.9.4. Use of SASL 6964 Because the initiating entity chooses an acceptable SASL mechanism 6965 from the list presented by the receiving entity, the initiating 6966 entity depends on the receiving entity's list for authentication. 6967 This dependency introduces the possibility of a downgrade attack if 6968 an attacker can gain control of the channel and therefore present a 6969 weak list of mechanisms. To help prevent this attack, the parties 6970 SHOULD protect the channel using TLS before attempting SASL 6971 negotiation. 6973 If the initiating entity (typically a client) is willing to use SASL 6974 PLAIN over TLS to authenticate to an XMPP server, it MUST verify the 6975 server certificate. If the server has not provided any certificate, 6976 or if certificate validation fails (as described under 6977 Section 13.7.2), the initiating entity MUST NOT attempt to 6978 authenticate using the SASL PLAIN mechanism. After a successful TLS 6979 negotiation, the initiating entity MUST check its understanding of 6980 the server hostname against the server's identity as presented in the 6981 TLS Certificate message, in order to prevent man-in-the-middle 6982 attacks. If the match fails, the client MUST NOT attempt to 6983 authenticate using the SASL PLAIN mechanism. Server identity 6984 matching MUST follow the rules specified in [TLS-CERTS]. 6986 The SASL framework itself does not provide a method for binding SASL 6987 authentication to a security layer providing confidentiality and 6988 integrity protection that was negotiated at a lower layer. Such a 6989 binding is known as a "channel binding" (see [CHANNEL]). Some SASL 6990 mechanisms provide channel bindings, which in the case of XMPP would 6991 typically be a binding to TLS (see [CHANNEL-TLS]). If a SASL 6992 mechanism provides a channel binding (e.g., this is true of [SCRAM]), 6993 then XMPP entities using that mechanism SHOULD prefer the channel 6994 binding variant (e.g., preferring "SCRAM-SHA-1-PLUS" over 6995 "SCRAM-SHA-1"). If a SASL mechanism does not provide a channel 6996 binding, then the mechanism cannot provide a way to verify that the 6997 source and destination end points to which the lower layer's security 6998 is bound are equivalent to the end points that SASL is 6999 authenticating; furthermore, if the end points are not identical, 7000 then the lower layer's security cannot be trusted to protect data 7001 transmitted between the SASL-authenticated entities. In such a 7002 situation, a SASL security layer SHOULD be negotiated that 7003 effectively ignores the presence of the lower-layer security. 7005 Most XMPP servers authenticate account connections by means of 7006 passwords. It is well-known that most human users choose relatively 7007 weak passwords. Although service provisioning is out of scope for 7008 this document, XMPP servers that allow password-based authentication 7009 SHOULD enforce minimal criteria for password strength to help prevent 7010 dictionary attacks. 7012 Some SASL mechanisms (e.g., [ANONYMOUS]) do not provide strong peer 7013 entity authentication of the client to the server. Service 7014 administrators are advised to enable such mechanisms with caution. 7015 Best practices for the use of the SASL ANONYMOUS mechanism in XMPP 7016 are described in [XEP-0175]. 7018 13.9.5. Use of TLS 7020 Implementations of TLS typically support multiple versions of the 7021 Transport Layer Security protocol as well as the older Secure Sockets 7022 Layer (SSL) protocol. Because of known security vulnerabilities, 7023 XMPP servers and clients MUST NOT request, offer, or use SSL 2.0. 7025 See Appendix E.2 of [TLS] for further details. 7027 13.9.6. Use of UTF-8 7029 The use of UTF-8 makes it possible to transport non-ASCII characters, 7030 and thus enables character "spoofing" scenarios, in which a displayed 7031 value appears to be something other than it is. Furthermore, there 7032 are known attack scenarios related to the decoding of UTF-8 data. On 7033 both of these points, refer to [UTF-8] for more information. 7035 13.9.7. Use of XML 7037 Because XMPP is an application profile of the Extensible Markup 7038 Language [XML], many of the security considerations described in 7039 [XML-MEDIA] and [XML-GUIDE] also apply to XMPP. Several aspects of 7040 XMPP mitigate the risks described there, such as the prohibitions 7041 specified under Section 11.1 and the lack of external references to 7042 style sheets or transformations, but these mitigating factors are by 7043 no means comprehensive. 7045 13.10. Information Leaks 7047 13.10.1. IP Addresses 7049 A client's IP address and method of access MUST NOT be made public by 7050 a server. 7052 13.10.2. Presence Information 7054 One of the core aspects of XMPP is presence: information about the 7055 network availability of an XMPP entity (i.e., whether the entity is 7056 currently online or offline). A "presence leak" occurs when an 7057 entity's network availability is inadvertently and involuntarily 7058 revealed to a second entity that is not authorized to know the first 7059 entity's network availability. 7061 Although presence is discussed more fully in [XMPP-IM], it is 7062 important to note that an XMPP server MUST NOT leak presence. In 7063 particular at the core XMPP level, real-time addressing and network 7064 availability is associated with a specific connected resource; 7065 therefore, any disclosure of a connected resource's full JID 7066 comprises a presence leak. To help prevent such a presence leak, a 7067 server MUST NOT return different stanza errors if a potential 7068 attacker sends XML stanzas to the entity's bare JID 7069 () or full JID 7070 (). 7072 13.11. Directory Harvesting 7074 If a server generates an error stanza in response to receiving a 7075 stanza for a user account that does not exist, using the stanza error condition can help protect against 7077 directory harvesting attacks, since this is the same error condition 7078 that is returned if, for instance, the namespace of an IQ child 7079 element is not understood, or if "offline message storage" 7080 ([XEP-0160]) or message forwarding is not enabled for a domain. 7081 However, subtle differences in the exact XML of error stanzas, as 7082 well as in the timing with which such errors are returned, can enable 7083 an attacker to determine the network presence of a user when more 7084 advanced blocking technologies are not used (see for instance 7085 [XEP-0016] and [XEP-0191]). Therefore, a server that exercises a 7086 higher level of caution might not return any error at all in response 7087 to certain kinds of received stanzas, so that a non-existent user 7088 appears to behave like a user that has no interest in conversing with 7089 the sender. 7091 13.12. Denial of Service 7093 [DOS] defines denial of service as follows: 7095 A Denial-of-Service (DoS) attack is an attack in which one or more 7096 machines target a victim and attempt to prevent the victim from 7097 doing useful work. The victim can be a network server, client or 7098 router, a network link or an entire network, an individual 7099 Internet user or a company doing business using the Internet, an 7100 Internet Service Provider (ISP), country, or any combination of or 7101 variant on these. 7103 Some considerations discussed in this document help to prevent denial 7104 of service attacks (e.g., the mandate that a server MUST NOT process 7105 XML stanzas from clients that have not yet provided appropriate 7106 authentication credentials and MUST NOT process XML stanzas from peer 7107 servers whose identity it has not either authenticated via SASL or 7108 weakly verified via Server Dialback). 7110 In addition, [XEP-0205] provides a detailed discussion of potential 7111 denial of service attacks against XMPP systems and best practices for 7112 preventing such attacks. The recommendations include: 7114 1. A server implementation SHOULD enable a server administrator to 7115 limit the number of TCP connections that it will accept from a 7116 given IP address at any one time. If an entity attempts to 7117 connect but the maximum number of TCP connections has been 7118 reached, the receiving server MUST NOT allow the new connection 7119 to proceed. 7121 2. A server implementation SHOULD enable a server administrator to 7122 limit the number of TCP connection attempts that it will accept 7123 from a given IP address in a given time period. If an entity 7124 attempts to connect but the maximum number of connection attempts 7125 has been reached, the receiving server MUST NOT allow the new 7126 connection to proceed. 7128 3. A server implementation SHOULD enable a server administrator to 7129 limit the number of connected resources it will allow an account 7130 to bind at any one time. If a client attempts to bind a resource 7131 but it has already reached the configured number of allowable 7132 resources, the receiving server MUST return a stanza error. 7135 4. A server implementation SHOULD enable a server administrator to 7136 limit the size of stanzas it will accept from a connected client 7137 or peer server (where "size" is inclusive of all XML markup as 7138 defined in Section 2.4 of [XML], from the opening "<" character 7139 of the stanza to the closing ">" character). An entity's maximum 7140 stanza size MUST NOT be smaller than 10000 bytes. If a connected 7141 resource or peer server sends a stanza that violates the upper 7142 limit, the receiving server MUST either return a stanza error (thus allowing the sender to recover) or 7144 close the stream with a stream error. 7146 5. A server implementation SHOULD enable a server administrator to 7147 limit the number of XML stanzas that a connected client is 7148 allowed to send to distinct recipients within a given time 7149 period. If a connected client sends too many stanzas to distinct 7150 recipients in a given time period, the receiving server SHOULD 7151 NOT process the stanza and instead SHOULD return a stanza error. 7154 6. A server implementation SHOULD enable a server administrator to 7155 limit the amount of bandwidth it will allow a connected client or 7156 peer server to use in a given time period. 7158 7. A server implementation MAY enable a server administrator to 7159 limit the types of stanzas (based on the extended content 7160 "payload") that it will allow a connected resource or peer server 7161 send over an active connection. Such limits and restrictions are 7162 a matter of deployment policy. 7164 8. A server implementation MAY refuse to route or deliver any stanza 7165 that it considers to be abusive, with or without returning an 7166 error to the sender. 7168 For more detailed recommendations regarding denial of service attacks 7169 in XMPP systems, refer to [XEP-0205]. 7171 13.13. Firewalls 7173 Although DNS SRV records can instruct connecting entities to use TCP 7174 ports other than 5222 (client-to-server) and 5269 (server-to-server), 7175 communication using XMPP typically occurs over those ports, which are 7176 registered with the IANA (see Section 14). Use of these well-known 7177 ports allows administrators to easily enable or disable XMPP activity 7178 through existing and commonly-deployed firewalls. 7180 13.14. Interdomain Federation 7182 The term "federation" is commonly used to describe communication 7183 between two servers. 7185 Because service provisioning is a matter of policy, it is OPTIONAL 7186 for any given server to support federation. If a particular server 7187 enables federation, it SHOULD enable strong security as previously 7188 described to ensure both authentication and confidentiality; 7189 compliant implementations SHOULD support TLS and SASL for this 7190 purpose. 7192 Before RFC 3920 defined TLS plus SASL EXTERNAL with certificates for 7193 encryption and authentication of server-to-server streams, the only 7194 method for weak identity verification of a peer server was Server 7195 Dialback as defined in [XEP-0220]. Even when [DNSSEC] is used, 7196 Server Dialback provides only weak identity verification and provides 7197 no confidentiality or integrity. At the time of writing, Server 7198 Dialback is still the most widely-used technique for some level of 7199 assurance over server-to-server streams. This reality introduces the 7200 possibility of a downgrade attack from TLS + SASL EXTERNAL to Server 7201 Dialback if an attacker can gain control of the channel and therefore 7202 convince the initiating server that the receiving server does not 7203 support TLS or does not have an appropriate certificate. To help 7204 prevent this attack, the parties SHOULD protect the channel using TLS 7205 before proceeding, even if the presented certificates are self-signed 7206 or otherwise untrusted. 7208 13.15. Non-Repudiation 7210 Systems that provide both peer entity authentication and data 7211 integrity have the potential to enable an entity to prove to a third 7212 party that another entity intended to send particular data. Although 7213 XMPP systems can provide both peer entity authentication and data 7214 integrity, XMPP was never designed to provide non-repudiation. 7216 14. IANA Considerations 7218 The following subsections update the registrations provided in 7219 [RFC3920]. This section is to be interpreted according to 7220 [IANA-GUIDE]. 7222 14.1. XML Namespace Name for TLS Data 7224 A URN sub-namespace for STARTTLS negotiation data in the Extensible 7225 Messaging and Presence Protocol (XMPP) is defined as follows. (This 7226 namespace name adheres to the format defined in [XML-REG].) 7228 URI: urn:ietf:params:xml:ns:xmpp-tls 7229 Specification: XXXX 7230 Description: This is the XML namespace name for STARTTLS negotiation 7231 data in the Extensible Messaging and Presence Protocol (XMPP) as 7232 defined by XXXX. 7233 Registrant Contact: IETF, XMPP Working Group, 7235 14.2. XML Namespace Name for SASL Data 7237 A URN sub-namespace for SASL negotiation data in the Extensible 7238 Messaging and Presence Protocol (XMPP) is defined as follows. (This 7239 namespace name adheres to the format defined in [XML-REG].) 7241 URI: urn:ietf:params:xml:ns:xmpp-sasl 7242 Specification: XXXX 7243 Description: This is the XML namespace name for SASL negotiation 7244 data in the Extensible Messaging and Presence Protocol (XMPP) as 7245 defined by XXXX. 7246 Registrant Contact: IETF, XMPP Working Group, 7248 14.3. XML Namespace Name for Stream Errors 7250 A URN sub-namespace for stream error data in the Extensible Messaging 7251 and Presence Protocol (XMPP) is defined as follows. (This namespace 7252 name adheres to the format defined in [XML-REG].) 7254 URI: urn:ietf:params:xml:ns:xmpp-streams 7255 Specification: XXXX 7256 Description: This is the XML namespace name for stream error data in 7257 the Extensible Messaging and Presence Protocol (XMPP) as defined 7258 by XXXX. 7259 Registrant Contact: IETF, XMPP Working Group, 7261 14.4. XML Namespace Name for Resource Binding 7263 A URN sub-namespace for resource binding in the Extensible Messaging 7264 and Presence Protocol (XMPP) is defined as follows. (This namespace 7265 name adheres to the format defined in [XML-REG].) 7267 URI: urn:ietf:params:xml:ns:xmpp-bind 7268 Specification: XXXX 7269 Description: This is the XML namespace name for resource binding in 7270 the Extensible Messaging and Presence Protocol (XMPP) as defined 7271 by XXXX. 7272 Registrant Contact: IETF, XMPP Working Group, 7274 14.5. XML Namespace Name for Stanza Errors 7276 A URN sub-namespace for stanza error data in the Extensible Messaging 7277 and Presence Protocol (XMPP) is defined as follows. (This namespace 7278 name adheres to the format defined in [XML-REG].) 7280 URI: urn:ietf:params:xml:ns:xmpp-stanzas 7281 Specification: XXXX 7282 Description: This is the XML namespace name for stanza error data in 7283 the Extensible Messaging and Presence Protocol (XMPP) as defined 7284 by XXXX. 7285 Registrant Contact: IETF, XMPP Working Group, 7287 14.6. GSSAPI Service Name 7289 The IANA has registered "xmpp" as a [GSS-API] service name, as 7290 defined under Section 6.6. 7292 14.7. Port Numbers and Service Names 7294 The IANA has registered "xmpp-client" and "xmpp-server" as keywords 7295 for [TCP] ports 5222 and 5269 respectively. In accordance with 7296 [IANA-PORTS], this document updates the existing registration, as 7297 follows. 7299 Service Name: xmpp-client 7300 Transport Protocol: TCP 7301 Description: A service offering support for connections by XMPP 7302 client applications 7303 Registrant: IETF XMPP Working Group 7304 Contact: IESG, 7305 Reference: XXXX 7306 Port Number: 5222 7308 Service Name: xmpp-server 7309 Transport Protocol: TCP 7310 Description: A service offering support for connections by XMPP 7311 server applications 7312 Registrant: IETF XMPP Working Group 7313 Contact: IESG, 7314 Reference: XXXX 7315 Port Number: 5269 7317 15. Conformance Requirements 7319 This section describes a protocol feature set that summarizes the 7320 conformance requirements of this specification. This feature set is 7321 appropriate for use in software certification, interoperability 7322 testing, and implementation reports. For each feature, this section 7323 provides the following information: 7325 o A human-readable name 7327 o An informational description 7329 o A reference to the particular section of this document that 7330 normatively defines the feature 7332 o Whether the feature applies to the Client role, the Server role, 7333 or both (where "N/A" signifies that the feature is not applicable 7334 to the specified role) 7336 o Whether the feature MUST or SHOULD be implemented, where the 7337 capitalized terms are to be understood as described in [KEYWORDS] 7339 The feature set specified here attempts to adhere to the concepts and 7340 formats proposed by Larry Masinter within the IETF's NEWTRK Working 7341 Group in 2005, as captured in [INTEROP]. Although this feature set 7342 is more detailed than called for by [REPORTS], it provides a suitable 7343 basis for the generation of implementation reports to be submitted in 7344 support of advancing this specification from Proposed Standard to 7345 Draft Standard in accordance with [PROCESS]. 7347 Feature: bind-gen 7348 Description: Generate a random resource on demand. 7349 Section: Section 7.6 7350 Roles: Client N/A, Server MUST. 7352 Feature: bind-mtn 7353 Description: Consider resource binding as mandatory-to-negotiate. 7354 Section: Section 7.3.1 7355 Roles: Client MUST, Server MUST. 7357 Feature: bind-restart 7358 Description: Do not restart the stream after negotiation of resource 7359 binding. 7360 Section: Section 7.3.2 7361 Roles: Client MUST, Server MUST. 7363 Feature: bind-support 7364 Description: Support binding of client resources to an authenticated 7365 stream. 7366 Section: Section 7 7367 Roles: Client MUST, Server MUST. 7369 Feature: sasl-errors 7370 Description: Support SASL errors during the negotiation process. 7371 Section: Section 6.5 7372 Roles: Client MUST, Server MUST. 7374 Feature: sasl-mtn 7375 Description: Consider SASL as mandatory-to-negotiate. 7376 Section: Section 6.3.1 7377 Roles: Client MUST, Server MUST. 7379 Feature: sasl-restart 7380 Description: Initiate or handle a stream restart after SASL 7381 negotiation. 7382 Section: Section 6.3.2 7383 Roles: Client MUST, Server MUST. 7385 Feature: sasl-support 7386 Description: Support the Simple Authentication and Security Layer 7387 for stream authentication. 7388 Section: Section 6 7389 Roles: Client MUST, Server MUST. 7391 Feature: sasl-whitespace 7392 Description: Ensure that no whitespace is sent between XML elements 7393 during SASL negotiation. 7394 Section: Section 6.3.5 7395 Roles: Client MUST, Server MUST. 7397 Feature: security-mti-auth-plain 7398 Description: Support the SASL PLAIN mechanism for authentication 7399 only. 7400 Section: Section 13.8 7401 Roles: Client MUST, Server MUST. 7403 Feature: security-mti-auth-scram 7404 Description: Support the SASL Salted Challenge Response mechanism 7405 for authentication only. 7406 Section: Section 13.8 7407 Roles: Client MUST, Server MUST. 7409 Feature: security-mti-both-external 7410 Description: Support TLS with SASL EXTERNAL for confidentiality and 7411 authentication. 7412 Section: Section 13.8 7413 Roles: Client SHOULD, Server MUST. 7415 Feature: security-mti-both-plain 7416 Description: Support TLS with SASL PLAIN for confidentiality and 7417 authentication. 7418 Section: Section 13.8 7419 Roles: Client MUST, Server MUST. 7421 Feature: security-mti-both-scram 7422 Description: Support TLS with SASL SCRAM for confidentiality and 7423 authentication. 7424 Section: Section 13.8 7425 Roles: Client MUST, Server MUST. 7427 Feature: security-mti-confidentiality 7428 Description: Support TLS using the TLS_RSA_WITH_AES_128_CBC_SHA 7429 cipher for confidentiality only. 7430 Section: Section 13.8 7431 Roles: Client MUST, Server MUST. 7433 Feature: stanza-attribute-from 7434 Description: Support the common 'from' attribute for all stanza 7435 kinds. 7437 Section: Section 8.1.1 7438 Roles: Client MUST, Server MUST. 7440 Feature: stanza-attribute-from-validate 7441 Description: Validate the 'from' address of all stanzas received 7442 from connected clients or peer servers. 7443 Section: Section 8.1.2 7444 Roles: Client N/A, Server MUST. 7446 Feature: stanza-attribute-id 7447 Description: Support the common 'id' attribute for all stanza kinds. 7448 Section: Section 8.1.3 7449 Roles: Client MUST, Server MUST. 7451 Feature: stanza-attribute-to 7452 Description: Support the common 'to' attribute for all stanza kinds. 7453 Section: Section 8.1.1 7454 Roles: Client MUST, Server MUST. 7456 Feature: stanza-attribute-to-validate 7457 Description: Ensure that all stanzas received from peer servers 7458 include a 'to' address. 7459 Section: Section 8.1.1 7460 Roles: Client N/A, Server MUST. 7462 Feature: stanza-attribute-type 7463 Description: Support the common 'type' attribute for all stanza 7464 kinds. 7465 Section: Section 8.1.4 7466 Roles: Client MUST, Server MUST. 7468 Feature: stanza-attribute-xmllang 7469 Description: Support the common 'xml:lang' attribute for all stanza 7470 kinds. 7471 Section: Section 8.1.5 7472 Roles: Client MUST, Server MUST. 7474 Feature: stanza-error 7475 Description: Generate and handle stanzas of type "error" for all 7476 stanza kinds. 7477 Section: Section 8.3 7478 Roles: Client MUST, Server MUST. 7480 Feature: stanza-error-child 7481 Description: Ensure that stanzas of type "error" include an 7482 child element. 7483 Section: Section 8.3 7484 Roles: Client MUST, Server MUST. 7486 Feature: stanza-error-id 7487 Description: Ensure that stanzas of type "error" preserve the 'id' 7488 provided in the triggering stanza. 7489 Section: Section 8.3 7490 Roles: Client MUST, Server MUST. 7492 Feature: stanza-error-reply 7493 Description: Do not reply to a stanza of type "error" with another 7494 stanza of type "error". 7495 Section: Section 8.3 7496 Roles: Client MUST, Server MUST. 7498 Feature: stanza-extension 7499 Description: Correctly process XML data qualified by an unsupported 7500 XML namespace, where "correctly process" means to ignore that 7501 portion of the stanza in the case of a message or presence stanza 7502 and return an error in the case of an IQ stanza (for the intended 7503 recipient), and to route or deliver the stanza (for a routing 7504 entity such as a server). 7505 Section: Section 8.4 7506 Roles: Client MUST, Server MUST. 7508 Feature: stanza-iq-child 7509 Description: Include exactly one child element in an stanza of 7510 type "get" or "set", zero or one child elements in an stanza 7511 of type "result", and one or two child elements in an stanza 7512 of type "error". 7513 Section: Section 8.2.3 7514 Roles: Client MUST, Server MUST. 7516 Feature: stanza-iq-id 7517 Description: Ensure that all stanzas include an 'id' 7518 attribute. 7519 Section: Section 8.2.3 7520 Roles: Client MUST, Server MUST. 7522 Feature: stanza-iq-reply 7523 Description: Reply to an stanza of type "get" or "set" with an 7524 stanza of type "result" or "error". 7526 Section: Section 8.2.3 7527 Roles: Client MUST, Server MUST. 7529 Feature: stanza-iq-type 7530 Description: Ensure that all stanzas include a 'type' 7531 attribute whose value is "get", "set", "result", or "error". 7532 Section: Section 8.2.3 7533 Roles: Client MUST, Server MUST. 7535 Feature: stanza-kind-iq 7536 Description: Support the stanza. 7537 Section: Section 8.2.3 7538 Roles: Client MUST, Server MUST. 7540 Feature: stanza-kind-message 7541 Description: Support the stanza. 7542 Section: Section 8.2.1 7543 Roles: Client MUST, Server MUST. 7545 Feature: stanza-kind-presence 7546 Description: Support the stanza. 7547 Section: Section 8.2.2 7548 Roles: Client MUST, Server MUST. 7550 Feature: stream-attribute-initial-from 7551 Description: Include a 'from' attribute in the initial stream 7552 header. 7553 Section: Section 4.6.1 7554 Roles: Client SHOULD, Server SHOULD. 7556 Feature: stream-attribute-initial-lang 7557 Description: Include an 'xml:lang' attribute in the initial stream 7558 header. 7559 Section: Section 4.6.4 7560 Roles: Client SHOULD, Server SHOULD. 7562 Feature: stream-attribute-initial-to 7563 Description: Include a 'to' attribute in the initial stream header. 7564 Section: Section 4.6.2 7565 Roles: Client SHOULD, Server SHOULD. 7567 Feature: stream-attribute-response-from 7568 Description: Include a 'from' attribute in the response stream 7569 header. 7571 Section: Section 4.6.1 7572 Roles: Client N/A, Server MUST. 7574 Feature: stream-attribute-response-id 7575 Description: Include an 'id' attribute in the response stream 7576 header. 7577 Section: Section 4.6.3 7578 Roles: Client N/A, Server MUST. 7580 Feature: stream-attribute-response-id-unique 7581 Description: Ensure that the 'id' attribute in the response stream 7582 header is unique within the context of the receiving entity. 7583 Section: Section 4.6.3 7584 Roles: Client N/A, Server MUST. 7586 Feature: stream-attribute-response-to 7587 Description: Include a 'to' attribute in the response stream header. 7588 Section: Section 4.6.2 7589 Roles: Client N/A, Server SHOULD. 7591 Feature: stream-error-generate 7592 Description: Generate a stream error (followed by a closing stream 7593 tag and termination of the TCP connection) upon detecting a 7594 stream-related error condition. 7595 Section: Section 4.8 7596 Roles: Client MUST, Server MUST. 7598 Feature: stream-hostname-resolution 7599 Description: Resolve hostnames before opening a TCP connection. 7600 Section: Section 3.2 7601 Roles: Client MUST, Server MUST. 7603 Feature: stream-negotiation-complete 7604 Description: Do not consider the stream negotiation process to be 7605 complete until the receiving entity sends a stream features 7606 advertisement that is empty or that contains only voluntary-to- 7607 negotiate features. 7608 Section: Section 4.2.5 7609 Roles: Client MUST, Server MUST. 7611 Feature: stream-negotiation-features 7612 Description: Send stream features after sending a response stream 7613 header. 7614 Section: Section 4.2.2 7615 Roles: Client N/A, Server MUST. 7617 Feature: stream-negotiation-restart 7618 Description: Consider the previous stream to be replaced upon 7619 negotiation of a stream feature that necessitates a stream 7620 restart, and send or receive a new initial stream header after 7621 negotiation of such a stream feature. 7622 Section: Section 4.2.3 7623 Roles: Client MUST, Server MUST. 7625 Feature: stream-reconnect 7626 Description: Reconnect with exponential backoff if a TCP connection 7627 is terminated unexpectedly. 7628 Section: Section 3.3 7629 Roles: Client MUST, Server MUST. 7631 Feature: stream-tcp-binding 7632 Description: Bind an XML stream to a TCP connection. 7633 Section: Section 3 7634 Roles: Client MUST, Server MUST. 7636 Feature: tls-certs 7637 Description: Check the identity specified in a certificate that is 7638 presented during TLS negotiation. 7639 Section: Section 13.7.2 7640 Roles: Client MUST, Server MUST. 7642 Feature: tls-mtn 7643 Description: Consider TLS as mandatory-to-negotiate if STARTTLS is 7644 the only feature advertised or if the STARTTLS feature includes an 7645 empty element. 7646 Section: Section 5.3.1 7647 Roles: Client MUST, Server MUST. 7649 Feature: tls-restart 7650 Description: Initiate or handle a stream restart after TLS 7651 negotiation. 7652 Section: Section 5.3.2 7653 Roles: Client MUST, Server MUST. 7655 Feature: tls-support 7656 Description: Support Transport Layer Security for stream encryption. 7657 Section: Section 5 7658 Roles: Client MUST, Server MUST. 7660 Feature: tls-whitespace 7661 Description: Ensure that no whitespace is sent between XML elements 7662 during TLS negotiation. 7663 Section: Section 5.3.3 7664 Roles: Client MUST, Server MUST. 7666 Feature: xml-namespace-content-client 7667 Description: Support 'jabber:client' as a content namespace. 7668 Section: Section 4.7.2 7669 Roles: Client MUST, Server MUST. 7671 Feature: xml-namespace-content-server 7672 Description: Support 'jabber:server' as a content namespace. 7673 Section: Section 4.7.2 7674 Roles: Client N/A, Server MUST. 7676 Feature: xml-namespace-streams-declaration 7677 Description: Ensure that there is a namespace declaration for the 7678 'http://etherx.jabber.org/streams' namespace. 7679 Section: Section 4.7.1 7680 Roles: Client MUST, Server MUST. 7682 Feature: xml-namespace-streams-prefix 7683 Description: Ensure that all elements qualified by the 7684 'http://etherx.jabber.org/streams' namespace are prefixed by the 7685 prefix defined in the namespace declaration. 7686 Section: Section 4.7.1 7687 Roles: Client MUST, Server MUST. 7689 Feature: xml-restriction-comment 7690 Description: Do not generate or accept XML comments. 7691 Section: Section 11.1 7692 Roles: Client MUST, Server MUST. 7694 Feature: xml-restriction-dtd 7695 Description: Do not generate or accept internal or external DTD 7696 subsets. 7697 Section: Section 11.1 7698 Roles: Client MUST, Server MUST. 7700 Feature: xml-restriction-pi 7701 Description: Do not generate or accept XML processing instructions. 7702 Section: Section 11.1 7703 Roles: Client MUST, Server MUST. 7705 Feature: xml-restriction-ref 7706 Description: Do not generate or accept internal or external entity 7707 references with the exception of the predefined entities. 7708 Section: Section 11.1 7709 Roles: Client MUST, Server MUST. 7711 Feature: xml-wellformed-xml 7712 Description: Do not generate or accept data that is not XML-well- 7713 formed. 7714 Section: Section 11.3 7715 Roles: Client MUST, Server MUST. 7717 Feature: xml-wellformed-ns 7718 Description: Do not generate or accept data that is not namespace- 7719 well-formed. 7720 Section: Section 11.3 7721 Roles: Client MUST, Server MUST. 7723 16. References 7725 16.1. Normative References 7727 [BASE64] Josefsson, S., "The Base16, Base32, and Base64 Data 7728 Encodings", RFC 4648, October 2006. 7730 [CHARSETS] 7731 Alvestrand, H., "IETF Policy on Character Sets and 7732 Languages", BCP 18, RFC 2277, January 1998. 7734 [DNS-SRV] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for 7735 specifying the location of services (DNS SRV)", RFC 2782, 7736 February 2000. 7738 [KEYWORDS] 7739 Bradner, S., "Key words for use in RFCs to Indicate 7740 Requirement Levels", BCP 14, RFC 2119, March 1997. 7742 [LANGTAGS] 7743 Phillips, A. and M. Davis, "Tags for Identifying 7744 Languages", BCP 47, RFC 5646, September 2009. 7746 [OCSP] Myers, M., Ankney, R., Malpani, A., Galperin, S., and C. 7747 Adams, "X.509 Internet Public Key Infrastructure Online 7748 Certificate Status Protocol - OCSP", RFC 2560, June 1999. 7750 [PKIX] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 7751 Housley, R., and W. Polk, "Internet X.509 Public Key 7752 Infrastructure Certificate and Certificate Revocation List 7753 (CRL) Profile", RFC 5280, May 2008. 7755 [PKIX-ALGO] 7756 Jonsson, J. and B. Kaliski, "Public-Key Cryptography 7757 Standards (PKCS) #1: RSA Cryptography Specifications 7758 Version 2.1", RFC 3447, February 2003. 7760 [PKIX-SRV] 7761 Santesson, S., "Internet X.509 Public Key Infrastructure 7762 Subject Alternative Name for Expression of Service Name", 7763 RFC 4985, August 2007. 7765 [PLAIN] Zeilenga, K., "The PLAIN Simple Authentication and 7766 Security Layer (SASL) Mechanism", RFC 4616, August 2006. 7768 [RANDOM] Eastlake, D., Schiller, J., and S. Crocker, "Randomness 7769 Requirements for Security", BCP 106, RFC 4086, June 2005. 7771 [SASL] Melnikov, A. and K. Zeilenga, "Simple Authentication and 7772 Security Layer (SASL)", RFC 4422, June 2006. 7774 [SCRAM] Newman, C., Menon-Sen, A., Melnikov, A., and N. Williams, 7775 "Salted Challenge Response Authentication Mechanism 7776 (SCRAM) SASL and GSS-API Mechanisms", RFC 5802, July 2010. 7778 [TCP] Postel, J., "Transmission Control Protocol", STD 7, 7779 RFC 793, September 1981. 7781 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 7782 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 7784 [TLS-CERTS] 7785 Saint-Andre, P. and J. Hodges, "Representation and 7786 Verification of Domain-Based Application Service Identity 7787 within Internet Public Key Infrastructure Using X.509 7788 (PKIX) Certificates in the Context of Transport Layer 7789 Security (TLS)", draft-saintandre-tls-server-id-check-10 7790 (work in progress), October 2010. 7792 [UCS2] International Organization for Standardization, 7793 "Information Technology - Universal Multiple-octet coded 7794 Character Set (UCS) - Amendment 2: UCS Transformation 7795 Format 8 (UTF-8)", ISO Standard 10646-1 Addendum 2, 7796 October 1996. 7798 [UNICODE] The Unicode Consortium, "The Unicode Standard, Version 7799 3.2.0", 2000. 7801 The Unicode Standard, Version 3.2.0 is defined by The 7802 Unicode Standard, Version 3.0 (Reading, MA, Addison- 7803 Wesley, 2000. ISBN 0-201-61633-5), as amended by the 7804 Unicode Standard Annex #27: Unicode 3.1 7805 (http://www.unicode.org/reports/tr27/) and by the Unicode 7806 Standard Annex #28: Unicode 3.2 7807 (http://www.unicode.org/reports/tr28/). 7809 [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 7810 10646", STD 63, RFC 3629, November 2003. 7812 [URI] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 7813 Resource Identifier (URI): Generic Syntax", STD 66, 7814 RFC 3986, January 2005. 7816 [X509] International Telecommunications Union, "Information 7817 technology - Open Systems Interconnection - The Directory: 7818 Public-key and attribute certificate frameworks", ITU- 7819 T Recommendation X.509, ISO Standard 9594-8, March 2000. 7821 [XML] Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., 7822 and T. Bray, "Extensible Markup Language (XML) 1.0 (Fifth 7823 Edition)", World Wide Web Consortium Recommendation REC- 7824 xml-20081126, November 2008, 7825 . 7827 [XML-GUIDE] 7828 Hollenbeck, S., Rose, M., and L. Masinter, "Guidelines for 7829 the Use of Extensible Markup Language (XML) 7830 within IETF Protocols", BCP 70, RFC 3470, January 2003. 7832 [XML-MEDIA] 7833 Murata, M., St. Laurent, S., and D. Kohn, "XML Media 7834 Types", RFC 3023, January 2001. 7836 [XML-NAMES] 7837 Thompson, H., Hollander, D., Layman, A., Bray, T., and R. 7838 Tobin, "Namespaces in XML 1.0 (Third Edition)", World Wide 7839 Web Consortium Recommendation REC-xml-names-20091208, 7840 December 2009, 7841 . 7843 [XMPP-ADDR] 7844 Saint-Andre, P., "Extensible Messaging and Presence 7845 Protocol (XMPP): Address Format", 7846 draft-ietf-xmpp-address-06 (work in progress), 7847 October 2010. 7849 16.2. Informative References 7851 [ACAP] Newman, C. and J. Myers, "ACAP -- Application 7852 Configuration Access Protocol", RFC 2244, November 1997. 7854 [ANONYMOUS] 7855 Zeilenga, K., "Anonymous Simple Authentication and 7856 Security Layer (SASL) Mechanism", RFC 4505, June 2006. 7858 [ASN.1] CCITT, "Recommendation X.208: Specification of Abstract 7859 Syntax Notation One (ASN.1)", 1988. 7861 [CHANNEL] Williams, N., "On the Use of Channel Bindings to Secure 7862 Channels", RFC 5056, November 2007. 7864 [CHANNEL-TLS] 7865 Altman, J., Williams, N., and L. Zhu, "Channel Bindings 7866 for TLS", RFC 5929, July 2010. 7868 [DIGEST-MD5] 7869 Leach, P. and C. Newman, "Using Digest Authentication as a 7870 SASL Mechanism", RFC 2831, May 2000. 7872 [DNSSEC] Arends, R., Austein, R., Larson, M., Massey, D., and S. 7873 Rose, "DNS Security Introduction and Requirements", 7874 RFC 4033, March 2005. 7876 [DNS-TXT] Rosenbaum, R., "Using the Domain Name System To Store 7877 Arbitrary String Attributes", RFC 1464, May 1993. 7879 [DOS] Handley, M., Rescorla, E., and IAB, "Internet Denial-of- 7880 Service Considerations", RFC 4732, December 2006. 7882 [E2E-REQS] 7883 Saint-Andre, P., "Requirements for End-to-End Encryption 7884 in the Extensible Messaging and Presence Protocol (XMPP)", 7885 draft-ietf-xmpp-e2e-requirements-01 (work in progress), 7886 March 2010. 7888 [EMAIL-ARCH] 7889 Crocker, D., "Internet Mail Architecture", RFC 5598, 7890 July 2009. 7892 [ETHERNET] 7893 "Information technology - Telecommunications and 7894 information exchange between systems - Local and 7895 metropolitan area networks - Specific requirements - Part 7896 3: Carrier sense multiple access with collision detection 7897 (CSMA/CD) access method and physical layer 7898 specifications"", IEEE Standard 802.3, September 1998. 7900 [GSS-API] Linn, J., "Generic Security Service Application Program 7901 Interface Version 2, Update 1", RFC 2743, January 2000. 7903 [HASHES] Hoffman, P. and B. Schneier, "Attacks on Cryptographic 7904 Hashes in Internet Protocols", RFC 4270, November 2005. 7906 [HTTP] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 7907 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 7908 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. 7910 [IANA-GUIDE] 7911 Narten, T. and H. Alvestrand, "Guidelines for Writing an 7912 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 7913 May 2008. 7915 [IANA-PORTS] 7916 Cotton, M., Eggert, L., Touch, J., Westerlund, M., and S. 7917 Cheshire, "Internet Assigned Numbers Authority (IANA) 7918 Procedures for the Management of the Transport Protocol 7919 Port Number and Service Name Registry", 7920 draft-ietf-tsvwg-iana-ports-08 (work in progress), 7921 October 2010. 7923 [IMAP] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 7924 4rev1", RFC 3501, March 2003. 7926 [IMP-REQS] 7927 Day, M., Aggarwal, S., and J. Vincent, "Instant Messaging 7928 / Presence Protocol Requirements", RFC 2779, 7929 February 2000. 7931 [INTEROP] Masinter, L., "Formalizing IETF Interoperability 7932 Reporting", draft-ietf-newtrk-interop-reports-00 (work in 7933 progress), October 2005. 7935 [IRI] Duerst, M. and M. Suignard, "Internationalized Resource 7936 Identifiers (IRIs)", RFC 3987, January 2005. 7938 [LINKLOCAL] 7939 Cheshire, S., Aboba, B., and E. Guttman, "Dynamic 7940 Configuration of IPv4 Link-Local Addresses", RFC 3927, 7941 May 2005. 7943 [MAILBOXES] 7944 Crocker, D., "MAILBOX NAMES FOR COMMON SERVICES, ROLES AND 7945 FUNCTIONS", RFC 2142, May 1997. 7947 [POP3] Myers, J. and M. Rose, "Post Office Protocol - Version 3", 7948 STD 53, RFC 1939, May 1996. 7950 [PROCESS] Bradner, S., "The Internet Standards Process -- Revision 7951 3", BCP 9, RFC 2026, October 1996. 7953 [REPORTS] Dusseault, L. and R. Sparks, "Guidance on Interoperation 7954 and Implementation Reports for Advancement to Draft 7955 Standard", BCP 9, RFC 5657, September 2009. 7957 [REST] Fielding, R., "Architectural Styles and the Design of 7958 Network-based Software Architectures", 2000. 7960 [RFC3920] Saint-Andre, P., Ed., "Extensible Messaging and Presence 7961 Protocol (XMPP): Core", RFC 3920, October 2004. 7963 [RFC3921] Saint-Andre, P., Ed., "Extensible Messaging and Presence 7964 Protocol (XMPP): Instant Messaging and Presence", 7965 RFC 3921, October 2004. 7967 [SASLPREP] 7968 Zeilenga, K., "SASLprep: Stringprep Profile for User Names 7969 and Passwords", RFC 4013, February 2005. 7971 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 7972 October 2008. 7974 [SEC-GUIDE] 7975 Rescorla, E. and B. Korver, "Guidelines for Writing RFC 7976 Text on Security Considerations", BCP 72, RFC 3552, 7977 July 2003. 7979 [SEC-TERMS] 7980 Shirey, R., "Internet Security Glossary, Version 2", 7981 RFC 4949, August 2007. 7983 [STRONGSEC] 7984 Schiller, J., "Strong Security Requirements for Internet 7985 Engineering Task Force Standard Protocols", BCP 61, 7986 RFC 3365, August 2002. 7988 [TLS-EXT] 3rd, D., "Transport Layer Security (TLS) Extensions: 7989 Extension Definitions", draft-ietf-tls-rfc4366-bis-12 7990 (work in progress), September 2010. 7992 [TLS-NEG] Rescorla, E., Ray, M., Dispensa, S., and N. Oskov, 7993 "Transport Layer Security (TLS) Renegotiation Indication 7994 Extension", RFC 5746, February 2010. 7996 [URN-OID] Mealling, M., "A URN Namespace of Object Identifiers", 7997 RFC 3061, February 2001. 7999 [USINGTLS] 8000 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 8001 RFC 2595, June 1999. 8003 [UUID] Leach, P., Mealling, M., and R. Salz, "A Universally 8004 Unique IDentifier (UUID) URN Namespace", RFC 4122, 8005 July 2005. 8007 [XEP-0001] 8008 Saint-Andre, P., "XMPP Extension Protocols", XSF XEP 0001, 8009 January 2008. 8011 [XEP-0016] 8012 Millard, P. and P. Saint-Andre, "Privacy Lists", XSF 8013 XEP 0016, February 2007. 8015 [XEP-0045] 8016 Saint-Andre, P., "Multi-User Chat", XSF XEP 0045, 8017 July 2007. 8019 [XEP-0060] 8020 Millard, P., Saint-Andre, P., and R. Meijer, "Publish- 8021 Subscribe", XSF XEP 0060, September 2008. 8023 [XEP-0071] 8024 Saint-Andre, P., "XHTML-IM", XSF XEP 0071, September 2008. 8026 [XEP-0077] 8027 Saint-Andre, P., "In-Band Registration", XSF XEP 0077, 8028 January 2006. 8030 [XEP-0086] 8031 Norris, R. and P. Saint-Andre, "Error Condition Mappings", 8032 XSF XEP 0086, February 2004. 8034 [XEP-0124] 8035 Paterson, I., Smith, D., and P. Saint-Andre, 8036 "Bidirectional-streams Over Synchronous HTTP (BOSH)", XSF 8037 XEP 0124, April 2009. 8039 [XEP-0138] 8040 Hildebrand, J. and P. Saint-Andre, "Stream Compression", 8041 XSF XEP 0138, May 2009. 8043 [XEP-0156] 8044 Hildebrand, J. and P. Saint-Andre, "Discovering 8045 Alternative XMPP Connection Methods", XSF XEP 0156, 8046 June 2007. 8048 [XEP-0160] 8049 Saint-Andre, P., "Best Practices for Handling Offline 8050 Messages", XSF XEP 0160, January 2006. 8052 [XEP-0174] 8053 Saint-Andre, P., "Link-Local Messaging", XSF XEP 0174, 8054 November 2008. 8056 [XEP-0175] 8057 Saint-Andre, P., "Best Practices for Use of SASL 8058 ANONYMOUS", XSF XEP 0175, November 2007. 8060 [XEP-0178] 8061 Saint-Andre, P. and P. Millard, "Best Practices for Use of 8062 SASL EXTERNAL with Certificates", XSF XEP 0178, 8063 February 2007. 8065 [XEP-0191] 8066 Saint-Andre, P., "Simple Communications Blocking", XSF 8067 XEP 0191, February 2007. 8069 [XEP-0198] 8070 Karneges, J., Hildebrand, J., Saint-Andre, P., and F. 8071 Forno, "Stream Management", XSF XEP 0198, June 2009. 8073 [XEP-0199] 8074 Saint-Andre, P., "XMPP Ping", XSF XEP 0199, June 2009. 8076 [XEP-0205] 8077 Saint-Andre, P., "Best Practices to Discourage Denial of 8078 Service Attacks", XSF XEP 0205, January 2009. 8080 [XEP-0206] 8081 Paterson, I., "XMPP Over BOSH", XSF XEP 0206, 8082 October 2008. 8084 [XEP-0220] 8085 Miller, J., Saint-Andre, P., and P. Hancke, "Server 8086 Dialback", XSF XEP 0220, March 2010. 8088 [XEP-0288] 8089 Hancke, P. and D. Cridland, "Bidirectional Server-to- 8090 Server Connections", XSF XEP 0288, October 2010. 8092 [XML-FRAG] 8093 Grosso, P. and D. Veillard, "XML Fragment Interchange", 8094 World Wide Web Consortium CR CR-xml-fragment-20010212, 8095 February 2001, 8096 . 8098 [XML-REG] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, 8099 January 2004. 8101 [XML-SCHEMA] 8102 Thompson, H., Maloney, M., Mendelsohn, N., and D. Beech, 8103 "XML Schema Part 1: Structures Second Edition", World Wide 8104 Web Consortium Recommendation REC-xmlschema-1-20041028, 8105 October 2004, 8106 . 8108 [XMPP-IM] Saint-Andre, P., "Extensible Messaging and Presence 8109 Protocol (XMPP): Instant Messaging and Presence", 8110 draft-ietf-xmpp-3921bis-16 (work in progress), 8111 October 2010. 8113 [XMPP-URI] 8114 Saint-Andre, P., "Internationalized Resource Identifiers 8115 (IRIs) and Uniform Resource Identifiers (URIs) for the 8116 Extensible Messaging and Presence Protocol (XMPP)", 8117 RFC 5122, February 2008. 8119 Appendix A. XML Schemas 8121 Because validation of XML streams and stanzas is optional, the 8122 following XML schemas are provided for descriptive purposes only. 8123 These schemas are not normative. 8125 The following schemas formally define various XML namespaces used in 8126 the core XMPP protocols, in conformance with [XML-SCHEMA]. For 8127 schemas defining the 'jabber:client' and 'jabber:server' namespaces, 8128 refer to [XMPP-IM]. 8130 A.1. Streams Namespace 8132 8134 8140 8141 8142 8143 8144 8146 8147 8148 8150 8153 8156 8159 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8185 8187 8188 8189 8190 8194 8195 8196 8198 8199 8200 8201 8202 8205 8209 8210 8211 8213 8215 A.2. Stream Error Namespace 8217 8219 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8290 8291 8292 8293 8294 8296 8298 A.3. STARTTLS Namespace 8300 8302 8308 8309 8310 8311 8312 8313 8314 8316 8318 8320 8321 8322 8323 8324 8326 8328 A.4. SASL Namespace 8330 8332 8338 8339 8340 8341 8345 8349 8350 8351 8353 8355 8356 8357 8358 8359 8362 8363 8364 8365 8367 8369 8371 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8395 8396 8397 8398 8399 8400 8401 8402 8403 8405 8406 8407 8408 8409 8411 8413 A.5. Resource Binding Namespace 8415 8417 8423 8424 8425 8426 8427 8428 8429 8430 8432 8433 8434 8435 8436 8437 8439 8440 8441 8442 8443 8444 8446 8448 A.6. Stanza Error Namespace 8450 8452 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8519 8520 8521 8522 8523 8525 8527 Appendix B. Contact Addresses 8529 Consistent with [MAILBOXES], an organization that offers an XMPP 8530 service SHOULD provide an Internet mailbox of "XMPP" for inquiries 8531 related to that service, where the host portion of the resulting 8532 mailto URI MUST be the organization's domain, not the domain of the 8533 XMPP service itself (e.g., the XMPP service might be offered at 8534 im.example.com but the Internet mailbox would be ). 8536 Appendix C. Account Provisioning 8538 Account provisioning is out of scope for this specification. 8539 Possible methods for account provisioning include account creation by 8540 a server administrator and in-band account registration using the 8541 'jabber:iq:register' namespace as documented in [XEP-0077]. An XMPP 8542 server implementation or administrative function MUST ensure that any 8543 JID assigned during account provisioning (including localpart, 8544 domainpart, resourcepart, and separator characters) conforms to the 8545 canonical format for XMPP addresses defined in [XMPP-ADDR]. 8547 Appendix D. Differences from RFC 3920 8549 Based on consensus derived from implementation and deployment 8550 experience as well as formal interoperability testing, the following 8551 substantive modifications were made from RFC 3920. 8553 o Moved specification of the XMPP address format to a separate 8554 document. 8555 o Recommended or mandated use of the 'from' and 'to' attributes on 8556 stream headers. 8557 o More fully specified the stream closing handshake. 8558 o Specified the recommended stream reconnection algorithm. 8559 o Changed the name of the stream error 8560 condition to for compliance with the XML 8561 specification. 8562 o Removed the unnecessary and unused stream error (see 8563 RFC 3920 for historical documentation). 8564 o Specified return of the stream error in response 8565 to receipt of prohibited XML features. 8566 o Specified that the SASL SCRAM mechanism is a mandatory-to- 8567 implement technology for client-to-server streams. 8568 o Specified that TLS plus the SASL PLAIN mechanism is a mandatory- 8569 to-implement technology for client-to-server streams. 8570 o Specified that support for the SASL EXTERNAL mechanism is required 8571 for servers but only recommended for clients (since end-user X.509 8572 certificates are difficult to obtain and not yet widely deployed). 8573 o Removed the hard two-connection rule for server-to-server streams. 8574 o More clearly specified the certificate profile for both public key 8575 certificates and issuer certificates. 8576 o Added the streams error condition to handle expired/ 8577 revoked certificates or the addition of security-critical features 8578 to an existing stream. 8579 o Added the , , 8580 , , and SASL error conditions to handle error flows mistakenly 8582 left out of RFC 3920 or discussed in RFC 4422 but not in RFC 2222. 8583 o Removed unnecessary requirement for escaping of characters that 8584 map to certain predefined entities, which do not need to be 8585 escaped in XML. 8586 o Clarified the process of DNS SRV lookups and fallbacks. 8587 o Clarified the handling of SASL security layers. 8588 o Clarified the stream negotiation process and associated flow 8589 chart. 8590 o Clarified the handling of stream features. 8591 o Added a 'by' attribute to the element for stanza errors 8592 so that the entity that has detected the error can include its JID 8593 for diagnostic or tracking purposes. 8594 o Clarified the handling of data that violates the well-formedness 8595 definitions for XML 1.0 and XML namespaces. 8596 o Specified the security considerations in more detail, especially 8597 with regard to presence leaks and denial of service attacks. 8598 o Moved documentation of the Server Dialback protocol from this 8599 specification to a separate specification maintained by the XMPP 8600 Standards Foundation. 8602 In addition, numerous changes of an editorial nature were made in 8603 order to more fully specify and clearly explain XMPP. 8605 Author's Address 8607 Peter Saint-Andre 8608 Cisco 8609 1899 Wyknoop Street, Suite 600 8610 Denver, CO 80202 8611 USA 8613 Phone: +1-303-308-3282 8614 Email: psaintan@cisco.com