| 1 |
<pre>Network Working Group J. Rosenberg |
| 2 |
Request for Comments: 5389 Cisco |
| 3 |
Obsoletes: <a href="./rfc3489">3489</a> R. Mahy |
| 4 |
Category: Standards Track P. Matthews |
| 5 |
Unaffiliated |
| 6 |
D. Wing |
| 7 |
Cisco |
| 8 |
October 2008 |
| 9 |
|
| 10 |
|
| 11 |
<span class="h1">Session Traversal Utilities for NAT (STUN)</span> |
| 12 |
|
| 13 |
Status of This Memo |
| 14 |
|
| 15 |
This document specifies an Internet standards track protocol for the |
| 16 |
Internet community, and requests discussion and suggestions for |
| 17 |
improvements. Please refer to the current edition of the "Internet |
| 18 |
Official Protocol Standards" (STD 1) for the standardization state |
| 19 |
and status of this protocol. Distribution of this memo is unlimited. |
| 20 |
|
| 21 |
Abstract |
| 22 |
|
| 23 |
Session Traversal Utilities for NAT (STUN) is a protocol that serves |
| 24 |
as a tool for other protocols in dealing with Network Address |
| 25 |
Translator (NAT) traversal. It can be used by an endpoint to |
| 26 |
determine the IP address and port allocated to it by a NAT. It can |
| 27 |
also be used to check connectivity between two endpoints, and as a |
| 28 |
keep-alive protocol to maintain NAT bindings. STUN works with many |
| 29 |
existing NATs, and does not require any special behavior from them. |
| 30 |
|
| 31 |
STUN is not a NAT traversal solution by itself. Rather, it is a tool |
| 32 |
to be used in the context of a NAT traversal solution. This is an |
| 33 |
important change from the previous version of this specification (<a href="./rfc3489">RFC</a> |
| 34 |
<a href="./rfc3489">3489</a>), which presented STUN as a complete solution. |
| 35 |
|
| 36 |
This document obsoletes <a href="./rfc3489">RFC 3489</a>. |
| 37 |
|
| 38 |
Table of Contents |
| 39 |
|
| 40 |
<a href="#section-1">1</a>. Introduction ....................................................<a href="#page-4">4</a> |
| 41 |
<a href="#section-2">2</a>. Evolution from <a href="./rfc3489">RFC 3489</a> .........................................<a href="#page-4">4</a> |
| 42 |
<a href="#section-3">3</a>. Overview of Operation ...........................................<a href="#page-5">5</a> |
| 43 |
<a href="#section-4">4</a>. Terminology .....................................................<a href="#page-8">8</a> |
| 44 |
<a href="#section-5">5</a>. Definitions .....................................................<a href="#page-8">8</a> |
| 45 |
<a href="#section-6">6</a>. STUN Message Structure .........................................<a href="#page-10">10</a> |
| 46 |
<a href="#section-7">7</a>. Base Protocol Procedures .......................................<a href="#page-12">12</a> |
| 47 |
<a href="#section-7.1">7.1</a>. Forming a Request or an Indication ........................<a href="#page-12">12</a> |
| 48 |
<a href="#section-7.2">7.2</a>. Sending the Request or Indication .........................<a href="#page-13">13</a> |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
<span class="grey">Rosenberg, et al. Standards Track [Page 1]</span></pre> |
| 53 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span> |
| 54 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 55 |
|
| 56 |
|
| 57 |
<a href="#section-7.2.1">7.2.1</a>. Sending over UDP ...................................<a href="#page-13">13</a> |
| 58 |
<a href="#section-7.2.2">7.2.2</a>. Sending over TCP or TLS-over-TCP ...................<a href="#page-14">14</a> |
| 59 |
<a href="#section-7.3">7.3</a>. Receiving a STUN Message ..................................<a href="#page-16">16</a> |
| 60 |
<a href="#section-7.3.1">7.3.1</a>. Processing a Request ...............................<a href="#page-17">17</a> |
| 61 |
<a href="#section-7.3.1.1">7.3.1.1</a>. Forming a Success or Error Response .......<a href="#page-18">18</a> |
| 62 |
<a href="#section-7.3.1.2">7.3.1.2</a>. Sending the Success or Error Response .....<a href="#page-19">19</a> |
| 63 |
<a href="#section-7.3.2">7.3.2</a>. Processing an Indication ...........................<a href="#page-19">19</a> |
| 64 |
<a href="#section-7.3.3">7.3.3</a>. Processing a Success Response ......................<a href="#page-19">19</a> |
| 65 |
<a href="#section-7.3.4">7.3.4</a>. Processing an Error Response .......................<a href="#page-20">20</a> |
| 66 |
<a href="#section-8">8</a>. FINGERPRINT Mechanism ..........................................<a href="#page-20">20</a> |
| 67 |
<a href="#section-9">9</a>. DNS Discovery of a Server ......................................<a href="#page-21">21</a> |
| 68 |
<a href="#section-10">10</a>. Authentication and Message-Integrity Mechanisms ...............<a href="#page-22">22</a> |
| 69 |
<a href="#section-10.1">10.1</a>. Short-Term Credential Mechanism ..........................<a href="#page-22">22</a> |
| 70 |
<a href="#section-10.1.1">10.1.1</a>. Forming a Request or Indication ...................<a href="#page-23">23</a> |
| 71 |
<a href="#section-10.1.2">10.1.2</a>. Receiving a Request or Indication .................<a href="#page-23">23</a> |
| 72 |
<a href="#section-10.1.3">10.1.3</a>. Receiving a Response ..............................<a href="#page-24">24</a> |
| 73 |
<a href="#section-10.2">10.2</a>. Long-Term Credential Mechanism ...........................<a href="#page-24">24</a> |
| 74 |
<a href="#section-10.2.1">10.2.1</a>. Forming a Request .................................<a href="#page-25">25</a> |
| 75 |
<a href="#section-10.2.1.1">10.2.1.1</a>. First Request ............................<a href="#page-25">25</a> |
| 76 |
<a href="#section-10.2.1.2">10.2.1.2</a>. Subsequent Requests ......................<a href="#page-26">26</a> |
| 77 |
<a href="#section-10.2.2">10.2.2</a>. Receiving a Request ...............................<a href="#page-26">26</a> |
| 78 |
<a href="#section-10.2.3">10.2.3</a>. Receiving a Response ..............................<a href="#page-27">27</a> |
| 79 |
<a href="#section-11">11</a>. ALTERNATE-SERVER Mechanism ....................................<a href="#page-28">28</a> |
| 80 |
<a href="#section-12">12</a>. Backwards Compatibility with <a href="./rfc3489">RFC 3489</a> .........................<a href="#page-28">28</a> |
| 81 |
<a href="#section-12.1">12.1</a>. Changes to Client Processing .............................<a href="#page-29">29</a> |
| 82 |
<a href="#section-12.2">12.2</a>. Changes to Server Processing .............................<a href="#page-29">29</a> |
| 83 |
<a href="#section-13">13</a>. Basic Server Behavior .........................................<a href="#page-30">30</a> |
| 84 |
<a href="#section-14">14</a>. STUN Usages ...................................................<a href="#page-30">30</a> |
| 85 |
<a href="#section-15">15</a>. STUN Attributes ...............................................<a href="#page-31">31</a> |
| 86 |
<a href="#section-15.1">15.1</a>. MAPPED-ADDRESS ...........................................<a href="#page-32">32</a> |
| 87 |
<a href="#section-15.2">15.2</a>. XOR-MAPPED-ADDRESS .......................................<a href="#page-33">33</a> |
| 88 |
<a href="#section-15.3">15.3</a>. USERNAME .................................................<a href="#page-34">34</a> |
| 89 |
<a href="#section-15.4">15.4</a>. MESSAGE-INTEGRITY ........................................<a href="#page-34">34</a> |
| 90 |
<a href="#section-15.5">15.5</a>. FINGERPRINT ..............................................<a href="#page-36">36</a> |
| 91 |
<a href="#section-15.6">15.6</a>. ERROR-CODE ...............................................<a href="#page-36">36</a> |
| 92 |
<a href="#section-15.7">15.7</a>. REALM ....................................................<a href="#page-38">38</a> |
| 93 |
<a href="#section-15.8">15.8</a>. NONCE ....................................................<a href="#page-38">38</a> |
| 94 |
<a href="#section-15.9">15.9</a>. UNKNOWN-ATTRIBUTES .......................................<a href="#page-38">38</a> |
| 95 |
<a href="#section-15.10">15.10</a>. SOFTWARE ................................................<a href="#page-39">39</a> |
| 96 |
<a href="#section-15.11">15.11</a>. ALTERNATE-SERVER ........................................<a href="#page-39">39</a> |
| 97 |
<a href="#section-16">16</a>. Security Considerations .......................................<a href="#page-39">39</a> |
| 98 |
<a href="#section-16.1">16.1</a>. Attacks against the Protocol .............................<a href="#page-39">39</a> |
| 99 |
<a href="#section-16.1.1">16.1.1</a>. Outside Attacks ...................................<a href="#page-39">39</a> |
| 100 |
<a href="#section-16.1.2">16.1.2</a>. Inside Attacks ....................................<a href="#page-40">40</a> |
| 101 |
<a href="#section-16.2">16.2</a>. Attacks Affecting the Usage ..............................<a href="#page-40">40</a> |
| 102 |
16.2.1. Attack I: Distributed DoS (DDoS) against a |
| 103 |
Target ............................................<a href="#page-41">41</a> |
| 104 |
<a href="#section-16.2.2">16.2.2</a>. Attack II: Silencing a Client .....................<a href="#page-41">41</a> |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
<span class="grey">Rosenberg, et al. Standards Track [Page 2]</span></pre> |
| 109 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span> |
| 110 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 111 |
|
| 112 |
|
| 113 |
<a href="#section-16.2.3">16.2.3</a>. Attack III: Assuming the Identity of a Client .....<a href="#page-42">42</a> |
| 114 |
<a href="#section-16.2.4">16.2.4</a>. Attack IV: Eavesdropping ..........................<a href="#page-42">42</a> |
| 115 |
<a href="#section-16.3">16.3</a>. Hash Agility Plan ........................................<a href="#page-42">42</a> |
| 116 |
<a href="#section-17">17</a>. IAB Considerations ............................................<a href="#page-42">42</a> |
| 117 |
<a href="#section-18">18</a>. IANA Considerations ...........................................<a href="#page-43">43</a> |
| 118 |
<a href="#section-18.1">18.1</a>. STUN Methods Registry ....................................<a href="#page-43">43</a> |
| 119 |
<a href="#section-18.2">18.2</a>. STUN Attribute Registry ..................................<a href="#page-43">43</a> |
| 120 |
<a href="#section-18.3">18.3</a>. STUN Error Code Registry .................................<a href="#page-44">44</a> |
| 121 |
<a href="#section-18.4">18.4</a>. STUN UDP and TCP Port Numbers ............................<a href="#page-45">45</a> |
| 122 |
<a href="#section-19">19</a>. Changes since <a href="./rfc3489">RFC 3489</a> ........................................<a href="#page-45">45</a> |
| 123 |
<a href="#section-20">20</a>. Contributors ..................................................<a href="#page-47">47</a> |
| 124 |
<a href="#section-21">21</a>. Acknowledgements ..............................................<a href="#page-47">47</a> |
| 125 |
<a href="#section-22">22</a>. References ....................................................<a href="#page-47">47</a> |
| 126 |
<a href="#section-22.1">22.1</a>. Normative References .....................................<a href="#page-47">47</a> |
| 127 |
<a href="#section-22.2">22.2</a>. Informative References ...................................<a href="#page-48">48</a> |
| 128 |
<a href="#appendix-A">Appendix A</a>. C Snippet to Determine STUN Message Types .............<a href="#page-50">50</a> |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
<span class="grey">Rosenberg, et al. Standards Track [Page 3]</span></pre> |
| 165 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span> |
| 166 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 167 |
|
| 168 |
|
| 169 |
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span> |
| 170 |
|
| 171 |
The protocol defined in this specification, Session Traversal |
| 172 |
Utilities for NAT, provides a tool for dealing with NATs. It |
| 173 |
provides a means for an endpoint to determine the IP address and port |
| 174 |
allocated by a NAT that corresponds to its private IP address and |
| 175 |
port. It also provides a way for an endpoint to keep a NAT binding |
| 176 |
alive. With some extensions, the protocol can be used to do |
| 177 |
connectivity checks between two endpoints [<a href="#ref-MMUSIC-ICE" title=""Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols"">MMUSIC-ICE</a>], or to relay |
| 178 |
packets between two endpoints [<a href="#ref-BEHAVE-TURN" title=""Traversal Using Relays around NAT (TURN): Relay Extensions to Session Traversal Utilities for NAT (STUN)"">BEHAVE-TURN</a>]. |
| 179 |
|
| 180 |
In keeping with its tool nature, this specification defines an |
| 181 |
extensible packet format, defines operation over several transport |
| 182 |
protocols, and provides for two forms of authentication. |
| 183 |
|
| 184 |
STUN is intended to be used in context of one or more NAT traversal |
| 185 |
solutions. These solutions are known as STUN usages. Each usage |
| 186 |
describes how STUN is utilized to achieve the NAT traversal solution. |
| 187 |
Typically, a usage indicates when STUN messages get sent, which |
| 188 |
optional attributes to include, what server is used, and what |
| 189 |
authentication mechanism is to be used. Interactive Connectivity |
| 190 |
Establishment (ICE) [<a href="#ref-MMUSIC-ICE" title=""Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols"">MMUSIC-ICE</a>] is one usage of STUN. SIP Outbound |
| 191 |
[<a href="#ref-SIP-OUTBOUND" title=""Managing Client Initiated Connections in the Session Initiation Protocol (SIP)"">SIP-OUTBOUND</a>] is another usage of STUN. In some cases, a usage will |
| 192 |
require extensions to STUN. A STUN extension can be in the form of |
| 193 |
new methods, attributes, or error response codes. More information |
| 194 |
on STUN usages can be found in <a href="#section-14">Section 14</a>. |
| 195 |
|
| 196 |
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Evolution from <a href="./rfc3489">RFC 3489</a></span> |
| 197 |
|
| 198 |
STUN was originally defined in <a href="./rfc3489">RFC 3489</a> [<a href="./rfc3489" title=""STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)"">RFC3489</a>]. That |
| 199 |
specification, sometimes referred to as "classic STUN", represented |
| 200 |
itself as a complete solution to the NAT traversal problem. In that |
| 201 |
solution, a client would discover whether it was behind a NAT, |
| 202 |
determine its NAT type, discover its IP address and port on the |
| 203 |
public side of the outermost NAT, and then utilize that IP address |
| 204 |
and port within the body of protocols, such as the Session Initiation |
| 205 |
Protocol (SIP) [<a href="./rfc3261" title=""SIP: Session Initiation Protocol"">RFC3261</a>]. However, experience since the publication |
| 206 |
of <a href="./rfc3489">RFC 3489</a> has found that classic STUN simply does not work |
| 207 |
sufficiently well to be a deployable solution. The address and port |
| 208 |
learned through classic STUN are sometimes usable for communications |
| 209 |
with a peer, and sometimes not. Classic STUN provided no way to |
| 210 |
discover whether it would, in fact, work or not, and it provided no |
| 211 |
remedy in cases where it did not. Furthermore, classic STUN's |
| 212 |
algorithm for classification of NAT types was found to be faulty, as |
| 213 |
many NATs did not fit cleanly into the types defined there. |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
<span class="grey">Rosenberg, et al. Standards Track [Page 4]</span></pre> |
| 221 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span> |
| 222 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 223 |
|
| 224 |
|
| 225 |
Classic STUN also had a security vulnerability -- attackers could |
| 226 |
provide the client with incorrect mapped addresses under certain |
| 227 |
topologies and constraints, and this was fundamentally not solvable |
| 228 |
through any cryptographic means. Though this problem remains with |
| 229 |
this specification, those attacks are now mitigated through the use |
| 230 |
of more complete solutions that make use of STUN. |
| 231 |
|
| 232 |
For these reasons, this specification obsoletes <a href="./rfc3489">RFC 3489</a>, and instead |
| 233 |
describes STUN as a tool that is utilized as part of a complete NAT |
| 234 |
traversal solution. ICE [<a href="#ref-MMUSIC-ICE" title=""Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols"">MMUSIC-ICE</a>] is a complete NAT traversal |
| 235 |
solution for protocols based on the offer/answer [<a href="./rfc3264" title=""An Offer/Answer Model with Session Description Protocol (SDP)"">RFC3264</a>] |
| 236 |
methodology, such as SIP. SIP Outbound [<a href="#ref-SIP-OUTBOUND" title=""Managing Client Initiated Connections in the Session Initiation Protocol (SIP)"">SIP-OUTBOUND</a>] is a complete |
| 237 |
solution for traversal of SIP signaling, and it uses STUN in a very |
| 238 |
different way. Though it is possible that a protocol may be able to |
| 239 |
use STUN by itself (classic STUN) as a traversal solution, such usage |
| 240 |
is not described here and is strongly discouraged for the reasons |
| 241 |
described above. |
| 242 |
|
| 243 |
The on-the-wire protocol described here is changed only slightly from |
| 244 |
classic STUN. The protocol now runs over TCP in addition to UDP. |
| 245 |
Extensibility was added to the protocol in a more structured way. A |
| 246 |
magic cookie mechanism for demultiplexing STUN with application |
| 247 |
protocols was added by stealing 32 bits from the 128-bit transaction |
| 248 |
ID defined in <a href="./rfc3489">RFC 3489</a>, allowing the change to be backwards |
| 249 |
compatible. Mapped addresses are encoded using a new exclusive-or |
| 250 |
format. There are other, more minor changes. See <a href="#section-19">Section 19</a> for a |
| 251 |
more complete listing. |
| 252 |
|
| 253 |
Due to the change in scope, STUN has also been renamed from "Simple |
| 254 |
Traversal of UDP through NAT" to "Session Traversal Utilities for |
| 255 |
NAT". The acronym remains STUN, which is all anyone ever remembers |
| 256 |
anyway. |
| 257 |
|
| 258 |
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Overview of Operation</span> |
| 259 |
|
| 260 |
This section is descriptive only. |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
<span class="grey">Rosenberg, et al. Standards Track [Page 5]</span></pre> |
| 277 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span> |
| 278 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 279 |
|
| 280 |
|
| 281 |
/-----\ |
| 282 |
// STUN \\ |
| 283 |
| Server | |
| 284 |
\\ // |
| 285 |
\-----/ |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
+--------------+ Public Internet |
| 291 |
................| NAT 2 |....................... |
| 292 |
+--------------+ |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
+--------------+ Private NET 2 |
| 297 |
................| NAT 1 |....................... |
| 298 |
+--------------+ |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
/-----\ |
| 304 |
// STUN \\ |
| 305 |
| Client | |
| 306 |
\\ // Private NET 1 |
| 307 |
\-----/ |
| 308 |
|
| 309 |
|
| 310 |
Figure 1: One Possible STUN Configuration |
| 311 |
|
| 312 |
One possible STUN configuration is shown in Figure 1. In this |
| 313 |
configuration, there are two entities (called STUN agents) that |
| 314 |
implement the STUN protocol. The lower agent in the figure is the |
| 315 |
client, and is connected to private network 1. This network connects |
| 316 |
to private network 2 through NAT 1. Private network 2 connects to |
| 317 |
the public Internet through NAT 2. The upper agent in the figure is |
| 318 |
the server, and resides on the public Internet. |
| 319 |
|
| 320 |
STUN is a client-server protocol. It supports two types of |
| 321 |
transactions. One is a request/response transaction in which a |
| 322 |
client sends a request to a server, and the server returns a |
| 323 |
response. The second is an indication transaction in which either |
| 324 |
agent -- client or server -- sends an indication that generates no |
| 325 |
response. Both types of transactions include a transaction ID, which |
| 326 |
is a randomly selected 96-bit number. For request/response |
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
<span class="grey">Rosenberg, et al. Standards Track [Page 6]</span></pre> |
| 333 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span> |
| 334 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 335 |
|
| 336 |
|
| 337 |
transactions, this transaction ID allows the client to associate the |
| 338 |
response with the request that generated it; for indications, the |
| 339 |
transaction ID serves as a debugging aid. |
| 340 |
|
| 341 |
All STUN messages start with a fixed header that includes a method, a |
| 342 |
class, and the transaction ID. The method indicates which of the |
| 343 |
various requests or indications this is; this specification defines |
| 344 |
just one method, Binding, but other methods are expected to be |
| 345 |
defined in other documents. The class indicates whether this is a |
| 346 |
request, a success response, an error response, or an indication. |
| 347 |
Following the fixed header comes zero or more attributes, which are |
| 348 |
Type-Length-Value extensions that convey additional information for |
| 349 |
the specific message. |
| 350 |
|
| 351 |
This document defines a single method called Binding. The Binding |
| 352 |
method can be used either in request/response transactions or in |
| 353 |
indication transactions. When used in request/response transactions, |
| 354 |
the Binding method can be used to determine the particular "binding" |
| 355 |
a NAT has allocated to a STUN client. When used in either request/ |
| 356 |
response or in indication transactions, the Binding method can also |
| 357 |
be used to keep these "bindings" alive. |
| 358 |
|
| 359 |
In the Binding request/response transaction, a Binding request is |
| 360 |
sent from a STUN client to a STUN server. When the Binding request |
| 361 |
arrives at the STUN server, it may have passed through one or more |
| 362 |
NATs between the STUN client and the STUN server (in Figure 1, there |
| 363 |
were two such NATs). As the Binding request message passes through a |
| 364 |
NAT, the NAT will modify the source transport address (that is, the |
| 365 |
source IP address and the source port) of the packet. As a result, |
| 366 |
the source transport address of the request received by the server |
| 367 |
will be the public IP address and port created by the NAT closest to |
| 368 |
the server. This is called a reflexive transport address. The STUN |
| 369 |
server copies that source transport address into an XOR-MAPPED- |
| 370 |
ADDRESS attribute in the STUN Binding response and sends the Binding |
| 371 |
response back to the STUN client. As this packet passes back through |
| 372 |
a NAT, the NAT will modify the destination transport address in the |
| 373 |
IP header, but the transport address in the XOR-MAPPED-ADDRESS |
| 374 |
attribute within the body of the STUN response will remain untouched. |
| 375 |
In this way, the client can learn its reflexive transport address |
| 376 |
allocated by the outermost NAT with respect to the STUN server. |
| 377 |
|
| 378 |
In some usages, STUN must be multiplexed with other protocols (e.g., |
| 379 |
[<a href="#ref-MMUSIC-ICE" title=""Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols"">MMUSIC-ICE</a>], [<a href="#ref-SIP-OUTBOUND" title=""Managing Client Initiated Connections in the Session Initiation Protocol (SIP)"">SIP-OUTBOUND</a>]). In these usages, there must be a way |
| 380 |
to inspect a packet and determine if it is a STUN packet or not. |
| 381 |
STUN provides three fields in the STUN header with fixed values that |
| 382 |
can be used for this purpose. If this is not sufficient, then STUN |
| 383 |
packets can also contain a FINGERPRINT value, which can further be |
| 384 |
used to distinguish the packets. |
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
<span class="grey">Rosenberg, et al. Standards Track [Page 7]</span></pre> |
| 389 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span> |
| 390 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 391 |
|
| 392 |
|
| 393 |
STUN defines a set of optional procedures that a usage can decide to |
| 394 |
use, called mechanisms. These mechanisms include DNS discovery, a |
| 395 |
redirection technique to an alternate server, a fingerprint attribute |
| 396 |
for demultiplexing, and two authentication and message-integrity |
| 397 |
exchanges. The authentication mechanisms revolve around the use of a |
| 398 |
username, password, and message-integrity value. Two authentication |
| 399 |
mechanisms, the long-term credential mechanism and the short-term |
| 400 |
credential mechanism, are defined in this specification. Each usage |
| 401 |
specifies the mechanisms allowed with that usage. |
| 402 |
|
| 403 |
In the long-term credential mechanism, the client and server share a |
| 404 |
pre-provisioned username and password and perform a digest challenge/ |
| 405 |
response exchange inspired by (but differing in details) to the one |
| 406 |
defined for HTTP [<a href="./rfc2617" title=""HTTP Authentication: Basic and Digest Access Authentication"">RFC2617</a>]. In the short-term credential mechanism, |
| 407 |
the client and the server exchange a username and password through |
| 408 |
some out-of-band method prior to the STUN exchange. For example, in |
| 409 |
the ICE usage [<a href="#ref-MMUSIC-ICE" title=""Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols"">MMUSIC-ICE</a>] the two endpoints use out-of-band |
| 410 |
signaling to exchange a username and password. These are used to |
| 411 |
integrity protect and authenticate the request and response. There |
| 412 |
is no challenge or nonce used. |
| 413 |
|
| 414 |
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. Terminology</span> |
| 415 |
|
| 416 |
In this document, the key words "MUST", "MUST NOT", "REQUIRED", |
| 417 |
"SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", |
| 418 |
and "OPTIONAL" are to be interpreted as described in <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a> |
| 419 |
[<a href="./rfc2119" title=""Key words for use in RFCs to Indicate Requirement Levels"">RFC2119</a>] and indicate requirement levels for compliant STUN |
| 420 |
implementations. |
| 421 |
|
| 422 |
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Definitions</span> |
| 423 |
|
| 424 |
STUN Agent: A STUN agent is an entity that implements the STUN |
| 425 |
protocol. The entity can be either a STUN client or a STUN |
| 426 |
server. |
| 427 |
|
| 428 |
STUN Client: A STUN client is an entity that sends STUN requests and |
| 429 |
receives STUN responses. A STUN client can also send indications. |
| 430 |
In this specification, the terms STUN client and client are |
| 431 |
synonymous. |
| 432 |
|
| 433 |
STUN Server: A STUN server is an entity that receives STUN requests |
| 434 |
and sends STUN responses. A STUN server can also send |
| 435 |
indications. In this specification, the terms STUN server and |
| 436 |
server are synonymous. |
| 437 |
|
| 438 |
Transport Address: The combination of an IP address and port number |
| 439 |
(such as a UDP or TCP port number). |
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
<span class="grey">Rosenberg, et al. Standards Track [Page 8]</span></pre> |
| 445 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span> |
| 446 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 447 |
|
| 448 |
|
| 449 |
Reflexive Transport Address: A transport address learned by a client |
| 450 |
that identifies that client as seen by another host on an IP |
| 451 |
network, typically a STUN server. When there is an intervening |
| 452 |
NAT between the client and the other host, the reflexive transport |
| 453 |
address represents the mapped address allocated to the client on |
| 454 |
the public side of the NAT. Reflexive transport addresses are |
| 455 |
learned from the mapped address attribute (MAPPED-ADDRESS or XOR- |
| 456 |
MAPPED-ADDRESS) in STUN responses. |
| 457 |
|
| 458 |
Mapped Address: Same meaning as reflexive address. This term is |
| 459 |
retained only for historic reasons and due to the naming of the |
| 460 |
MAPPED-ADDRESS and XOR-MAPPED-ADDRESS attributes. |
| 461 |
|
| 462 |
Long-Term Credential: A username and associated password that |
| 463 |
represent a shared secret between client and server. Long-term |
| 464 |
credentials are generally granted to the client when a subscriber |
| 465 |
enrolls in a service and persist until the subscriber leaves the |
| 466 |
service or explicitly changes the credential. |
| 467 |
|
| 468 |
Long-Term Password: The password from a long-term credential. |
| 469 |
|
| 470 |
Short-Term Credential: A temporary username and associated password |
| 471 |
that represent a shared secret between client and server. Short- |
| 472 |
term credentials are obtained through some kind of protocol |
| 473 |
mechanism between the client and server, preceding the STUN |
| 474 |
exchange. A short-term credential has an explicit temporal scope, |
| 475 |
which may be based on a specific amount of time (such as 5 |
| 476 |
minutes) or on an event (such as termination of a SIP dialog). |
| 477 |
The specific scope of a short-term credential is defined by the |
| 478 |
application usage. |
| 479 |
|
| 480 |
Short-Term Password: The password component of a short-term |
| 481 |
credential. |
| 482 |
|
| 483 |
STUN Indication: A STUN message that does not receive a response. |
| 484 |
|
| 485 |
Attribute: The STUN term for a Type-Length-Value (TLV) object that |
| 486 |
can be added to a STUN message. Attributes are divided into two |
| 487 |
types: comprehension-required and comprehension-optional. STUN |
| 488 |
agents can safely ignore comprehension-optional attributes they |
| 489 |
don't understand, but cannot successfully process a message if it |
| 490 |
contains comprehension-required attributes that are not |
| 491 |
understood. |
| 492 |
|
| 493 |
RTO: Retransmission TimeOut, which defines the initial period of |
| 494 |
time between transmission of a request and the first retransmit of |
| 495 |
that request. |
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
<span class="grey">Rosenberg, et al. Standards Track [Page 9]</span></pre> |
| 501 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span> |
| 502 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 503 |
|
| 504 |
|
| 505 |
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. STUN Message Structure</span> |
| 506 |
|
| 507 |
STUN messages are encoded in binary using network-oriented format |
| 508 |
(most significant byte or octet first, also commonly known as big- |
| 509 |
endian). The transmission order is described in detail in <a href="./rfc791#appendix-B">Appendix B |
| 510 |
of RFC 791</a> [<a href="./rfc0791" title=""Internet Protocol"">RFC0791</a>]. Unless otherwise noted, numeric constants are |
| 511 |
in decimal (base 10). |
| 512 |
|
| 513 |
All STUN messages MUST start with a 20-byte header followed by zero |
| 514 |
or more Attributes. The STUN header contains a STUN message type, |
| 515 |
magic cookie, transaction ID, and message length. |
| 516 |
|
| 517 |
0 1 2 3 |
| 518 |
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 519 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 520 |
|0 0| STUN Message Type | Message Length | |
| 521 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 522 |
| Magic Cookie | |
| 523 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 524 |
| | |
| 525 |
| Transaction ID (96 bits) | |
| 526 |
| | |
| 527 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 528 |
|
| 529 |
Figure 2: Format of STUN Message Header |
| 530 |
|
| 531 |
The most significant 2 bits of every STUN message MUST be zeroes. |
| 532 |
This can be used to differentiate STUN packets from other protocols |
| 533 |
when STUN is multiplexed with other protocols on the same port. |
| 534 |
|
| 535 |
The message type defines the message class (request, success |
| 536 |
response, failure response, or indication) and the message method |
| 537 |
(the primary function) of the STUN message. Although there are four |
| 538 |
message classes, there are only two types of transactions in STUN: |
| 539 |
request/response transactions (which consist of a request message and |
| 540 |
a response message) and indication transactions (which consist of a |
| 541 |
single indication message). Response classes are split into error |
| 542 |
and success responses to aid in quickly processing the STUN message. |
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
<span class="grey">Rosenberg, et al. Standards Track [Page 10]</span></pre> |
| 557 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span> |
| 558 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 559 |
|
| 560 |
|
| 561 |
The message type field is decomposed further into the following |
| 562 |
structure: |
| 563 |
|
| 564 |
0 1 |
| 565 |
2 3 4 5 6 7 8 9 0 1 2 3 4 5 |
| 566 |
|
| 567 |
+--+--+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 568 |
|M |M |M|M|M|C|M|M|M|C|M|M|M|M| |
| 569 |
|11|10|9|8|7|1|6|5|4|0|3|2|1|0| |
| 570 |
+--+--+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 571 |
|
| 572 |
Figure 3: Format of STUN Message Type Field |
| 573 |
|
| 574 |
Here the bits in the message type field are shown as most significant |
| 575 |
(M11) through least significant (M0). M11 through M0 represent a 12- |
| 576 |
bit encoding of the method. C1 and C0 represent a 2-bit encoding of |
| 577 |
the class. A class of 0b00 is a request, a class of 0b01 is an |
| 578 |
indication, a class of 0b10 is a success response, and a class of |
| 579 |
0b11 is an error response. This specification defines a single |
| 580 |
method, Binding. The method and class are orthogonal, so that for |
| 581 |
each method, a request, success response, error response, and |
| 582 |
indication are possible for that method. Extensions defining new |
| 583 |
methods MUST indicate which classes are permitted for that method. |
| 584 |
|
| 585 |
For example, a Binding request has class=0b00 (request) and |
| 586 |
method=0b000000000001 (Binding) and is encoded into the first 16 bits |
| 587 |
as 0x0001. A Binding response has class=0b10 (success response) and |
| 588 |
method=0b000000000001, and is encoded into the first 16 bits as |
| 589 |
0x0101. |
| 590 |
|
| 591 |
Note: This unfortunate encoding is due to assignment of values in |
| 592 |
[<a href="./rfc3489" title=""STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)"">RFC3489</a>] that did not consider encoding Indications, Success, and |
| 593 |
Errors using bit fields. |
| 594 |
|
| 595 |
The magic cookie field MUST contain the fixed value 0x2112A442 in |
| 596 |
network byte order. In <a href="./rfc3489">RFC 3489</a> [<a href="./rfc3489" title=""STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)"">RFC3489</a>], this field was part of |
| 597 |
the transaction ID; placing the magic cookie in this location allows |
| 598 |
a server to detect if the client will understand certain attributes |
| 599 |
that were added in this revised specification. In addition, it aids |
| 600 |
in distinguishing STUN packets from packets of other protocols when |
| 601 |
STUN is multiplexed with those other protocols on the same port. |
| 602 |
|
| 603 |
The transaction ID is a 96-bit identifier, used to uniquely identify |
| 604 |
STUN transactions. For request/response transactions, the |
| 605 |
transaction ID is chosen by the STUN client for the request and |
| 606 |
echoed by the server in the response. For indications, it is chosen |
| 607 |
by the agent sending the indication. It primarily serves to |
| 608 |
correlate requests with responses, though it also plays a small role |
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
<span class="grey">Rosenberg, et al. Standards Track [Page 11]</span></pre> |
| 613 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span> |
| 614 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 615 |
|
| 616 |
|
| 617 |
in helping to prevent certain types of attacks. The server also uses |
| 618 |
the transaction ID as a key to identify each transaction uniquely |
| 619 |
across all clients. As such, the transaction ID MUST be uniformly |
| 620 |
and randomly chosen from the interval 0 .. 2**96-1, and SHOULD be |
| 621 |
cryptographically random. Resends of the same request reuse the same |
| 622 |
transaction ID, but the client MUST choose a new transaction ID for |
| 623 |
new transactions unless the new request is bit-wise identical to the |
| 624 |
previous request and sent from the same transport address to the same |
| 625 |
IP address. Success and error responses MUST carry the same |
| 626 |
transaction ID as their corresponding request. When an agent is |
| 627 |
acting as a STUN server and STUN client on the same port, the |
| 628 |
transaction IDs in requests sent by the agent have no relationship to |
| 629 |
the transaction IDs in requests received by the agent. |
| 630 |
|
| 631 |
The message length MUST contain the size, in bytes, of the message |
| 632 |
not including the 20-byte STUN header. Since all STUN attributes are |
| 633 |
padded to a multiple of 4 bytes, the last 2 bits of this field are |
| 634 |
always zero. This provides another way to distinguish STUN packets |
| 635 |
from packets of other protocols. |
| 636 |
|
| 637 |
Following the STUN fixed portion of the header are zero or more |
| 638 |
attributes. Each attribute is TLV (Type-Length-Value) encoded. The |
| 639 |
details of the encoding, and of the attributes themselves are given |
| 640 |
in <a href="#section-15">Section 15</a>. |
| 641 |
|
| 642 |
<span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Base Protocol Procedures</span> |
| 643 |
|
| 644 |
This section defines the base procedures of the STUN protocol. It |
| 645 |
describes how messages are formed, how they are sent, and how they |
| 646 |
are processed when they are received. It also defines the detailed |
| 647 |
processing of the Binding method. Other sections in this document |
| 648 |
describe optional procedures that a usage may elect to use in certain |
| 649 |
situations. Other documents may define other extensions to STUN, by |
| 650 |
adding new methods, new attributes, or new error response codes. |
| 651 |
|
| 652 |
<span class="h3"><a class="selflink" id="section-7.1" href="#section-7.1">7.1</a>. Forming a Request or an Indication</span> |
| 653 |
|
| 654 |
When formulating a request or indication message, the agent MUST |
| 655 |
follow the rules in <a href="#section-6">Section 6</a> when creating the header. In addition, |
| 656 |
the message class MUST be either "Request" or "Indication" (as |
| 657 |
appropriate), and the method must be either Binding or some method |
| 658 |
defined in another document. |
| 659 |
|
| 660 |
The agent then adds any attributes specified by the method or the |
| 661 |
usage. For example, some usages may specify that the agent use an |
| 662 |
authentication method (<a href="#section-10">Section 10</a>) or the FINGERPRINT attribute |
| 663 |
(<a href="#section-8">Section 8</a>). |
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
<span class="grey">Rosenberg, et al. Standards Track [Page 12]</span></pre> |
| 669 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span> |
| 670 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 671 |
|
| 672 |
|
| 673 |
If the agent is sending a request, it SHOULD add a SOFTWARE attribute |
| 674 |
to the request. Agents MAY include a SOFTWARE attribute in |
| 675 |
indications, depending on the method. Extensions to STUN should |
| 676 |
discuss whether SOFTWARE is useful in new indications. |
| 677 |
|
| 678 |
For the Binding method with no authentication, no attributes are |
| 679 |
required unless the usage specifies otherwise. |
| 680 |
|
| 681 |
All STUN messages sent over UDP SHOULD be less than the path MTU, if |
| 682 |
known. If the path MTU is unknown, messages SHOULD be the smaller of |
| 683 |
576 bytes and the first-hop MTU for IPv4 [<a href="./rfc1122" title=""Requirements for Internet Hosts - Communication Layers"">RFC1122</a>] and 1280 bytes for |
| 684 |
IPv6 [<a href="./rfc2460" title=""Internet Protocol, Version 6 (IPv6) Specification"">RFC2460</a>]. This value corresponds to the overall size of the IP |
| 685 |
packet. Consequently, for IPv4, the actual STUN message would need |
| 686 |
to be less than 548 bytes (576 minus 20-byte IP header, minus 8-byte |
| 687 |
UDP header, assuming no IP options are used). STUN provides no |
| 688 |
ability to handle the case where the request is under the MTU but the |
| 689 |
response would be larger than the MTU. It is not envisioned that |
| 690 |
this limitation will be an issue for STUN. The MTU limitation is a |
| 691 |
SHOULD, and not a MUST, to account for cases where STUN itself is |
| 692 |
being used to probe for MTU characteristics [<a href="#ref-BEHAVE-NAT" title=""NAT Behavior Discovery Using STUN"">BEHAVE-NAT</a>]. Outside of |
| 693 |
this or similar applications, the MTU constraint MUST be followed. |
| 694 |
|
| 695 |
<span class="h3"><a class="selflink" id="section-7.2" href="#section-7.2">7.2</a>. Sending the Request or Indication</span> |
| 696 |
|
| 697 |
The agent then sends the request or indication. This document |
| 698 |
specifies how to send STUN messages over UDP, TCP, or TLS-over-TCP; |
| 699 |
other transport protocols may be added in the future. The STUN usage |
| 700 |
must specify which transport protocol is used, and how the agent |
| 701 |
determines the IP address and port of the recipient. <a href="#section-9">Section 9</a> |
| 702 |
describes a DNS-based method of determining the IP address and port |
| 703 |
of a server that a usage may elect to use. STUN may be used with |
| 704 |
anycast addresses, but only with UDP and in usages where |
| 705 |
authentication is not used. |
| 706 |
|
| 707 |
At any time, a client MAY have multiple outstanding STUN requests |
| 708 |
with the same STUN server (that is, multiple transactions in |
| 709 |
progress, with different transaction IDs). Absent other limits to |
| 710 |
the rate of new transactions (such as those specified by ICE for |
| 711 |
connectivity checks or when STUN is run over TCP), a client SHOULD |
| 712 |
space new transactions to a server by RTO and SHOULD limit itself to |
| 713 |
ten outstanding transactions to the same server. |
| 714 |
|
| 715 |
<span class="h4"><a class="selflink" id="section-7.2.1" href="#section-7.2.1">7.2.1</a>. Sending over UDP</span> |
| 716 |
|
| 717 |
When running STUN over UDP, it is possible that the STUN message |
| 718 |
might be dropped by the network. Reliability of STUN request/ |
| 719 |
response transactions is accomplished through retransmissions of the |
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
<span class="grey">Rosenberg, et al. Standards Track [Page 13]</span></pre> |
| 725 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-14" ></span> |
| 726 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 727 |
|
| 728 |
|
| 729 |
request message by the client application itself. STUN indications |
| 730 |
are not retransmitted; thus, indication transactions over UDP are not |
| 731 |
reliable. |
| 732 |
|
| 733 |
A client SHOULD retransmit a STUN request message starting with an |
| 734 |
interval of RTO ("Retransmission TimeOut"), doubling after each |
| 735 |
retransmission. The RTO is an estimate of the round-trip time (RTT), |
| 736 |
and is computed as described in <a href="./rfc2988">RFC 2988</a> [<a href="./rfc2988" title=""Computing TCP's Retransmission Timer"">RFC2988</a>], with two |
| 737 |
exceptions. First, the initial value for RTO SHOULD be configurable |
| 738 |
(rather than the 3 s recommended in <a href="./rfc2988">RFC 2988</a>) and SHOULD be greater |
| 739 |
than 500 ms. The exception cases for this "SHOULD" are when other |
| 740 |
mechanisms are used to derive congestion thresholds (such as the ones |
| 741 |
defined in ICE for fixed rate streams), or when STUN is used in non- |
| 742 |
Internet environments with known network capacities. In fixed-line |
| 743 |
access links, a value of 500 ms is RECOMMENDED. Second, the value of |
| 744 |
RTO SHOULD NOT be rounded up to the nearest second. Rather, a 1 ms |
| 745 |
accuracy SHOULD be maintained. As with TCP, the usage of Karn's |
| 746 |
algorithm is RECOMMENDED [<a href="#ref-KARN87" title=""Improving Round-Trip Time Estimates in Reliable Transport Protocols"">KARN87</a>]. When applied to STUN, it means |
| 747 |
that RTT estimates SHOULD NOT be computed from STUN transactions that |
| 748 |
result in the retransmission of a request. |
| 749 |
|
| 750 |
The value for RTO SHOULD be cached by a client after the completion |
| 751 |
of the transaction, and used as the starting value for RTO for the |
| 752 |
next transaction to the same server (based on equality of IP |
| 753 |
address). The value SHOULD be considered stale and discarded after |
| 754 |
10 minutes. |
| 755 |
|
| 756 |
Retransmissions continue until a response is received, or until a |
| 757 |
total of Rc requests have been sent. Rc SHOULD be configurable and |
| 758 |
SHOULD have a default of 7. If, after the last request, a duration |
| 759 |
equal to Rm times the RTO has passed without a response (providing |
| 760 |
ample time to get a response if only this final request actually |
| 761 |
succeeds), the client SHOULD consider the transaction to have failed. |
| 762 |
Rm SHOULD be configurable and SHOULD have a default of 16. A STUN |
| 763 |
transaction over UDP is also considered failed if there has been a |
| 764 |
hard ICMP error [<a href="./rfc1122" title=""Requirements for Internet Hosts - Communication Layers"">RFC1122</a>]. For example, assuming an RTO of 500 ms, |
| 765 |
requests would be sent at times 0 ms, 500 ms, 1500 ms, 3500 ms, 7500 |
| 766 |
ms, 15500 ms, and 31500 ms. If the client has not received a |
| 767 |
response after 39500 ms, the client will consider the transaction to |
| 768 |
have timed out. |
| 769 |
|
| 770 |
<span class="h4"><a class="selflink" id="section-7.2.2" href="#section-7.2.2">7.2.2</a>. Sending over TCP or TLS-over-TCP</span> |
| 771 |
|
| 772 |
For TCP and TLS-over-TCP, the client opens a TCP connection to the |
| 773 |
server. |
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
<span class="grey">Rosenberg, et al. Standards Track [Page 14]</span></pre> |
| 781 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-15" ></span> |
| 782 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 783 |
|
| 784 |
|
| 785 |
In some usages of STUN, STUN is sent as the only protocol over the |
| 786 |
TCP connection. In this case, it can be sent without the aid of any |
| 787 |
additional framing or demultiplexing. In other usages, or with other |
| 788 |
extensions, it may be multiplexed with other data over a TCP |
| 789 |
connection. In that case, STUN MUST be run on top of some kind of |
| 790 |
framing protocol, specified by the usage or extension, which allows |
| 791 |
for the agent to extract complete STUN messages and complete |
| 792 |
application layer messages. The STUN service running on the well- |
| 793 |
known port or ports discovered through the DNS procedures in |
| 794 |
<a href="#section-9">Section 9</a> is for STUN alone, and not for STUN multiplexed with other |
| 795 |
data. Consequently, no framing protocols are used in connections to |
| 796 |
those servers. When additional framing is utilized, the usage will |
| 797 |
specify how the client knows to apply it and what port to connect to. |
| 798 |
For example, in the case of ICE connectivity checks, this information |
| 799 |
is learned through out-of-band negotiation between client and server. |
| 800 |
|
| 801 |
When STUN is run by itself over TLS-over-TCP, the |
| 802 |
TLS_RSA_WITH_AES_128_CBC_SHA ciphersuite MUST be implemented at a |
| 803 |
minimum. Implementations MAY also support any other ciphersuite. |
| 804 |
When it receives the TLS Certificate message, the client SHOULD |
| 805 |
verify the certificate and inspect the site identified by the |
| 806 |
certificate. If the certificate is invalid or revoked, or if it does |
| 807 |
not identify the appropriate party, the client MUST NOT send the STUN |
| 808 |
message or otherwise proceed with the STUN transaction. The client |
| 809 |
MUST verify the identity of the server. To do that, it follows the |
| 810 |
identification procedures defined in <a href="./rfc2818#section-3.1">Section 3.1 of RFC 2818</a> |
| 811 |
[<a href="./rfc2818" title=""HTTP Over TLS"">RFC2818</a>]. Those procedures assume the client is dereferencing a |
| 812 |
URI. For purposes of usage with this specification, the client |
| 813 |
treats the domain name or IP address used in <a href="#section-8.1">Section 8.1</a> as the host |
| 814 |
portion of the URI that has been dereferenced. Alternatively, a |
| 815 |
client MAY be configured with a set of domains or IP addresses that |
| 816 |
are trusted; if a certificate is received that identifies one of |
| 817 |
those domains or IP addresses, the client considers the identity of |
| 818 |
the server to be verified. |
| 819 |
|
| 820 |
When STUN is run multiplexed with other protocols over a TLS-over-TCP |
| 821 |
connection, the mandatory ciphersuites and TLS handling procedures |
| 822 |
operate as defined by those protocols. |
| 823 |
|
| 824 |
Reliability of STUN over TCP and TLS-over-TCP is handled by TCP |
| 825 |
itself, and there are no retransmissions at the STUN protocol level. |
| 826 |
However, for a request/response transaction, if the client has not |
| 827 |
received a response by Ti seconds after it sent the SYN to establish |
| 828 |
the connection, it considers the transaction to have timed out. Ti |
| 829 |
SHOULD be configurable and SHOULD have a default of 39.5s. This |
| 830 |
value has been chosen to equalize the TCP and UDP timeouts for the |
| 831 |
default initial RTO. |
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
<span class="grey">Rosenberg, et al. Standards Track [Page 15]</span></pre> |
| 837 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-16" ></span> |
| 838 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 839 |
|
| 840 |
|
| 841 |
In addition, if the client is unable to establish the TCP connection, |
| 842 |
or the TCP connection is reset or fails before a response is |
| 843 |
received, any request/response transaction in progress is considered |
| 844 |
to have failed. |
| 845 |
|
| 846 |
The client MAY send multiple transactions over a single TCP (or TLS- |
| 847 |
over-TCP) connection, and it MAY send another request before |
| 848 |
receiving a response to the previous. The client SHOULD keep the |
| 849 |
connection open until it: |
| 850 |
|
| 851 |
o has no further STUN requests or indications to send over that |
| 852 |
connection, and |
| 853 |
|
| 854 |
o has no plans to use any resources (such as a mapped address |
| 855 |
(MAPPED-ADDRESS or XOR-MAPPED-ADDRESS) or relayed address |
| 856 |
[<a href="#ref-BEHAVE-TURN" title=""Traversal Using Relays around NAT (TURN): Relay Extensions to Session Traversal Utilities for NAT (STUN)"">BEHAVE-TURN</a>]) that were learned though STUN requests sent over |
| 857 |
that connection, and |
| 858 |
|
| 859 |
o if multiplexing other application protocols over that port, has |
| 860 |
finished using that other application, and |
| 861 |
|
| 862 |
o if using that learned port with a remote peer, has established |
| 863 |
communications with that remote peer, as is required by some TCP |
| 864 |
NAT traversal techniques (e.g., [<a href="#ref-MMUSIC-ICE-TCP" title=""TCP Candidates with Interactive Connectivity Establishment (ICE)"">MMUSIC-ICE-TCP</a>]). |
| 865 |
|
| 866 |
At the server end, the server SHOULD keep the connection open, and |
| 867 |
let the client close it, unless the server has determined that the |
| 868 |
connection has timed out (for example, due to the client |
| 869 |
disconnecting from the network). Bindings learned by the client will |
| 870 |
remain valid in intervening NATs only while the connection remains |
| 871 |
open. Only the client knows how long it needs the binding. The |
| 872 |
server SHOULD NOT close a connection if a request was received over |
| 873 |
that connection for which a response was not sent. A server MUST NOT |
| 874 |
ever open a connection back towards the client in order to send a |
| 875 |
response. Servers SHOULD follow best practices regarding connection |
| 876 |
management in cases of overload. |
| 877 |
|
| 878 |
<span class="h3"><a class="selflink" id="section-7.3" href="#section-7.3">7.3</a>. Receiving a STUN Message</span> |
| 879 |
|
| 880 |
This section specifies the processing of a STUN message. The |
| 881 |
processing specified here is for STUN messages as defined in this |
| 882 |
specification; additional rules for backwards compatibility are |
| 883 |
defined in <a href="#section-12">Section 12</a>. Those additional procedures are optional, and |
| 884 |
usages can elect to utilize them. First, a set of processing |
| 885 |
operations is applied that is independent of the class. This is |
| 886 |
followed by class-specific processing, described in the subsections |
| 887 |
that follow. |
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
<span class="grey">Rosenberg, et al. Standards Track [Page 16]</span></pre> |
| 893 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-17" ></span> |
| 894 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 895 |
|
| 896 |
|
| 897 |
When a STUN agent receives a STUN message, it first checks that the |
| 898 |
message obeys the rules of <a href="#section-6">Section 6</a>. It checks that the first two |
| 899 |
bits are 0, that the magic cookie field has the correct value, that |
| 900 |
the message length is sensible, and that the method value is a |
| 901 |
supported method. It checks that the message class is allowed for |
| 902 |
the particular method. If the message class is "Success Response" or |
| 903 |
"Error Response", the agent checks that the transaction ID matches a |
| 904 |
transaction that is still in progress. If the FINGERPRINT extension |
| 905 |
is being used, the agent checks that the FINGERPRINT attribute is |
| 906 |
present and contains the correct value. If any errors are detected, |
| 907 |
the message is silently discarded. In the case when STUN is being |
| 908 |
multiplexed with another protocol, an error may indicate that this is |
| 909 |
not really a STUN message; in this case, the agent should try to |
| 910 |
parse the message as a different protocol. |
| 911 |
|
| 912 |
The STUN agent then does any checks that are required by a |
| 913 |
authentication mechanism that the usage has specified (see |
| 914 |
<a href="#section-10">Section 10</a>). |
| 915 |
|
| 916 |
Once the authentication checks are done, the STUN agent checks for |
| 917 |
unknown attributes and known-but-unexpected attributes in the |
| 918 |
message. Unknown comprehension-optional attributes MUST be ignored |
| 919 |
by the agent. Known-but-unexpected attributes SHOULD be ignored by |
| 920 |
the agent. Unknown comprehension-required attributes cause |
| 921 |
processing that depends on the message class and is described below. |
| 922 |
|
| 923 |
At this point, further processing depends on the message class of the |
| 924 |
request. |
| 925 |
|
| 926 |
<span class="h4"><a class="selflink" id="section-7.3.1" href="#section-7.3.1">7.3.1</a>. Processing a Request</span> |
| 927 |
|
| 928 |
If the request contains one or more unknown comprehension-required |
| 929 |
attributes, the server replies with an error response with an error |
| 930 |
code of 420 (Unknown Attribute), and includes an UNKNOWN-ATTRIBUTES |
| 931 |
attribute in the response that lists the unknown comprehension- |
| 932 |
required attributes. |
| 933 |
|
| 934 |
The server then does any additional checking that the method or the |
| 935 |
specific usage requires. If all the checks succeed, the server |
| 936 |
formulates a success response as described below. |
| 937 |
|
| 938 |
When run over UDP, a request received by the server could be the |
| 939 |
first request of a transaction, or a retransmission. The server MUST |
| 940 |
respond to retransmissions such that the following property is |
| 941 |
preserved: if the client receives the response to the retransmission |
| 942 |
and not the response that was sent to the original request, the |
| 943 |
overall state on the client and server is identical to the case where |
| 944 |
only the response to the original retransmission is received, or |
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
<span class="grey">Rosenberg, et al. Standards Track [Page 17]</span></pre> |
| 949 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-18" ></span> |
| 950 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 951 |
|
| 952 |
|
| 953 |
where both responses are received (in which case the client will use |
| 954 |
the first). The easiest way to meet this requirement is for the |
| 955 |
server to remember all transaction IDs received over UDP and their |
| 956 |
corresponding responses in the last 40 seconds. However, this |
| 957 |
requires the server to hold state, and will be inappropriate for any |
| 958 |
requests which are not authenticated. Another way is to reprocess |
| 959 |
the request and recompute the response. The latter technique MUST |
| 960 |
only be applied to requests that are idempotent (a request is |
| 961 |
considered idempotent when the same request can be safely repeated |
| 962 |
without impacting the overall state of the system) and result in the |
| 963 |
same success response for the same request. The Binding method is |
| 964 |
considered to be idempotent. Note that there are certain rare |
| 965 |
network events that could cause the reflexive transport address value |
| 966 |
to change, resulting in a different mapped address in different |
| 967 |
success responses. Extensions to STUN MUST discuss the implications |
| 968 |
of request retransmissions on servers that do not store transaction |
| 969 |
state. |
| 970 |
|
| 971 |
<span class="h5"><a class="selflink" id="section-7.3.1.1" href="#section-7.3.1.1">7.3.1.1</a>. Forming a Success or Error Response</span> |
| 972 |
|
| 973 |
When forming the response (success or error), the server follows the |
| 974 |
rules of <a href="#section-6">Section 6</a>. The method of the response is the same as that |
| 975 |
of the request, and the message class is either "Success Response" or |
| 976 |
"Error Response". |
| 977 |
|
| 978 |
For an error response, the server MUST add an ERROR-CODE attribute |
| 979 |
containing the error code specified in the processing above. The |
| 980 |
reason phrase is not fixed, but SHOULD be something suitable for the |
| 981 |
error code. For certain errors, additional attributes are added to |
| 982 |
the message. These attributes are spelled out in the description |
| 983 |
where the error code is specified. For example, for an error code of |
| 984 |
420 (Unknown Attribute), the server MUST include an UNKNOWN- |
| 985 |
ATTRIBUTES attribute. Certain authentication errors also cause |
| 986 |
attributes to be added (see <a href="#section-10">Section 10</a>). Extensions may define other |
| 987 |
errors and/or additional attributes to add in error cases. |
| 988 |
|
| 989 |
If the server authenticated the request using an authentication |
| 990 |
mechanism, then the server SHOULD add the appropriate authentication |
| 991 |
attributes to the response (see <a href="#section-10">Section 10</a>). |
| 992 |
|
| 993 |
The server also adds any attributes required by the specific method |
| 994 |
or usage. In addition, the server SHOULD add a SOFTWARE attribute to |
| 995 |
the message. |
| 996 |
|
| 997 |
For the Binding method, no additional checking is required unless the |
| 998 |
usage specifies otherwise. When forming the success response, the |
| 999 |
server adds a XOR-MAPPED-ADDRESS attribute to the response, where the |
| 1000 |
contents of the attribute are the source transport address of the |
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
<span class="grey">Rosenberg, et al. Standards Track [Page 18]</span></pre> |
| 1005 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-19" ></span> |
| 1006 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1007 |
|
| 1008 |
|
| 1009 |
request message. For UDP, this is the source IP address and source |
| 1010 |
UDP port of the request message. For TCP and TLS-over-TCP, this is |
| 1011 |
the source IP address and source TCP port of the TCP connection as |
| 1012 |
seen by the server. |
| 1013 |
|
| 1014 |
<span class="h5"><a class="selflink" id="section-7.3.1.2" href="#section-7.3.1.2">7.3.1.2</a>. Sending the Success or Error Response</span> |
| 1015 |
|
| 1016 |
The response (success or error) is sent over the same transport as |
| 1017 |
the request was received on. If the request was received over UDP, |
| 1018 |
the destination IP address and port of the response are the source IP |
| 1019 |
address and port of the received request message, and the source IP |
| 1020 |
address and port of the response are equal to the destination IP |
| 1021 |
address and port of the received request message. If the request was |
| 1022 |
received over TCP or TLS-over-TCP, the response is sent back on the |
| 1023 |
same TCP connection as the request was received on. |
| 1024 |
|
| 1025 |
<span class="h4"><a class="selflink" id="section-7.3.2" href="#section-7.3.2">7.3.2</a>. Processing an Indication</span> |
| 1026 |
|
| 1027 |
If the indication contains unknown comprehension-required attributes, |
| 1028 |
the indication is discarded and processing ceases. |
| 1029 |
|
| 1030 |
The agent then does any additional checking that the method or the |
| 1031 |
specific usage requires. If all the checks succeed, the agent then |
| 1032 |
processes the indication. No response is generated for an |
| 1033 |
indication. |
| 1034 |
|
| 1035 |
For the Binding method, no additional checking or processing is |
| 1036 |
required, unless the usage specifies otherwise. The mere receipt of |
| 1037 |
the message by the agent has refreshed the "bindings" in the |
| 1038 |
intervening NATs. |
| 1039 |
|
| 1040 |
Since indications are not re-transmitted over UDP (unlike requests), |
| 1041 |
there is no need to handle re-transmissions of indications at the |
| 1042 |
sending agent. |
| 1043 |
|
| 1044 |
<span class="h4"><a class="selflink" id="section-7.3.3" href="#section-7.3.3">7.3.3</a>. Processing a Success Response</span> |
| 1045 |
|
| 1046 |
If the success response contains unknown comprehension-required |
| 1047 |
attributes, the response is discarded and the transaction is |
| 1048 |
considered to have failed. |
| 1049 |
|
| 1050 |
The client then does any additional checking that the method or the |
| 1051 |
specific usage requires. If all the checks succeed, the client then |
| 1052 |
processes the success response. |
| 1053 |
|
| 1054 |
For the Binding method, the client checks that the XOR-MAPPED-ADDRESS |
| 1055 |
attribute is present in the response. The client checks the address |
| 1056 |
family specified. If it is an unsupported address family, the |
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
<span class="grey">Rosenberg, et al. Standards Track [Page 19]</span></pre> |
| 1061 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-20" ></span> |
| 1062 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1063 |
|
| 1064 |
|
| 1065 |
attribute SHOULD be ignored. If it is an unexpected but supported |
| 1066 |
address family (for example, the Binding transaction was sent over |
| 1067 |
IPv4, but the address family specified is IPv6), then the client MAY |
| 1068 |
accept and use the value. |
| 1069 |
|
| 1070 |
<span class="h4"><a class="selflink" id="section-7.3.4" href="#section-7.3.4">7.3.4</a>. Processing an Error Response</span> |
| 1071 |
|
| 1072 |
If the error response contains unknown comprehension-required |
| 1073 |
attributes, or if the error response does not contain an ERROR-CODE |
| 1074 |
attribute, then the transaction is simply considered to have failed. |
| 1075 |
|
| 1076 |
The client then does any processing specified by the authentication |
| 1077 |
mechanism (see <a href="#section-10">Section 10</a>). This may result in a new transaction |
| 1078 |
attempt. |
| 1079 |
|
| 1080 |
The processing at this point depends on the error code, the method, |
| 1081 |
and the usage; the following are the default rules: |
| 1082 |
|
| 1083 |
o If the error code is 300 through 399, the client SHOULD consider |
| 1084 |
the transaction as failed unless the ALTERNATE-SERVER extension is |
| 1085 |
being used. See <a href="#section-11">Section 11</a>. |
| 1086 |
|
| 1087 |
o If the error code is 400 through 499, the client declares the |
| 1088 |
transaction failed; in the case of 420 (Unknown Attribute), the |
| 1089 |
response should contain a UNKNOWN-ATTRIBUTES attribute that gives |
| 1090 |
additional information. |
| 1091 |
|
| 1092 |
o If the error code is 500 through 599, the client MAY resend the |
| 1093 |
request; clients that do so MUST limit the number of times they do |
| 1094 |
this. |
| 1095 |
|
| 1096 |
Any other error code causes the client to consider the transaction |
| 1097 |
failed. |
| 1098 |
|
| 1099 |
<span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. FINGERPRINT Mechanism</span> |
| 1100 |
|
| 1101 |
This section describes an optional mechanism for STUN that aids in |
| 1102 |
distinguishing STUN messages from packets of other protocols when the |
| 1103 |
two are multiplexed on the same transport address. This mechanism is |
| 1104 |
optional, and a STUN usage must describe if and when it is used. The |
| 1105 |
FINGERPRINT mechanism is not backwards compatible with <a href="./rfc3489">RFC 3489</a>, and |
| 1106 |
cannot be used in environments where such compatibility is required. |
| 1107 |
|
| 1108 |
In some usages, STUN messages are multiplexed on the same transport |
| 1109 |
address as other protocols, such as the Real Time Transport Protocol |
| 1110 |
(RTP). In order to apply the processing described in <a href="#section-7">Section 7</a>, STUN |
| 1111 |
messages must first be separated from the application packets. |
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
<span class="grey">Rosenberg, et al. Standards Track [Page 20]</span></pre> |
| 1117 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-21" ></span> |
| 1118 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1119 |
|
| 1120 |
|
| 1121 |
<a href="#section-6">Section 6</a> describes three fixed fields in the STUN header that can be |
| 1122 |
used for this purpose. However, in some cases, these three fixed |
| 1123 |
fields may not be sufficient. |
| 1124 |
|
| 1125 |
When the FINGERPRINT extension is used, an agent includes the |
| 1126 |
FINGERPRINT attribute in messages it sends to another agent. |
| 1127 |
<a href="#section-15.5">Section 15.5</a> describes the placement and value of this attribute. |
| 1128 |
When the agent receives what it believes is a STUN message, then, in |
| 1129 |
addition to other basic checks, the agent also checks that the |
| 1130 |
message contains a FINGERPRINT attribute and that the attribute |
| 1131 |
contains the correct value. <a href="#section-7.3">Section 7.3</a> describes when in the |
| 1132 |
overall processing of a STUN message the FINGERPRINT check is |
| 1133 |
performed. This additional check helps the agent detect messages of |
| 1134 |
other protocols that might otherwise seem to be STUN messages. |
| 1135 |
|
| 1136 |
<span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. DNS Discovery of a Server</span> |
| 1137 |
|
| 1138 |
This section describes an optional procedure for STUN that allows a |
| 1139 |
client to use DNS to determine the IP address and port of a server. |
| 1140 |
A STUN usage must describe if and when this extension is used. To |
| 1141 |
use this procedure, the client must know a server's domain name and a |
| 1142 |
service name; the usage must also describe how the client obtains |
| 1143 |
these. Hard-coding the domain name of the server into software is |
| 1144 |
NOT RECOMMENDED in case the domain name is lost or needs to change |
| 1145 |
for legal or other reasons. |
| 1146 |
|
| 1147 |
When a client wishes to locate a STUN server in the public Internet |
| 1148 |
that accepts Binding request/response transactions, the SRV service |
| 1149 |
name is "stun". When it wishes to locate a STUN server that accepts |
| 1150 |
Binding request/response transactions over a TLS session, the SRV |
| 1151 |
service name is "stuns". STUN usages MAY define additional DNS SRV |
| 1152 |
service names. |
| 1153 |
|
| 1154 |
The domain name is resolved to a transport address using the SRV |
| 1155 |
procedures specified in [<a href="./rfc2782" title=""A DNS RR for specifying the location of services (DNS SRV)"">RFC2782</a>]. The DNS SRV service name is the |
| 1156 |
service name provided as input to this procedure. The protocol in |
| 1157 |
the SRV lookup is the transport protocol the client will run STUN |
| 1158 |
over: "udp" for UDP and "tcp" for TCP. Note that only "tcp" is |
| 1159 |
defined with "stuns" at this time. |
| 1160 |
|
| 1161 |
The procedures of <a href="./rfc2782">RFC 2782</a> are followed to determine the server to |
| 1162 |
contact. <a href="./rfc2782">RFC 2782</a> spells out the details of how a set of SRV records |
| 1163 |
is sorted and then tried. However, <a href="./rfc2782">RFC 2782</a> only states that the |
| 1164 |
client should "try to connect to the (protocol, address, service)" |
| 1165 |
without giving any details on what happens in the event of failure. |
| 1166 |
When following these procedures, if the STUN transaction times out |
| 1167 |
without receipt of a response, the client SHOULD retry the request to |
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
<span class="grey">Rosenberg, et al. Standards Track [Page 21]</span></pre> |
| 1173 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-22" ></span> |
| 1174 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1175 |
|
| 1176 |
|
| 1177 |
the next server in the ordered defined by <a href="./rfc2782">RFC 2782</a>. Such a retry is |
| 1178 |
only possible for request/response transmissions, since indication |
| 1179 |
transactions generate no response or timeout. |
| 1180 |
|
| 1181 |
The default port for STUN requests is 3478, for both TCP and UDP. |
| 1182 |
|
| 1183 |
Administrators of STUN servers SHOULD use this port in their SRV |
| 1184 |
records for UDP and TCP. In all cases, the port in DNS MUST reflect |
| 1185 |
the one on which the server is listening. The default port for STUN |
| 1186 |
over TLS is 5349. Servers can run STUN over TLS on the same port as |
| 1187 |
STUN over TCP if the server software supports determining whether the |
| 1188 |
initial message is a TLS or STUN message. |
| 1189 |
|
| 1190 |
If no SRV records were found, the client performs an A or AAAA record |
| 1191 |
lookup of the domain name. The result will be a list of IP |
| 1192 |
addresses, each of which can be contacted at the default port using |
| 1193 |
UDP or TCP, independent of the STUN usage. For usages that require |
| 1194 |
TLS, the client connects to one of the IP addresses using the default |
| 1195 |
STUN over TLS port. |
| 1196 |
|
| 1197 |
<span class="h2"><a class="selflink" id="section-10" href="#section-10">10</a>. Authentication and Message-Integrity Mechanisms</span> |
| 1198 |
|
| 1199 |
This section defines two mechanisms for STUN that a client and server |
| 1200 |
can use to provide authentication and message integrity; these two |
| 1201 |
mechanisms are known as the short-term credential mechanism and the |
| 1202 |
long-term credential mechanism. These two mechanisms are optional, |
| 1203 |
and each usage must specify if and when these mechanisms are used. |
| 1204 |
Consequently, both clients and servers will know which mechanism (if |
| 1205 |
any) to follow based on knowledge of which usage applies. For |
| 1206 |
example, a STUN server on the public Internet supporting ICE would |
| 1207 |
have no authentication, whereas the STUN server functionality in an |
| 1208 |
agent supporting connectivity checks would utilize short-term |
| 1209 |
credentials. An overview of these two mechanisms is given in |
| 1210 |
<a href="#section-3">Section 3</a>. |
| 1211 |
|
| 1212 |
Each mechanism specifies the additional processing required to use |
| 1213 |
that mechanism, extending the processing specified in <a href="#section-7">Section 7</a>. The |
| 1214 |
additional processing occurs in three different places: when forming |
| 1215 |
a message, when receiving a message immediately after the basic |
| 1216 |
checks have been performed, and when doing the detailed processing of |
| 1217 |
error responses. |
| 1218 |
|
| 1219 |
<span class="h3"><a class="selflink" id="section-10.1" href="#section-10.1">10.1</a>. Short-Term Credential Mechanism</span> |
| 1220 |
|
| 1221 |
The short-term credential mechanism assumes that, prior to the STUN |
| 1222 |
transaction, the client and server have used some other protocol to |
| 1223 |
exchange a credential in the form of a username and password. This |
| 1224 |
credential is time-limited. The time limit is defined by the usage. |
| 1225 |
|
| 1226 |
|
| 1227 |
|
| 1228 |
<span class="grey">Rosenberg, et al. Standards Track [Page 22]</span></pre> |
| 1229 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-23" ></span> |
| 1230 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1231 |
|
| 1232 |
|
| 1233 |
As an example, in the ICE usage [<a href="#ref-MMUSIC-ICE" title=""Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols"">MMUSIC-ICE</a>], the two endpoints use |
| 1234 |
out-of-band signaling to agree on a username and password, and this |
| 1235 |
username and password are applicable for the duration of the media |
| 1236 |
session. |
| 1237 |
|
| 1238 |
This credential is used to form a message-integrity check in each |
| 1239 |
request and in many responses. There is no challenge and response as |
| 1240 |
in the long-term mechanism; consequently, replay is prevented by |
| 1241 |
virtue of the time-limited nature of the credential. |
| 1242 |
|
| 1243 |
<span class="h4"><a class="selflink" id="section-10.1.1" href="#section-10.1.1">10.1.1</a>. Forming a Request or Indication</span> |
| 1244 |
|
| 1245 |
For a request or indication message, the agent MUST include the |
| 1246 |
USERNAME and MESSAGE-INTEGRITY attributes in the message. The HMAC |
| 1247 |
for the MESSAGE-INTEGRITY attribute is computed as described in |
| 1248 |
<a href="#section-15.4">Section 15.4</a>. Note that the password is never included in the |
| 1249 |
request or indication. |
| 1250 |
|
| 1251 |
<span class="h4"><a class="selflink" id="section-10.1.2" href="#section-10.1.2">10.1.2</a>. Receiving a Request or Indication</span> |
| 1252 |
|
| 1253 |
After the agent has done the basic processing of a message, the agent |
| 1254 |
performs the checks listed below in order specified: |
| 1255 |
|
| 1256 |
o If the message does not contain both a MESSAGE-INTEGRITY and a |
| 1257 |
USERNAME attribute: |
| 1258 |
|
| 1259 |
* If the message is a request, the server MUST reject the request |
| 1260 |
with an error response. This response MUST use an error code |
| 1261 |
of 400 (Bad Request). |
| 1262 |
|
| 1263 |
* If the message is an indication, the agent MUST silently |
| 1264 |
discard the indication. |
| 1265 |
|
| 1266 |
o If the USERNAME does not contain a username value currently valid |
| 1267 |
within the server: |
| 1268 |
|
| 1269 |
* If the message is a request, the server MUST reject the request |
| 1270 |
with an error response. This response MUST use an error code |
| 1271 |
of 401 (Unauthorized). |
| 1272 |
|
| 1273 |
* If the message is an indication, the agent MUST silently |
| 1274 |
discard the indication. |
| 1275 |
|
| 1276 |
o Using the password associated with the username, compute the value |
| 1277 |
for the message integrity as described in <a href="#section-15.4">Section 15.4</a>. If the |
| 1278 |
resulting value does not match the contents of the MESSAGE- |
| 1279 |
INTEGRITY attribute: |
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
|
| 1284 |
<span class="grey">Rosenberg, et al. Standards Track [Page 23]</span></pre> |
| 1285 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-24" ></span> |
| 1286 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1287 |
|
| 1288 |
|
| 1289 |
* If the message is a request, the server MUST reject the request |
| 1290 |
with an error response. This response MUST use an error code |
| 1291 |
of 401 (Unauthorized). |
| 1292 |
|
| 1293 |
* If the message is an indication, the agent MUST silently |
| 1294 |
discard the indication. |
| 1295 |
|
| 1296 |
If these checks pass, the agent continues to process the request or |
| 1297 |
indication. Any response generated by a server MUST include the |
| 1298 |
MESSAGE-INTEGRITY attribute, computed using the password utilized to |
| 1299 |
authenticate the request. The response MUST NOT contain the USERNAME |
| 1300 |
attribute. |
| 1301 |
|
| 1302 |
If any of the checks fail, a server MUST NOT include a MESSAGE- |
| 1303 |
INTEGRITY or USERNAME attribute in the error response. This is |
| 1304 |
because, in these failure cases, the server cannot determine the |
| 1305 |
shared secret necessary to compute MESSAGE-INTEGRITY. |
| 1306 |
|
| 1307 |
<span class="h4"><a class="selflink" id="section-10.1.3" href="#section-10.1.3">10.1.3</a>. Receiving a Response</span> |
| 1308 |
|
| 1309 |
The client looks for the MESSAGE-INTEGRITY attribute in the response. |
| 1310 |
If present, the client computes the message integrity over the |
| 1311 |
response as defined in <a href="#section-15.4">Section 15.4</a>, using the same password it |
| 1312 |
utilized for the request. If the resulting value matches the |
| 1313 |
contents of the MESSAGE-INTEGRITY attribute, the response is |
| 1314 |
considered authenticated. If the value does not match, or if |
| 1315 |
MESSAGE-INTEGRITY was absent, the response MUST be discarded, as if |
| 1316 |
it was never received. This means that retransmits, if applicable, |
| 1317 |
will continue. |
| 1318 |
|
| 1319 |
<span class="h3"><a class="selflink" id="section-10.2" href="#section-10.2">10.2</a>. Long-Term Credential Mechanism</span> |
| 1320 |
|
| 1321 |
The long-term credential mechanism relies on a long-term credential, |
| 1322 |
in the form of a username and password that are shared between client |
| 1323 |
and server. The credential is considered long-term since it is |
| 1324 |
assumed that it is provisioned for a user, and remains in effect |
| 1325 |
until the user is no longer a subscriber of the system, or is |
| 1326 |
changed. This is basically a traditional "log-in" username and |
| 1327 |
password given to users. |
| 1328 |
|
| 1329 |
Because these usernames and passwords are expected to be valid for |
| 1330 |
extended periods of time, replay prevention is provided in the form |
| 1331 |
of a digest challenge. In this mechanism, the client initially sends |
| 1332 |
a request, without offering any credentials or any integrity checks. |
| 1333 |
The server rejects this request, providing the user a realm (used to |
| 1334 |
guide the user or agent in selection of a username and password) and |
| 1335 |
a nonce. The nonce provides the replay protection. It is a cookie, |
| 1336 |
selected by the server, and encoded in such a way as to indicate a |
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
<span class="grey">Rosenberg, et al. Standards Track [Page 24]</span></pre> |
| 1341 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-25" ></span> |
| 1342 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1343 |
|
| 1344 |
|
| 1345 |
duration of validity or client identity from which it is valid. The |
| 1346 |
client retries the request, this time including its username and the |
| 1347 |
realm, and echoing the nonce provided by the server. The client also |
| 1348 |
includes a message-integrity, which provides an HMAC over the entire |
| 1349 |
request, including the nonce. The server validates the nonce and |
| 1350 |
checks the message integrity. If they match, the request is |
| 1351 |
authenticated. If the nonce is no longer valid, it is considered |
| 1352 |
"stale", and the server rejects the request, providing a new nonce. |
| 1353 |
|
| 1354 |
In subsequent requests to the same server, the client reuses the |
| 1355 |
nonce, username, realm, and password it used previously. In this |
| 1356 |
way, subsequent requests are not rejected until the nonce becomes |
| 1357 |
invalid by the server, in which case the rejection provides a new |
| 1358 |
nonce to the client. |
| 1359 |
|
| 1360 |
Note that the long-term credential mechanism cannot be used to |
| 1361 |
protect indications, since indications cannot be challenged. Usages |
| 1362 |
utilizing indications must either use a short-term credential or omit |
| 1363 |
authentication and message integrity for them. |
| 1364 |
|
| 1365 |
Since the long-term credential mechanism is susceptible to offline |
| 1366 |
dictionary attacks, deployments SHOULD utilize passwords that are |
| 1367 |
difficult to guess. In cases where the credentials are not entered |
| 1368 |
by the user, but are rather placed on a client device during device |
| 1369 |
provisioning, the password SHOULD have at least 128 bits of |
| 1370 |
randomness. In cases where the credentials are entered by the user, |
| 1371 |
they should follow best current practices around password structure. |
| 1372 |
|
| 1373 |
<span class="h4"><a class="selflink" id="section-10.2.1" href="#section-10.2.1">10.2.1</a>. Forming a Request</span> |
| 1374 |
|
| 1375 |
There are two cases when forming a request. In the first case, this |
| 1376 |
is the first request from the client to the server (as identified by |
| 1377 |
its IP address and port). In the second case, the client is |
| 1378 |
submitting a subsequent request once a previous request/response |
| 1379 |
transaction has completed successfully. Forming a request as a |
| 1380 |
consequence of a 401 or 438 error response is covered in |
| 1381 |
<a href="#section-10.2.3">Section 10.2.3</a> and is not considered a "subsequent request" and thus |
| 1382 |
does not utilize the rules described in <a href="#section-10.2.1.2">Section 10.2.1.2</a>. |
| 1383 |
|
| 1384 |
<span class="h5"><a class="selflink" id="section-10.2.1.1" href="#section-10.2.1.1">10.2.1.1</a>. First Request</span> |
| 1385 |
|
| 1386 |
If the client has not completed a successful request/response |
| 1387 |
transaction with the server (as identified by hostname, if the DNS |
| 1388 |
procedures of <a href="#section-9">Section 9</a> are used, else IP address if not), it SHOULD |
| 1389 |
omit the USERNAME, MESSAGE-INTEGRITY, REALM, and NONCE attributes. |
| 1390 |
In other words, the very first request is sent as if there were no |
| 1391 |
authentication or message integrity applied. |
| 1392 |
|
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
<span class="grey">Rosenberg, et al. Standards Track [Page 25]</span></pre> |
| 1397 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-26" ></span> |
| 1398 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1399 |
|
| 1400 |
|
| 1401 |
<span class="h5"><a class="selflink" id="section-10.2.1.2" href="#section-10.2.1.2">10.2.1.2</a>. Subsequent Requests</span> |
| 1402 |
|
| 1403 |
Once a request/response transaction has completed successfully, the |
| 1404 |
client will have been presented a realm and nonce by the server, and |
| 1405 |
selected a username and password with which it authenticated. The |
| 1406 |
client SHOULD cache the username, password, realm, and nonce for |
| 1407 |
subsequent communications with the server. When the client sends a |
| 1408 |
subsequent request, it SHOULD include the USERNAME, REALM, and NONCE |
| 1409 |
attributes with these cached values. It SHOULD include a MESSAGE- |
| 1410 |
INTEGRITY attribute, computed as described in <a href="#section-15.4">Section 15.4</a> using the |
| 1411 |
cached password. |
| 1412 |
|
| 1413 |
<span class="h4"><a class="selflink" id="section-10.2.2" href="#section-10.2.2">10.2.2</a>. Receiving a Request</span> |
| 1414 |
|
| 1415 |
After the server has done the basic processing of a request, it |
| 1416 |
performs the checks listed below in the order specified: |
| 1417 |
|
| 1418 |
o If the message does not contain a MESSAGE-INTEGRITY attribute, the |
| 1419 |
server MUST generate an error response with an error code of 401 |
| 1420 |
(Unauthorized). This response MUST include a REALM value. It is |
| 1421 |
RECOMMENDED that the REALM value be the domain name of the |
| 1422 |
provider of the STUN server. The response MUST include a NONCE, |
| 1423 |
selected by the server. The response SHOULD NOT contain a |
| 1424 |
USERNAME or MESSAGE-INTEGRITY attribute. |
| 1425 |
|
| 1426 |
o If the message contains a MESSAGE-INTEGRITY attribute, but is |
| 1427 |
missing the USERNAME, REALM, or NONCE attribute, the server MUST |
| 1428 |
generate an error response with an error code of 400 (Bad |
| 1429 |
Request). This response SHOULD NOT include a USERNAME, NONCE, |
| 1430 |
REALM, or MESSAGE-INTEGRITY attribute. |
| 1431 |
|
| 1432 |
o If the NONCE is no longer valid, the server MUST generate an error |
| 1433 |
response with an error code of 438 (Stale Nonce). This response |
| 1434 |
MUST include NONCE and REALM attributes and SHOULD NOT include the |
| 1435 |
USERNAME or MESSAGE-INTEGRITY attribute. Servers can invalidate |
| 1436 |
nonces in order to provide additional security. See <a href="./rfc2617#section-4.3">Section 4.3 |
| 1437 |
of [RFC2617]</a> for guidelines. |
| 1438 |
|
| 1439 |
o If the username in the USERNAME attribute is not valid, the server |
| 1440 |
MUST generate an error response with an error code of 401 |
| 1441 |
(Unauthorized). This response MUST include a REALM value. It is |
| 1442 |
RECOMMENDED that the REALM value be the domain name of the |
| 1443 |
provider of the STUN server. The response MUST include a NONCE, |
| 1444 |
selected by the server. The response SHOULD NOT contain a |
| 1445 |
USERNAME or MESSAGE-INTEGRITY attribute. |
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
<span class="grey">Rosenberg, et al. Standards Track [Page 26]</span></pre> |
| 1453 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-27" ></span> |
| 1454 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1455 |
|
| 1456 |
|
| 1457 |
o Using the password associated with the username in the USERNAME |
| 1458 |
attribute, compute the value for the message integrity as |
| 1459 |
described in <a href="#section-15.4">Section 15.4</a>. If the resulting value does not match |
| 1460 |
the contents of the MESSAGE-INTEGRITY attribute, the server MUST |
| 1461 |
reject the request with an error response. This response MUST use |
| 1462 |
an error code of 401 (Unauthorized). It MUST include REALM and |
| 1463 |
NONCE attributes and SHOULD NOT include the USERNAME or MESSAGE- |
| 1464 |
INTEGRITY attribute. |
| 1465 |
|
| 1466 |
If these checks pass, the server continues to process the request. |
| 1467 |
Any response generated by the server (excepting the cases described |
| 1468 |
above) MUST include the MESSAGE-INTEGRITY attribute, computed using |
| 1469 |
the username and password utilized to authenticate the request. The |
| 1470 |
REALM, NONCE, and USERNAME attributes SHOULD NOT be included. |
| 1471 |
|
| 1472 |
<span class="h4"><a class="selflink" id="section-10.2.3" href="#section-10.2.3">10.2.3</a>. Receiving a Response</span> |
| 1473 |
|
| 1474 |
If the response is an error response with an error code of 401 |
| 1475 |
(Unauthorized), the client SHOULD retry the request with a new |
| 1476 |
transaction. This request MUST contain a USERNAME, determined by the |
| 1477 |
client as the appropriate username for the REALM from the error |
| 1478 |
response. The request MUST contain the REALM, copied from the error |
| 1479 |
response. The request MUST contain the NONCE, copied from the error |
| 1480 |
response. The request MUST contain the MESSAGE-INTEGRITY attribute, |
| 1481 |
computed using the password associated with the username in the |
| 1482 |
USERNAME attribute. The client MUST NOT perform this retry if it is |
| 1483 |
not changing the USERNAME or REALM or its associated password, from |
| 1484 |
the previous attempt. |
| 1485 |
|
| 1486 |
If the response is an error response with an error code of 438 (Stale |
| 1487 |
Nonce), the client MUST retry the request, using the new NONCE |
| 1488 |
supplied in the 438 (Stale Nonce) response. This retry MUST also |
| 1489 |
include the USERNAME, REALM, and MESSAGE-INTEGRITY. |
| 1490 |
|
| 1491 |
The client looks for the MESSAGE-INTEGRITY attribute in the response |
| 1492 |
(either success or failure). If present, the client computes the |
| 1493 |
message integrity over the response as defined in <a href="#section-15.4">Section 15.4</a>, using |
| 1494 |
the same password it utilized for the request. If the resulting |
| 1495 |
value matches the contents of the MESSAGE-INTEGRITY attribute, the |
| 1496 |
response is considered authenticated. If the value does not match, |
| 1497 |
or if MESSAGE-INTEGRITY was absent, the response MUST be discarded, |
| 1498 |
as if it was never received. This means that retransmits, if |
| 1499 |
applicable, will continue. |
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
|
| 1505 |
|
| 1506 |
|
| 1507 |
|
| 1508 |
<span class="grey">Rosenberg, et al. Standards Track [Page 27]</span></pre> |
| 1509 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-28" ></span> |
| 1510 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1511 |
|
| 1512 |
|
| 1513 |
<span class="h2"><a class="selflink" id="section-11" href="#section-11">11</a>. ALTERNATE-SERVER Mechanism</span> |
| 1514 |
|
| 1515 |
This section describes a mechanism in STUN that allows a server to |
| 1516 |
redirect a client to another server. This extension is optional, and |
| 1517 |
a usage must define if and when this extension is used. |
| 1518 |
|
| 1519 |
A server using this extension redirects a client to another server by |
| 1520 |
replying to a request message with an error response message with an |
| 1521 |
error code of 300 (Try Alternate). The server MUST include an |
| 1522 |
ALTERNATE-SERVER attribute in the error response. The error response |
| 1523 |
message MAY be authenticated; however, there are uses cases for |
| 1524 |
ALTERNATE-SERVER where authentication of the response is not possible |
| 1525 |
or practical. |
| 1526 |
|
| 1527 |
A client using this extension handles a 300 (Try Alternate) error |
| 1528 |
code as follows. The client looks for an ALTERNATE-SERVER attribute |
| 1529 |
in the error response. If one is found, then the client considers |
| 1530 |
the current transaction as failed, and reattempts the request with |
| 1531 |
the server specified in the attribute, using the same transport |
| 1532 |
protocol used for the previous request. That request, if |
| 1533 |
authenticated, MUST utilize the same credentials that the client |
| 1534 |
would have used in the request to the server that performed the |
| 1535 |
redirection. If the client has been redirected to a server on which |
| 1536 |
it has already tried this request within the last five minutes, it |
| 1537 |
MUST ignore the redirection and consider the transaction to have |
| 1538 |
failed. This prevents infinite ping-ponging between servers in case |
| 1539 |
of redirection loops. |
| 1540 |
|
| 1541 |
<span class="h2"><a class="selflink" id="section-12" href="#section-12">12</a>. Backwards Compatibility with <a href="./rfc3489">RFC 3489</a></span> |
| 1542 |
|
| 1543 |
This section defines procedures that allow a degree of backwards |
| 1544 |
compatibility with the original protocol defined in <a href="./rfc3489">RFC 3489</a> |
| 1545 |
[<a href="./rfc3489" title=""STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)"">RFC3489</a>]. This mechanism is optional, meant to be utilized only in |
| 1546 |
cases where a new client can connect to an old server, or vice versa. |
| 1547 |
A usage must define if and when this procedure is used. |
| 1548 |
|
| 1549 |
<a href="#section-19">Section 19</a> lists all the changes between this specification and <a href="./rfc3489">RFC</a> |
| 1550 |
<a href="./rfc3489">3489</a> [<a href="./rfc3489" title=""STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)"">RFC3489</a>]. However, not all of these differences are important, |
| 1551 |
because "classic STUN" was only used in a few specific ways. For the |
| 1552 |
purposes of this extension, the important changes are the following. |
| 1553 |
In <a href="./rfc3489">RFC 3489</a>: |
| 1554 |
|
| 1555 |
o UDP was the only supported transport. |
| 1556 |
|
| 1557 |
o The field that is now the magic cookie field was a part of the |
| 1558 |
transaction ID field, and transaction IDs were 128 bits long. |
| 1559 |
|
| 1560 |
|
| 1561 |
|
| 1562 |
|
| 1563 |
|
| 1564 |
<span class="grey">Rosenberg, et al. Standards Track [Page 28]</span></pre> |
| 1565 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-29" ></span> |
| 1566 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1567 |
|
| 1568 |
|
| 1569 |
o The XOR-MAPPED-ADDRESS attribute did not exist, and the Binding |
| 1570 |
method used the MAPPED-ADDRESS attribute instead. |
| 1571 |
|
| 1572 |
o There were three comprehension-required attributes, RESPONSE- |
| 1573 |
ADDRESS, CHANGE-REQUEST, and CHANGED-ADDRESS, that have been |
| 1574 |
removed from this specification. |
| 1575 |
|
| 1576 |
* CHANGE-REQUEST and CHANGED-ADDRESS are now part of the NAT |
| 1577 |
Behavior Discovery usage [<a href="#ref-BEHAVE-NAT" title=""NAT Behavior Discovery Using STUN"">BEHAVE-NAT</a>], and the other is |
| 1578 |
deprecated. |
| 1579 |
|
| 1580 |
<span class="h3"><a class="selflink" id="section-12.1" href="#section-12.1">12.1</a>. Changes to Client Processing</span> |
| 1581 |
|
| 1582 |
A client that wants to interoperate with an [<a href="./rfc3489" title=""STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)"">RFC3489</a>] server SHOULD |
| 1583 |
send a request message that uses the Binding method, contains no |
| 1584 |
attributes, and uses UDP as the transport protocol to the server. If |
| 1585 |
successful, the success response received from the server will |
| 1586 |
contain a MAPPED-ADDRESS attribute rather than an XOR-MAPPED-ADDRESS |
| 1587 |
attribute. A client seeking to interoperate with an older server |
| 1588 |
MUST be prepared to receive either. Furthermore, the client MUST |
| 1589 |
ignore any Reserved comprehension-required attributes that might |
| 1590 |
appear in the response. Of the Reserved attributes in <a href="#section-18.2">Section 18.2</a>, |
| 1591 |
0x0002, 0x0004, 0x0005, and 0x000B may appear in Binding responses |
| 1592 |
from a server compliant to <a href="./rfc3489">RFC 3489</a>. Other than this change, the |
| 1593 |
processing of the response is identical to the procedures described |
| 1594 |
above. |
| 1595 |
|
| 1596 |
<span class="h3"><a class="selflink" id="section-12.2" href="#section-12.2">12.2</a>. Changes to Server Processing</span> |
| 1597 |
|
| 1598 |
A STUN server can detect when a given Binding request message was |
| 1599 |
sent from an <a href="./rfc3489">RFC 3489</a> [<a href="./rfc3489" title=""STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)"">RFC3489</a>] client by the absence of the correct |
| 1600 |
value in the magic cookie field. When the server detects an <a href="./rfc3489">RFC 3489</a> |
| 1601 |
client, it SHOULD copy the value seen in the magic cookie field in |
| 1602 |
the Binding request to the magic cookie field in the Binding response |
| 1603 |
message, and insert a MAPPED-ADDRESS attribute instead of an XOR- |
| 1604 |
MAPPED-ADDRESS attribute. |
| 1605 |
|
| 1606 |
The client might, in rare situations, include either the RESPONSE- |
| 1607 |
ADDRESS or CHANGE-REQUEST attributes. In these situations, the |
| 1608 |
server will view these as unknown comprehension-required attributes |
| 1609 |
and reply with an error response. Since the mechanisms utilizing |
| 1610 |
those attributes are no longer supported, this behavior is |
| 1611 |
acceptable. |
| 1612 |
|
| 1613 |
The <a href="./rfc3489">RFC 3489</a> version of STUN lacks both the magic cookie and the |
| 1614 |
FINGERPRINT attribute that allows for a very high probability of |
| 1615 |
correctly identifying STUN messages when multiplexed with other |
| 1616 |
protocols. Therefore, STUN implementations that are backwards |
| 1617 |
|
| 1618 |
|
| 1619 |
|
| 1620 |
<span class="grey">Rosenberg, et al. Standards Track [Page 29]</span></pre> |
| 1621 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-30" ></span> |
| 1622 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1623 |
|
| 1624 |
|
| 1625 |
compatible with <a href="./rfc3489">RFC 3489</a> SHOULD NOT be used in cases where STUN will |
| 1626 |
be multiplexed with another protocol. However, that should not be an |
| 1627 |
issue as such multiplexing was not available in <a href="./rfc3489">RFC 3489</a>. |
| 1628 |
|
| 1629 |
<span class="h2"><a class="selflink" id="section-13" href="#section-13">13</a>. Basic Server Behavior</span> |
| 1630 |
|
| 1631 |
This section defines the behavior of a basic, stand-alone STUN |
| 1632 |
server. A basic STUN server provides clients with server reflexive |
| 1633 |
transport addresses by receiving and replying to STUN Binding |
| 1634 |
requests. |
| 1635 |
|
| 1636 |
The STUN server MUST support the Binding method. It SHOULD NOT |
| 1637 |
utilize the short-term or long-term credential mechanism. This is |
| 1638 |
because the work involved in authenticating the request is more than |
| 1639 |
the work in simply processing it. It SHOULD NOT utilize the |
| 1640 |
ALTERNATE-SERVER mechanism for the same reason. It MUST support UDP |
| 1641 |
and TCP. It MAY support STUN over TCP/TLS; however, TLS provides |
| 1642 |
minimal security benefits in this basic mode of operation. It MAY |
| 1643 |
utilize the FINGERPRINT mechanism but MUST NOT require it. Since the |
| 1644 |
stand-alone server only runs STUN, FINGERPRINT provides no benefit. |
| 1645 |
Requiring it would break compatibility with <a href="./rfc3489">RFC 3489</a>, and such |
| 1646 |
compatibility is desirable in a stand-alone server. Stand-alone STUN |
| 1647 |
servers SHOULD support backwards compatibility with [<a href="./rfc3489" title=""STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)"">RFC3489</a>] |
| 1648 |
clients, as described in <a href="#section-12">Section 12</a>. |
| 1649 |
|
| 1650 |
It is RECOMMENDED that administrators of STUN servers provide DNS |
| 1651 |
entries for those servers as described in <a href="#section-9">Section 9</a>. |
| 1652 |
|
| 1653 |
A basic STUN server is not a solution for NAT traversal by itself. |
| 1654 |
However, it can be utilized as part of a solution through STUN |
| 1655 |
usages. This is discussed further in <a href="#section-14">Section 14</a>. |
| 1656 |
|
| 1657 |
<span class="h2"><a class="selflink" id="section-14" href="#section-14">14</a>. STUN Usages</span> |
| 1658 |
|
| 1659 |
STUN by itself is not a solution to the NAT traversal problem. |
| 1660 |
Rather, STUN defines a tool that can be used inside a larger |
| 1661 |
solution. The term "STUN usage" is used for any solution that uses |
| 1662 |
STUN as a component. |
| 1663 |
|
| 1664 |
At the time of writing, three STUN usages are defined: Interactive |
| 1665 |
Connectivity Establishment (ICE) [<a href="#ref-MMUSIC-ICE" title=""Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols"">MMUSIC-ICE</a>], Client-initiated |
| 1666 |
connections for SIP [<a href="#ref-SIP-OUTBOUND" title=""Managing Client Initiated Connections in the Session Initiation Protocol (SIP)"">SIP-OUTBOUND</a>], and NAT Behavior Discovery |
| 1667 |
[<a href="#ref-BEHAVE-NAT" title=""NAT Behavior Discovery Using STUN"">BEHAVE-NAT</a>]. Other STUN usages may be defined in the future. |
| 1668 |
|
| 1669 |
A STUN usage defines how STUN is actually utilized -- when to send |
| 1670 |
requests, what to do with the responses, and which optional |
| 1671 |
procedures defined here (or in an extension to STUN) are to be used. |
| 1672 |
A usage would also define: |
| 1673 |
|
| 1674 |
|
| 1675 |
|
| 1676 |
<span class="grey">Rosenberg, et al. Standards Track [Page 30]</span></pre> |
| 1677 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-31" ></span> |
| 1678 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1679 |
|
| 1680 |
|
| 1681 |
o Which STUN methods are used. |
| 1682 |
|
| 1683 |
o What authentication and message-integrity mechanisms are used. |
| 1684 |
|
| 1685 |
o The considerations around manual vs. automatic key derivation for |
| 1686 |
the integrity mechanism, as discussed in [<a href="./rfc4107" title=""Guidelines for Cryptographic Key Management"">RFC4107</a>]. |
| 1687 |
|
| 1688 |
o What mechanisms are used to distinguish STUN messages from other |
| 1689 |
messages. When STUN is run over TCP, a framing mechanism may be |
| 1690 |
required. |
| 1691 |
|
| 1692 |
o How a STUN client determines the IP address and port of the STUN |
| 1693 |
server. |
| 1694 |
|
| 1695 |
o Whether backwards compatibility to <a href="./rfc3489">RFC 3489</a> is required. |
| 1696 |
|
| 1697 |
o What optional attributes defined here (such as FINGERPRINT and |
| 1698 |
ALTERNATE-SERVER) or in other extensions are required. |
| 1699 |
|
| 1700 |
In addition, any STUN usage must consider the security implications |
| 1701 |
of using STUN in that usage. A number of attacks against STUN are |
| 1702 |
known (see the Security Considerations section in this document), and |
| 1703 |
any usage must consider how these attacks can be thwarted or |
| 1704 |
mitigated. |
| 1705 |
|
| 1706 |
Finally, a usage must consider whether its usage of STUN is an |
| 1707 |
example of the Unilateral Self-Address Fixing approach to NAT |
| 1708 |
traversal, and if so, address the questions raised in <a href="./rfc3424">RFC 3424</a> |
| 1709 |
[<a href="./rfc3424" title=""IAB Considerations for UNilateral Self-Address Fixing (UNSAF) Across Network Address Translation"">RFC3424</a>]. |
| 1710 |
|
| 1711 |
<span class="h2"><a class="selflink" id="section-15" href="#section-15">15</a>. STUN Attributes</span> |
| 1712 |
|
| 1713 |
After the STUN header are zero or more attributes. Each attribute |
| 1714 |
MUST be TLV encoded, with a 16-bit type, 16-bit length, and value. |
| 1715 |
Each STUN attribute MUST end on a 32-bit boundary. As mentioned |
| 1716 |
above, all fields in an attribute are transmitted most significant |
| 1717 |
bit first. |
| 1718 |
|
| 1719 |
0 1 2 3 |
| 1720 |
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 1721 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 1722 |
| Type | Length | |
| 1723 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 1724 |
| Value (variable) .... |
| 1725 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 1726 |
|
| 1727 |
Figure 4: Format of STUN Attributes |
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
<span class="grey">Rosenberg, et al. Standards Track [Page 31]</span></pre> |
| 1733 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-32" ></span> |
| 1734 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1735 |
|
| 1736 |
|
| 1737 |
The value in the length field MUST contain the length of the Value |
| 1738 |
part of the attribute, prior to padding, measured in bytes. Since |
| 1739 |
STUN aligns attributes on 32-bit boundaries, attributes whose content |
| 1740 |
is not a multiple of 4 bytes are padded with 1, 2, or 3 bytes of |
| 1741 |
padding so that its value contains a multiple of 4 bytes. The |
| 1742 |
padding bits are ignored, and may be any value. |
| 1743 |
|
| 1744 |
Any attribute type MAY appear more than once in a STUN message. |
| 1745 |
Unless specified otherwise, the order of appearance is significant: |
| 1746 |
only the first occurrence needs to be processed by a receiver, and |
| 1747 |
any duplicates MAY be ignored by a receiver. |
| 1748 |
|
| 1749 |
To allow future revisions of this specification to add new attributes |
| 1750 |
if needed, the attribute space is divided into two ranges. |
| 1751 |
Attributes with type values between 0x0000 and 0x7FFF are |
| 1752 |
comprehension-required attributes, which means that the STUN agent |
| 1753 |
cannot successfully process the message unless it understands the |
| 1754 |
attribute. Attributes with type values between 0x8000 and 0xFFFF are |
| 1755 |
comprehension-optional attributes, which means that those attributes |
| 1756 |
can be ignored by the STUN agent if it does not understand them. |
| 1757 |
|
| 1758 |
The set of STUN attribute types is maintained by IANA. The initial |
| 1759 |
set defined by this specification is found in <a href="#section-18.2">Section 18.2</a>. |
| 1760 |
|
| 1761 |
The rest of this section describes the format of the various |
| 1762 |
attributes defined in this specification. |
| 1763 |
|
| 1764 |
<span class="h3"><a class="selflink" id="section-15.1" href="#section-15.1">15.1</a>. MAPPED-ADDRESS</span> |
| 1765 |
|
| 1766 |
The MAPPED-ADDRESS attribute indicates a reflexive transport address |
| 1767 |
of the client. It consists of an 8-bit address family and a 16-bit |
| 1768 |
port, followed by a fixed-length value representing the IP address. |
| 1769 |
If the address family is IPv4, the address MUST be 32 bits. If the |
| 1770 |
address family is IPv6, the address MUST be 128 bits. All fields |
| 1771 |
must be in network byte order. |
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
|
| 1776 |
|
| 1777 |
|
| 1778 |
|
| 1779 |
|
| 1780 |
|
| 1781 |
|
| 1782 |
|
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
|
| 1787 |
|
| 1788 |
<span class="grey">Rosenberg, et al. Standards Track [Page 32]</span></pre> |
| 1789 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-33" ></span> |
| 1790 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1791 |
|
| 1792 |
|
| 1793 |
The format of the MAPPED-ADDRESS attribute is: |
| 1794 |
|
| 1795 |
0 1 2 3 |
| 1796 |
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 1797 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 1798 |
|0 0 0 0 0 0 0 0| Family | Port | |
| 1799 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 1800 |
| | |
| 1801 |
| Address (32 bits or 128 bits) | |
| 1802 |
| | |
| 1803 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 1804 |
|
| 1805 |
Figure 5: Format of MAPPED-ADDRESS Attribute |
| 1806 |
|
| 1807 |
The address family can take on the following values: |
| 1808 |
|
| 1809 |
0x01:IPv4 |
| 1810 |
0x02:IPv6 |
| 1811 |
|
| 1812 |
The first 8 bits of the MAPPED-ADDRESS MUST be set to 0 and MUST be |
| 1813 |
ignored by receivers. These bits are present for aligning parameters |
| 1814 |
on natural 32-bit boundaries. |
| 1815 |
|
| 1816 |
This attribute is used only by servers for achieving backwards |
| 1817 |
compatibility with <a href="./rfc3489">RFC 3489</a> [<a href="./rfc3489" title=""STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)"">RFC3489</a>] clients. |
| 1818 |
|
| 1819 |
<span class="h3"><a class="selflink" id="section-15.2" href="#section-15.2">15.2</a>. XOR-MAPPED-ADDRESS</span> |
| 1820 |
|
| 1821 |
The XOR-MAPPED-ADDRESS attribute is identical to the MAPPED-ADDRESS |
| 1822 |
attribute, except that the reflexive transport address is obfuscated |
| 1823 |
through the XOR function. |
| 1824 |
|
| 1825 |
The format of the XOR-MAPPED-ADDRESS is: |
| 1826 |
|
| 1827 |
0 1 2 3 |
| 1828 |
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 1829 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 1830 |
|x x x x x x x x| Family | X-Port | |
| 1831 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 1832 |
| X-Address (Variable) |
| 1833 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 1834 |
|
| 1835 |
Figure 6: Format of XOR-MAPPED-ADDRESS Attribute |
| 1836 |
|
| 1837 |
The Family represents the IP address family, and is encoded |
| 1838 |
identically to the Family in MAPPED-ADDRESS. |
| 1839 |
|
| 1840 |
|
| 1841 |
|
| 1842 |
|
| 1843 |
|
| 1844 |
<span class="grey">Rosenberg, et al. Standards Track [Page 33]</span></pre> |
| 1845 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-34" ></span> |
| 1846 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1847 |
|
| 1848 |
|
| 1849 |
X-Port is computed by taking the mapped port in host byte order, |
| 1850 |
XOR'ing it with the most significant 16 bits of the magic cookie, and |
| 1851 |
then the converting the result to network byte order. If the IP |
| 1852 |
address family is IPv4, X-Address is computed by taking the mapped IP |
| 1853 |
address in host byte order, XOR'ing it with the magic cookie, and |
| 1854 |
converting the result to network byte order. If the IP address |
| 1855 |
family is IPv6, X-Address is computed by taking the mapped IP address |
| 1856 |
in host byte order, XOR'ing it with the concatenation of the magic |
| 1857 |
cookie and the 96-bit transaction ID, and converting the result to |
| 1858 |
network byte order. |
| 1859 |
|
| 1860 |
The rules for encoding and processing the first 8 bits of the |
| 1861 |
attribute's value, the rules for handling multiple occurrences of the |
| 1862 |
attribute, and the rules for processing address families are the same |
| 1863 |
as for MAPPED-ADDRESS. |
| 1864 |
|
| 1865 |
Note: XOR-MAPPED-ADDRESS and MAPPED-ADDRESS differ only in their |
| 1866 |
encoding of the transport address. The former encodes the transport |
| 1867 |
address by exclusive-or'ing it with the magic cookie. The latter |
| 1868 |
encodes it directly in binary. <a href="./rfc3489">RFC 3489</a> originally specified only |
| 1869 |
MAPPED-ADDRESS. However, deployment experience found that some NATs |
| 1870 |
rewrite the 32-bit binary payloads containing the NAT's public IP |
| 1871 |
address, such as STUN's MAPPED-ADDRESS attribute, in the well-meaning |
| 1872 |
but misguided attempt at providing a generic ALG function. Such |
| 1873 |
behavior interferes with the operation of STUN and also causes |
| 1874 |
failure of STUN's message-integrity checking. |
| 1875 |
|
| 1876 |
<span class="h3"><a class="selflink" id="section-15.3" href="#section-15.3">15.3</a>. USERNAME</span> |
| 1877 |
|
| 1878 |
The USERNAME attribute is used for message integrity. It identifies |
| 1879 |
the username and password combination used in the message-integrity |
| 1880 |
check. |
| 1881 |
|
| 1882 |
The value of USERNAME is a variable-length value. It MUST contain a |
| 1883 |
UTF-8 [<a href="./rfc3629" title=""UTF-8, a transformation format of ISO 10646"">RFC3629</a>] encoded sequence of less than 513 bytes, and MUST |
| 1884 |
have been processed using SASLprep [<a href="./rfc4013" title=""SASLprep: Stringprep Profile for User Names and Passwords"">RFC4013</a>]. |
| 1885 |
|
| 1886 |
<span class="h3"><a class="selflink" id="section-15.4" href="#section-15.4">15.4</a>. MESSAGE-INTEGRITY</span> |
| 1887 |
|
| 1888 |
The MESSAGE-INTEGRITY attribute contains an HMAC-SHA1 [<a href="./rfc2104" title=""HMAC: Keyed-Hashing for Message Authentication"">RFC2104</a>] of |
| 1889 |
the STUN message. The MESSAGE-INTEGRITY attribute can be present in |
| 1890 |
any STUN message type. Since it uses the SHA1 hash, the HMAC will be |
| 1891 |
20 bytes. The text used as input to HMAC is the STUN message, |
| 1892 |
including the header, up to and including the attribute preceding the |
| 1893 |
MESSAGE-INTEGRITY attribute. With the exception of the FINGERPRINT |
| 1894 |
attribute, which appears after MESSAGE-INTEGRITY, agents MUST ignore |
| 1895 |
all other attributes that follow MESSAGE-INTEGRITY. |
| 1896 |
|
| 1897 |
|
| 1898 |
|
| 1899 |
|
| 1900 |
<span class="grey">Rosenberg, et al. Standards Track [Page 34]</span></pre> |
| 1901 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-35" ></span> |
| 1902 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1903 |
|
| 1904 |
|
| 1905 |
The key for the HMAC depends on whether long-term or short-term |
| 1906 |
credentials are in use. For long-term credentials, the key is 16 |
| 1907 |
bytes: |
| 1908 |
|
| 1909 |
key = MD5(username ":" realm ":" SASLprep(password)) |
| 1910 |
|
| 1911 |
That is, the 16-byte key is formed by taking the MD5 hash of the |
| 1912 |
result of concatenating the following five fields: (1) the username, |
| 1913 |
with any quotes and trailing nulls removed, as taken from the |
| 1914 |
USERNAME attribute (in which case SASLprep has already been applied); |
| 1915 |
(2) a single colon; (3) the realm, with any quotes and trailing nulls |
| 1916 |
removed; (4) a single colon; and (5) the password, with any trailing |
| 1917 |
nulls removed and after processing using SASLprep. For example, if |
| 1918 |
the username was 'user', the realm was 'realm', and the password was |
| 1919 |
'pass', then the 16-byte HMAC key would be the result of performing |
| 1920 |
an MD5 hash on the string 'user:realm:pass', the resulting hash being |
| 1921 |
0x8493fbc53ba582fb4c044c456bdc40eb. |
| 1922 |
|
| 1923 |
For short-term credentials: |
| 1924 |
|
| 1925 |
key = SASLprep(password) |
| 1926 |
|
| 1927 |
where MD5 is defined in <a href="./rfc1321">RFC 1321</a> [<a href="./rfc1321" title=""The MD5 Message-Digest Algorithm"">RFC1321</a>] and SASLprep() is defined |
| 1928 |
in <a href="./rfc4013">RFC 4013</a> [<a href="./rfc4013" title=""SASLprep: Stringprep Profile for User Names and Passwords"">RFC4013</a>]. |
| 1929 |
|
| 1930 |
The structure of the key when used with long-term credentials |
| 1931 |
facilitates deployment in systems that also utilize SIP. Typically, |
| 1932 |
SIP systems utilizing SIP's digest authentication mechanism do not |
| 1933 |
actually store the password in the database. Rather, they store a |
| 1934 |
value called H(A1), which is equal to the key defined above. |
| 1935 |
|
| 1936 |
Based on the rules above, the hash used to construct MESSAGE- |
| 1937 |
INTEGRITY includes the length field from the STUN message header. |
| 1938 |
Prior to performing the hash, the MESSAGE-INTEGRITY attribute MUST be |
| 1939 |
inserted into the message (with dummy content). The length MUST then |
| 1940 |
be set to point to the length of the message up to, and including, |
| 1941 |
the MESSAGE-INTEGRITY attribute itself, but excluding any attributes |
| 1942 |
after it. Once the computation is performed, the value of the |
| 1943 |
MESSAGE-INTEGRITY attribute can be filled in, and the value of the |
| 1944 |
length in the STUN header can be set to its correct value -- the |
| 1945 |
length of the entire message. Similarly, when validating the |
| 1946 |
MESSAGE-INTEGRITY, the length field should be adjusted to point to |
| 1947 |
the end of the MESSAGE-INTEGRITY attribute prior to calculating the |
| 1948 |
HMAC. Such adjustment is necessary when attributes, such as |
| 1949 |
FINGERPRINT, appear after MESSAGE-INTEGRITY. |
| 1950 |
|
| 1951 |
|
| 1952 |
|
| 1953 |
|
| 1954 |
|
| 1955 |
|
| 1956 |
<span class="grey">Rosenberg, et al. Standards Track [Page 35]</span></pre> |
| 1957 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-36" ></span> |
| 1958 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 1959 |
|
| 1960 |
|
| 1961 |
<span class="h3"><a class="selflink" id="section-15.5" href="#section-15.5">15.5</a>. FINGERPRINT</span> |
| 1962 |
|
| 1963 |
The FINGERPRINT attribute MAY be present in all STUN messages. The |
| 1964 |
value of the attribute is computed as the CRC-32 of the STUN message |
| 1965 |
up to (but excluding) the FINGERPRINT attribute itself, XOR'ed with |
| 1966 |
the 32-bit value 0x5354554e (the XOR helps in cases where an |
| 1967 |
application packet is also using CRC-32 in it). The 32-bit CRC is |
| 1968 |
the one defined in ITU V.42 [<a href="#ref-ITU.V42.2002" title=""Error- correcting Procedures for DCEs Using Asynchronous- to-Synchronous Conversion"">ITU.V42.2002</a>], which has a generator |
| 1969 |
polynomial of x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1. |
| 1970 |
When present, the FINGERPRINT attribute MUST be the last attribute in |
| 1971 |
the message, and thus will appear after MESSAGE-INTEGRITY. |
| 1972 |
|
| 1973 |
The FINGERPRINT attribute can aid in distinguishing STUN packets from |
| 1974 |
packets of other protocols. See <a href="#section-8">Section 8</a>. |
| 1975 |
|
| 1976 |
As with MESSAGE-INTEGRITY, the CRC used in the FINGERPRINT attribute |
| 1977 |
covers the length field from the STUN message header. Therefore, |
| 1978 |
this value must be correct and include the CRC attribute as part of |
| 1979 |
the message length, prior to computation of the CRC. When using the |
| 1980 |
FINGERPRINT attribute in a message, the attribute is first placed |
| 1981 |
into the message with a dummy value, then the CRC is computed, and |
| 1982 |
then the value of the attribute is updated. If the MESSAGE-INTEGRITY |
| 1983 |
attribute is also present, then it must be present with the correct |
| 1984 |
message-integrity value before the CRC is computed, since the CRC is |
| 1985 |
done over the value of the MESSAGE-INTEGRITY attribute as well. |
| 1986 |
|
| 1987 |
<span class="h3"><a class="selflink" id="section-15.6" href="#section-15.6">15.6</a>. ERROR-CODE</span> |
| 1988 |
|
| 1989 |
The ERROR-CODE attribute is used in error response messages. It |
| 1990 |
contains a numeric error code value in the range of 300 to 699 plus a |
| 1991 |
textual reason phrase encoded in UTF-8 [<a href="./rfc3629" title=""UTF-8, a transformation format of ISO 10646"">RFC3629</a>], and is consistent |
| 1992 |
in its code assignments and semantics with SIP [<a href="./rfc3261" title=""SIP: Session Initiation Protocol"">RFC3261</a>] and HTTP |
| 1993 |
[<a href="./rfc2616" title=""Hypertext Transfer Protocol -- HTTP/1.1"">RFC2616</a>]. The reason phrase is meant for user consumption, and can |
| 1994 |
be anything appropriate for the error code. Recommended reason |
| 1995 |
phrases for the defined error codes are included in the IANA registry |
| 1996 |
for error codes. The reason phrase MUST be a UTF-8 [<a href="./rfc3629" title=""UTF-8, a transformation format of ISO 10646"">RFC3629</a>] encoded |
| 1997 |
sequence of less than 128 characters (which can be as long as 763 |
| 1998 |
bytes). |
| 1999 |
|
| 2000 |
0 1 2 3 |
| 2001 |
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 2002 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 2003 |
| Reserved, should be 0 |Class| Number | |
| 2004 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 2005 |
| Reason Phrase (variable) .. |
| 2006 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 2007 |
|
| 2008 |
Figure 7: ERROR-CODE Attribute |
| 2009 |
|
| 2010 |
|
| 2011 |
|
| 2012 |
<span class="grey">Rosenberg, et al. Standards Track [Page 36]</span></pre> |
| 2013 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-37" ></span> |
| 2014 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2015 |
|
| 2016 |
|
| 2017 |
To facilitate processing, the class of the error code (the hundreds |
| 2018 |
digit) is encoded separately from the rest of the code, as shown in |
| 2019 |
Figure 7. |
| 2020 |
|
| 2021 |
The Reserved bits SHOULD be 0, and are for alignment on 32-bit |
| 2022 |
boundaries. Receivers MUST ignore these bits. The Class represents |
| 2023 |
the hundreds digit of the error code. The value MUST be between 3 |
| 2024 |
and 6. The Number represents the error code modulo 100, and its |
| 2025 |
value MUST be between 0 and 99. |
| 2026 |
|
| 2027 |
The following error codes, along with their recommended reason |
| 2028 |
phrases, are defined: |
| 2029 |
|
| 2030 |
300 Try Alternate: The client should contact an alternate server for |
| 2031 |
this request. This error response MUST only be sent if the |
| 2032 |
request included a USERNAME attribute and a valid MESSAGE- |
| 2033 |
INTEGRITY attribute; otherwise, it MUST NOT be sent and error |
| 2034 |
code 400 (Bad Request) is suggested. This error response MUST |
| 2035 |
be protected with the MESSAGE-INTEGRITY attribute, and receivers |
| 2036 |
MUST validate the MESSAGE-INTEGRITY of this response before |
| 2037 |
redirecting themselves to an alternate server. |
| 2038 |
|
| 2039 |
Note: Failure to generate and validate message integrity |
| 2040 |
for a 300 response allows an on-path attacker to falsify a |
| 2041 |
300 response thus causing subsequent STUN messages to be |
| 2042 |
sent to a victim. |
| 2043 |
|
| 2044 |
400 Bad Request: The request was malformed. The client SHOULD NOT |
| 2045 |
retry the request without modification from the previous |
| 2046 |
attempt. The server may not be able to generate a valid |
| 2047 |
MESSAGE-INTEGRITY for this error, so the client MUST NOT expect |
| 2048 |
a valid MESSAGE-INTEGRITY attribute on this response. |
| 2049 |
|
| 2050 |
401 Unauthorized: The request did not contain the correct |
| 2051 |
credentials to proceed. The client should retry the request |
| 2052 |
with proper credentials. |
| 2053 |
|
| 2054 |
420 Unknown Attribute: The server received a STUN packet containing |
| 2055 |
a comprehension-required attribute that it did not understand. |
| 2056 |
The server MUST put this unknown attribute in the UNKNOWN- |
| 2057 |
ATTRIBUTE attribute of its error response. |
| 2058 |
|
| 2059 |
438 Stale Nonce: The NONCE used by the client was no longer valid. |
| 2060 |
The client should retry, using the NONCE provided in the |
| 2061 |
response. |
| 2062 |
|
| 2063 |
500 Server Error: The server has suffered a temporary error. The |
| 2064 |
client should try again. |
| 2065 |
|
| 2066 |
|
| 2067 |
|
| 2068 |
<span class="grey">Rosenberg, et al. Standards Track [Page 37]</span></pre> |
| 2069 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-38" ></span> |
| 2070 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2071 |
|
| 2072 |
|
| 2073 |
<span class="h3"><a class="selflink" id="section-15.7" href="#section-15.7">15.7</a>. REALM</span> |
| 2074 |
|
| 2075 |
The REALM attribute may be present in requests and responses. It |
| 2076 |
contains text that meets the grammar for "realm-value" as described |
| 2077 |
in <a href="./rfc3261">RFC 3261</a> [<a href="./rfc3261" title=""SIP: Session Initiation Protocol"">RFC3261</a>] but without the double quotes and their |
| 2078 |
surrounding whitespace. That is, it is an unquoted realm-value (and |
| 2079 |
is therefore a sequence of qdtext or quoted-pair). It MUST be a |
| 2080 |
UTF-8 [<a href="./rfc3629" title=""UTF-8, a transformation format of ISO 10646"">RFC3629</a>] encoded sequence of less than 128 characters (which |
| 2081 |
can be as long as 763 bytes), and MUST have been processed using |
| 2082 |
SASLprep [<a href="./rfc4013" title=""SASLprep: Stringprep Profile for User Names and Passwords"">RFC4013</a>]. |
| 2083 |
|
| 2084 |
Presence of the REALM attribute in a request indicates that long-term |
| 2085 |
credentials are being used for authentication. Presence in certain |
| 2086 |
error responses indicates that the server wishes the client to use a |
| 2087 |
long-term credential for authentication. |
| 2088 |
|
| 2089 |
<span class="h3"><a class="selflink" id="section-15.8" href="#section-15.8">15.8</a>. NONCE</span> |
| 2090 |
|
| 2091 |
The NONCE attribute may be present in requests and responses. It |
| 2092 |
contains a sequence of qdtext or quoted-pair, which are defined in |
| 2093 |
<a href="./rfc3261">RFC 3261</a> [<a href="./rfc3261" title=""SIP: Session Initiation Protocol"">RFC3261</a>]. Note that this means that the NONCE attribute |
| 2094 |
will not contain actual quote characters. See <a href="./rfc2617">RFC 2617</a> <a href="./rfc2617#section-4.3">[RFC2617], |
| 2095 |
Section 4.3</a>, for guidance on selection of nonce values in a server. |
| 2096 |
|
| 2097 |
It MUST be less than 128 characters (which can be as long as 763 |
| 2098 |
bytes). |
| 2099 |
|
| 2100 |
<span class="h3"><a class="selflink" id="section-15.9" href="#section-15.9">15.9</a>. UNKNOWN-ATTRIBUTES</span> |
| 2101 |
|
| 2102 |
The UNKNOWN-ATTRIBUTES attribute is present only in an error response |
| 2103 |
when the response code in the ERROR-CODE attribute is 420. |
| 2104 |
|
| 2105 |
The attribute contains a list of 16-bit values, each of which |
| 2106 |
represents an attribute type that was not understood by the server. |
| 2107 |
|
| 2108 |
0 1 2 3 |
| 2109 |
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 2110 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 2111 |
| Attribute 1 Type | Attribute 2 Type | |
| 2112 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 2113 |
| Attribute 3 Type | Attribute 4 Type ... |
| 2114 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 2115 |
|
| 2116 |
|
| 2117 |
Figure 8: Format of UNKNOWN-ATTRIBUTES Attribute |
| 2118 |
|
| 2119 |
|
| 2120 |
|
| 2121 |
|
| 2122 |
|
| 2123 |
|
| 2124 |
<span class="grey">Rosenberg, et al. Standards Track [Page 38]</span></pre> |
| 2125 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-39" ></span> |
| 2126 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2127 |
|
| 2128 |
|
| 2129 |
Note: In [<a href="./rfc3489" title=""STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)"">RFC3489</a>], this field was padded to 32 by duplicating the |
| 2130 |
last attribute. In this version of the specification, the normal |
| 2131 |
padding rules for attributes are used instead. |
| 2132 |
|
| 2133 |
<span class="h3"><a class="selflink" id="section-15.10" href="#section-15.10">15.10</a>. SOFTWARE</span> |
| 2134 |
|
| 2135 |
The SOFTWARE attribute contains a textual description of the software |
| 2136 |
being used by the agent sending the message. It is used by clients |
| 2137 |
and servers. Its value SHOULD include manufacturer and version |
| 2138 |
number. The attribute has no impact on operation of the protocol, |
| 2139 |
and serves only as a tool for diagnostic and debugging purposes. The |
| 2140 |
value of SOFTWARE is variable length. It MUST be a UTF-8 [<a href="./rfc3629" title=""UTF-8, a transformation format of ISO 10646"">RFC3629</a>] |
| 2141 |
encoded sequence of less than 128 characters (which can be as long as |
| 2142 |
763 bytes). |
| 2143 |
|
| 2144 |
<span class="h3"><a class="selflink" id="section-15.11" href="#section-15.11">15.11</a>. ALTERNATE-SERVER</span> |
| 2145 |
|
| 2146 |
The alternate server represents an alternate transport address |
| 2147 |
identifying a different STUN server that the STUN client should try. |
| 2148 |
|
| 2149 |
It is encoded in the same way as MAPPED-ADDRESS, and thus refers to a |
| 2150 |
single server by IP address. The IP address family MUST be identical |
| 2151 |
to that of the source IP address of the request. |
| 2152 |
|
| 2153 |
<span class="h2"><a class="selflink" id="section-16" href="#section-16">16</a>. Security Considerations</span> |
| 2154 |
|
| 2155 |
<span class="h3"><a class="selflink" id="section-16.1" href="#section-16.1">16.1</a>. Attacks against the Protocol</span> |
| 2156 |
|
| 2157 |
<span class="h4"><a class="selflink" id="section-16.1.1" href="#section-16.1.1">16.1.1</a>. Outside Attacks</span> |
| 2158 |
|
| 2159 |
An attacker can try to modify STUN messages in transit, in order to |
| 2160 |
cause a failure in STUN operation. These attacks are detected for |
| 2161 |
both requests and responses through the message-integrity mechanism, |
| 2162 |
using either a short-term or long-term credential. Of course, once |
| 2163 |
detected, the manipulated packets will be dropped, causing the STUN |
| 2164 |
transaction to effectively fail. This attack is possible only by an |
| 2165 |
on-path attacker. |
| 2166 |
|
| 2167 |
An attacker that can observe, but not modify, STUN messages in- |
| 2168 |
transit (for example, an attacker present on a shared access medium, |
| 2169 |
such as Wi-Fi), can see a STUN request, and then immediately send a |
| 2170 |
STUN response, typically an error response, in order to disrupt STUN |
| 2171 |
processing. This attack is also prevented for messages that utilize |
| 2172 |
MESSAGE-INTEGRITY. However, some error responses, those related to |
| 2173 |
authentication in particular, cannot be protected by MESSAGE- |
| 2174 |
INTEGRITY. When STUN itself is run over a secure transport protocol |
| 2175 |
(e.g., TLS), these attacks are completely mitigated. |
| 2176 |
|
| 2177 |
|
| 2178 |
|
| 2179 |
|
| 2180 |
<span class="grey">Rosenberg, et al. Standards Track [Page 39]</span></pre> |
| 2181 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-40" ></span> |
| 2182 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2183 |
|
| 2184 |
|
| 2185 |
Depending on the STUN usage, these attacks may be of minimal |
| 2186 |
consequence and thus do not require message integrity to mitigate. |
| 2187 |
For example, when STUN is used to a basic STUN server to discover a |
| 2188 |
server reflexive candidate for usage with ICE, authentication and |
| 2189 |
message integrity are not required since these attacks are detected |
| 2190 |
during the connectivity check phase. The connectivity checks |
| 2191 |
themselves, however, require protection for proper operation of ICE |
| 2192 |
overall. As described in <a href="#section-14">Section 14</a>, STUN usages describe when |
| 2193 |
authentication and message integrity are needed. |
| 2194 |
|
| 2195 |
Since STUN uses the HMAC of a shared secret for authentication and |
| 2196 |
integrity protection, it is subject to offline dictionary attacks. |
| 2197 |
When authentication is utilized, it SHOULD be with a strong password |
| 2198 |
that is not readily subject to offline dictionary attacks. |
| 2199 |
Protection of the channel itself, using TLS, mitigates these attacks. |
| 2200 |
However, STUN is most often run over UDP and in those cases, strong |
| 2201 |
passwords are the only way to protect against these attacks. |
| 2202 |
|
| 2203 |
<span class="h4"><a class="selflink" id="section-16.1.2" href="#section-16.1.2">16.1.2</a>. Inside Attacks</span> |
| 2204 |
|
| 2205 |
A rogue client may try to launch a DoS attack against a server by |
| 2206 |
sending it a large number of STUN requests. Fortunately, STUN |
| 2207 |
requests can be processed statelessly by a server, making such |
| 2208 |
attacks hard to launch. |
| 2209 |
|
| 2210 |
A rogue client may use a STUN server as a reflector, sending it |
| 2211 |
requests with a falsified source IP address and port. In such a |
| 2212 |
case, the response would be delivered to that source IP and port. |
| 2213 |
There is no amplification of the number of packets with this attack |
| 2214 |
(the STUN server sends one packet for each packet sent by the |
| 2215 |
client), though there is a small increase in the amount of data, |
| 2216 |
since STUN responses are typically larger than requests. This attack |
| 2217 |
is mitigated by ingress source address filtering. |
| 2218 |
|
| 2219 |
Revealing the specific software version of the agent through the |
| 2220 |
SOFTWARE attribute might allow them to become more vulnerable to |
| 2221 |
attacks against software that is known to contain security holes. |
| 2222 |
Implementers SHOULD make usage of the SOFTWARE attribute a |
| 2223 |
configurable option. |
| 2224 |
|
| 2225 |
<span class="h3"><a class="selflink" id="section-16.2" href="#section-16.2">16.2</a>. Attacks Affecting the Usage</span> |
| 2226 |
|
| 2227 |
This section lists attacks that might be launched against a usage of |
| 2228 |
STUN. Each STUN usage must consider whether these attacks are |
| 2229 |
applicable to it, and if so, discuss counter-measures. |
| 2230 |
|
| 2231 |
Most of the attacks in this section revolve around an attacker |
| 2232 |
modifying the reflexive address learned by a STUN client through a |
| 2233 |
|
| 2234 |
|
| 2235 |
|
| 2236 |
<span class="grey">Rosenberg, et al. Standards Track [Page 40]</span></pre> |
| 2237 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-41" ></span> |
| 2238 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2239 |
|
| 2240 |
|
| 2241 |
Binding request/response transaction. Since the usage of the |
| 2242 |
reflexive address is a function of the usage, the applicability and |
| 2243 |
remediation of these attacks are usage-specific. In common |
| 2244 |
situations, modification of the reflexive address by an on-path |
| 2245 |
attacker is easy to do. Consider, for example, the common situation |
| 2246 |
where STUN is run directly over UDP. In this case, an on-path |
| 2247 |
attacker can modify the source IP address of the Binding request |
| 2248 |
before it arrives at the STUN server. The STUN server will then |
| 2249 |
return this IP address in the XOR-MAPPED-ADDRESS attribute to the |
| 2250 |
client, and send the response back to that (falsified) IP address and |
| 2251 |
port. If the attacker can also intercept this response, it can |
| 2252 |
direct it back towards the client. Protecting against this attack by |
| 2253 |
using a message-integrity check is impossible, since a message- |
| 2254 |
integrity value cannot cover the source IP address, since the |
| 2255 |
intervening NAT must be able to modify this value. Instead, one |
| 2256 |
solution to preventing the attacks listed below is for the client to |
| 2257 |
verify the reflexive address learned, as is done in ICE [<a href="#ref-MMUSIC-ICE" title=""Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols"">MMUSIC-ICE</a>]. |
| 2258 |
Other usages may use other means to prevent these attacks. |
| 2259 |
|
| 2260 |
<span class="h4"><a class="selflink" id="section-16.2.1" href="#section-16.2.1">16.2.1</a>. Attack I: Distributed DoS (DDoS) against a Target</span> |
| 2261 |
|
| 2262 |
In this attack, the attacker provides one or more clients with the |
| 2263 |
same faked reflexive address that points to the intended target. |
| 2264 |
This will trick the STUN clients into thinking that their reflexive |
| 2265 |
addresses are equal to that of the target. If the clients hand out |
| 2266 |
that reflexive address in order to receive traffic on it (for |
| 2267 |
example, in SIP messages), the traffic will instead be sent to the |
| 2268 |
target. This attack can provide substantial amplification, |
| 2269 |
especially when used with clients that are using STUN to enable |
| 2270 |
multimedia applications. However, it can only be launched against |
| 2271 |
targets for which packets from the STUN server to the target pass |
| 2272 |
through the attacker, limiting the cases in which it is possible. |
| 2273 |
|
| 2274 |
<span class="h4"><a class="selflink" id="section-16.2.2" href="#section-16.2.2">16.2.2</a>. Attack II: Silencing a Client</span> |
| 2275 |
|
| 2276 |
In this attack, the attacker provides a STUN client with a faked |
| 2277 |
reflexive address. The reflexive address it provides is a transport |
| 2278 |
address that routes to nowhere. As a result, the client won't |
| 2279 |
receive any of the packets it expects to receive when it hands out |
| 2280 |
the reflexive address. This exploitation is not very interesting for |
| 2281 |
the attacker. It impacts a single client, which is frequently not |
| 2282 |
the desired target. Moreover, any attacker that can mount the attack |
| 2283 |
could also deny service to the client by other means, such as |
| 2284 |
preventing the client from receiving any response from the STUN |
| 2285 |
server, or even a DHCP server. As with the attack in <a href="#section-16.2.1">Section 16.2.1</a>, |
| 2286 |
this attack is only possible when the attacker is on path for packets |
| 2287 |
sent from the STUN server towards this unused IP address. |
| 2288 |
|
| 2289 |
|
| 2290 |
|
| 2291 |
|
| 2292 |
<span class="grey">Rosenberg, et al. Standards Track [Page 41]</span></pre> |
| 2293 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-42" ></span> |
| 2294 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2295 |
|
| 2296 |
|
| 2297 |
<span class="h4"><a class="selflink" id="section-16.2.3" href="#section-16.2.3">16.2.3</a>. Attack III: Assuming the Identity of a Client</span> |
| 2298 |
|
| 2299 |
This attack is similar to attack II. However, the faked reflexive |
| 2300 |
address points to the attacker itself. This allows the attacker to |
| 2301 |
receive traffic that was destined for the client. |
| 2302 |
|
| 2303 |
<span class="h4"><a class="selflink" id="section-16.2.4" href="#section-16.2.4">16.2.4</a>. Attack IV: Eavesdropping</span> |
| 2304 |
|
| 2305 |
In this attack, the attacker forces the client to use a reflexive |
| 2306 |
address that routes to itself. It then forwards any packets it |
| 2307 |
receives to the client. This attack would allow the attacker to |
| 2308 |
observe all packets sent to the client. However, in order to launch |
| 2309 |
the attack, the attacker must have already been able to observe |
| 2310 |
packets from the client to the STUN server. In most cases (such as |
| 2311 |
when the attack is launched from an access network), this means that |
| 2312 |
the attacker could already observe packets sent to the client. This |
| 2313 |
attack is, as a result, only useful for observing traffic by |
| 2314 |
attackers on the path from the client to the STUN server, but not |
| 2315 |
generally on the path of packets being routed towards the client. |
| 2316 |
|
| 2317 |
<span class="h3"><a class="selflink" id="section-16.3" href="#section-16.3">16.3</a>. Hash Agility Plan</span> |
| 2318 |
|
| 2319 |
This specification uses HMAC-SHA-1 for computation of the message |
| 2320 |
integrity. If, at a later time, HMAC-SHA-1 is found to be |
| 2321 |
compromised, the following is the remedy that will be applied. |
| 2322 |
|
| 2323 |
We will define a STUN extension that introduces a new message- |
| 2324 |
integrity attribute, computed using a new hash. Clients would be |
| 2325 |
required to include both the new and old message-integrity attributes |
| 2326 |
in their requests or indications. A new server will utilize the new |
| 2327 |
message-integrity attribute, and an old one, the old. After a |
| 2328 |
transition period where mixed implementations are in deployment, the |
| 2329 |
old message-integrity attribute will be deprecated by another |
| 2330 |
specification, and clients will cease including it in requests. |
| 2331 |
|
| 2332 |
It is also important to note that the HMAC is done using a key that |
| 2333 |
is itself computed using an MD5 of the user's password. The choice |
| 2334 |
of the MD5 hash was made because of the existence of legacy databases |
| 2335 |
that store passwords in that form. If future work finds that an HMAC |
| 2336 |
of an MD5 input is not secure, and a different hash is needed, it can |
| 2337 |
also be changed using this plan. However, this would require |
| 2338 |
administrators to repopulate their databases. |
| 2339 |
|
| 2340 |
<span class="h2"><a class="selflink" id="section-17" href="#section-17">17</a>. IAB Considerations</span> |
| 2341 |
|
| 2342 |
The IAB has studied the problem of Unilateral Self-Address Fixing |
| 2343 |
(UNSAF), which is the general process by which a client attempts to |
| 2344 |
determine its address in another realm on the other side of a NAT |
| 2345 |
|
| 2346 |
|
| 2347 |
|
| 2348 |
<span class="grey">Rosenberg, et al. Standards Track [Page 42]</span></pre> |
| 2349 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-43" ></span> |
| 2350 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2351 |
|
| 2352 |
|
| 2353 |
through a collaborative protocol reflection mechanism (<a href="./rfc3424">RFC3424</a> |
| 2354 |
[<a href="./rfc3424" title=""IAB Considerations for UNilateral Self-Address Fixing (UNSAF) Across Network Address Translation"">RFC3424</a>]). STUN can be used to perform this function using a |
| 2355 |
Binding request/response transaction if one agent is behind a NAT and |
| 2356 |
the other is on the public side of the NAT. |
| 2357 |
|
| 2358 |
The IAB has mandated that protocols developed for this purpose |
| 2359 |
document a specific set of considerations. Because some STUN usages |
| 2360 |
provide UNSAF functions (such as ICE [<a href="#ref-MMUSIC-ICE" title=""Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols"">MMUSIC-ICE</a>] ), and others do |
| 2361 |
not (such as SIP Outbound [<a href="#ref-SIP-OUTBOUND" title=""Managing Client Initiated Connections in the Session Initiation Protocol (SIP)"">SIP-OUTBOUND</a>]), answers to these |
| 2362 |
considerations need to be addressed by the usages themselves. |
| 2363 |
|
| 2364 |
<span class="h2"><a class="selflink" id="section-18" href="#section-18">18</a>. IANA Considerations</span> |
| 2365 |
|
| 2366 |
IANA has created three new registries: a "STUN Methods Registry", a |
| 2367 |
"STUN Attributes Registry", and a "STUN Error Codes Registry". IANA |
| 2368 |
has also changed the name of the assigned IANA port for STUN from |
| 2369 |
"nat-stun-port" to "stun". |
| 2370 |
|
| 2371 |
<span class="h3"><a class="selflink" id="section-18.1" href="#section-18.1">18.1</a>. STUN Methods Registry</span> |
| 2372 |
|
| 2373 |
A STUN method is a hex number in the range 0x000 - 0xFFF. The |
| 2374 |
encoding of STUN method into a STUN message is described in |
| 2375 |
<a href="#section-6">Section 6</a>. |
| 2376 |
|
| 2377 |
The initial STUN methods are: |
| 2378 |
|
| 2379 |
0x000: (Reserved) |
| 2380 |
0x001: Binding |
| 2381 |
0x002: (Reserved; was SharedSecret) |
| 2382 |
|
| 2383 |
STUN methods in the range 0x000 - 0x7FF are assigned by IETF Review |
| 2384 |
[<a href="./rfc5226" title="">RFC5226</a>]. STUN methods in the range 0x800 - 0xFFF are assigned by |
| 2385 |
Designated Expert [<a href="./rfc5226" title="">RFC5226</a>]. The responsibility of the expert is to |
| 2386 |
verify that the selected codepoint(s) are not in use and that the |
| 2387 |
request is not for an abnormally large number of codepoints. |
| 2388 |
Technical review of the extension itself is outside the scope of the |
| 2389 |
designated expert responsibility. |
| 2390 |
|
| 2391 |
<span class="h3"><a class="selflink" id="section-18.2" href="#section-18.2">18.2</a>. STUN Attribute Registry</span> |
| 2392 |
|
| 2393 |
A STUN Attribute type is a hex number in the range 0x0000 - 0xFFFF. |
| 2394 |
STUN attribute types in the range 0x0000 - 0x7FFF are considered |
| 2395 |
comprehension-required; STUN attribute types in the range 0x8000 - |
| 2396 |
0xFFFF are considered comprehension-optional. A STUN agent handles |
| 2397 |
unknown comprehension-required and comprehension-optional attributes |
| 2398 |
differently. |
| 2399 |
|
| 2400 |
The initial STUN Attributes types are: |
| 2401 |
|
| 2402 |
|
| 2403 |
|
| 2404 |
<span class="grey">Rosenberg, et al. Standards Track [Page 43]</span></pre> |
| 2405 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-44" ></span> |
| 2406 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2407 |
|
| 2408 |
|
| 2409 |
Comprehension-required range (0x0000-0x7FFF): |
| 2410 |
0x0000: (Reserved) |
| 2411 |
0x0001: MAPPED-ADDRESS |
| 2412 |
0x0002: (Reserved; was RESPONSE-ADDRESS) |
| 2413 |
0x0003: (Reserved; was CHANGE-ADDRESS) |
| 2414 |
0x0004: (Reserved; was SOURCE-ADDRESS) |
| 2415 |
0x0005: (Reserved; was CHANGED-ADDRESS) |
| 2416 |
0x0006: USERNAME |
| 2417 |
0x0007: (Reserved; was PASSWORD) |
| 2418 |
0x0008: MESSAGE-INTEGRITY |
| 2419 |
0x0009: ERROR-CODE |
| 2420 |
0x000A: UNKNOWN-ATTRIBUTES |
| 2421 |
0x000B: (Reserved; was REFLECTED-FROM) |
| 2422 |
0x0014: REALM |
| 2423 |
0x0015: NONCE |
| 2424 |
0x0020: XOR-MAPPED-ADDRESS |
| 2425 |
|
| 2426 |
Comprehension-optional range (0x8000-0xFFFF) |
| 2427 |
0x8022: SOFTWARE |
| 2428 |
0x8023: ALTERNATE-SERVER |
| 2429 |
0x8028: FINGERPRINT |
| 2430 |
|
| 2431 |
STUN Attribute types in the first half of the comprehension-required |
| 2432 |
range (0x0000 - 0x3FFF) and in the first half of the comprehension- |
| 2433 |
optional range (0x8000 - 0xBFFF) are assigned by IETF Review |
| 2434 |
[<a href="./rfc5226" title="">RFC5226</a>]. STUN Attribute types in the second half of the |
| 2435 |
comprehension-required range (0x4000 - 0x7FFF) and in the second half |
| 2436 |
of the comprehension-optional range (0xC000 - 0xFFFF) are assigned by |
| 2437 |
Designated Expert [<a href="./rfc5226" title="">RFC5226</a>]. The responsibility of the expert is to |
| 2438 |
verify that the selected codepoint(s) are not in use, and that the |
| 2439 |
request is not for an abnormally large number of codepoints. |
| 2440 |
Technical review of the extension itself is outside the scope of the |
| 2441 |
designated expert responsibility. |
| 2442 |
|
| 2443 |
<span class="h3"><a class="selflink" id="section-18.3" href="#section-18.3">18.3</a>. STUN Error Code Registry</span> |
| 2444 |
|
| 2445 |
A STUN error code is a number in the range 0 - 699. STUN error codes |
| 2446 |
are accompanied by a textual reason phrase in UTF-8 [<a href="./rfc3629" title=""UTF-8, a transformation format of ISO 10646"">RFC3629</a>] that is |
| 2447 |
intended only for human consumption and can be anything appropriate; |
| 2448 |
this document proposes only suggested values. |
| 2449 |
|
| 2450 |
STUN error codes are consistent in codepoint assignments and |
| 2451 |
semantics with SIP [<a href="./rfc3261" title=""SIP: Session Initiation Protocol"">RFC3261</a>] and HTTP [<a href="./rfc2616" title=""Hypertext Transfer Protocol -- HTTP/1.1"">RFC2616</a>]. |
| 2452 |
|
| 2453 |
The initial values in this registry are given in <a href="#section-15.6">Section 15.6</a>. |
| 2454 |
|
| 2455 |
|
| 2456 |
|
| 2457 |
|
| 2458 |
|
| 2459 |
|
| 2460 |
<span class="grey">Rosenberg, et al. Standards Track [Page 44]</span></pre> |
| 2461 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-45" ></span> |
| 2462 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2463 |
|
| 2464 |
|
| 2465 |
New STUN error codes are assigned based on IETF Review [<a href="./rfc5226" title="">RFC5226</a>]. |
| 2466 |
The specification must carefully consider how clients that do not |
| 2467 |
understand this error code will process it before granting the |
| 2468 |
request. See the rules in <a href="#section-7.3.4">Section 7.3.4</a>. |
| 2469 |
|
| 2470 |
<span class="h3"><a class="selflink" id="section-18.4" href="#section-18.4">18.4</a>. STUN UDP and TCP Port Numbers</span> |
| 2471 |
|
| 2472 |
IANA has previously assigned port 3478 for STUN. This port appears |
| 2473 |
in the IANA registry under the moniker "nat-stun-port". In order to |
| 2474 |
align the DNS SRV procedures with the registered protocol service, |
| 2475 |
IANA is requested to change the name of protocol assigned to port |
| 2476 |
3478 from "nat-stun-port" to "stun", and the textual name from |
| 2477 |
"Simple Traversal of UDP Through NAT (STUN)" to "Session Traversal |
| 2478 |
Utilities for NAT", so that the IANA port registry would read: |
| 2479 |
|
| 2480 |
stun 3478/tcp Session Traversal Utilities for NAT (STUN) port |
| 2481 |
stun 3478/udp Session Traversal Utilities for NAT (STUN) port |
| 2482 |
|
| 2483 |
In addition, IANA has assigned port number 5349 for the "stuns" |
| 2484 |
service, defined over TCP and UDP. The UDP port is not currently |
| 2485 |
defined; however, it is reserved for future use. |
| 2486 |
|
| 2487 |
<span class="h2"><a class="selflink" id="section-19" href="#section-19">19</a>. Changes since <a href="./rfc3489">RFC 3489</a></span> |
| 2488 |
|
| 2489 |
This specification obsoletes <a href="./rfc3489">RFC 3489</a> [<a href="./rfc3489" title=""STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)"">RFC3489</a>]. This specification |
| 2490 |
differs from <a href="./rfc3489">RFC 3489</a> in the following ways: |
| 2491 |
|
| 2492 |
o Removed the notion that STUN is a complete NAT traversal solution. |
| 2493 |
STUN is now a tool that can be used to produce a NAT traversal |
| 2494 |
solution. As a consequence, changed the name of the protocol to |
| 2495 |
Session Traversal Utilities for NAT. |
| 2496 |
|
| 2497 |
o Introduced the concept of STUN usages, and described what a usage |
| 2498 |
of STUN must document. |
| 2499 |
|
| 2500 |
o Removed the usage of STUN for NAT type detection and binding |
| 2501 |
lifetime discovery. These techniques have proven overly brittle |
| 2502 |
due to wider variations in the types of NAT devices than described |
| 2503 |
in this document. Removed the RESPONSE-ADDRESS, CHANGED-ADDRESS, |
| 2504 |
CHANGE-REQUEST, SOURCE-ADDRESS, and REFLECTED-FROM attributes. |
| 2505 |
|
| 2506 |
o Added a fixed 32-bit magic cookie and reduced length of |
| 2507 |
transaction ID by 32 bits. The magic cookie begins at the same |
| 2508 |
offset as the original transaction ID. |
| 2509 |
|
| 2510 |
|
| 2511 |
|
| 2512 |
|
| 2513 |
|
| 2514 |
|
| 2515 |
|
| 2516 |
<span class="grey">Rosenberg, et al. Standards Track [Page 45]</span></pre> |
| 2517 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-46" ></span> |
| 2518 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2519 |
|
| 2520 |
|
| 2521 |
o Added the XOR-MAPPED-ADDRESS attribute, which is included in |
| 2522 |
Binding responses if the magic cookie is present in the request. |
| 2523 |
Otherwise, the <a href="./rfc3489">RFC 3489</a> behavior is retained (that is, Binding |
| 2524 |
response includes MAPPED-ADDRESS). See discussion in XOR-MAPPED- |
| 2525 |
ADDRESS regarding this change. |
| 2526 |
|
| 2527 |
o Introduced formal structure into the message type header field, |
| 2528 |
with an explicit pair of bits for indication of request, response, |
| 2529 |
error response, or indication. Consequently, the message type |
| 2530 |
field is split into the class (one of the previous four) and |
| 2531 |
method. |
| 2532 |
|
| 2533 |
o Explicitly point out that the most significant 2 bits of STUN are |
| 2534 |
0b00, allowing easy differentiation with RTP packets when used |
| 2535 |
with ICE. |
| 2536 |
|
| 2537 |
o Added the FINGERPRINT attribute to provide a method of definitely |
| 2538 |
detecting the difference between STUN and another protocol when |
| 2539 |
the two protocols are multiplexed together. |
| 2540 |
|
| 2541 |
o Added support for IPv6. Made it clear that an IPv4 client could |
| 2542 |
get a v6 mapped address, and vice versa. |
| 2543 |
|
| 2544 |
o Added long-term-credential-based authentication. |
| 2545 |
|
| 2546 |
o Added the SOFTWARE, REALM, NONCE, and ALTERNATE-SERVER attributes. |
| 2547 |
|
| 2548 |
o Removed the SharedSecret method, and thus the PASSWORD attribute. |
| 2549 |
This method was almost never implemented and is not needed with |
| 2550 |
current usages. |
| 2551 |
|
| 2552 |
o Removed recommendation to continue listening for STUN responses |
| 2553 |
for 10 seconds in an attempt to recognize an attack. |
| 2554 |
|
| 2555 |
o Changed transaction timers to be more TCP friendly. |
| 2556 |
|
| 2557 |
o Removed the STUN example that centered around the separation of |
| 2558 |
the control and media planes. Instead, provided more information |
| 2559 |
on using STUN with protocols. |
| 2560 |
|
| 2561 |
o Defined a generic padding mechanism that changes the |
| 2562 |
interpretation of the length attribute. This would, in theory, |
| 2563 |
break backwards compatibility. However, the mechanism in <a href="./rfc3489">RFC 3489</a> |
| 2564 |
never worked for the few attributes that weren't aligned naturally |
| 2565 |
on 32-bit boundaries. |
| 2566 |
|
| 2567 |
o REALM, SERVER, reason phrases, and NONCE limited to 127 |
| 2568 |
characters. USERNAME to 513 bytes. |
| 2569 |
|
| 2570 |
|
| 2571 |
|
| 2572 |
<span class="grey">Rosenberg, et al. Standards Track [Page 46]</span></pre> |
| 2573 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-47" ></span> |
| 2574 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2575 |
|
| 2576 |
|
| 2577 |
o Changed the DNS SRV procedures for TCP and TLS. UDP remains the |
| 2578 |
same as before. |
| 2579 |
|
| 2580 |
<span class="h2"><a class="selflink" id="section-20" href="#section-20">20</a>. Contributors</span> |
| 2581 |
|
| 2582 |
Christian Huitema and Joel Weinberger were original co-authors of <a href="./rfc3489">RFC</a> |
| 2583 |
<a href="./rfc3489">3489</a>. |
| 2584 |
|
| 2585 |
<span class="h2"><a class="selflink" id="section-21" href="#section-21">21</a>. Acknowledgements</span> |
| 2586 |
|
| 2587 |
The authors would like to thank Cedric Aoun, Pete Cordell, Cullen |
| 2588 |
Jennings, Bob Penfield, Xavier Marjou, Magnus Westerlund, Miguel |
| 2589 |
Garcia, Bruce Lowekamp, and Chris Sullivan for their comments, and |
| 2590 |
Baruch Sterman and Alan Hawrylyshen for initial implementations. |
| 2591 |
Thanks for Leslie Daigle, Allison Mankin, Eric Rescorla, and Henning |
| 2592 |
Schulzrinne for IESG and IAB input on this work. |
| 2593 |
|
| 2594 |
<span class="h2"><a class="selflink" id="section-22" href="#section-22">22</a>. References</span> |
| 2595 |
|
| 2596 |
<span class="h3"><a class="selflink" id="section-22.1" href="#section-22.1">22.1</a>. Normative References</span> |
| 2597 |
|
| 2598 |
[<a id="ref-ITU.V42.2002">ITU.V42.2002</a>] International Telecommunications Union, "Error- |
| 2599 |
correcting Procedures for DCEs Using Asynchronous- |
| 2600 |
to-Synchronous Conversion", ITU-T Recommendation |
| 2601 |
V.42, March 2002. |
| 2602 |
|
| 2603 |
[<a id="ref-RFC0791">RFC0791</a>] Postel, J., "Internet Protocol", STD 5, <a href="./rfc791">RFC 791</a>, |
| 2604 |
September 1981. |
| 2605 |
|
| 2606 |
[<a id="ref-RFC1122">RFC1122</a>] Braden, R., "Requirements for Internet Hosts - |
| 2607 |
Communication Layers", STD 3, <a href="./rfc1122">RFC 1122</a>, |
| 2608 |
October 1989. |
| 2609 |
|
| 2610 |
[<a id="ref-RFC1321">RFC1321</a>] Rivest, R., "The MD5 Message-Digest Algorithm", |
| 2611 |
<a href="./rfc1321">RFC 1321</a>, April 1992. |
| 2612 |
|
| 2613 |
[<a id="ref-RFC2104">RFC2104</a>] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: |
| 2614 |
Keyed-Hashing for Message Authentication", |
| 2615 |
<a href="./rfc2104">RFC 2104</a>, February 1997. |
| 2616 |
|
| 2617 |
[<a id="ref-RFC2119">RFC2119</a>] Bradner, S., "Key words for use in RFCs to Indicate |
| 2618 |
Requirement Levels", <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a>, March 1997. |
| 2619 |
|
| 2620 |
[<a id="ref-RFC2460">RFC2460</a>] Deering, S. and R. Hinden, "Internet Protocol, |
| 2621 |
Version 6 (IPv6) Specification", <a href="./rfc2460">RFC 2460</a>, |
| 2622 |
December 1998. |
| 2623 |
|
| 2624 |
|
| 2625 |
|
| 2626 |
|
| 2627 |
|
| 2628 |
<span class="grey">Rosenberg, et al. Standards Track [Page 47]</span></pre> |
| 2629 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-48" ></span> |
| 2630 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2631 |
|
| 2632 |
|
| 2633 |
[<a id="ref-RFC2617">RFC2617</a>] Franks, J., Hallam-Baker, P., Hostetler, J., |
| 2634 |
Lawrence, S., Leach, P., Luotonen, A., and L. |
| 2635 |
Stewart, "HTTP Authentication: Basic and Digest |
| 2636 |
Access Authentication", <a href="./rfc2617">RFC 2617</a>, June 1999. |
| 2637 |
|
| 2638 |
[<a id="ref-RFC2782">RFC2782</a>] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS |
| 2639 |
RR for specifying the location of services (DNS |
| 2640 |
SRV)", <a href="./rfc2782">RFC 2782</a>, February 2000. |
| 2641 |
|
| 2642 |
[<a id="ref-RFC2818">RFC2818</a>] Rescorla, E., "HTTP Over TLS", <a href="./rfc2818">RFC 2818</a>, May 2000. |
| 2643 |
|
| 2644 |
[<a id="ref-RFC2988">RFC2988</a>] Paxson, V. and M. Allman, "Computing TCP's |
| 2645 |
Retransmission Timer", <a href="./rfc2988">RFC 2988</a>, November 2000. |
| 2646 |
|
| 2647 |
[<a id="ref-RFC3629">RFC3629</a>] Yergeau, F., "UTF-8, a transformation format of ISO |
| 2648 |
10646", STD 63, <a href="./rfc3629">RFC 3629</a>, November 2003. |
| 2649 |
|
| 2650 |
[<a id="ref-RFC4013">RFC4013</a>] Zeilenga, K., "SASLprep: Stringprep Profile for |
| 2651 |
User Names and Passwords", <a href="./rfc4013">RFC 4013</a>, February 2005. |
| 2652 |
|
| 2653 |
<span class="h3"><a class="selflink" id="section-22.2" href="#section-22.2">22.2</a>. Informative References</span> |
| 2654 |
|
| 2655 |
[<a id="ref-BEHAVE-NAT">BEHAVE-NAT</a>] MacDonald, D. and B. Lowekamp, "NAT Behavior |
| 2656 |
Discovery Using STUN", Work in Progress, July 2008. |
| 2657 |
|
| 2658 |
[<a id="ref-BEHAVE-TURN">BEHAVE-TURN</a>] Rosenberg, J., Mahy, R., and P. Matthews, |
| 2659 |
"Traversal Using Relays around NAT (TURN): Relay |
| 2660 |
Extensions to Session Traversal Utilities for NAT |
| 2661 |
(STUN)", Work in Progress, July 2008. |
| 2662 |
|
| 2663 |
[<a id="ref-KARN87">KARN87</a>] Karn, P. and C. Partridge, "Improving Round-Trip |
| 2664 |
Time Estimates in Reliable Transport Protocols", |
| 2665 |
SIGCOMM 1987, August 1987. |
| 2666 |
|
| 2667 |
[<a id="ref-MMUSIC-ICE">MMUSIC-ICE</a>] Rosenberg, J., "Interactive Connectivity |
| 2668 |
Establishment (ICE): A Protocol for Network Address |
| 2669 |
Translator (NAT) Traversal for Offer/Answer |
| 2670 |
Protocols", Work in Progress, October 2007. |
| 2671 |
|
| 2672 |
[<a id="ref-MMUSIC-ICE-TCP">MMUSIC-ICE-TCP</a>] Rosenberg, J., "TCP Candidates with Interactive |
| 2673 |
Connectivity Establishment (ICE)", Work |
| 2674 |
in Progress, July 2008. |
| 2675 |
|
| 2676 |
[<a id="ref-RFC2616">RFC2616</a>] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., |
| 2677 |
Masinter, L., Leach, P., and T. Berners-Lee, |
| 2678 |
"Hypertext Transfer Protocol -- HTTP/1.1", |
| 2679 |
<a href="./rfc2616">RFC 2616</a>, June 1999. |
| 2680 |
|
| 2681 |
|
| 2682 |
|
| 2683 |
|
| 2684 |
<span class="grey">Rosenberg, et al. Standards Track [Page 48]</span></pre> |
| 2685 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-49" ></span> |
| 2686 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2687 |
|
| 2688 |
|
| 2689 |
[<a id="ref-RFC3261">RFC3261</a>] Rosenberg, J., Schulzrinne, H., Camarillo, G., |
| 2690 |
Johnston, A., Peterson, J., Sparks, R., Handley, |
| 2691 |
M., and E. Schooler, "SIP: Session Initiation |
| 2692 |
Protocol", <a href="./rfc3261">RFC 3261</a>, June 2002. |
| 2693 |
|
| 2694 |
[<a id="ref-RFC3264">RFC3264</a>] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer |
| 2695 |
Model with Session Description Protocol (SDP)", |
| 2696 |
<a href="./rfc3264">RFC 3264</a>, June 2002. |
| 2697 |
|
| 2698 |
[<a id="ref-RFC3424">RFC3424</a>] Daigle, L. and IAB, "IAB Considerations for |
| 2699 |
UNilateral Self-Address Fixing (UNSAF) Across |
| 2700 |
Network Address Translation", <a href="./rfc3424">RFC 3424</a>, |
| 2701 |
November 2002. |
| 2702 |
|
| 2703 |
[<a id="ref-RFC3489">RFC3489</a>] Rosenberg, J., Weinberger, J., Huitema, C., and R. |
| 2704 |
Mahy, "STUN - Simple Traversal of User Datagram |
| 2705 |
Protocol (UDP) Through Network Address Translators |
| 2706 |
(NATs)", <a href="./rfc3489">RFC 3489</a>, March 2003. |
| 2707 |
|
| 2708 |
[<a id="ref-RFC4107">RFC4107</a>] Bellovin, S. and R. Housley, "Guidelines for |
| 2709 |
Cryptographic Key Management", <a href="https://www.rfc-editor.org/bcp/bcp107">BCP 107</a>, <a href="./rfc4107">RFC 4107</a>, |
| 2710 |
June 2005. |
| 2711 |
|
| 2712 |
[<a id="ref-RFC5226">RFC5226</a>] Narten, T. and H. Alvestrand, "Guidelines for |
| 2713 |
Writing an IANA Considerations Section in RFCs", |
| 2714 |
<a href="https://www.rfc-editor.org/bcp/bcp26">BCP 26</a>, <a href="./rfc5226">RFC 5226</a>, May 2008. |
| 2715 |
|
| 2716 |
[<a id="ref-SIP-OUTBOUND">SIP-OUTBOUND</a>] Jennings, C. and R. Mahy, "Managing Client |
| 2717 |
Initiated Connections in the Session Initiation |
| 2718 |
Protocol (SIP)", Work in Progress, June 2008. |
| 2719 |
|
| 2720 |
|
| 2721 |
|
| 2722 |
|
| 2723 |
|
| 2724 |
|
| 2725 |
|
| 2726 |
|
| 2727 |
|
| 2728 |
|
| 2729 |
|
| 2730 |
|
| 2731 |
|
| 2732 |
|
| 2733 |
|
| 2734 |
|
| 2735 |
|
| 2736 |
|
| 2737 |
|
| 2738 |
|
| 2739 |
|
| 2740 |
<span class="grey">Rosenberg, et al. Standards Track [Page 49]</span></pre> |
| 2741 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-50" ></span> |
| 2742 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2743 |
|
| 2744 |
|
| 2745 |
<span class="h2"><a class="selflink" id="appendix-A" href="#appendix-A">Appendix A</a>. C Snippet to Determine STUN Message Types</span> |
| 2746 |
|
| 2747 |
Given a 16-bit STUN message type value in host byte order in msg_type |
| 2748 |
parameter, below are C macros to determine the STUN message types: |
| 2749 |
|
| 2750 |
#define IS_REQUEST(msg_type) (((msg_type) & 0x0110) == 0x0000) |
| 2751 |
#define IS_INDICATION(msg_type) (((msg_type) & 0x0110) == 0x0010) |
| 2752 |
#define IS_SUCCESS_RESP(msg_type) (((msg_type) & 0x0110) == 0x0100) |
| 2753 |
#define IS_ERR_RESP(msg_type) (((msg_type) & 0x0110) == 0x0110) |
| 2754 |
|
| 2755 |
|
| 2756 |
Authors' Addresses |
| 2757 |
|
| 2758 |
Jonathan Rosenberg |
| 2759 |
Cisco |
| 2760 |
Edison, NJ |
| 2761 |
US |
| 2762 |
|
| 2763 |
EMail: [email protected] |
| 2764 |
URI: <a href="http://www.jdrosen.net">http://www.jdrosen.net</a> |
| 2765 |
|
| 2766 |
|
| 2767 |
Rohan Mahy |
| 2768 |
Unaffiliated |
| 2769 |
|
| 2770 |
EMail: [email protected] |
| 2771 |
|
| 2772 |
|
| 2773 |
Philip Matthews |
| 2774 |
Unaffiliated |
| 2775 |
|
| 2776 |
EMail: [email protected] |
| 2777 |
|
| 2778 |
|
| 2779 |
Dan Wing |
| 2780 |
Cisco |
| 2781 |
771 Alder Drive |
| 2782 |
San Jose, CA 95035 |
| 2783 |
US |
| 2784 |
|
| 2785 |
EMail: [email protected] |
| 2786 |
|
| 2787 |
|
| 2788 |
|
| 2789 |
|
| 2790 |
|
| 2791 |
|
| 2792 |
|
| 2793 |
|
| 2794 |
|
| 2795 |
|
| 2796 |
<span class="grey">Rosenberg, et al. Standards Track [Page 50]</span></pre> |
| 2797 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-51" ></span> |
| 2798 |
<span class="grey"><a href="./rfc5389">RFC 5389</a> STUN October 2008</span> |
| 2799 |
|
| 2800 |
|
| 2801 |
Full Copyright Statement |
| 2802 |
|
| 2803 |
Copyright (C) The IETF Trust (2008). |
| 2804 |
|
| 2805 |
This document is subject to the rights, licenses and restrictions |
| 2806 |
contained in <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a>, and except as set forth therein, the authors |
| 2807 |
retain all their rights. |
| 2808 |
|
| 2809 |
This document and the information contained herein are provided on an |
| 2810 |
"AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS |
| 2811 |
OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND |
| 2812 |
THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS |
| 2813 |
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF |
| 2814 |
THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED |
| 2815 |
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. |
| 2816 |
|
| 2817 |
Intellectual Property |
| 2818 |
|
| 2819 |
The IETF takes no position regarding the validity or scope of any |
| 2820 |
Intellectual Property Rights or other rights that might be claimed to |
| 2821 |
pertain to the implementation or use of the technology described in |
| 2822 |
this document or the extent to which any license under such rights |
| 2823 |
might or might not be available; nor does it represent that it has |
| 2824 |
made any independent effort to identify any such rights. Information |
| 2825 |
on the procedures with respect to rights in RFC documents can be |
| 2826 |
found in <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a> and <a href="https://www.rfc-editor.org/bcp/bcp79">BCP 79</a>. |
| 2827 |
|
| 2828 |
Copies of IPR disclosures made to the IETF Secretariat and any |
| 2829 |
assurances of licenses to be made available, or the result of an |
| 2830 |
attempt made to obtain a general license or permission for the use of |
| 2831 |
such proprietary rights by implementers or users of this |
| 2832 |
specification can be obtained from the IETF on-line IPR repository at |
| 2833 |
<a href="http://www.ietf.org/ipr">http://www.ietf.org/ipr</a>. |
| 2834 |
|
| 2835 |
The IETF invites any interested party to bring to its attention any |
| 2836 |
copyrights, patents or patent applications, or other proprietary |
| 2837 |
rights that may cover technology that may be required to implement |
| 2838 |
this standard. Please address the information to the IETF at |
| 2839 |
[email protected]. |
| 2840 |
|
| 2841 |
|
| 2842 |
|
| 2843 |
|
| 2844 |
|
| 2845 |
|
| 2846 |
|
| 2847 |
|
| 2848 |
|
| 2849 |
|
| 2850 |
|
| 2851 |
|
| 2852 |
Rosenberg, et al. Standards Track [Page 51] |
| 2853 |
</pre> |