diff --git a/xep-0065.xml b/xep-0065.xml
index c717ba17..663178e5 100644
--- a/xep-0065.xml
+++ b/xep-0065.xml
@@ -11,6 +11,7 @@
&LEGALNOTICE;
XMPP is designed for sending relatively small fragments of XML between network entities (see &xmppcore;) and is not designed for sending binary data. However, sometimes it is desirable to send binary data to another entity that one has discovered on the XMPP network (e.g., to send a file). Therefore it is valuable to have a generic protocol for streaming binary data between any two entities on an XMPP network. The main application for such a bytestreaming technology is file transfer as specified in &xep0096; and &xep0234;. However, other applications are possible, which is why it is important to develop a generic protocol rather than one that is specialized for a particular application such as file transfer. XMPP is designed for sending relatively small chunks of XML between network entities and is not designed for sending binary data. However, sometimes it is desirable to send binary data to another entity that one has discovered on the XMPP network (e.g., to send a file). Therefore it is valuable to have a generic protocol for streaming binary data between any two entities on an XMPP network. The main application for such a bytestreaming technology is file transfer as specified in &xep0096; and &xep0234;. However, other applications are possible, which is why it is important to develop a generic protocol rather than one that is specialized for a particular application such as file transfer. This document defines a protocol that meets the following conditions: Specifically, this document makes use of the SOCKS 5 protocol, which is an IETF-approved, IPv6-ready technology for bytestreams defined in &rfc1928;. However, because this proposal uses a subset of the SOCKS5 protocol that is specially adapted for bytestreaming over XMPP, existing SOCKS5 proxies cannot be used to implement this proposal without modifications. Specifically, this protocol makes use of the SOCKS 5 protocol, which is an IETF-approved, IPv6-ready technology for bytestreams defined in &rfc1928;. However, because this protocol uses a subset of the SOCKS5 protocol that is specially adapted for bytestreaming over XMPP, existing SOCKS5 proxies cannot be used to implement this protocol without modifications. There are two scenarios addressed by this protocol: Early versions of this specification documented only the use of TCP connections. In version 1.6 (approved in November 2004), optional UDP associations were added, as described in the Optional UDP Support section of this document. However, the main body of this document describes the use of TCP, which is the primary method of SOCKS5 Bytestreams ("S5B"). Note: Because either party can attempt to establish a bytestream (this is formalized in &xep0260;), the Requester and the Target roles apply to a particular S5B negotiation, and do not map to the Initiator and Responder roles from &xep0166; in a fixed way. For example, during a Jingle negotiation the Initiator might first take on the role of an S5B Requester but if that first bytestreams negotiation fails then the Jingle Responder might take on the role of an S5B Requester. Note: Because either party can attempt to establish a bytestream (this is formalized in &xep0260;), the Requester and the Target roles apply to a particular S5B negotiation, and do not map to the Initiator and Responder roles from &xep0166; in a fixed way. For example, during a Jingle negotiation the Jingle Initiator might first take on the role of an S5B Requester but if that first bytestreams negotiation fails then the Jingle Responder might take on the role of an S5B Requester. In the protocol flow diagrams, the line types have the following meaning: In the examples, "streamer.example.com" is a Proxy that services bytestreams on port 7625. In this case, the bytestreams proxy is hosted at "streamer.example.com". In this case, the "streamer.example.com" is a bytestreams proxy. For each item in the disco#items result, the Requester needs to query to determine if it is a bytestreams proxy. Next the Requester needs to request the full network address to be used for bytestreaming through the Proxy. This is done by sending an IQ-get to the proxy containing a &QUERY; element qualified by the bytestreams namespace. Next the Requester needs to request the full network address to be used for bytestreaming through the Proxy. This is done by sending an IQ-get to the proxy containing a &QUERY; element qualified by the bytestreams namespace (not the service discovery namespace). The Proxy replies by returning an IQ-result that contains its network address, structured using the <streamhost/> child of the &QUERY; element; the <streamhost/> element MUST possess the following attributes: In this situation, the StreamHost is the Requester, which means that the Requester knows the network address of the StreamHost and knows when to activate the bytestream. For direct connections, the process for establishing a bytestream is as follows: The data flow is shown in the following diagram. To initiate an S5B negotiation with the Target, the Requester sends the Target network address information about one or more StreamHosts. In the case of a direct connection, the Requester might include information only about itself (as shown in the following example) or about itself and a Proxy. The &QUERY; element MUST possess a 'sid' attribute the specifies the Stream ID for this bytestream and MAY possess a 'mode' attribute whose value is "tcp" (the default) or "udp"; the &QUERY; element also MUST contain one or more <streamhost/> elements, each of which MUST possess the 'host', 'jid', and 'port' attributes. To initiate an S5B negotiation with the Target, the Requester sends network address information about one or more StreamHosts to the Target. In the case of a direct connection, the Requester might include information only about itself (as shown in the following example) or about itself and a Proxy. The &QUERY; element MUST possess a 'sid' attribute the specifies the Stream ID for this bytestream and MAY possess a 'mode' attribute whose value is "tcp" (the default) or "udp" (for which see Optional UDP Support); the &QUERY; element also MUST contain one or more <streamhost/> elements, each of which MUST possess the 'host', 'jid', and 'port' attributes. If the Target is unwilling to accept the bytestream, it MUST return a ¬acceptable; error to the Requester. If the request is malformed (e.g., the &QUERY; element does not include the 'sid' attribute), the Target MUST return an error of &badrequest;. Else if the Target is unwilling to accept the bytestream, it MUST return an error of ¬acceptable; to the Requester. If the Target is willing to negotiate a bytestream, it proceeds as shown in the following sections. Next the Target attempts to open a standard TCP socket on the network address of the StreamHost/Requester. Next the Target attempts to open a standard TCP socket on the network address of the StreamHost/Requester (for information about UDP usage, see the Optional UDP Support section of this document). Note: If the Requester provides more than one StreamHost, the Target SHOULD try to connect to them in the order of the <streamhost/> children within the &QUERY; element. &xep0260; modifies this rule by providing explicit priorities for each streamhost candidate. If the Target is able to open a TCP socket on a StreamHost/Requester, it MUST use the SOCKS5 protocol to establish a SOCKS5 connection. In accordance with RFC 1928, the Target might need to authenticate in order to use the proxy. However, any authentication required is beyond the scope of this document. Once the Target has successfully authenticated with the StreamHost/Requester, it sends a CONNECT request to the appropriate host in order to continue the negotiation. The following rules apply: Once the Target has successfully authenticated with the StreamHost/Requester, it sends a CONNECT request (CMD = X'01') in order to continue the negotiation. The following rules apply: When replying to the Target in accordance with Section 6 of RFC 1928, the StreamHost MUST set the BND.ADDR and BND.PORT to the values provided by the client in the connection request. When replying to the Target in accordance with Section 6 of RFC 1928, the StreamHost MUST set the BND.ADDR and BND.PORT to the DST.ADDR and DST.PORT values provided by the client in the connection request. If the Target tries but is unable to connect to any of the StreamHosts and it does not wish to attempt a connection from its side, it MUST return an ¬found; error to the Requester. In this situation, the StreamHost is not the Requester but a Proxy, which means that the Requester needs to discover the network address of the StreamHost before sending the initiation request to the Target, needs to negotiate a connection with the StreamHost in the same way that the Target does, and needs to ask the StreamHost to activate the bytestream before it can be used. For mediated connections, the process for establishing a bytestream is as follows: The data flow is shown in the following diagram. To initiate an S5B negotiation with the Target, the Requester sends the Target network address information about one or more StreamHosts. In the case of a mediated connection, the Requester might include information only about the Proxy (as shown in the following example) or about the Proxy and itself. The &QUERY; element MUST possess a 'sid' attribute the specifies the Stream ID for this bytestream and MAY possess a 'mode' attribute whose value is "tcp" (the default) or "udp"; the &QUERY; element also MUST contain one or more <streamhost/> elements, each of which MUST possess the 'host', 'jid', and 'port' attributes. To initiate an S5B negotiation with the Target, the Requester sends network address information about one or more StreamHosts to the Target. In the case of a mediated connection, the Requester might include information only about the Proxy (as shown in the following example) or about the Proxy and itself. The &QUERY; element MUST possess a 'sid' attribute the specifies the Stream ID for this bytestream and MAY possess a 'mode' attribute whose value is "tcp" (the default) or "udp" (for which see Optional UDP Support); the &QUERY; element also MUST contain one or more <streamhost/> elements, each of which MUST possess the 'host', 'jid', and 'port' attributes. Next the Target attempts to open a standard TCP socket on the network address of the Proxy. If the Target is able to open a TCP socket on the Proxy, it uses the SOCKS5 protocol to establish a SOCKS5 connection. In accordance with RFC 1928, the Target might need to authenticate in order to use the proxy. However, any authentication required is beyond the scope of this document. Once the Target has successfully authenticated with the Proxy, it sends a CONNECT request to the appropriate host in order to continue the negotiation. The following rules apply: Once the Target has successfully authenticated with the Proxy, it sends a CONNECT request (CMD = X'01') in order to continue the negotiation. The following rules apply: When replying to the Target in accordance with Section 6 of RFC 1928, the Proxy MUST set the BND.ADDR and BND.PORT to the values provided by the client in the connection request. When replying to the Target in accordance with Section 6 of RFC 1928, the Proxy MUST set the BND.ADDR and BND.PORT to the DST.ADDR and DST.PORT values provided by the client in the connection request. After the Target has established a SOCKS5 connection with the Proxy, it replies to the initiate request with an IQ-result whose &QUERY; element contains a <streamhost-used/> child that specifies which StreamHost was used (in this case, the Proxy). Next the Requester needs to activate the bytestream with the Proxy. This is done by sending an IQ-set to the Proxy, including an <activate/> element whose XML character data specifies the full JID of the Target. Next the Requester needs to activate the bytestream with the Proxy. This is done by sending an IQ-set to the Proxy, including an <activate/> element whose XML character data specifies the full or bare JID of the Target. Using this information, with the SID and from address on the packet, the Proxy is able to activate the stream by hashing the SID + Requester JID + Target JID. This provides a reasonable level of trust that the activation request came from the Requester. Using this information, with the SID and from address on the packet, the Proxy is able to activate the stream by hashing the SID + Requester JID + Target JID and comparing the result against the DST.ADDR it has received from the Target and Receiver. Although this provides a reasonable level of trust that the activation request came from the Requester, it does not guard against active or even passive attacks against the bytestreams negotiation (see the Security Considerations for information about potential hijacking of the negotiation). If the Proxy can fulfill the request, it MUST respond to the Requester with an IQ-result.
@@ -40,6 +41,10 @@
-
-
-
@@ -291,9 +296,9 @@
id='uj2c15z9'
to='streamer.example.com'
type='error'>
- |
- | |
- | Open TCP socket |
- | <_______________________________ |
- | |
- | Request SOCKS 5 connection |
- | <\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ |
- | |
- | Acknowledge SOCKS 5 connection |
- | ///////////////////////////////> |
- | |
- | Send S5B acceptance |
- | <------------------------------- |
- | |
- | Exchange data over S5B |
- | <==============================> |
- | |
+Requester Target
+ | |
+ | Send S5B initiation request |
+ | -----------------------------> |
+ | |
+ | Open TCP socket |
+ | <_____________________________ |
+ | |
+ | Request SOCKS5 connection |
+ | <\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ |
+ | |
+ | Acknowledge SOCKS5 connection |
+ | /////////////////////////////> |
+ | |
+ | Send S5B acceptance |
+ | <----------------------------- |
+ | |
+ | Exchange data over S5B |
+ | <============================> |
+ | |
]]>
|
- | | |
- | | Open TCP socket |
- | | <_______________________________ |
- | |
- | | Request SOCKS 5 connection |
- | | <\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ |
- | |
- | | Acknowledge SOCKS 5 connection |
- | | ///////////////////////////////> |
- | | |
- | Send S5B acceptance |
- | <------------------------------------------------------------------ |
- | | |
- | Open TCP socket | |
- | _______________________________> | |
- | | |
- | Request SOCKS 5 connection | |
- | ///////////////////////////////> | |
- | | |
- | Acknowledge SOCKS 5 connection | |
- | <\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ | |
- | | |
- | Request activation | |
- | -------------------------------> | |
- | | |
- | Acknowledge activation | |
- | <------------------------------- | |
- | | |
- | Exchange data over S5B |
- | <=================================================================> |
- | | |
+Requester Proxy Target
+ | | |
+ | Send S5B initiation request |
+ | --------------------------------------------------------------> |
+ | | |
+ | | Open TCP socket |
+ | | <_____________________________ |
+ | | |
+ | | Request SOCKS 5 connection |
+ | | <\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ |
+ | | |
+ | | Acknowledge SOCKS 5 connection |
+ | | /////////////////////////////> |
+ | | |
+ | Send S5B acceptance |
+ | <-------------------------------------------------------------- |
+ | | |
+ | Open TCP socket | |
+ | _____________________________> | |
+ | | |
+ | Request SOCKS 5 connection | |
+ | /////////////////////////////> | |
+ | | |
+ | Acknowledge SOCKS 5 connection | |
+ | <\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ | |
+ | | |
+ | Request activation | |
+ | -----------------------------> | |
+ | | |
+ | Acknowledge activation | |
+ | <----------------------------- | |
+ | | |
+ | Exchange data over S5B |
+ | <=============================================================> |
+ | | |
]]>
-
If the Proxy cannot fulfill the request, it MUST return an IQ-error to the Requester; the following conditions are defined:
The <query/> element is the container for all in-band communications. This element MUST be qualified by the "http://jabber.org/protocol/bytestreams" namespace. Depending on the use case, this element contains multiple <streamhost/> elements, a single <streamhost-used/> element, or a single <activate/> element.
-The "sid" specifies the bytestream session identifier. The value of this attribute is any character data.
-The "mode" specifies the mode to use, either 'tcp' or 'udp'. If this attribute is missing, the default value of "tcp" MUST be assumed.
-The <streamhost/> element conveys the network connection information. At least one instance MUST be present in the initial IQ-set from the Requester to the Target. If multiple instances of this element are present, each one MUST be a separate host/port combination.
-The <streamhost-used/> element transports the out-of-band token. It MUST be present in the IQ-set from the Target to the Requester, and there MUST be only one instance.
-The <activate/> element is used to request activation of a unidirectional or bidirectional bytestream. It MUST be present in the IQ-set sent from the Requester to the StreamHost after the Requester receives an IQ-result from the Target, and there MUST be only one instance.
-The <streamhost/> element contains the bytestream connection information. This element has attributes for the StreamHost's JID, network host/address, and network port. This element MUST NOT contain any content nodes.
-The "jid" attribute specifies the StreamHost's JID. This attribute MUST be present, and MUST be a valid JID for use with an <iq/>.
-The "host" attribute specifies the host to connect to. This attribute MUST be present. The value MUST be either a resolvable domain name or the "dotted decimal" IP address (e.g. "1.2.3.4").
-The "port" attribute specifies the port to connect to. This attribute MAY be present. The value MUST be a valid port number in decimal form.
-When communicating the available hosts, the Requester MUST the host and port.
-The <streamhost-used/> element indicates the StreamHost connected to. This element has a single attribute for the JID of the StreamHost to which the Target connected. This element MUST NOT contain any content node.
-The "jid" attribute specifies the JID of the StreamHost. This attribute MUST be present, and MUST be a valid JID for use with an <iq/>.
-The <activate/> element is a flag to trigger a Proxy to complete a connection.
-When one occupant of a &xep0045; conference sends an S5B invitation to another occupant, the MUC room obscures the real JID of the Target from the Requester and the real JID of the Requester from the Target. This means that the two parties do not have the same view of the information needed to calculate the DST.ADDR. To overcome this problem, the Requester SHOULD calculate the DST.ADDR based on the SID, its real JID, and the room JID (room@host/nick) of the Target, then include the calculated hash as the value of a 'dstaddr' attribute on the &QUERY; element. The Requester then sends the IQ-set to the Target's room JID because it does not know the Target's real JID.
+An example follows.
+The MUC room will then forward the IQ-set to the Target's real JID with a 'from' address of the Requester's room JID.
+Now the parties can proceed as defined for the direct or mediated connection. See the Security Considerations for information about potential hijacking of the negotiation.
If an implementation supports UDP associations, it MUST advertise that separately by returning a feature of 'http://jabber.org/protocol/bytestreams#udp' in response to Service Discovery information requests.
If the Target supports UDP associations, it MUST answer to that effect in the service discovery result.
+If the Target supports UDP associations, it MUST include a feature of 'http://jabber.org/protocol/bytestreams#udp' in the service discovery result.
UDP associations are requested by setting the 'mode' attribute to a value of "udp" rather than "tcp".
The processes for establishing the UDP association and for initializing the UDP channel are described below.
Once the Target has successfully authenticated with the Proxy (as described under Target Establishes SOCKS5 Connection with StreamHost), it MUST send a UDP ASSOCIATE (rather than CONNECT) request to the host identified by the algorithm defined above.
+Once the Target has successfully authenticated with the Proxy over TCP (as described under Target Establishes SOCKS5 Connection with StreamHost), it MUST send a UDP ASSOCIATE request (CMD = X'03') to the host identified by the algorithm defined above.
The <query/> element is the container for all in-band communications. This element MUST be qualified by the "http://jabber.org/protocol/bytestreams" namespace. Depending on the use case, this element contains multiple <streamhost/> elements, a single <streamhost-used/> element, or a single <activate/> element.
+The 'sid' attribute specifies the bytestream session identifier. The value of this attribute is any character data.
+The 'mode' attribute specifies the mode to use, either "tcp" or "udp". If this attribute is not included, the default value of "tcp" MUST be assumed.
+The <streamhost/> element conveys the network connection information. At least one instance MUST be present in the initial IQ-set from the Requester to the Target. If multiple instances of this element are present, each one MUST be a separate host/port combination.
+The <streamhost-used/> element informs the Requester about the StreamHost to which the Target has connected. It MUST be present in the IQ-set from the Target to the Requester, and there MUST be only one instance.
+The <activate/> element is used to request activation of a unidirectional or bidirectional bytestream. It MUST be present in the IQ-set sent from the Requester to the Proxy after the Requester receives an IQ-result from the Target, and there MUST be only one instance.
+The <streamhost/> element contains the bytestream connection information. This element has attributes for the StreamHost's JID, network host/address, and network port. This element MUST NOT contain any XML character data or child elements.
+The "jid" attribute specifies the StreamHost's JID. This attribute MUST be present, and MUST be a valid JID for communication over XMPP.
+The "host" attribute specifies the host to connect to. This attribute MUST be present. The value MUST be either an IPv4 or IPv6 address, or a resolvable DNS domain name.
+The "port" attribute specifies the port to connect to. This attribute MAY be present. The value MUST be a valid port number in decimal form.
+When communicating the available hosts, the Requester MUST the host and port.
+The <streamhost-used/> element informs the Requester about the StreamHost to which the Target has connected. This element has a single attribute for the JID of the StreamHost to which the Target connected. This element MUST NOT contain any XML character data or child elements.
+The "jid" attribute specifies the JID of the StreamHost. This attribute MUST be present, and MUST be a valid JID for communication over XMPP.
+The <activate/> element is sent from the Requester to the Proxy in order to formally start the bytestream.
+A StreamHost MUST support TCP connections.
A StreamHost SHOULD:
A StreamHost MAY:
This proposal does not include a method for securing or encrypting SOCKS5 bytetreams. If such security is desired, it MUST be negotiated over the bytestream (once established) using standard protocols such as SSL or TLS. Negotiation of such security methods is outside the scope of this document.
+This protocol does not include a method for securing or encrypting the data sent over a SOCKS5 bytetream. If such security is desired, it MUST be negotiated over the bytestream (once established) using standard protocols such as SSL or TLS. Negotiation of such security methods is outside the scope of this document.
+In the absence of end-to-end encryption of the negotiation stanzas between the Requester and the Target, a passive attacker (eavesdropper) could authenticate to the bytestream before the Target, thus preventing the Target from connecting and also hijacking the data sent from the Requester.
+A SOCKS5 Bytestreams Proxy can be subject to denial of service attacks (e.g., generating a large number of session requests that are never activated). A Proxy SHOULD monitor usage from particular Requesters and blacklist them if their usage is excessive.
+The use of the SHA-1 algorithm to hash the SID, Requester's JID, and Target's JID is not security-critical. Therefore, the known weaknesses of SHA-1 are not of significant concern in this protocol.
+