draft-ietf-tram-stunbis-00.txt   draft-ietf-tram-stunbis-01.txt 
TRAM M. Petit-Huguenin TRAM M. Petit-Huguenin
Internet-Draft Impedance Mismatch Internet-Draft Impedance Mismatch
Obsoletes: 5389 (if approved) G. Salgueiro Obsoletes: 5389 (if approved) G. Salgueiro
Intended status: Standards Track J. Rosenberg Intended status: Standards Track J. Rosenberg
Expires: May 17, 2015 D. Wing Expires: August 21, 2015 D. Wing
Cisco Cisco
R. Mahy R. Mahy
Plantronics Plantronics
P. Matthews P. Matthews
Avaya Avaya
November 13, 2014 February 17, 2015
Session Traversal Utilities for NAT (STUN) Session Traversal Utilities for NAT (STUN)
draft-ietf-tram-stunbis-00 draft-ietf-tram-stunbis-01
Abstract Abstract
Session Traversal Utilities for NAT (STUN) is a protocol that serves Session Traversal Utilities for NAT (STUN) is a protocol that serves
as a tool for other protocols in dealing with Network Address as a tool for other protocols in dealing with Network Address
Translator (NAT) traversal. It can be used by an endpoint to Translator (NAT) traversal. It can be used by an endpoint to
determine the IP address and port allocated to it by a NAT. It can determine the IP address and port allocated to it by a NAT. It can
also be used to check connectivity between two endpoints, and as a also be used to check connectivity between two endpoints, and as a
keep-alive protocol to maintain NAT bindings. STUN works with many keep-alive protocol to maintain NAT bindings. STUN works with many
existing NATs, and does not require any special behavior from them. existing NATs, and does not require any special behavior from them.
skipping to change at page 1, line 48 skipping to change at page 1, line 48
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/. Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on May 17, 2015. This Internet-Draft will expire on August 21, 2015.
Copyright Notice Copyright Notice
Copyright (c) 2014 IETF Trust and the persons identified as the Copyright (c) 2015 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
skipping to change at page 2, line 30 skipping to change at page 2, line 30
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4
2. Overview of Operation . . . . . . . . . . . . . . . . . . . . 4 2. Overview of Operation . . . . . . . . . . . . . . . . . . . . 4
3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 7 3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 7
4. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 7 4. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 7
5. STUN Message Structure . . . . . . . . . . . . . . . . . . . 9 5. STUN Message Structure . . . . . . . . . . . . . . . . . . . 9
6. Base Protocol Procedures . . . . . . . . . . . . . . . . . . 11 6. Base Protocol Procedures . . . . . . . . . . . . . . . . . . 11
6.1. Forming a Request or an Indication . . . . . . . . . . . 11 6.1. Forming a Request or an Indication . . . . . . . . . . . 11
6.2. Sending the Request or Indication . . . . . . . . . . . . 12 6.2. Sending the Request or Indication . . . . . . . . . . . . 12
6.2.1. Sending over UDP . . . . . . . . . . . . . . . . . . 12 6.2.1. Sending over UDP or DTLS-over-UDP . . . . . . . . . . 13
6.2.2. Sending over TCP or TLS-over-TCP . . . . . . . . . . 13 6.2.2. Sending over TCP or TLS-over-TCP . . . . . . . . . . 14
6.3. Receiving a STUN Message . . . . . . . . . . . . . . . . 15 6.2.3. Sending over SCTP-over-UDP or SCTP-over-DTLS-over-UDP 15
6.3.1. Processing a Request . . . . . . . . . . . . . . . . 16 6.2.4. Sending over TLS-over-TCP or DTLS-over-UDP or SCTP-
6.3.1.1. Forming a Success or Error Response . . . . . . . 17 over-DTLS-over-UDP . . . . . . . . . . . . . . . . . 16
6.3.1.2. Sending the Success or Error Response . . . . . . 18 6.3. Receiving a STUN Message . . . . . . . . . . . . . . . . 17
6.3.2. Processing an Indication . . . . . . . . . . . . . . 18 6.3.1. Processing a Request . . . . . . . . . . . . . . . . 18
6.3.3. Processing a Success Response . . . . . . . . . . . . 18 6.3.1.1. Forming a Success or Error Response . . . . . . . 19
6.3.4. Processing an Error Response . . . . . . . . . . . . 19 6.3.1.2. Sending the Success or Error Response . . . . . . 20
7. FINGERPRINT Mechanism . . . . . . . . . . . . . . . . . . . . 19 6.3.2. Processing an Indication . . . . . . . . . . . . . . 20
8. DNS Discovery of a Server . . . . . . . . . . . . . . . . . 20 6.3.3. Processing a Success Response . . . . . . . . . . . . 20
9. Authentication and Message-Integrity Mechanisms . . . . . . . 21 6.3.4. Processing an Error Response . . . . . . . . . . . . 21
9.1. Short-Term Credential Mechanism . . . . . . . . . . . . . 21 7. FINGERPRINT Mechanism . . . . . . . . . . . . . . . . . . . . 21
9.1.1. Forming a Request or Indication . . . . . . . . . . . 22 8. DNS Discovery of a Server . . . . . . . . . . . . . . . . . . 22
9.1.2. Receiving a Request or Indication . . . . . . . . . . 22 8.1. STUN URI Scheme Semantics . . . . . . . . . . . . . . . . 22
9.1.3. Receiving a Response . . . . . . . . . . . . . . . . 23 9. Authentication and Message-Integrity Mechanisms . . . . . . . 23
9.2. Long-Term Credential Mechanism . . . . . . . . . . . . . 23 9.1. Short-Term Credential Mechanism . . . . . . . . . . . . . 24
9.2.1. Forming a Request . . . . . . . . . . . . . . . . . . 24 9.1.1. HMAC Key . . . . . . . . . . . . . . . . . . . . . . 24
9.2.1.1. First Request . . . . . . . . . . . . . . . . . . 24 9.1.2. Forming a Request or Indication . . . . . . . . . . . 24
9.2.1.2. Subsequent Requests . . . . . . . . . . . . . . . 25 9.1.3. Receiving a Request or Indication . . . . . . . . . . 24
9.2.2. Receiving a Request . . . . . . . . . . . . . . . . . 25 9.1.4. Receiving a Response . . . . . . . . . . . . . . . . 26
9.2.3. Receiving a Response . . . . . . . . . . . . . . . . 26 9.1.5. Sending Subsequent Requests . . . . . . . . . . . . . 26
10. ALTERNATE-SERVER Mechanism . . . . . . . . . . . . . . . . . 26 9.2. Long-Term Credential Mechanism . . . . . . . . . . . . . 26
11. Backwards Compatibility with RFC 3489 . . . . . . . . . . . . 27 9.2.1. HMAC Key . . . . . . . . . . . . . . . . . . . . . . 27
11.1. Changes to Client Processing . . . . . . . . . . . . . . 28 9.2.2. Forming a Request . . . . . . . . . . . . . . . . . . 28
11.2. Changes to Server Processing . . . . . . . . . . . . . . 28 9.2.2.1. First Request . . . . . . . . . . . . . . . . . . 28
12. Basic Server Behavior . . . . . . . . . . . . . . . . . . . . 29 9.2.2.2. Subsequent Requests . . . . . . . . . . . . . . . 28
13. STUN Usages . . . . . . . . . . . . . . . . . . . . . . . . . 29 9.2.3. Receiving a Request . . . . . . . . . . . . . . . . . 28
14. STUN Attributes . . . . . . . . . . . . . . . . . . . . . . . 30 9.2.4. Receiving a Response . . . . . . . . . . . . . . . . 30
14.1. MAPPED-ADDRESS . . . . . . . . . . . . . . . . . . . . . 31 10. ALTERNATE-SERVER Mechanism . . . . . . . . . . . . . . . . . 31
14.2. XOR-MAPPED-ADDRESS . . . . . . . . . . . . . . . . . . . 32 11. Backwards Compatibility with RFC 3489 . . . . . . . . . . . . 31
14.3. USERNAME . . . . . . . . . . . . . . . . . . . . . . . . 33 12. Basic Server Behavior . . . . . . . . . . . . . . . . . . . . 32
14.4. MESSAGE-INTEGRITY . . . . . . . . . . . . . . . . . . . 33 13. STUN Usages . . . . . . . . . . . . . . . . . . . . . . . . . 32
14.5. MESSAGE-INTEGRITY2 . . . . . . . . . . . . . . . . . . . 34 14. STUN Attributes . . . . . . . . . . . . . . . . . . . . . . . 33
14.6. FINGERPRINT . . . . . . . . . . . . . . . . . . . . . . 35 14.1. MAPPED-ADDRESS . . . . . . . . . . . . . . . . . . . . . 34
14.7. ERROR-CODE . . . . . . . . . . . . . . . . . . . . . . . 36 14.2. XOR-MAPPED-ADDRESS . . . . . . . . . . . . . . . . . . . 35
14.8. REALM . . . . . . . . . . . . . . . . . . . . . . . . . 37 14.3. USERNAME . . . . . . . . . . . . . . . . . . . . . . . . 36
14.9. NONCE . . . . . . . . . . . . . . . . . . . . . . . . . 38 14.4. MESSAGE-INTEGRITY . . . . . . . . . . . . . . . . . . . 36
14.10. UNKNOWN-ATTRIBUTES . . . . . . . . . . . . . . . . . . . 38 14.5. MESSAGE-INTEGRITY2 . . . . . . . . . . . . . . . . . . . 37
14.11. SOFTWARE . . . . . . . . . . . . . . . . . . . . . . . . 38 14.6. FINGERPRINT . . . . . . . . . . . . . . . . . . . . . . 38
14.12. ALTERNATE-SERVER . . . . . . . . . . . . . . . . . . . . 39 14.7. ERROR-CODE . . . . . . . . . . . . . . . . . . . . . . . 38
15. Security Considerations . . . . . . . . . . . . . . . . . . . 39 14.8. REALM . . . . . . . . . . . . . . . . . . . . . . . . . 40
15.1. Attacks against the Protocol . . . . . . . . . . . . . . 39 14.9. NONCE . . . . . . . . . . . . . . . . . . . . . . . . . 40
15.1.1. Outside Attacks . . . . . . . . . . . . . . . . . . 39 14.10. PASSWORD-ALGORITHMS . . . . . . . . . . . . . . . . . . 40
15.1.2. Inside Attacks . . . . . . . . . . . . . . . . . . . 40 14.11. PASSWORD-ALGORITHM . . . . . . . . . . . . . . . . . . . 41
15.2. Attacks Affecting the Usage . . . . . . . . . . . . . . 40 14.12. UNKNOWN-ATTRIBUTES . . . . . . . . . . . . . . . . . . . 42
15.2.1. Attack I: Distributed DoS (DDoS) against a Target . 41 14.13. SOFTWARE . . . . . . . . . . . . . . . . . . . . . . . . 42
15.2.2. Attack II: Silencing a Client . . . . . . . . . . . 41 14.14. ALTERNATE-SERVER . . . . . . . . . . . . . . . . . . . . 42
15.2.3. Attack III: Assuming the Identity of a Client . . . 41 15. Security Considerations . . . . . . . . . . . . . . . . . . . 42
15.2.4. Attack IV: Eavesdropping . . . . . . . . . . . . . . 42 15.1. Attacks against the Protocol . . . . . . . . . . . . . . 43
15.3. Hash Agility Plan . . . . . . . . . . . . . . . . . . . 42 15.1.1. Outside Attacks . . . . . . . . . . . . . . . . . . 43
16. IAB Considerations . . . . . . . . . . . . . . . . . . . . . 42 15.1.2. Inside Attacks . . . . . . . . . . . . . . . . . . . 43
17. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 43 15.2. Attacks Affecting the Usage . . . . . . . . . . . . . . 44
17.1. STUN Methods Registry . . . . . . . . . . . . . . . . . 43 15.2.1. Attack I: Distributed DoS (DDoS) against a Target . 44
17.2. STUN Attribute Registry . . . . . . . . . . . . . . . . 43 15.2.2. Attack II: Silencing a Client . . . . . . . . . . . 45
17.3. STUN Error Code Registry . . . . . . . . . . . . . . . . 44 15.2.3. Attack III: Assuming the Identity of a Client . . . 45
17.4. STUN UDP and TCP Port Numbers . . . . . . . . . . . . . 45 15.2.4. Attack IV: Eavesdropping . . . . . . . . . . . . . . 45
18. Changes since RFC 5389 . . . . . . . . . . . . . . . . . . . 45 15.3. Hash Agility Plan . . . . . . . . . . . . . . . . . . . 45
19. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 45 16. IAB Considerations . . . . . . . . . . . . . . . . . . . . . 46
20. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 45 17. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 46
21. References . . . . . . . . . . . . . . . . . . . . . . . . . 46 17.1. STUN Methods Registry . . . . . . . . . . . . . . . . . 46
21.1. Normative References . . . . . . . . . . . . . . . . . . 46 17.2. STUN Attribute Registry . . . . . . . . . . . . . . . . 47
21.2. Informational References . . . . . . . . . . . . . . . . 47 17.3. STUN Error Code Registry . . . . . . . . . . . . . . . . 48
Appendix A. C Snippet to Determine STUN Message Types . . . . . 48 17.4. Password Algorithm Registry . . . . . . . . . . . . . . 48
Appendix B. Release notes . . . . . . . . . . . . . . . . . . . 48 17.4.1. Password Algorithms . . . . . . . . . . . . . . . . 48
B.1. Open Issues . . . . . . . . . . . . . . . . . . . . . . . 48 17.4.1.1. Salted SHA256 . . . . . . . . . . . . . . . . . 49
B.2. Modifications between draft-salgueiro-tram-stunbis-02 and 17.5. STUN UDP and TCP Port Numbers . . . . . . . . . . . . . 49
draft-salgueiro-tram-stunbis-01 . . . . . . . . . . . . . 49 18. Changes since RFC 5389 . . . . . . . . . . . . . . . . . . . 49
B.3. Modifications between draft-salgueiro-tram-stunbis-01 and 19. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 49
draft-salgueiro-tram-stunbis-00 . . . . . . . . . . . . . 49 20. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 49
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 50 21. References . . . . . . . . . . . . . . . . . . . . . . . . . 50
21.1. Normative References . . . . . . . . . . . . . . . . . . 50
21.2. Informational References . . . . . . . . . . . . . . . . 52
Appendix A. C Snippet to Determine STUN Message Types . . . . . 53
Appendix B. Release notes . . . . . . . . . . . . . . . . . . . 54
B.1. Open Issues . . . . . . . . . . . . . . . . . . . . . . . 54
B.2. Modifications between draft-ietf-tram-stunbis-01 and
draft-ietf-tram-stunbis-00 . . . . . . . . . . . . . . . 54
B.3. Modifications between draft-salgueiro-tram-stunbis-02 and
draft-ietf-tram-stunbis-00 . . . . . . . . . . . . . . . 55
B.4. Modifications between draft-salgueiro-tram-stunbis-02 and
draft-salgueiro-tram-stunbis-01 . . . . . . . . . . . . . 55
B.5. Modifications between draft-salgueiro-tram-stunbis-01 and
draft-salgueiro-tram-stunbis-00 . . . . . . . . . . . . . 56
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 56
1. Introduction 1. Introduction
The protocol defined in this specification, Session Traversal The protocol defined in this specification, Session Traversal
Utilities for NAT, provides a tool for dealing with NATs. It Utilities for NAT, provides a tool for dealing with NATs. It
provides a means for an endpoint to determine the IP address and port provides a means for an endpoint to determine the IP address and port
allocated by a NAT that corresponds to its private IP address and allocated by a NAT that corresponds to its private IP address and
port. It also provides a way for an endpoint to keep a NAT binding port. It also provides a way for an endpoint to keep a NAT binding
alive. With some extensions, the protocol can be used to do alive. With some extensions, the protocol can be used to do
connectivity checks between two endpoints [RFC5245], or to relay connectivity checks between two endpoints [RFC5245], or to relay
skipping to change at page 12, line 13 skipping to change at page 12, line 13
(Section 7). (Section 7).
If the agent is sending a request, it SHOULD add a SOFTWARE attribute If the agent is sending a request, it SHOULD add a SOFTWARE attribute
to the request. Agents MAY include a SOFTWARE attribute in to the request. Agents MAY include a SOFTWARE attribute in
indications, depending on the method. Extensions to STUN should indications, depending on the method. Extensions to STUN should
discuss whether SOFTWARE is useful in new indications. discuss whether SOFTWARE is useful in new indications.
For the Binding method with no authentication, no attributes are For the Binding method with no authentication, no attributes are
required unless the usage specifies otherwise. required unless the usage specifies otherwise.
All STUN messages sent over UDP SHOULD be less than the path MTU, if All STUN messages sent over UDP or DTLS-over-UDP [RFC6347] SHOULD be
known. If the path MTU is unknown, messages SHOULD be the smaller of less than the path MTU, if known.
If the path MTU is unknown for UDP, messages SHOULD be the smaller of
576 bytes and the first-hop MTU for IPv4 [RFC1122] and 1280 bytes for 576 bytes and the first-hop MTU for IPv4 [RFC1122] and 1280 bytes for
IPv6 [RFC2460]. This value corresponds to the overall size of the IP IPv6 [RFC2460]. This value corresponds to the overall size of the IP
packet. Consequently, for IPv4, the actual STUN message would need packet. Consequently, for IPv4, the actual STUN message would need
to be less than 548 bytes (576 minus 20-byte IP header, minus 8-byte to be less than 548 bytes (576 minus 20-byte IP header, minus 8-byte
UDP header, assuming no IP options are used). STUN provides no UDP header, assuming no IP options are used).
ability to handle the case where the request is under the MTU but the
response would be larger than the MTU. It is not envisioned that If the path MTU is unknown for DTLS-over-UDP, the rules described in
this limitation will be an issue for STUN. The MTU limitation is a the previous paragraph need to be adjusted to take into account the
SHOULD, and not a MUST, to account for cases where STUN itself is size of the (13-byte) DTLS Record header, the MAC size, and the
being used to probe for MTU characteristics [RFC5780]. Outside of padding size.
this or similar applications, the MTU constraint MUST be followed.
If a STUN client needs to send requests that are larger than the MTU,
or if an application envisions that a response would be larger then
the MTU, then it MUST use SCTP-over-UDP or SCTP-over-DTLS-over-UDP as
transport, unless the purpose of sending an oversized packet is to
probe for MTU characteristics (see [RFC5780]).
6.2. Sending the Request or Indication 6.2. Sending the Request or Indication
The agent then sends the request or indication. This document The agent then sends the request or indication. This document
specifies how to send STUN messages over UDP, TCP, or TLS-over-TCP; specifies how to send STUN messages over UDP, TCP, TLS-over-TCP,
other transport protocols may be added in the future. The STUN usage DTLS-over-UDP, SCTP-over-UDP, or SCTP-over-DTLS-over-UDP; other
must specify which transport protocol is used, and how the agent transport protocols may be added in the future. The STUN usage must
specify which transport protocol is used, and how the agent
determines the IP address and port of the recipient. Section 8 determines the IP address and port of the recipient. Section 8
describes a DNS-based method of determining the IP address and port describes a DNS-based method of determining the IP address and port
of a server that a usage may elect to use. STUN may be used with of a server that a usage may elect to use. STUN may be used with
anycast addresses, but only with UDP and in usages where anycast addresses, but only with UDP and in usages where
authentication is not used. authentication is not used.
At any time, a client MAY have multiple outstanding STUN requests At any time, a client MAY have multiple outstanding STUN requests
with the same STUN server (that is, multiple transactions in with the same STUN server (that is, multiple transactions in
progress, with different transaction IDs). Absent other limits to progress, with different transaction IDs). Absent other limits to
the rate of new transactions (such as those specified by ICE for the rate of new transactions (such as those specified by ICE for
connectivity checks or when STUN is run over TCP), a client SHOULD connectivity checks or when STUN is run over TCP), a client SHOULD
space new transactions to a server by RTO and SHOULD limit itself to space new transactions to a server by RTO and SHOULD limit itself to
ten outstanding transactions to the same server. ten outstanding transactions to the same server.
6.2.1. Sending over UDP 6.2.1. Sending over UDP or DTLS-over-UDP
When running STUN over UDP, it is possible that the STUN message When running STUN over UDP or STUN over DTLS-over-UDP [RFC7350], it
might be dropped by the network. Reliability of STUN request/ is possible that the STUN message might be dropped by the network.
response transactions is accomplished through retransmissions of the Reliability of STUN request/response transactions is accomplished
request message by the client application itself. STUN indications through retransmissions of the request message by the client
are not retransmitted; thus, indication transactions over UDP are not application itself. STUN indications are not retransmitted; thus,
reliable. indication transactions over UDP or DTLS-over-UDP are not reliable.
A client SHOULD retransmit a STUN request message starting with an A client SHOULD retransmit a STUN request message starting with an
interval of RTO ("Retransmission TimeOut"), doubling after each interval of RTO ("Retransmission TimeOut"), doubling after each
retransmission. The RTO is an estimate of the round-trip time (RTT), retransmission. The RTO is an estimate of the round-trip time (RTT),
and is computed as described in RFC 6298 [RFC6298], with two and is computed as described in RFC 6298 [RFC6298], with two
exceptions. First, the initial value for RTO SHOULD be greater than exceptions. First, the initial value for RTO SHOULD be greater than
500 ms. The exception cases for this "SHOULD" are when other 500 ms. The exception cases for this "SHOULD" are when other
mechanisms are used to derive congestion thresholds (such as the ones mechanisms are used to derive congestion thresholds (such as the ones
defined in ICE for fixed rate streams), or when STUN is used in non- defined in ICE for fixed rate streams), or when STUN is used in non-
Internet environments with known network capacities. In fixed-line Internet environments with known network capacities. In fixed-line
skipping to change at page 13, line 27 skipping to change at page 13, line 36
RTO SHOULD NOT be rounded up to the nearest second. Rather, a 1 ms RTO SHOULD NOT be rounded up to the nearest second. Rather, a 1 ms
accuracy SHOULD be maintained. As with TCP, the usage of Karn's accuracy SHOULD be maintained. As with TCP, the usage of Karn's
algorithm is RECOMMENDED [KARN87]. When applied to STUN, it means algorithm is RECOMMENDED [KARN87]. When applied to STUN, it means
that RTT estimates SHOULD NOT be computed from STUN transactions that that RTT estimates SHOULD NOT be computed from STUN transactions that
result in the retransmission of a request. result in the retransmission of a request.
The value for RTO SHOULD be cached by a client after the completion The value for RTO SHOULD be cached by a client after the completion
of the transaction, and used as the starting value for RTO for the of the transaction, and used as the starting value for RTO for the
next transaction to the same server (based on equality of IP next transaction to the same server (based on equality of IP
address). The value SHOULD be considered stale and discarded after address). The value SHOULD be considered stale and discarded after
10 minutes. 10 minutes without any transactions to the same server.
Retransmissions continue until a response is received, or until a Retransmissions continue until a response is received, or until a
total of Rc requests have been sent. Rc SHOULD be configurable and total of Rc requests have been sent. Rc SHOULD be configurable and
SHOULD have a default of 7. If, after the last request, a duration SHOULD have a default of 7. If, after the last request, a duration
equal to Rm times the RTO has passed without a response (providing equal to Rm times the RTO has passed without a response (providing
ample time to get a response if only this final request actually ample time to get a response if only this final request actually
succeeds), the client SHOULD consider the transaction to have failed. succeeds), the client SHOULD consider the transaction to have failed.
Rm SHOULD be configurable and SHOULD have a default of 16. A STUN Rm SHOULD be configurable and SHOULD have a default of 16. A STUN
transaction over UDP is also considered failed if there has been a transaction over UDP or DTLS-over-UDP is also considered failed if
hard ICMP error [RFC1122]. For example, assuming an RTO of 500ms, there has been a hard ICMP error [RFC1122]. For example, assuming an
requests would be sent at times 0 ms, 500 ms, 1500 ms, 3500 ms, 7500 RTO of 500ms, requests would be sent at times 0 ms, 500 ms, 1500 ms,
ms, 15500 ms, and 31500 ms. If the client has not received a 3500 ms, 7500 ms, 15500 ms, and 31500 ms. If the client has not
response after 39500 ms, the client will consider the transaction to received a response after 39500 ms, the client will consider the
have timed out. transaction to have timed out.
6.2.2. Sending over TCP or TLS-over-TCP 6.2.2. Sending over TCP or TLS-over-TCP
For TCP and TLS-over-TCP, the client opens a TCP connection to the For TCP and TLS-over-TCP [RFC5246], the client opens a TCP connection
server. to the server.
In some usages of STUN, STUN is sent as the only protocol over the In some usages of STUN, STUN is sent as the only protocol over the
TCP connection. In this case, it can be sent without the aid of any TCP connection. In this case, it can be sent without the aid of any
additional framing or demultiplexing. In other usages, or with other additional framing or demultiplexing. In other usages, or with other
extensions, it may be multiplexed with other data over a TCP extensions, it may be multiplexed with other data over a TCP
connection. In that case, STUN MUST be run on top of some kind of connection. In that case, STUN MUST be run on top of some kind of
framing protocol, specified by the usage or extension, which allows framing protocol, specified by the usage or extension, which allows
for the agent to extract complete STUN messages and complete for the agent to extract complete STUN messages and complete
application layer messages. The STUN service running on the well- application layer messages. The STUN service running on the well-
known port or ports discovered through the DNS procedures in known port or ports discovered through the DNS procedures in
Section 8 is for STUN alone, and not for STUN multiplexed with other Section 8 is for STUN alone, and not for STUN multiplexed with other
data. Consequently, no framing protocols are used in connections to data. Consequently, no framing protocols are used in connections to
those servers. When additional framing is utilized, the usage will those servers. When additional framing is utilized, the usage will
specify how the client knows to apply it and what port to connect to. specify how the client knows to apply it and what port to connect to.
For example, in the case of ICE connectivity checks, this information For example, in the case of ICE connectivity checks, this information
is learned through out-of-band negotiation between client and server. is learned through out-of-band negotiation between client and server.
When STUN is run by itself over TLS-over-TCP, the
TLS_RSA_WITH_AES_128_CBC_SHA ciphersuite MUST be implemented at a
minimum. Implementations MAY also support any other ciphersuite.
When it receives the TLS Certificate message, the client SHOULD
verify the certificate and inspect the site identified by the
certificate. If the certificate is invalid or revoked, or if it does
not identify the appropriate party, the client MUST NOT send the STUN
message or otherwise proceed with the STUN transaction. The client
MUST verify the identity of the server. To do that, it follows the
identification procedures defined in Section 3.1 of RFC 2818
[RFC2818]. Those procedures assume the client is dereferencing a
URI. For purposes of usage with this specification, the client
treats the original domain name or IP address used in Section 8 as
the host portion of the URI that has been dereferenced.
Alternatively, a client MAY be configured with a set of domains or IP
addresses that are trusted; if a certificate is received that
identifies one of those domains or IP addresses, the client considers
the identity of the server to be verified.
When STUN is run multiplexed with other protocols over a TLS-over-TCP
connection, the mandatory ciphersuites and TLS handling procedures
operate as defined by those protocols.
Reliability of STUN over TCP and TLS-over-TCP is handled by TCP Reliability of STUN over TCP and TLS-over-TCP is handled by TCP
itself, and there are no retransmissions at the STUN protocol level. itself, and there are no retransmissions at the STUN protocol level.
However, for a request/response transaction, if the client has not However, for a request/response transaction, if the client has not
received a response by Ti seconds after it sent the SYN to establish received a response by Ti seconds after it sent the SYN to establish
the connection, it considers the transaction to have timed out. Ti the connection, it considers the transaction to have timed out. Ti
SHOULD be configurable and SHOULD have a default of 39.5s. This SHOULD be configurable and SHOULD have a default of 39.5s. This
value has been chosen to equalize the TCP and UDP timeouts for the value has been chosen to equalize the TCP and UDP timeouts for the
default initial RTO. default initial RTO.
In addition, if the client is unable to establish the TCP connection, In addition, if the client is unable to establish the TCP connection,
skipping to change at page 15, line 37 skipping to change at page 15, line 24
connection has timed out (for example, due to the client connection has timed out (for example, due to the client
disconnecting from the network). Bindings learned by the client will disconnecting from the network). Bindings learned by the client will
remain valid in intervening NATs only while the connection remains remain valid in intervening NATs only while the connection remains
open. Only the client knows how long it needs the binding. The open. Only the client knows how long it needs the binding. The
server SHOULD NOT close a connection if a request was received over server SHOULD NOT close a connection if a request was received over
that connection for which a response was not sent. A server MUST NOT that connection for which a response was not sent. A server MUST NOT
ever open a connection back towards the client in order to send a ever open a connection back towards the client in order to send a
response. Servers SHOULD follow best practices regarding connection response. Servers SHOULD follow best practices regarding connection
management in cases of overload. management in cases of overload.
6.2.3. Sending over SCTP-over-UDP or SCTP-over-DTLS-over-UDP
For SCTP-over-UDP [RFC6951] and SCTP-over-DTLS-over-UDP
[I-D.ietf-tsvwg-sctp-dtls-encaps], the client opens a Stream Control
Transmission Protocol (SCTP) connection to the server.
For some STUN usages, STUN is sent over SCTP as the only protocol
over the UDP association. In this case, it can be sent without the
aid of any additional demultiplexing. In other usages, or with other
extensions, it may be multiplexed with other data over a UDP
association. In that case, the SCTP source and destination ports
MUST be chosen so the two most significant bits are 0b11.
Reliability of STUN over SCTP-over-UDP and STUN over SCTP-over-DTLS-
over-UDP is handled by SCTP itself and there are no retransmissions
at the STUN protocol level. However, for a request/response
transaction, if the client has not received a response by Ti seconds
after it sent the INIT to establish the connection, it considers the
transaction to have timed out. Ti SHOULD be configurable and SHOULD
have a default of 39.5s. This value has been chosen to equalize the
SCTP-over-UDP, TCP, and UDP timeouts for the default initial RTO.
In addition, if the client is unable to establish the SCTP
connection, or the SCTP connection is reset or fails before a
response is received, any request/response transaction in progress is
considered to have failed.
The client MAY send multiple transactions over a single SCTP (or
SCTP-over-DTLS) connection and it MAY send another request before
receiving a response to the previous. Each transaction MUST use a
different SCTP stream ID. The client SHOULD keep the connection open
until it:
o has no further STUN requests or indications to send over that
connection, and
o has no plans to use any resources (such as a mapped address
(MAPPED-ADDRESS or XOR-MAPPED-ADDRESS) or relayed address
[RFC5766]) that were learned through STUN requests sent over that
connection, and
o has finished using all corresponding applications if multiplexing
other application protocols over that port
When using SCTP-over-UDP, the SCTP source port and destination port
MUST be selected so the two most significant bits are set to "1".
This permits multiplexing of STUN-over-UDP, STUN-over-SCTP-over-UDP,
DTLS, and RTP/RTCP on the same socket.
STUN indications MAY be sent unreliably by using the SCTP extension
in [RFC3758], augmented with the policies of
[I-D.ietf-tsvwg-sctp-prpolicies]. Each STUN usage MUST specify the
conditions under which STUN indications are sent reliably or not, and
MUST specify the policy for allocating an SCTP stream ID. The NAT
Discovery usage described in this document does not use STUN
indications.
At the server end, the server SHOULD keep the connection open and let
the client close it unless the server has determined that the
connection has timed out (for example, due to the client
disconnecting from the network). Bindings learned by the client will
remain valid in intervening NATs only while the connection remains
open. Only the client knows how long it needs the binding. The
server SHOULD NOT close a connection if a request was received over
that connection for which a response was not sent. A server MUST NOT
ever open a connection back towards the client in order to send a
response. Servers SHOULD follow best practices regarding connection
management in cases of overload.
6.2.4. Sending over TLS-over-TCP or DTLS-over-UDP or SCTP-over-DTLS-
over-UDP
When STUN is run by itself over TLS-over-TCP or DTLS-over-UDP or
SCTP-over-DTLS-over-UDP, the TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 and
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suites MUST be
implemented and other cipher suites MAY be implemented. Perfect
Forward Secrecy (PFS) cipher suites MUST be preferred over non-PFS
cipher suites. Cipher suites with known weaknesses, such as those
based on (single) DES and RC4, MUST NOT be used. Implementations
MUST disable TLS-level compression.
When it receives the TLS Certificate message, the client SHOULD
verify the certificate and inspect the site identified by the
certificate. If the certificate is invalid or revoked, or if it does
not identify the appropriate party, the client MUST NOT send the STUN
message or otherwise proceed with the STUN transaction. The client
MUST verify the identity of the server using the following procedure.
STUN clients that are using the mechanism in Section 8, and that have
established that all DNS Resource Records from the Source Domain to
the Host Name are secure according to DNSsec [RFC4033] (i.e., that
the AD bit is set in all the DNS responses) MUST lookup a TLSA
Resource Record [RFC6698] for the protocol, port and Host Name
selected. If the TLSA Resource Record is secure then the STUN client
MUST use it to validate the certificate presented by the STUN server.
If there is no TLSA Resource Record or if the Resource Record is not
secure, then the client MUST fallback to the validation process
defined in Section 3.1 of RFC 2818 [RFC2818].
Alternatively, a client MAY be configured with a set of domains or IP
addresses that are trusted. If a certificate is received that
identifies one of those trusted domains or IP addresses, the client
considers the identity of the server to be verified.
When STUN is multiplexed with other protocols over a TLS-over-TCP
connection or a DTLS-over-UDP or a SCTP-over-DTLS-over-UDP
association, the mandatory ciphersuites and TLS handling procedures
operate as defined by those protocols.
6.3. Receiving a STUN Message 6.3. Receiving a STUN Message
This section specifies the processing of a STUN message. The This section specifies the processing of a STUN message. The
processing specified here is for STUN messages as defined in this processing specified here is for STUN messages as defined in this
specification; additional rules for backwards compatibility are specification; additional rules for backwards compatibility are
defined in Section 11. Those additional procedures are optional, and defined in Section 11. Those additional procedures are optional, and
usages can elect to utilize them. First, a set of processing usages can elect to utilize them. First, a set of processing
operations is applied that is independent of the class. This is operations is applied that is independent of the class. This is
followed by class-specific processing, described in the subsections followed by class-specific processing, described in the subsections
that follow. that follow.
skipping to change at page 16, line 40 skipping to change at page 18, line 40
If the request contains one or more unknown comprehension-required If the request contains one or more unknown comprehension-required
attributes, the server replies with an error response with an error attributes, the server replies with an error response with an error
code of 420 (Unknown Attribute), and includes an UNKNOWN-ATTRIBUTES code of 420 (Unknown Attribute), and includes an UNKNOWN-ATTRIBUTES
attribute in the response that lists the unknown comprehension- attribute in the response that lists the unknown comprehension-
required attributes. required attributes.
The server then does any additional checking that the method or the The server then does any additional checking that the method or the
specific usage requires. If all the checks succeed, the server specific usage requires. If all the checks succeed, the server
formulates a success response as described below. formulates a success response as described below.
When run over UDP, a request received by the server could be the When run over UDP or DTLS-over-UDP or SCTP-over-UDP or SCTP-over-
first request of a transaction, or a retransmission. The server MUST DTLS-over-UDP, a request received by the server could be the first
request of a transaction, or a retransmission. The server MUST
respond to retransmissions such that the following property is respond to retransmissions such that the following property is
preserved: if the client receives the response to the retransmission preserved: if the client receives the response to the retransmission
and not the response that was sent to the original request, the and not the response that was sent to the original request, the
overall state on the client and server is identical to the case where overall state on the client and server is identical to the case where
only the response to the original retransmission is received, or only the response to the original retransmission is received, or
where both responses are received (in which case the client will use where both responses are received (in which case the client will use
the first). The easiest way to meet this requirement is for the the first). The easiest way to meet this requirement is for the
server to remember all transaction IDs received over UDP and their server to remember all transaction IDs received over UDP or DTLS-
corresponding responses in the last 40 seconds. However, this over-UDP and their corresponding responses in the last 40 seconds.
requires the server to hold state, and will be inappropriate for any
requests which are not authenticated. Another way is to reprocess However, this requires the server to hold state, and will be
the request and recompute the response. The latter technique MUST inappropriate for any requests which are not authenticated. Another
only be applied to requests that are idempotent (a request is way is to reprocess the request and recompute the response. The
considered idempotent when the same request can be safely repeated latter technique MUST only be applied to requests that are idempotent
without impacting the overall state of the system) and result in the (a request is considered idempotent when the same request can be
same success response for the same request. The Binding method is safely repeated without impacting the overall state of the system)
considered to be idempotent. Note that there are certain rare and result in the same success response for the same request. The
network events that could cause the reflexive transport address value Binding method is considered to be idempotent. Note that there are
to change, resulting in a different mapped address in different certain rare network events that could cause the reflexive transport
success responses. Extensions to STUN MUST discuss the implications address value to change, resulting in a different mapped address in
of request retransmissions on servers that do not store transaction different success responses. Extensions to STUN MUST discuss the
state. implications of request retransmissions on servers that do not store
transaction state.
6.3.1.1. Forming a Success or Error Response 6.3.1.1. Forming a Success or Error Response
When forming the response (success or error), the server follows the When forming the response (success or error), the server follows the
rules of Section 6. The method of the response is the same as that rules of Section 6. The method of the response is the same as that
of the request, and the message class is either "Success Response" or of the request, and the message class is either "Success Response" or
"Error Response". "Error Response".
For an error response, the server MUST add an ERROR-CODE attribute For an error response, the server MUST add an ERROR-CODE attribute
containing the error code specified in the processing above. The containing the error code specified in the processing above. The
skipping to change at page 17, line 47 skipping to change at page 19, line 49
attributes to the response (see Section 9). attributes to the response (see Section 9).
The server also adds any attributes required by the specific method The server also adds any attributes required by the specific method
or usage. In addition, the server SHOULD add a SOFTWARE attribute to or usage. In addition, the server SHOULD add a SOFTWARE attribute to
the message. the message.
For the Binding method, no additional checking is required unless the For the Binding method, no additional checking is required unless the
usage specifies otherwise. When forming the success response, the usage specifies otherwise. When forming the success response, the
server adds a XOR-MAPPED-ADDRESS attribute to the response, where the server adds a XOR-MAPPED-ADDRESS attribute to the response, where the
contents of the attribute are the source transport address of the contents of the attribute are the source transport address of the
request message. For UDP, this is the source IP address and source request message. For UDP and DTLS-over-UDP, this is the source IP
UDP port of the request message. For TCP and TLS-over-TCP, this is address and source UDP port of the request message. For TCP and TLS-
the source IP address and source TCP port of the TCP connection as over-TCP, this is the source IP address and source TCP port of the
seen by the server. TCP connection as seen by the server.
6.3.1.2. Sending the Success or Error Response 6.3.1.2. Sending the Success or Error Response
The response (success or error) is sent over the same transport as The response (success or error) is sent over the same transport as
the request was received on. If the request was received over UDP, the request was received on. If the request was received over UDP or
the destination IP address and port of the response are the source IP DTLS-over-UDP, the destination IP address and port of the response
address and port of the received request message, and the source IP are the source IP address and port of the received request message,
address and port of the response are equal to the destination IP and the source IP address and port of the response are equal to the
address and port of the received request message. If the request was destination IP address and port of the received request message. If
received over TCP or TLS-over-TCP, the response is sent back on the the request was received over TCP or TLS-over-TCP, the response is
same TCP connection as the request was received on. sent back on the same TCP connection as the request was received on.
6.3.2. Processing an Indication 6.3.2. Processing an Indication
If the indication contains unknown comprehension-required attributes, If the indication contains unknown comprehension-required attributes,
the indication is discarded and processing ceases. the indication is discarded and processing ceases.
The agent then does any additional checking that the method or the The agent then does any additional checking that the method or the
specific usage requires. If all the checks succeed, the agent then specific usage requires. If all the checks succeed, the agent then
processes the indication. No response is generated for an processes the indication. No response is generated for an
indication. indication.
For the Binding method, no additional checking or processing is For the Binding method, no additional checking or processing is
required, unless the usage specifies otherwise. The mere receipt of required, unless the usage specifies otherwise. The mere receipt of
the message by the agent has refreshed the "bindings" in the the message by the agent has refreshed the "bindings" in the
intervening NATs. intervening NATs.
Since indications are not re-transmitted over UDP (unlike requests), Since indications are not re-transmitted over UDP or DTLS-over-UDP
there is no need to handle re-transmissions of indications at the (unlike requests), there is no need to handle re-transmissions of
sending agent. indications at the sending agent.
6.3.3. Processing a Success Response 6.3.3. Processing a Success Response
If the success response contains unknown comprehension-required If the success response contains unknown comprehension-required
attributes, the response is discarded and the transaction is attributes, the response is discarded and the transaction is
considered to have failed. considered to have failed.
The client then does any additional checking that the method or the The client then does any additional checking that the method or the
specific usage requires. If all the checks succeed, the client then specific usage requires. If all the checks succeed, the client then
processes the success response. processes the success response.
skipping to change at page 20, line 22 skipping to change at page 22, line 22
contains the correct value. Section 6.3 describes when in the contains the correct value. Section 6.3 describes when in the
overall processing of a STUN message the FINGERPRINT check is overall processing of a STUN message the FINGERPRINT check is
performed. This additional check helps the agent detect messages of performed. This additional check helps the agent detect messages of
other protocols that might otherwise seem to be STUN messages. other protocols that might otherwise seem to be STUN messages.
8. DNS Discovery of a Server 8. DNS Discovery of a Server
This section describes an optional procedure for STUN that allows a This section describes an optional procedure for STUN that allows a
client to use DNS to determine the IP address and port of a server. client to use DNS to determine the IP address and port of a server.
A STUN usage must describe if and when this extension is used. To A STUN usage must describe if and when this extension is used. To
use this procedure, the client must know a server's domain name and a use this procedure, the client must know a STUN URI [RFC7064]; the
service name; the usage must also describe how the client obtains usage must also describe how the client obtains this URI. Hard-
these. Hard-coding the domain name of the server into software is coding a STUN URI into software is NOT RECOMMENDED in case the domain
NOT RECOMMENDED in case the domain name is lost or needs to change name is lost or needs to change for legal or other reasons.
for legal or other reasons.
When a client wishes to locate a STUN server in the public Internet When a client wishes to locate a STUN server on the public Internet
that accepts Binding request/response transactions, the SRV service that accepts Binding request/response transactions, the STUN URI
name is "stun". When it wishes to locate a STUN server that accepts scheme is "stun". When it wishes to locate a STUN server that
Binding request/response transactions over a TLS session, the SRV accepts Binding request/response transactions over a TLS, or DTLS, or
service name is "stuns". STUN usages MAY define additional DNS SRV SCTP-over-DTLS session, the URI scheme is "stuns".
service names.
The domain name is resolved to a transport address using the SRV The syntax of the "stun" and "stuns" URIs are defined in Section 3.1
of [RFC7064]. STUN usages MAY define additional URI schemes.
8.1. STUN URI Scheme Semantics
If the <host> part contains an IP address, then this IP address is
used directly to contact the server. A "stuns" URI containing an IP
address MUST be rejected, unless the domain name is provided by the
same mechanism that provided the STUN URI, and that domain name can
be passed to the verification code.
If the URI does not contain an IP address, the domain name contained
in the <host> part is resolved to a transport address using the SRV
procedures specified in [RFC2782]. The DNS SRV service name is the procedures specified in [RFC2782]. The DNS SRV service name is the
service name provided as input to this procedure. The protocol in content of the <host> part. The protocol in the SRV lookup is the
the SRV lookup is the transport protocol the client will run STUN transport protocol the client will run STUN over: "udp" for UDP,
over: "udp" for UDP and "tcp" for TCP. Note that only "tcp" is "tcp" for TCP, and "sctp-udp" for SCTP-over-UDP.
defined with "stuns" at this time.
The procedures of RFC 2782 are followed to determine the server to The procedures of RFC 2782 are followed to determine the server to
contact. RFC 2782 spells out the details of how a set of SRV records contact. RFC 2782 spells out the details of how a set of SRV records
is sorted and then tried. However, RFC 2782 only states that the is sorted and then tried. However, RFC 2782 only states that the
client should "try to connect to the (protocol, address, service)" client should "try to connect to the (protocol, address, service)"
without giving any details on what happens in the event of failure. without giving any details on what happens in the event of failure.
When following these procedures, if the STUN transaction times out When following these procedures, if the STUN transaction times out
without receipt of a response, the client SHOULD retry the request to without receipt of a response, the client SHOULD retry the request to
the next server in the ordered defined by RFC 2782. Such a retry is the next server in the ordered defined by RFC 2782. Such a retry is
only possible for request/response transmissions, since indication only possible for request/response transmissions, since indication
transactions generate no response or timeout. transactions generate no response or timeout.
The default port for STUN requests is 3478, for both TCP and UDP. The default port for STUN requests is 3478, for both TCP and UDP.
The default port for STUN over TLS and STUN over DTLS requests is
5349. The default port for STUN over SCTP-over-UDP requests is XXXX.
The default port for STUN over SCTP-over-DTLS-over-UDP requests is
XXXX. Servers can run STUN over DTLS on the same port as STUN over
UDP if the server software supports determining whether the initial
message is a DTLS or STUN message. Servers can run STUN over TLS on
the same port as STUN over TCP if the server software supports
determining whether the initial message is a TLS or STUN message.
Administrators of STUN servers SHOULD use this port in their SRV Administrators of STUN servers SHOULD use these ports in their SRV
records for UDP and TCP. In all cases, the port in DNS MUST reflect records for UDP and TCP. In all cases, the port in DNS MUST reflect
the one on which the server is listening. The default port for STUN the one on which the server is listening.
over TLS is 5349. Servers can run STUN over TLS on the same port as
STUN over TCP if the server software supports determining whether the
initial message is a TLS or STUN message.
If no SRV records were found, the client performs an A or AAAA record If no SRV records were found, the client performs an A or AAAA record
lookup of the domain name. The result will be a list of IP lookup of the domain name. The result will be a list of IP
addresses, each of which can be contacted at the default port using addresses, each of which can be contacted at the default port using
UDP or TCP, independent of the STUN usage. For usages that require UDP or TCP, independent of the STUN usage. For usages that require
TLS, the client connects to one of the IP addresses using the default TLS, the client connects to one of the IP addresses using the default
STUN over TLS port. STUN over TLS port. For usages that require DTLS, the client
connects to one of the IP addresses using the default STUN over DTLS
port.
9. Authentication and Message-Integrity Mechanisms 9. Authentication and Message-Integrity Mechanisms
This section defines two mechanisms for STUN that a client and server This section defines two mechanisms for STUN that a client and server
can use to provide authentication and message integrity; these two can use to provide authentication and message integrity; these two
mechanisms are known as the short-term credential mechanism and the mechanisms are known as the short-term credential mechanism and the
long-term credential mechanism. These two mechanisms are optional, long-term credential mechanism. These two mechanisms are optional,
and each usage must specify if and when these mechanisms are used. and each usage must specify if and when these mechanisms are used.
Consequently, both clients and servers will know which mechanism (if Consequently, both clients and servers will know which mechanism (if
any) to follow based on knowledge of which usage applies. For any) to follow based on knowledge of which usage applies. For
skipping to change at page 22, line 10 skipping to change at page 24, line 28
As an example, in the ICE usage [RFC5245], the two endpoints use out- As an example, in the ICE usage [RFC5245], the two endpoints use out-
of-band signaling to agree on a username and password, and this of-band signaling to agree on a username and password, and this
username and password are applicable for the duration of the media username and password are applicable for the duration of the media
session. session.
This credential is used to form a message-integrity check in each This credential is used to form a message-integrity check in each
request and in many responses. There is no challenge and response as request and in many responses. There is no challenge and response as
in the long-term mechanism; consequently, replay is prevented by in the long-term mechanism; consequently, replay is prevented by
virtue of the time-limited nature of the credential. virtue of the time-limited nature of the credential.
9.1.1. Forming a Request or Indication 9.1.1. HMAC Key
For short-term credentials the HMAC key is defined as follow:
key = SASLprep(password)
where SASLprep() is defined in RFC 4013 [RFC4013].
9.1.2. Forming a Request or Indication
For a request or indication message, the agent MUST include the For a request or indication message, the agent MUST include the
USERNAME and MESSAGE-INTEGRITY attributes in the message. The HMAC USERNAME, MESSAGE-INTEGRITY2, and MESSAGE-INTEGRITY attributes in the
for the MESSAGE-INTEGRITY attribute is computed as described in message. The HMAC for the MESSAGE-INTEGRITY attribute is computed as
Section 14.4. Note that the password is never included in the described in Section 14.4 and the HMAC for the MESSAGE-INTEGRITY2
request or indication. attributes is computed as described in Section 14.5. Note that the
password is never included in the request or indication.
9.1.2. Receiving a Request or Indication 9.1.3. Receiving a Request or Indication
After the agent has done the basic processing of a message, the agent After the agent has done the basic processing of a message, the agent
performs the checks listed below in order specified: performs the checks listed below in order specified:
o If the message does not contain both a MESSAGE-INTEGRITY and a o If the message does not contain 1) a MESSAGE-INTEGRITY or a
USERNAME attribute: MESSAGE-INTEGRITY2 attribute and 2) a USERNAME attribute:
* If the message is a request, the server MUST reject the request * If the message is a request, the server MUST reject the request
with an error response. This response MUST use an error code with an error response. This response MUST use an error code
of 400 (Bad Request). of 400 (Bad Request).
* If the message is an indication, the agent MUST silently * If the message is an indication, the agent MUST silently
discard the indication. discard the indication.
o If the USERNAME does not contain a username value currently valid o If the USERNAME does not contain a username value currently valid
within the server: within the server:
* If the message is a request, the server MUST reject the request * If the message is a request, the server MUST reject the request
with an error response. This response MUST use an error code with an error response. This response MUST use an error code
of 401 (Unauthorized). of 401 (Unauthorized).
* If the message is an indication, the agent MUST silently * If the message is an indication, the agent MUST silently
discard the indication. discard the indication.
o Using the password associated with the username, compute the value o If the MESSAGE-INTEGRITY2 attribute is present compute the value
for the message integrity as described in Section 14.4. If the for the message integrity as described in Section 14.5, using the
resulting value does not match the contents of the MESSAGE- password associated with the username. If the MESSAGE-INTEGRITY2
INTEGRITY attribute: attribute is not present, and using the same password, compute the
value for the message integrity as described in Section 14.4. If
the resulting value does not match the contents of the MESSAGE-
INTEGRITY2 attribute or the MESSAGE-INTEGRITY attribute:
* If the message is a request, the server MUST reject the request * If the message is a request, the server MUST reject the request
with an error response. This response MUST use an error code with an error response. This response MUST use an error code
of 401 (Unauthorized). of 401 (Unauthorized).
* If the message is an indication, the agent MUST silently * If the message is an indication, the agent MUST silently
discard the indication. discard the indication.
If these checks pass, the agent continues to process the request or If these checks pass, the agent continues to process the request or
indication. Any response generated by a server MUST include the indication. Any response generated by a server to a request that
MESSAGE-INTEGRITY attribute, computed using the password utilized to contains a MESSAGE-INTEGRITY2 attribute MUST include the MESSAGE-
authenticate the request. The response MUST NOT contain the USERNAME INTEGRITY2 attribute, computed using the password utilized to
attribute. authenticate the request. Any response generated by a server to a
request that contains only a MESSAGE-INTEGRITY attribute MUST include
the MESSAGE-INTEGRITY attribute, computed using the password utilized
to authenticate the request. The response MUST NOT contain the
USERNAME attribute.
If any of the checks fail, a server MUST NOT include a MESSAGE- If any of the checks fail, a server MUST NOT include a MESSAGE-
INTEGRITY or USERNAME attribute in the error response. This is INTEGRITY2, MESSAGE-INTEGRITY, or USERNAME attribute in the error
because, in these failure cases, the server cannot determine the response. This is because, in these failure cases, the server cannot
shared secret necessary to compute MESSAGE-INTEGRITY. determine the shared secret necessary to compute the MESSAGE-
INTEGRITY2 or MESSAGE-INTEGRITY attributes.
9.1.3. Receiving a Response 9.1.4. Receiving a Response
The client looks for the MESSAGE-INTEGRITY attribute in the response. The client looks for the MESSAGE-INTEGRITY2 or the MESSAGE-INTEGRITY
If present, the client computes the message integrity over the attribute in the response. If present, the client computes the
response as defined in Section 14.4, using the same password it message integrity over the response as defined in Section 14.4 or
utilized for the request. If the resulting value matches the Section 14.5, using the same password it utilized for the request.
contents of the MESSAGE-INTEGRITY attribute, the response is If the resulting value matches the contents of the MESSAGE-INTEGRITY
considered authenticated. If the value does not match, or if or MESSAGE-INTEGRITY2 attribute, the response is considered
MESSAGE-INTEGRITY was absent, the response MUST be discarded, as if authenticated. If the value does not match, or if both MESSAGE-
it was never received. This means that retransmits, if applicable, INTEGRITY and MESSAGE-INTEGRITY2 were absent, the response MUST be
will continue. discarded, as if it was never received. This means that retransmits,
if applicable, will continue.
9.1.5. Sending Subsequent Requests
A client sending subsequent requests to the same server a MAY choose
to send only the MESSAGE-INTEGRITY2 or the MESSAGE-INTEGRITY
attribute depending upon the attribute that was received in the
response to the initial request.
9.2. Long-Term Credential Mechanism 9.2. Long-Term Credential Mechanism
The long-term credential mechanism relies on a long-term credential, The long-term credential mechanism relies on a long-term credential,
in the form of a username and password that are shared between client in the form of a username and password that are shared between client
and server. The credential is considered long-term since it is and server. The credential is considered long-term since it is
assumed that it is provisioned for a user, and remains in effect assumed that it is provisioned for a user, and remains in effect
until the user is no longer a subscriber of the system, or is until the user is no longer a subscriber of the system, or is
changed. This is basically a traditional "log-in" username and changed. This is basically a traditional "log-in" username and
password given to users. password given to users.
skipping to change at page 24, line 28 skipping to change at page 27, line 24
authentication and message integrity for them. authentication and message integrity for them.
Since the long-term credential mechanism is susceptible to offline Since the long-term credential mechanism is susceptible to offline
dictionary attacks, deployments SHOULD utilize passwords that are dictionary attacks, deployments SHOULD utilize passwords that are
difficult to guess. In cases where the credentials are not entered difficult to guess. In cases where the credentials are not entered
by the user, but are rather placed on a client device during device by the user, but are rather placed on a client device during device
provisioning, the password SHOULD have at least 128 bits of provisioning, the password SHOULD have at least 128 bits of
randomness. In cases where the credentials are entered by the user, randomness. In cases where the credentials are entered by the user,
they should follow best current practices around password structure. they should follow best current practices around password structure.
9.2.1. Forming a Request 9.2.1. HMAC Key
For long-term credentials that do not use a different algorithm, as
specified by the PASSWORD-ALGORITHM attribute, the key is 16 bytes:
key = MD5(username ":" realm ":" SASLprep(password))
Where MD5 is defined in RFC 1321 [RFC1321] and SASLprep() is defined
in RFC 4013 [RFC4013].
The 16-byte key is formed by taking the MD5 hash of the result of
concatenating the following five fields: (1) the username, with any
quotes and trailing nulls removed, as taken from the USERNAME
attribute (in which case SASLprep has already been applied); (2) a
single colon; (3) the realm, with any quotes and trailing nulls
removed; (4) a single colon; and (5) the password, with any trailing
nulls removed and after processing using SASLprep. For example, if
the username was 'user', the realm was 'realm', and the password was
'pass', then the 16-byte HMAC key would be the result of performing
an MD5 hash on the string 'user:realm:pass', the resulting hash being
0x8493fbc53ba582fb4c044c456bdc40eb.
The structure of the key when used with long-term credentials
facilitates deployment in systems that also utilize SIP. Typically,
SIP systems utilizing SIP's digest authentication mechanism do not
actually store the password in the database. Rather, they store a
value called H(A1), which is equal to the key defined above.
When a PASSWORD-ALGORITHM is used, the key length and algorithm to
use are described in Section 17.4.1.
9.2.2. Forming a Request
There are two cases when forming a request. In the first case, this There are two cases when forming a request. In the first case, this
is the first request from the client to the server (as identified by is the first request from the client to the server (as identified by
its IP address and port). In the second case, the client is its IP address and port). In the second case, the client is
submitting a subsequent request once a previous request/response submitting a subsequent request once a previous request/response
transaction has completed successfully. Forming a request as a transaction has completed successfully. Forming a request as a
consequence of a 401 or 438 error response is covered in consequence of a 401 or 438 error response is covered in
Section 9.2.3 and is not considered a "subsequent request" and thus Section 9.2.4 and is not considered a "subsequent request" and thus
does not utilize the rules described in Section 9.2.1.2. does not utilize the rules described in Section 9.2.2.2.
9.2.1.1. First Request 9.2.2.1. First Request
If the client has not completed a successful request/response If the client has not completed a successful request/response
transaction with the server (as identified by hostname, if the DNS transaction with the server (as identified by hostname, if the DNS
procedures of Section 8 are used, else IP address if not), it SHOULD procedures of Section 8 are used, else IP address if not), it SHOULD
omit the USERNAME, MESSAGE-INTEGRITY, REALM, and NONCE attributes. omit the USERNAME, MESSAGE-INTEGRITY, MESSAGE-INTEGRITY2, REALM,
In other words, the very first request is sent as if there were no NONCE, PASSWORD-ALGORITHMS, and PASSWORD-ALGORITHM attributes. In
other words, the very first request is sent as if there were no
authentication or message integrity applied. authentication or message integrity applied.
9.2.1.2. Subsequent Requests 9.2.2.2. Subsequent Requests
Once a request/response transaction has completed successfully, the Once a request/response transaction has completed successfully, the
client will have been presented a realm and nonce by the server, and client will have been presented a realm and nonce by the server, and
selected a username and password with which it authenticated. The selected a username and password with which it authenticated. The
client SHOULD cache the username, password, realm, and nonce for client SHOULD cache the username, password, realm, and nonce for
subsequent communications with the server. When the client sends a subsequent communications with the server. When the client sends a
subsequent request, it SHOULD include the USERNAME, REALM, and NONCE subsequent request, it SHOULD include the USERNAME, REALM, NONCE, and
attributes with these cached values. It SHOULD include a MESSAGE- PASSWORD-ALGORITHM attributes with these cached values. It SHOULD
INTEGRITY attribute, computed as described in Section 14.4 using the include a MESSAGE-INTEGRITY attribute or a MESSAGE-INTEGRITY2
cached password. attribute, computed as described in Section 14.4 and Section 14.5
using the cached password. The choice between the two attributes
depends on the attribute received in the response to the first
request.
9.2.2. Receiving a Request 9.2.3. Receiving a Request
After the server has done the basic processing of a request, it After the server has done the basic processing of a request, it
performs the checks listed below in the order specified: performs the checks listed below in the order specified:
o If the message does not contain a MESSAGE-INTEGRITY attribute, the o If the message does not contain a MESSAGE-INTEGRITY or MESSAGE-
server MUST generate an error response with an error code of 401 INTEGRITY2 attribute, the server MUST generate an error response
(Unauthorized). This response MUST include a REALM value. It is with an error code of 401 (Unauthorized). This response MUST
RECOMMENDED that the REALM value be the domain name of the include a REALM value. It is RECOMMENDED that the REALM value be
provider of the STUN server. The response MUST include a NONCE, the domain name of the provider of the STUN server. The response
selected by the server. The response SHOULD NOT contain a MUST include a NONCE, selected by the server. The server MAY
USERNAME or MESSAGE-INTEGRITY attribute. support alternate password algorithms, in which case it can list
them in preferential order in a PASSWORD-ALGORITHMS attribute. If
the server adds a PASSWORD-ALGORITHMS attribute it MUST prepend
the NONCE attribute value with the chracater string "obMatJos2".
The response SHOULD NOT contain a USERNAME, MESSAGE-INTEGRITY or
MESSAGE-INTEGRITY2 attribute.
o If the message contains a MESSAGE-INTEGRITY attribute, but is o If the message contains a MESSAGE-INTEGRITY or a MESSAGE-
missing the USERNAME, REALM, or NONCE attribute, the server MUST INTEGRITY2 attribute, but is missing the USERNAME, REALM, or NONCE
generate an error response with an error code of 400 (Bad attribute, the server MUST generate an error response with an
Request). This response SHOULD NOT include a USERNAME, NONCE, error code of 400 (Bad Request). This response SHOULD NOT include
REALM, or MESSAGE-INTEGRITY attribute. a USERNAME, NONCE, REALM, MESSAGE-INTEGRITY or MESSAGE-INTEGRITY2
attribute.
o If the NONCE attribute starts with the value "obMatJos2" but the
PASSWORD-ALGORITHMS attribute is not present or is not identical
to the PASSWORD-ALGORITHMS attribute sent in the response, the
server MUST generate an error response with an error code of 400
(Bad Request). This response SHOULD NOT include a USERNAME,
NONCE, REALM, MESSAGE-INTEGRITY, or MESSAGE-INTEGRITY2 attribute.
o If the NONCE is no longer valid, the server MUST generate an error o If the NONCE is no longer valid, the server MUST generate an error
response with an error code of 438 (Stale Nonce). This response response with an error code of 438 (Stale Nonce). This response
MUST include NONCE and REALM attributes and SHOULD NOT include the MUST include NONCE and REALM attributes and SHOULD NOT include the
USERNAME or MESSAGE-INTEGRITY attribute. Servers can invalidate USERNAME, MESSAGE-INTEGRITY, or MESSAGE-INTEGRITY2 attribute.
nonces in order to provide additional security. See Section 4.3 Servers can invalidate nonces in order to provide additional
of [RFC2617] for guidelines. security. See Section 4.3 of [RFC2617] for guidelines.
o If the username in the USERNAME attribute is not valid, the server o If the username in the USERNAME attribute is not valid, the server
MUST generate an error response with an error code of 401 MUST generate an error response with an error code of 401
(Unauthorized). This response MUST include a REALM value. It is (Unauthorized). This response MUST include a REALM value. It is
RECOMMENDED that the REALM value be the domain name of the RECOMMENDED that the REALM value be the domain name of the
provider of the STUN server. The response MUST include a NONCE, provider of the STUN server. The response MUST include a NONCE,
selected by the server. The response SHOULD NOT contain a selected by the server. The response SHOULD NOT contain a
USERNAME or MESSAGE-INTEGRITY attribute. USERNAME, MESSAGE-INTEGRITY or MESSAGE-INTEGRITY2 attribute.
o Using the password associated with the username in the USERNAME o If the MESSAGE-INTEGRITY2 attribute is present compute the value
attribute, compute the value for the message integrity as for the message integrity as described in Section 14.5, using the
described in Section 14.4. If the resulting value does not match password associated with the username. Else, using the same
the contents of the MESSAGE-INTEGRITY attribute, the server MUST password, compute the value for the message integrity as described
reject the request with an error response. This response MUST use in Section 14.4. If the resulting value does not match the
an error code of 401 (Unauthorized). It MUST include REALM and contents of the MESSAGE-INTEGRITY attribute or the MESSAGE-
NONCE attributes and SHOULD NOT include the USERNAME or MESSAGE- INTEGRITY2 attribute, the server MUST reject the request with an
INTEGRITY attribute. error response. This response MUST use an error code of 401
(Unauthorized). It MUST include REALM and NONCE attributes and
SHOULD NOT include the USERNAME, MESSAGE-INTEGRITY, or MESSAGE-
INTEGRITY2 attribute.
If these checks pass, the server continues to process the request. If these checks pass, the server continues to process the request.
Any response generated by the server (excepting the cases described Any response generated by the server (excepting the cases described
above) MUST include the MESSAGE-INTEGRITY attribute, computed using above) MUST include both the MESSAGE-INTEGRITY and MESSAGE-INTEGRITY2
the username and password utilized to authenticate the request. The attributes, computed using the username and password utilized to
REALM, NONCE, and USERNAME attributes SHOULD NOT be included. authenticate the request. The REALM, NONCE, and USERNAME attributes
SHOULD NOT be included.
9.2.3. Receiving a Response 9.2.4. Receiving a Response
If the response is an error response with an error code of 401
(Unauthorized), the client MUST test if the NONCE attribute value
starts with the character string "obMatJos2". If the test succeeds
and no PASSWORD-ALGORITHMS attribute is present, then the client MUST
NOT retry the request with a new transaction.
If the response is an error response with an error code of 401 If the response is an error response with an error code of 401
(Unauthorized), the client SHOULD retry the request with a new (Unauthorized), the client SHOULD retry the request with a new
transaction. This request MUST contain a USERNAME, determined by the transaction. This request MUST contain a USERNAME, determined by the
client as the appropriate username for the REALM from the error client as the appropriate username for the REALM from the error
response. The request MUST contain the REALM, copied from the error response. The request MUST contain the REALM, copied from the error
response. The request MUST contain the NONCE, copied from the error response. The request MUST contain the NONCE, copied from the error
response. The request MUST contain the MESSAGE-INTEGRITY attribute, response. If the response contains a PASSWORD-ALGORITHMS attribute,
the request MUST contain the PASSWORD-ALGORITHMS attribute with the
same content. If the response contains a PASSWORD-ALGORITHMS
attribute, and this attribute contains at least one algorithm that is
supported by the client then the request MUST contain a PASSWORD-
ALGORITHM attribute with the first algorithm supported on the list.
if the response contains a MESSAGE-INTEGRITY2 attribute then the
request MUST contain a MESSAGE-INTEGRITY2 attribute, computed using
the password associated with the username in the USERNAME attribute.
Else the request MUST contain the MESSAGE-INTEGRITY attribute,
computed using the password associated with the username in the computed using the password associated with the username in the
USERNAME attribute. The client MUST NOT perform this retry if it is USERNAME attribute. The client MUST NOT perform this retry if it is
not changing the USERNAME or REALM or its associated password, from not changing the USERNAME or REALM or its associated password, from
the previous attempt. the previous attempt.
If the response is an error response with an error code of 438 (Stale If the response is an error response with an error code of 438 (Stale
Nonce), the client MUST retry the request, using the new NONCE Nonce), the client MUST retry the request, using the new NONCE
supplied in the 438 (Stale Nonce) response. This retry MUST also attribute supplied in the 438 (Stale Nonce) response. This retry
include the USERNAME, REALM, and MESSAGE-INTEGRITY. MUST also include the USERNAME, REALM and either the MESSAGE-
INTEGRITY or MESSAGE-INTEGRITY2 attributes.
The client looks for the MESSAGE-INTEGRITY attribute in the response The client looks for the MESSAGE-INTEGRITY or MESSAGE-INTEGRITY2
(either success or failure). If present, the client computes the attribute in the response (either success or failure). If present,
message integrity over the response as defined in Section 14.4, using the client computes the message integrity over the response as
the same password it utilized for the request. If the resulting defined in Section 14.4 or Section 14.5, using the same password it
value matches the contents of the MESSAGE-INTEGRITY attribute, the utilized for the request. If the resulting value matches the
response is considered authenticated. If the value does not match, contents of the MESSAGE-INTEGRITY or MESSAGE-INTEGRITY2 attribute,
or if MESSAGE-INTEGRITY was absent, the response MUST be discarded, the response is considered authenticated. If the value does not
as if it was never received. This means that retransmits, if match, or if both MESSAGE-INTEGRITY and MESSAGE-INTEGRITY2 were
applicable, will continue. absent, the response MUST be discarded, as if it was never received.
This means that retransmits, if applicable, will continue.
10. ALTERNATE-SERVER Mechanism 10. ALTERNATE-SERVER Mechanism
This section describes a mechanism in STUN that allows a server to This section describes a mechanism in STUN that allows a server to
redirect a client to another server. This extension is optional, and redirect a client to another server. This extension is optional, and
a usage must define if and when this extension is used. a usage must define if and when this extension is used.
A server using this extension redirects a client to another server by A server using this extension redirects a client to another server by
replying to a request message with an error response message with an replying to a request message with an error response message with an
error code of 300 (Try Alternate). The server MUST include an error code of 300 (Try Alternate). The server MUST include an
skipping to change at page 27, line 29 skipping to change at page 31, line 42
authenticated, MUST utilize the same credentials that the client authenticated, MUST utilize the same credentials that the client
would have used in the request to the server that performed the would have used in the request to the server that performed the
redirection. If the client has been redirected to a server on which redirection. If the client has been redirected to a server on which
it has already tried this request within the last five minutes, it it has already tried this request within the last five minutes, it
MUST ignore the redirection and consider the transaction to have MUST ignore the redirection and consider the transaction to have
failed. This prevents infinite ping-ponging between servers in case failed. This prevents infinite ping-ponging between servers in case
of redirection loops. of redirection loops.
11. Backwards Compatibility with RFC 3489 11. Backwards Compatibility with RFC 3489
This section defines procedures that allow a degree of backwards In addition to the backward compatibility already described in
compatibility with the original protocol defined in RFC 3489 Section 12 of [RFC5389], DTLS MUST NOT be used with RFC 3489 STUN
[RFC3489]. This mechanism is optional, meant to be utilized only in [RFC3489] (also referred to as "classic STUN"). Any STUN request or
cases where a new client can connect to an old server, or vice versa. indication without the magic cookie (see Section 6 of [RFC5389]) over
A usage must define if and when this procedure is used. DTLS MUST always result in an error.
Section 19 of [RFC5389] lists all the changes between this
specification and RFC 3489 [RFC3489]. However, not all of these
differences are important, because "classic STUN" was only used in a
few specific ways. For the purposes of this extension, the important
changes are the following. In RFC 3489:
o UDP was the only supported transport.
o The field that is now the magic cookie field was a part of the
transaction ID field, and transaction IDs were 128 bits long.
o The XOR-MAPPED-ADDRESS attribute did not exist, and the Binding
method used the MAPPED-ADDRESS attribute instead.
o There were three comprehension-required attributes, RESPONSE-
ADDRESS, CHANGE-REQUEST, and CHANGED-ADDRESS, that have been
removed from this specification.
* CHANGE-REQUEST and CHANGED-ADDRESS are now part of the NAT
Behavior Discovery usage [RFC5780], and the other is
deprecated.
11.1. Changes to Client Processing
A client that wants to interoperate with an [RFC3489] server SHOULD
send a request message that uses the Binding method, contains no
attributes, and uses UDP as the transport protocol to the server. If
successful, the success response received from the server will
contain a MAPPED-ADDRESS attribute rather than an XOR-MAPPED-ADDRESS
attribute. A client seeking to interoperate with an older server
MUST be prepared to receive either. Furthermore, the client MUST
ignore any Reserved comprehension-required attributes that might
appear in the response. Of the Reserved attributes in Section 17.2,
0x0002, 0x0004, 0x0005, and 0x000B may appear in Binding responses
from a server compliant to RFC 3489. Other than this change, the
processing of the response is identical to the procedures described
above.
11.2. Changes to Server Processing
A STUN server can detect when a given Binding request message was
sent from an RFC 3489 [RFC3489] client by the absence of the correct
value in the magic cookie field. When the server detects an RFC 3489
client, it SHOULD copy the value seen in the magic cookie field in
the Binding request to the magic cookie field in the Binding response
message, and insert a MAPPED-ADDRESS attribute instead of an XOR-
MAPPED-ADDRESS attribute.
The client might, in rare situations, include either the RESPONSE-
ADDRESS or CHANGE-REQUEST attributes. In these situations, the
server will view these as unknown comprehension-required attributes
and reply with an error response. Since the mechanisms utilizing
those attributes are no longer supported, this behavior is
acceptable.
The RFC 3489 version of STUN lacks both the magic cookie and the
FINGERPRINT attribute that allows for a very high probability of
correctly identifying STUN messages when multiplexed with other
protocols. Therefore, STUN implementations that are backwards
compatible with RFC 3489 SHOULD NOT be used in cases where STUN will
be multiplexed with another protocol. However, that should not be an
issue as such multiplexing was not available in RFC 3489.
12. Basic Server Behavior 12. Basic Server Behavior
This section defines the behavior of a basic, stand-alone STUN This section defines the behavior of a basic, stand-alone STUN
server. A basic STUN server provides clients with server reflexive server. A basic STUN server provides clients with server reflexive
transport addresses by receiving and replying to STUN Binding transport addresses by receiving and replying to STUN Binding
requests. requests.
The STUN server MUST support the Binding method. It SHOULD NOT The STUN server MUST support the Binding method. It SHOULD NOT
utilize the short-term or long-term credential mechanism. This is utilize the short-term or long-term credential mechanism. This is
because the work involved in authenticating the request is more than because the work involved in authenticating the request is more than
the work in simply processing it. It SHOULD NOT utilize the the work in simply processing it. It SHOULD NOT utilize the
ALTERNATE-SERVER mechanism for the same reason. It MUST support UDP ALTERNATE-SERVER mechanism for the same reason. It MUST support UDP
and TCP. It MAY support STUN over TCP/TLS; however, TLS provides and TCP. It MAY support STUN over TCP/TLS or STUN over UDP/DTLS;
minimal security benefits in this basic mode of operation. It MAY however, DTLS and TLS provide minimal security benefits in this basic
utilize the FINGERPRINT mechanism but MUST NOT require it. Since the mode of operation. It MAY utilize the FINGERPRINT mechanism but MUST
stand-alone server only runs STUN, FINGERPRINT provides no benefit. NOT require it. Since the stand-alone server only runs STUN,
Requiring it would break compatibility with RFC 3489, and such FINGERPRINT provides no benefit. Requiring it would break
compatibility is desirable in a stand-alone server. Stand-alone STUN compatibility with RFC 3489, and such compatibility is desirable in a
servers SHOULD support backwards compatibility with [RFC3489] stand-alone server. Stand-alone STUN servers SHOULD support
clients, as described in Section 11. backwards compatibility with [RFC3489] clients, as described in
Section 11.
It is RECOMMENDED that administrators of STUN servers provide DNS It is RECOMMENDED that administrators of STUN servers provide DNS
entries for those servers as described in Section 8. entries for those servers as described in Section 8.
A basic STUN server is not a solution for NAT traversal by itself. A basic STUN server is not a solution for NAT traversal by itself.
However, it can be utilized as part of a solution through STUN However, it can be utilized as part of a solution through STUN
usages. This is discussed further in Section 13. usages. This is discussed further in Section 13.
13. STUN Usages 13. STUN Usages
skipping to change at page 29, line 52 skipping to change at page 33, line 5
connections for SIP [RFC5626], and NAT Behavior Discovery [RFC5780]. connections for SIP [RFC5626], and NAT Behavior Discovery [RFC5780].
Other STUN usages may be defined in the future. Other STUN usages may be defined in the future.
A STUN usage defines how STUN is actually utilized -- when to send A STUN usage defines how STUN is actually utilized -- when to send
requests, what to do with the responses, and which optional requests, what to do with the responses, and which optional
procedures defined here (or in an extension to STUN) are to be used. procedures defined here (or in an extension to STUN) are to be used.
A usage would also define: A usage would also define:
o Which STUN methods are used. o Which STUN methods are used.
o What transports are used. If DTLS-over-UDP is used then
implementing the denial-of-service countermeasure described in
Section 4.2.1 of [RFC6347] is mandatory.
o What authentication and message-integrity mechanisms are used. o What authentication and message-integrity mechanisms are used.
o The considerations around manual vs. automatic key derivation for o The considerations around manual vs. automatic key derivation for
the integrity mechanism, as discussed in [RFC4107]. the integrity mechanism, as discussed in [RFC4107].
o What mechanisms are used to distinguish STUN messages from other o What mechanisms are used to distinguish STUN messages from other
messages. When STUN is run over TCP, a framing mechanism may be messages. When STUN is run over TCP, a framing mechanism may be
required. required.
o How a STUN client determines the IP address and port of the STUN o How a STUN client determines the IP address and port of the STUN
skipping to change at page 33, line 38 skipping to change at page 37, line 8
The MESSAGE-INTEGRITY attribute contains an HMAC-SHA1 [RFC2104] of The MESSAGE-INTEGRITY attribute contains an HMAC-SHA1 [RFC2104] of
the STUN message. The MESSAGE-INTEGRITY attribute can be present in the STUN message. The MESSAGE-INTEGRITY attribute can be present in
any STUN message type. Since it uses the SHA1 hash, the HMAC will be any STUN message type. Since it uses the SHA1 hash, the HMAC will be
20 bytes. The text used as input to HMAC is the STUN message, 20 bytes. The text used as input to HMAC is the STUN message,
including the header, up to and including the attribute preceding the including the header, up to and including the attribute preceding the
MESSAGE-INTEGRITY attribute. With the exception of the MESSAGE- MESSAGE-INTEGRITY attribute. With the exception of the MESSAGE-
INTEGRITY2 and FINGERPRINT attributes, which appear after MESSAGE- INTEGRITY2 and FINGERPRINT attributes, which appear after MESSAGE-
INTEGRITY, agents MUST ignore all other attributes that follow INTEGRITY, agents MUST ignore all other attributes that follow
MESSAGE-INTEGRITY. MESSAGE-INTEGRITY.
The key for the HMAC depends on whether long-term or short-term The key for the HMAC depends on which credential mechanism is in use.
credentials are in use. For long-term credentials, the key is 16 Section 9.1.1 defines the key for the short-term credential mechanism
bytes: and Section 9.2.1 defines the key for the long-term credential
mechanism. Other credential mechanisms MUST define the key that is
key = MD5(username ":" realm ":" SASLprep(password)) used for the HMAC.
That is, the 16-byte key is formed by taking the MD5 hash of the
result of concatenating the following five fields: (1) the username,
with any quotes and trailing nulls removed, as taken from the
USERNAME attribute (in which case SASLprep has already been applied);
(2) a single colon; (3) the realm, with any quotes and trailing nulls
removed; (4) a single colon; and (5) the password, with any trailing
nulls removed and after processing using SASLprep. For example, if
the username was 'user', the realm was 'realm', and the password was
'pass', then the 16-byte HMAC key would be the result of performing
an MD5 hash on the string 'user:realm:pass', the resulting hash being
0x8493fbc53ba582fb4c044c456bdc40eb.
For short-term credentials:
key = SASLprep(password)
where MD5 is defined in RFC 1321 [RFC1321] and SASLprep() is defined
in RFC 4013 [RFC4013].
The structure of the key when used with long-term credentials
facilitates deployment in systems that also utilize SIP. Typically,
SIP systems utilizing SIP's digest authentication mechanism do not
actually store the password in the database. Rather, they store a
value called H(A1), which is equal to the key defined above.
Based on the rules above, the hash used to construct MESSAGE- Based on the rules above, the hash used to construct MESSAGE-
INTEGRITY includes the length field from the STUN message header. INTEGRITY includes the length field from the STUN message header.
Prior to performing the hash, the MESSAGE-INTEGRITY attribute MUST be Prior to performing the hash, the MESSAGE-INTEGRITY attribute MUST be
inserted into the message (with dummy content). The length MUST then inserted into the message (with dummy content). The length MUST then
be set to point to the length of the message up to, and including, be set to point to the length of the message up to, and including,
the MESSAGE-INTEGRITY attribute itself, but excluding any attributes the MESSAGE-INTEGRITY attribute itself, but excluding any attributes
after it. Once the computation is performed, the value of the after it. Once the computation is performed, the value of the
MESSAGE-INTEGRITY attribute can be filled in, and the value of the MESSAGE-INTEGRITY attribute can be filled in, and the value of the
length in the STUN header can be set to its correct value -- the length in the STUN header can be set to its correct value -- the
length of the entire message. Similarly, when validating the length of the entire message. Similarly, when validating the
MESSAGE-INTEGRITY, the length field should be adjusted to point to MESSAGE-INTEGRITY, the length field should be adjusted to point to
the end of the MESSAGE-INTEGRITY attribute prior to calculating the the end of the MESSAGE-INTEGRITY attribute prior to calculating the
HMAC. Such adjustment is necessary when attributes, such as HMAC. Such adjustment is necessary when attributes, such as
FINGERPRINT, appear after MESSAGE-INTEGRITY. FINGERPRINT, appear after MESSAGE-INTEGRITY.
14.5. MESSAGE-INTEGRITY2 14.5. MESSAGE-INTEGRITY2
The MESSAGE-INTEGRITY2 attribute contains an HMAC-SHA-256 [RFC2104] The MESSAGE-INTEGRITY2 attribute contains an HMAC-SHA-256 [RFC2104]
of the STUN message. The MESSAGE-INTEGRITY attribute can be present of the STUN message. The MESSAGE-INTEGRITY2 attribute can be present
in any STUN message type. Since it uses the SHA-256 hash, the HMAC in any STUN message type. Since it uses the SHA-256 hash, the HMAC
will be 32 bytes. The text used as input to HMAC is the STUN will be 32 bytes. The text used as input to HMAC is the STUN
message, including the header, up to and including the attribute message, including the header, up to and including the attribute
preceding the MESSAGE-INTEGRITY2 attribute. With the exception of preceding the MESSAGE-INTEGRITY2 attribute. With the exception of
the FINGERPRINT attribute, which appears after MESSAGE-INTEGRITY2, the FINGERPRINT attribute, which appears after MESSAGE-INTEGRITY2,
agents MUST ignore all other attributes that follow MESSAGE- agents MUST ignore all other attributes that follow MESSAGE-
INTEGRITY2. INTEGRITY2.
The key for the HMAC depends on whether long-term or short-term The key for the HMAC depends on which credential mechanism is in use.
credentials are in use. For long-term credentials, the key is 16 Section 9.1.1 defines the key for the short-term credential mechanism
bytes: and Section 9.2.1 defines the key for the long-term credential
mechanism. Other credential mechanism MUST define the key that is
key = MD5(username ":" realm ":" SASLprep(password)) used for the HMAC.
That is, the 16-byte key is formed by taking the MD5 hash of the
result of concatenating the following five fields: (1) the username,
with any quotes and trailing nulls removed, as taken from the
USERNAME attribute (in which case SASLprep has already been applied);
(2) a single colon; (3) the realm, with any quotes and trailing nulls
removed; (4) a single colon; and (5) the password, with any trailing
nulls removed and after processing using SASLprep. For example, if
the username was 'user', the realm was 'realm', and the password was
'pass', then the 16-byte HMAC key would be the result of performing
an MD5 hash on the string 'user:realm:pass', the resulting hash being
0x8493fbc53ba582fb4c044c456bdc40eb.
For short-term credentials:
+key = SASLprep(password)
where MD5 is defined in RFC 1321 [RFC1321] and SASLprep() is defined
in RFC 4013 [RFC4013].
The structure of the key when used with long-term credentials
facilitates deployment in systems that also utilize SIP. Typically,
SIP systems utilizing SIP's digest authentication mechanism do not
actually store the password in the database. Rather, they store a
value called H(A1), which is equal to the key defined above.
Based on the rules above, the hash used to construct MESSAGE- Based on the rules above, the hash used to construct MESSAGE-
INTEGRITY2 includes the length field from the STUN message header. INTEGRITY2 includes the length field from the STUN message header.
Prior to performing the hash, the MESSAGE-INTEGRITY2 attribute MUST Prior to performing the hash, the MESSAGE-INTEGRITY2 attribute MUST
be inserted into the message (with dummy content). The length MUST be inserted into the message (with dummy content). The length MUST
then be set to point to the length of the message up to, and then be set to point to the length of the message up to, and
including, the MESSAGE-INTEGRITY2 attribute itself, but excluding any including, the MESSAGE-INTEGRITY2 attribute itself, but excluding any
attributes after it. Once the computation is performed, the value of attributes after it. Once the computation is performed, the value of
the MESSAGE-INTEGRITY2 attribute can be filled in, and the value of the MESSAGE-INTEGRITY2 attribute can be filled in, and the value of
the length in the STUN header can be set to its correct value -- the the length in the STUN header can be set to its correct value -- the
skipping to change at page 38, line 24 skipping to change at page 40, line 43
14.9. NONCE 14.9. NONCE
The NONCE attribute may be present in requests and responses. It The NONCE attribute may be present in requests and responses. It
contains a sequence of qdtext or quoted-pair, which are defined in contains a sequence of qdtext or quoted-pair, which are defined in
RFC 3261 [RFC3261]. Note that this means that the NONCE attribute RFC 3261 [RFC3261]. Note that this means that the NONCE attribute
will not contain actual quote characters. See RFC 2617 [RFC2617], will not contain actual quote characters. See RFC 2617 [RFC2617],
Section 4.3, for guidance on selection of nonce values in a server. Section 4.3, for guidance on selection of nonce values in a server.
It MUST be less than 128 characters (which can be as long as 763 It MUST be less than 128 characters (which can be as long as 763
bytes). bytes).
14.10. UNKNOWN-ATTRIBUTES 14.10. PASSWORD-ALGORITHMS
The PASSWORD-ALGORITHMS attribute is present only in responses. It
contains the list of algorithms that the server can use to derive the
long-term password.
The set of known algorithms is maintained by IANA. The initial set
defined by this specification is found in Section 17.4.
The attribute contains a list of algorithm numbers and variable
length parameters. The algorithm number is a 16-bit value as defined
in Section 17.4. The parameters start with the actual length of the
parameters as a 16-bit value, followed by the parameters that are
specific to each algorithm. The parameters are padded to a 32-bit
boundary, in the same manner as an attribute.
0 1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Algorithm 1 | Algorithm 1 Parameters Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Algorithm 1 Parameters (variable)
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Algorithm 2 | Algorithm 2 Parameters Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Algorithm 2 Parameter (variable)
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ...
Figure 8: Format of PASSWORD-ALGORITHMS Attribute
14.11. PASSWORD-ALGORITHM
The PASSWORD-ALGORITHM attribute is present only in requests. It
contains the algorithms that the server must use to derive the long-
term password.
The set of known algorithms is maintained by IANA. The initial set
defined by this specification is found in Section 17.4.
The attribute contains an algorithm number and variable length
parameters. The algorithm number is a 16-bit value as defined in
Section 17.4. The parameters starts with the actual length of the
parameters as a 16-bit value, followed by the parameters that are
specific to the algorithm. The parameters are padded to a 32-bit
boundary, in the same manner as an attribute.
0 1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Algorithm | Algorithm Parameters Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Algorithm Parameters (variable)
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 9: Format of PASSWORD-ALGORITHM Attribute
14.12. UNKNOWN-ATTRIBUTES
The UNKNOWN-ATTRIBUTES attribute is present only in an error response The UNKNOWN-ATTRIBUTES attribute is present only in an error response
when the response code in the ERROR-CODE attribute is 420. when the response code in the ERROR-CODE attribute is 420.
The attribute contains a list of 16-bit values, each of which The attribute contains a list of 16-bit values, each of which
represents an attribute type that was not understood by the server. represents an attribute type that was not understood by the server.
0 1 2 3 0 1 2 3
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 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Attribute 1 Type | Attribute 2 Type | | Attribute 1 Type | Attribute 2 Type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Attribute 3 Type | Attribute 4 Type ... | Attribute 3 Type | Attribute 4 Type ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 8: Format of UNKNOWN-ATTRIBUTES Attribute Figure 10: Format of UNKNOWN-ATTRIBUTES Attribute
Note: In [RFC3489], this field was padded to 32 by duplicating the Note: In [RFC3489], this field was padded to 32 by duplicating the
last attribute. In this version of the specification, the normal last attribute. In this version of the specification, the normal
padding rules for attributes are used instead. padding rules for attributes are used instead.
14.11. SOFTWARE 14.13. SOFTWARE
The SOFTWARE attribute contains a textual description of the software The SOFTWARE attribute contains a textual description of the software
being used by the agent sending the message. It is used by clients being used by the agent sending the message. It is used by clients
and servers. Its value SHOULD include manufacturer and version and servers. Its value SHOULD include manufacturer and version
number. The attribute has no impact on operation of the protocol, number. The attribute has no impact on operation of the protocol,
and serves only as a tool for diagnostic and debugging purposes. The and serves only as a tool for diagnostic and debugging purposes. The
value of SOFTWARE is variable length. It MUST be a UTF-8 [RFC3629] value of SOFTWARE is variable length. It MUST be a UTF-8 [RFC3629]
encoded sequence of less than 128 characters (which can be as long as encoded sequence of less than 128 characters (which can be as long as
763 bytes). 763 bytes).
14.12. ALTERNATE-SERVER 14.14. ALTERNATE-SERVER
The alternate server represents an alternate transport address The alternate server represents an alternate transport address
identifying a different STUN server that the STUN client should try. identifying a different STUN server that the STUN client should try.
It is encoded in the same way as MAPPED-ADDRESS, and thus refers to a It is encoded in the same way as MAPPED-ADDRESS, and thus refers to a
single server by IP address. The IP address family MUST be identical single server by IP address. The IP address family MUST be identical
to that of the source IP address of the request. to that of the source IP address of the request.
15. Security Considerations 15. Security Considerations
15.1. Attacks against the Protocol 15.1. Attacks against the Protocol
15.1.1. Outside Attacks 15.1.1. Outside Attacks
An attacker can try to modify STUN messages in transit, in order to An attacker can try to modify STUN messages in transit, in order to
cause a failure in STUN operation. These attacks are detected for cause a failure in STUN operation. These attacks are detected for
both requests and responses through the message-integrity mechanism, both requests and responses through the message-integrity mechanism,
using either a short-term or long-term credential. Of course, once using either a short-term or long-term credential. Of course, once
detected, the manipulated packets will be dropped, causing the STUN detected, the manipulated packets will be dropped, causing the STUN
transaction to effectively fail. This attack is possible only by an transaction to effectively fail. This attack is possible only by an
skipping to change at page 44, line 23 skipping to change at page 47, line 46
0x0005: (Reserved; was CHANGED-ADDRESS) 0x0005: (Reserved; was CHANGED-ADDRESS)
0x0006: USERNAME 0x0006: USERNAME
0x0007: (Reserved; was PASSWORD) 0x0007: (Reserved; was PASSWORD)
0x0008: MESSAGE-INTEGRITY 0x0008: MESSAGE-INTEGRITY
0x0009: ERROR-CODE 0x0009: ERROR-CODE
0x000A: UNKNOWN-ATTRIBUTES 0x000A: UNKNOWN-ATTRIBUTES
0x000B: (Reserved; was REFLECTED-FROM) 0x000B: (Reserved; was REFLECTED-FROM)
0x0014: REALM 0x0014: REALM
0x0015: NONCE 0x0015: NONCE
0x0020: XOR-MAPPED-ADDRESS 0x0020: XOR-MAPPED-ADDRESS
0xXXXX: PASSWORD-ALGORITHM
Comprehension-optional range (0x8000-0xFFFF) Comprehension-optional range (0x8000-0xFFFF)
0x8022: SOFTWARE 0x8022: SOFTWARE
0x8023: ALTERNATE-SERVER 0x8023: ALTERNATE-SERVER
0x8028: FINGERPRINT 0x8028: FINGERPRINT
0xXXXX: PASSSORD-ALGORITHMS
STUN Attribute types in the first half of the comprehension-required STUN Attribute types in the first half of the comprehension-required
range (0x0000 - 0x3FFF) and in the first half of the comprehension- range (0x0000 - 0x3FFF) and in the first half of the comprehension-
optional range (0x8000 - 0xBFFF) are assigned by IETF Review optional range (0x8000 - 0xBFFF) are assigned by IETF Review
[RFC5226]. STUN Attribute types in the second half of the [RFC5226]. STUN Attribute types in the second half of the
comprehension-required range (0x4000 - 0x7FFF) and in the second half comprehension-required range (0x4000 - 0x7FFF) and in the second half
of the comprehension-optional range (0xC000 - 0xFFFF) are assigned by of the comprehension-optional range (0xC000 - 0xFFFF) are assigned by
Designated Expert [RFC5226]. The responsibility of the expert is to Designated Expert [RFC5226]. The responsibility of the expert is to
verify that the selected codepoint(s) are not in use, and that the verify that the selected codepoint(s) are not in use, and that the
request is not for an abnormally large number of codepoints. request is not for an abnormally large number of codepoints.
Technical review of the extension itself is outside the scope of the Technical review of the extension itself is outside the scope of the
skipping to change at page 45, line 10 skipping to change at page 48, line 33
STUN error codes are consistent in codepoint assignments and STUN error codes are consistent in codepoint assignments and
semantics with SIP [RFC3261] and HTTP [RFC2616]. semantics with SIP [RFC3261] and HTTP [RFC2616].
The initial values in this registry are given in Section 14.7. The initial values in this registry are given in Section 14.7.
New STUN error codes are assigned based on IETF Review [RFC5226]. New STUN error codes are assigned based on IETF Review [RFC5226].
The specification must carefully consider how clients that do not The specification must carefully consider how clients that do not
understand this error code will process it before granting the understand this error code will process it before granting the
request. See the rules in Section 6.3.4. request. See the rules in Section 6.3.4.
17.4. STUN UDP and TCP Port Numbers 17.4. Password Algorithm Registry
A Password Algorithm is a hex number in the range 0x0000 - 0xFFFF.
The initial Password Algorithms are:
0x0001: Salted SHA256
Password Algorithms in the first half of the range (0x0000 - 0x7FFF)
are assigned by IETF Review [RFC5226]. Password Algorithms in the
second half of the range (0x8000 - 0xFFFF) are assigned by Designated
Expert [RFC5226].
17.4.1. Password Algorithms
The initial list of password algorithms is taken from
[I-D.veltri-sip-alt-auth].
17.4.1.1. Salted SHA256
The key length is 32 bytes and the parameters contains the salt.
key = SHA256(username ":" realm ":" SASLprep(password) ":" salt)
17.5. STUN UDP and TCP Port Numbers
IANA has previously assigned port 3478 for STUN. This port appears IANA has previously assigned port 3478 for STUN. This port appears
in the IANA registry under the moniker "nat-stun-port". In order to in the IANA registry under the moniker "nat-stun-port". In order to
align the DNS SRV procedures with the registered protocol service, align the DNS SRV procedures with the registered protocol service,
IANA is requested to change the name of protocol assigned to port IANA is requested to change the name of protocol assigned to port
3478 from "nat-stun-port" to "stun", and the textual name from 3478 from "nat-stun-port" to "stun", and the textual name from
"Simple Traversal of UDP Through NAT (STUN)" to "Session Traversal "Simple Traversal of UDP Through NAT (STUN)" to "Session Traversal
Utilities for NAT", so that the IANA port registry would read: Utilities for NAT", so that the IANA port registry would read:
stun 3478/tcp Session Traversal Utilities for NAT (STUN) port stun 3478/tcp Session Traversal Utilities for NAT (STUN) port
skipping to change at page 46, line 9 skipping to change at page 50, line 9
Westerlund, Miguel Garcia, Bruce Lowekamp, and Chris Sullivan for Westerlund, Miguel Garcia, Bruce Lowekamp, and Chris Sullivan for
their comments, and Baruch Sterman and Alan Hawrylyshen for initial their comments, and Baruch Sterman and Alan Hawrylyshen for initial
implementations. Thanks for Leslie Daigle, Allison Mankin, Eric implementations. Thanks for Leslie Daigle, Allison Mankin, Eric
Rescorla, and Henning Schulzrinne for IESG and IAB input on this Rescorla, and Henning Schulzrinne for IESG and IAB input on this
work. work.
21. References 21. References
21.1. Normative References 21.1. Normative References
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [I-D.ietf-tsvwg-sctp-dtls-encaps]
Requirement Levels", BCP 14, RFC 2119, March 1997. Jesup, R., Loreto, S., Stewart, R., and M. Tuexen, "DTLS
Encapsulation of SCTP Packets for RTCWEB", draft-ietf-
tsvwg-sctp-dtls-encaps-00 (work in progress), February
2013.
[RFC0791] Postel, J., "Internet Protocol", STD 5, RFC 791, September [I-D.ietf-tsvwg-sctp-prpolicies]
1981. Tuexen, M., Seggelmann, R., Stewart, R., and S. Loreto,
"Additional Policies for the Partial Reliability Extension
of the Stream Control Transmission Protocol", draft-ietf-
tsvwg-sctp-prpolicies-05 (work in progress), November
2014.
[RFC2782] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for [ITU.V42.2002]
specifying the location of services (DNS SRV)", RFC 2782, International Telecommunications Union, "Error-correcting
February 2000. Procedures for DCEs Using Asynchronous-to-Synchronous
Conversion", ITU-T Recommendation V.42, 2002.
[RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. [RFC0791] Postel, J., "Internet Protocol", STD 5, RFC 791, September
1981.
[RFC1122] Braden, R., "Requirements for Internet Hosts - [RFC1122] Braden, R., "Requirements for Internet Hosts -
Communication Layers", STD 3, RFC 1122, October 1989. Communication Layers", STD 3, RFC 1122, October 1989.
[RFC1321] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321,
April 1992.
[RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed-
Hashing for Message Authentication", RFC 2104, February
1997.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997.
[RFC2460] Deering, S. and R. Hinden, "Internet Protocol, Version 6 [RFC2460] Deering, S. and R. Hinden, "Internet Protocol, Version 6
(IPv6) Specification", RFC 2460, December 1998. (IPv6) Specification", RFC 2460, December 1998.
[RFC2617] Franks, J., Hallam-Baker, P., Hostetler, J., Lawrence, S., [RFC2617] Franks, J., Hallam-Baker, P., Hostetler, J., Lawrence, S.,
Leach, P., Luotonen, A., and L. Stewart, "HTTP Leach, P., Luotonen, A., and L. Stewart, "HTTP
Authentication: Basic and Digest Access Authentication", Authentication: Basic and Digest Access Authentication",
RFC 2617, June 1999. RFC 2617, June 1999.
[RFC6298] Paxson, V., Allman, M., Chu, J., and M. Sargent, [RFC2782] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for
"Computing TCP's Retransmission Timer", RFC 6298, June specifying the location of services (DNS SRV)", RFC 2782,
2011. February 2000.
[RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000.
Hashing for Message Authentication", RFC 2104, February
1997.
[RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO
10646", STD 63, RFC 3629, November 2003. 10646", STD 63, RFC 3629, November 2003.
[RFC1321] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, [RFC3758] Stewart, R., Ramalho, M., Xie, Q., Tuexen, M., and P.
April 1992. Conrad, "Stream Control Transmission Protocol (SCTP)
Partial Reliability Extension", RFC 3758, May 2004.
[RFC4013] Zeilenga, K., "SASLprep: Stringprep Profile for User Names [RFC4013] Zeilenga, K., "SASLprep: Stringprep Profile for User Names
and Passwords", RFC 4013, February 2005. and Passwords", RFC 4013, February 2005.
[ITU.V42.2002] [RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., and S.
International Telecommunications Union, "Error-correcting Rose, "DNS Security Introduction and Requirements", RFC
Procedures for DCEs Using Asynchronous-to-Synchronous 4033, March 2005.
Conversion", ITU-T Recommendation V.42, 2002.
[RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security
(TLS) Protocol Version 1.2", RFC 5246, August 2008.
[RFC6298] Paxson, V., Allman, M., Chu, J., and M. Sargent,
"Computing TCP's Retransmission Timer", RFC 6298, June
2011.
[RFC6347] Rescorla, E. and N. Modadugu, "Datagram Transport Layer
Security Version 1.2", RFC 6347, January 2012.
[RFC6698] Hoffman, P. and J. Schlyter, "The DNS-Based Authentication
of Named Entities (DANE) Transport Layer Security (TLS)
Protocol: TLSA", RFC 6698, August 2012.
[RFC6951] Tuexen, M. and R. Stewart, "UDP Encapsulation of Stream
Control Transmission Protocol (SCTP) Packets for End-Host
to End-Host Communication", RFC 6951, May 2013.
[RFC7064] Nandakumar, S., Salgueiro, G., Jones, P., and M. Petit-
Huguenin, "URI Scheme for the Session Traversal Utilities
for NAT (STUN) Protocol", RFC 7064, November 2013.
[RFC7350] Petit-Huguenin, M. and G. Salgueiro, "Datagram Transport
Layer Security (DTLS) as Transport for Session Traversal
Utilities for NAT (STUN)", RFC 7350, August 2014.
21.2. Informational References 21.2. Informational References
[I-D.veltri-sip-alt-auth]
Veltri, L., Salsano, S., and A. Polidoro, "HTTP digest
authentication using alternate password storage schemes",
draft-veltri-sip-alt-auth-00 (work in progress), April
2008.
[KARN87] Karn, P. and C. Partridge, "Improving Round-Trip Time
Estimates in Reliable Transport Protocols", SIGCOMM 1987,
August 1987.
[RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext
Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999.
[RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston,
A., Peterson, J., Sparks, R., Handley, M., and E. A., Peterson, J., Sparks, R., Handley, M., and E.
Schooler, "SIP: Session Initiation Protocol", RFC 3261, Schooler, "SIP: Session Initiation Protocol", RFC 3261,
June 2002. June 2002.
[RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., [RFC3424] Daigle, L. and IAB, "IAB Considerations for UNilateral
Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext Self-Address Fixing (UNSAF) Across Network Address
Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. Translation", RFC 3424, November 2002.
[RFC3489] Rosenberg, J., Weinberger, J., Huitema, C., and R. Mahy,
"STUN - Simple Traversal of User Datagram Protocol (UDP)
Through Network Address Translators (NATs)", RFC 3489,
March 2003.
[RFC4107] Bellovin, S. and R. Housley, "Guidelines for Cryptographic [RFC4107] Bellovin, S. and R. Housley, "Guidelines for Cryptographic
Key Management", BCP 107, RFC 4107, June 2005. Key Management", BCP 107, RFC 4107, June 2005.
[RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an
IANA Considerations Section in RFCs", BCP 26, RFC 5226,
May 2008.
[RFC5245] Rosenberg, J., "Interactive Connectivity Establishment [RFC5245] Rosenberg, J., "Interactive Connectivity Establishment
(ICE): A Protocol for Network Address Translator (NAT) (ICE): A Protocol for Network Address Translator (NAT)
Traversal for Offer/Answer Protocols", RFC 5245, April Traversal for Offer/Answer Protocols", RFC 5245, April
2010. 2010.
[RFC3489] Rosenberg, J., Weinberger, J., Huitema, C., and R. Mahy, [RFC5389] Rosenberg, J., Mahy, R., Matthews, P., and D. Wing,
"STUN - Simple Traversal of User Datagram Protocol (UDP) "Session Traversal Utilities for NAT (STUN)", RFC 5389,
Through Network Address Translators (NATs)", RFC 3489, October 2008.
March 2003.
[RFC5766] Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using
Relays around NAT (TURN): Relay Extensions to Session
Traversal Utilities for NAT (STUN)", RFC 5766, April 2010.
[RFC5626] Jennings, C., Mahy, R., and F. Audet, "Managing Client- [RFC5626] Jennings, C., Mahy, R., and F. Audet, "Managing Client-
Initiated Connections in the Session Initiation Protocol Initiated Connections in the Session Initiation Protocol
(SIP)", RFC 5626, October 2009. (SIP)", RFC 5626, October 2009.
[RFC5766] Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using
Relays around NAT (TURN): Relay Extensions to Session
Traversal Utilities for NAT (STUN)", RFC 5766, April 2010.
[RFC5780] MacDonald, D. and B. Lowekamp, "NAT Behavior Discovery [RFC5780] MacDonald, D. and B. Lowekamp, "NAT Behavior Discovery
Using Session Traversal Utilities for NAT (STUN)", RFC Using Session Traversal Utilities for NAT (STUN)", RFC
5780, May 2010. 5780, May 2010.
[RFC6544] Rosenberg, J., Keranen, A., Lowekamp, B., and A. Roach, [RFC6544] Rosenberg, J., Keranen, A., Lowekamp, B., and A. Roach,
"TCP Candidates with Interactive Connectivity "TCP Candidates with Interactive Connectivity
Establishment (ICE)", RFC 6544, March 2012. Establishment (ICE)", RFC 6544, March 2012.
[RFC3264] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer Model
with Session Description Protocol (SDP)", RFC 3264, June
2002.
[RFC3424] Daigle, L. and IAB, "IAB Considerations for UNilateral
Self-Address Fixing (UNSAF) Across Network Address
Translation", RFC 3424, November 2002.
[RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an
IANA Considerations Section in RFCs", BCP 26, RFC 5226,
May 2008.
[RFC5389] Rosenberg, J., Mahy, R., Matthews, P., and D. Wing,
"Session Traversal Utilities for NAT (STUN)", RFC 5389,
October 2008.
[KARN87] Karn, P. and C. Partridge, "Improving Round-Trip Time
Estimates in Reliable Transport Protocols", SIGCOMM 1987,
August 1987.
Appendix A. C Snippet to Determine STUN Message Types Appendix A. C Snippet to Determine STUN Message Types
Given a 16-bit STUN message type value in host byte order in msg_type Given a 16-bit STUN message type value in host byte order in msg_type
parameter, below are C macros to determine the STUN message types: parameter, below are C macros to determine the STUN message types:
#define IS_REQUEST(msg_type) (((msg_type) & 0x0110) == 0x0000) #define IS_REQUEST(msg_type) (((msg_type) & 0x0110) == 0x0000)
#define IS_INDICATION(msg_type) (((msg_type) & 0x0110) == 0x0010) #define IS_INDICATION(msg_type) (((msg_type) & 0x0110) == 0x0010)
#define IS_SUCCESS_RESP(msg_type) (((msg_type) & 0x0110) == 0x0100) #define IS_SUCCESS_RESP(msg_type) (((msg_type) & 0x0110) == 0x0100)
#define IS_ERR_RESP(msg_type) (((msg_type) & 0x0110) == 0x0110) #define IS_ERR_RESP(msg_type) (((msg_type) & 0x0110) == 0x0110)
A function to convert method and class into a message type:
int type(int method, int cls) {
return (method & 0x0F80) << 9 | (method & 0x0070) << 5
| (method & 0x000F) | (cls & 0x0002) << 8
| (cls & 0x0001) << 4;
}
A function to extract the method from the message type:
int method(int type) {
return (type & 0x3E00) >> 2 | (type & 0x00E0) >> 1
| (type & 0x000F);
}
A function to extract the class from the message type:
int cls(int type) {
return (type & 0x0100) >> 7 | (type & 0x0010) >> 4;
}
Appendix B. Release notes Appendix B. Release notes
This section must be removed before publication as an RFC. This section must be removed before publication as an RFC.
B.1. Open Issues B.1. Open Issues
1. Clean the IANA section. 1. Clean the IANA section.
2. Fix bug on retransmission RTO in section 7.2. 2. Fix bug on retransmission RTO in section 7.2.
3. Fix unclear text about RTO caching in section 7.2.1. 3. Integrate RFC 5769 (stun vectors) as examples
4. Integrate RFC 5769 (stun vectors) as examples 4. Clarify whether it's valid to share nonces across TURN
allocations.
5. Integrate RFC 7350 (dtls) 5. Clarify nonce behavior for both invalid and expired nonces.
Right now only expired nonces are described. Define a new
"invalid nonce" error code (presumably 438)
6. Integrate RFC 7064 (URI). 6. This question was raised: If a STUN (TURN) client receives a "300
Try Alternate" response to a STUN request sent over TLS, it
should then connect to a different STUN server over TLS. What
subjectAltName should it expect in the redirected-to server's
certificate?
7. STUN hash algorithm agility (currently only SHA-1 is allowed). 7. Normatively reference the new ORIGIN RFC
8. Clarify terminology, text and guidance for STUN fragmentation. B.2. Modifications between draft-ietf-tram-stunbis-01 and draft-ietf-
tram-stunbis-00
9. Clarify whether it's valid to share nonces across TURN o Add negotiation mechanism for new password algorithms.
allocations.
10. Clarify nonce behavior for both invalid and expired nonces. o Describe the MESSAGE-INTEGRITY/MESSAGE-INTEGRITY2 protocol.
Right now only expired nonces are described. Define a new
"invalid nonce" error code (presumably 438)
11. This question was raised: If a STUN (TURN) client receives a o Add support for SCTP to solve the fragmentation problem.
"300 Try Alternate" response to a STUN request sent over TLS, it
should then connect to a different STUN server over TLS. What
subjectAltName should it expect in the redirected-to server's
certificate?
12. Normatively reference the new ORIGIN RFC o Merge RFC 7350:
B.2. Modifications between draft-salgueiro-tram-stunbis-02 and draft- * Split the "Sending over..." sections in 3.
* Add DTLS-over-UDP as transport.
* Update the cipher suites and cipher/compression restrictions.
* A stuns uri with an IP address is rejected.
* Replace most of the RFC 3489 compatibility by a reference to
the section in RFC 5389.
* Update the STUN Usages list with transport applicability.
o Merge RFC 7064:
* DNS discovery is done from the URI.
* Reorganized the text about default ports.
o Add more C snippets.
o Make clear that the cached RTO is discarded only if there is no
new transations for 10 minutes.
B.3. Modifications between draft-salgueiro-tram-stunbis-02 and draft-
ietf-tram-stunbis-00
o Draft adopted as WG item.
B.4. Modifications between draft-salgueiro-tram-stunbis-02 and draft-
salgueiro-tram-stunbis-01 salgueiro-tram-stunbis-01
o Add definition of MESSAGE-INTEGRITY2. o Add definition of MESSAGE-INTEGRITY2.
o Update text and reference from RFC 2988 to RFC 6298. o Update text and reference from RFC 2988 to RFC 6298.
o s/The IAB has mandated/The IAB has suggested/ (Errata #3737). o s/The IAB has mandated/The IAB has suggested/ (Errata #3737).
o Fix the figure for the UNKNOWN-ATTRIBUTES (Errata #2972). o Fix the figure for the UNKNOWN-ATTRIBUTES (Errata #2972).
skipping to change at page 49, line 46 skipping to change at page 56, line 5
o Update text and reference from RFC 2988 to RFC 6298. o Update text and reference from RFC 2988 to RFC 6298.
o s/The IAB has mandated/The IAB has suggested/ (Errata #3737). o s/The IAB has mandated/The IAB has suggested/ (Errata #3737).
o Fix the figure for the UNKNOWN-ATTRIBUTES (Errata #2972). o Fix the figure for the UNKNOWN-ATTRIBUTES (Errata #2972).
o Fix section number and make clear that the original domain name is o Fix section number and make clear that the original domain name is
used for the server certificate verification. This is consistent used for the server certificate verification. This is consistent
with what RFC 5922 (section 4) is doing. (Errata #2010) with what RFC 5922 (section 4) is doing. (Errata #2010)
B.3. Modifications between draft-salgueiro-tram-stunbis-01 and draft- B.5. Modifications between draft-salgueiro-tram-stunbis-01 and draft-
salgueiro-tram-stunbis-00 salgueiro-tram-stunbis-00
o Restore the RFC 5389 text. o Restore the RFC 5389 text.
o Add list of open issues. o Add list of open issues.
Authors' Addresses Authors' Addresses
Marc Petit-Huguenin Marc Petit-Huguenin
Impedance Mismatch Impedance Mismatch
 End of changes. 99 change blocks. 
477 lines changed or deleted 766 lines changed or added

This html diff was produced by rfcdiff 1.42. The latest version is available from http://tools.ietf.org/tools/rfcdiff/