<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
     which is available here: http://xml.resource.org. -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" >
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs),
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
     (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<rfc category="info" docName="draft-johnston-tram-stun-origin-00" ipr="trust200902">
  <!-- category values: std, bcp, info, exp, and historic
     ipr values: full3667, noModification3667, noDerivatives3667
     you can add the attributes updates="NNNN" and obsoletes="NNNN"
     they will automatically be output with "(if approved)" -->

  <!-- ***** FRONT MATTER ***** -->

  <front>

    <title abbrev="STUN Origin">An Origin Attribute for the STUN Protocol</title>

    <author fullname="Alan Johnston" initials="A."
            surname="Johnston">
      <organization>Avaya</organization>

      <address>
        <postal>
          <street></street>

          <city>St. Louis</city>

          <region>MO</region>

          <code></code>

          <country>USA</country>
        </postal>

        <phone></phone>

        <email>alan.b.johnston@gmail.com</email>

      </address>
    </author>

    <author fullname="Justin Uberti" initials="J."
            surname="Uberti">
      <organization>Google</organization>

      <address>
        <postal>
          <street></street>

          <city>Kirkland</city>

          <region>WA</region>

          <code></code>

          <country>USA</country>
        </postal>

        <phone></phone>

        <email>justin@uberti.name</email>

      </address>
    </author>

    <author fullname="John Yoakum" initials="J."
            surname="Yoakum">
      <organization>Avaya</organization>

      <address>
        <postal>
          <street></street>

          <city>Cary</city>

          <region>NC</region>

          <code></code>

          <country>USA</country>
        </postal>

        <phone></phone>

        <email>yoakum@avaya.com</email>

      </address>
    </author>

    <author fullname="Kundan Singh" initials="K."
            surname="Singh">
      <organization>Avaya</organization>

      <address>
        <postal>
          <street></street>

          <city>San Francisco</city>

          <region>CA</region>

          <code></code>

          <country>USA</country>
        </postal>

        <phone></phone>

        <email>kundan10@gmail.com</email>

      </address>
    </author>

    <date month="January" year="2014" />

    <!-- If the month and year are both specified and are the current ones, xml2rfc will fill
         in the current day for you. If only the current year is specified, xml2rfc will fill
         in the current day and month for you. If the year is not the current one, it is
         necessary to specify at least a month (xml2rfc assumes day="1" if not specified for the
         purpose of calculating the expiry date).  With drafts it is normally sufficient to
         specify just the year. -->

    <!-- Meta-data Declarations -->

    <area>RAI</area>

    <workgroup>Internet Engineering Task Force</workgroup>

    <!-- WG name at the upperleft corner of the doc,
         IETF is fine for individual submissions.
         If this element is not present, the default is "Network Working Group",
         which is used by the RFC Editor as a nod to the history of the IETF. -->

    <keyword>turn</keyword>
    <keyword>webrtc</keyword>
    <keyword>rtcweb</keyword>
    <keyword>origin</keyword>
    <keyword>attribute</keyword>
    <keyword>stun</keyword>

    <!-- Keywords will be incorporated into HTML output
         files in a meta tag but they have no effect on text or nroff
         output. If you submit your draft to the RFC Editor, the
         keywords will be used for the search engine. -->

    <abstract>
      <t>STUN, or Session Traversal Utilities for NAT, is a protocol used to assist other protocols traverse Network Address Translators or NATs.  STUN, and STUN extensions such as TURN, or Traversal Using Relays around NAT, and ICE, Interactive Communications Establishment, have been around for many years but with WebRTC, Web Real-Time Communications, STUN and related extensions are about to see major deployments and implementation due to these protocols being implemented in browsers.  This specification defines an ORIGIN attribute for STUN that can be used in similar ways to the HTTP header field of the same name.  WebRTC browsers utilizing STUN and TURN would include this attribute which would provide servers with additional information about the STUN and TURN requests they receive.  This specification defines the usage of the STUN ORIGIN attribute for web and SIP contexts.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
<t>
STUN, or Session Traversal Utilities for NAT, is a protocol used to assist other protocols traverse Network Address Translators or NATs.  TURN, or Traversal Using Relays around NAT <xref target="RFC5766" />, is a STUN extension <xref target="RFC5389" /> that allows endpoints to acquire a relayed address for media flows.  It is most commonly used in conjunction with ICE, Interactive Connectivity Establishment <xref target="RFC5245" />, which is used to establish peer-to-peer flows between endpoints through NATs and firewalls.
</t>
<t>STUN defines three authentication modes, depending on the STUN usage.  For STUN binding requests sent between peers, such as for ICE connectivity checks, a short term authentication method is recommended.  Each peer contributes random strings which are exchanged over signaling and used to authenticate the connectivity checks.  For TURN, a usage of STUN used to acquire and refresh relay addresses, a long term authentication method is recommended.  This authentication is similar to SIP Digest <xref target="RFC3261" />, which involves an authentication challenge for each request.  A server, upon receipt of a TURN request, generates an authentication challenge that includes a realm and nonce.  The client resends the TURN request supplying a user name and password based on the realm indicated by the server.  For a STUN binding request sent to a STUN server, no authentication is recommended, as generating the response is less work for a server than the server utilizing the short term or long term authentication approach.
</t>
<t>
WebRTC, Web Real-Time Communications, adds peer-to-peer real-time, interactive voice and video media capabilities and data channels to browsers <xref target="I-D.ietf-rtcweb-overview" /> without a plugin or download, and allows web developers to access this functionality using JavaScript API calls <xref target="WebRTC-API" />.  WebRTC includes STUN, TURN, and ICE client functionality built into browsers.  For a session established between two browsers, if either browser is behind a NAT, a STUN server is necessary.  Public STUN servers are currently available and a web application can suggest a particular STUN server be used.  In other cases, a TURN server is needed to establish a peer connection.  In this case, TURN credentials need to be available to the browser for the long term authentication approach.  A TURN server for WebRTC might serve a number of different domains and realms.
 </t>
 <t>
From the perspective of the web application provider, providing service for a number of different domains and realms, it is useful to know something about the source of the STUN request when processing the request.  For a web application provider STUN or TURN server, the server will have no idea which web pages or sites are sending binding requests to the service.  In conventional applications, the SOFTWARE attribute would provide some identifying information to the service, but that no longer works when the browser is the application.  For a web application provider TURN server, the TURN server does not know which realm to include in an authentication challenge. 
</t>
<t>
In the web world, HTTP requests have the concept of origin.  The origin of a web page, as defined in <xref target="RFC6454" />, is defined by the URI's scheme, host or IP address, and port portions.   The HTTP Origin header field inserted by the web browser carries this information and is useful information for servers that receive HTTP requests generated via JavaScript.  For example, Cross Origin Resource Sharing, CORS, allows an HTTP server to serve HTTP requests from multiple origins.
</t>
<t>
This specification proposes extending the origin concept to STUN requests.  STUN requests generated by a web browser would include the origin of the HTTP page that is initiating the Peer Connection.  Using this extra information, a STUN server could use the origin to determine which STUN binding requests to respond to, reducing the load on a STUN server.  Using this  information, a TURN server could use the origin to determine which realm to include in the authentication challenge. A TURN server can also use the origin information for logging and analytics, and also as additional information after authentication for providing service.
</t>
<t>
The following sections of this document define the STUN ORIGIN attribute and define its usage.
</t>

      <section title="Requirements Language">
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
        "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
        document are to be interpreted as described in <xref
        target="RFC2119">RFC 2119</xref>.</t>
      </section>
    </section>

<section title="STUN ORIGIN attribute">
<t>
This specification defines how to apply the web origin concept and syntax of <xref target="RFC6454" /> to the STUN protocol. 
</t>
<t>
This specification defines a new Attribute to the STUN protocol <xref target="RFC5389" />.  The attribute is called ORIGIN and uses the syntax defined in Section 15 of  <xref target="RFC5389" />.  A STUN Attribute type is a hex number in the range 0x0000 - 0xFFFF.  The ORIGIN attribute value is TBD, chosen in the comprehension optional range.
</t>
<t>
For a web browser (HTTP User Agent), the contents of the ORIGIN attribute is the unicode-serialization of an origin defined in Section 6.1 of <xref target="RFC6454" />.  The origin value included is the same as the Origin header field for an HTTP request generated from the web page that is creating the Peer Connection.  It does not include any string terminating (\x00) character in the serialization.
</t>
<t>
For a SIP User Agent <xref target="RFC3261" /> using STUN and TURN, the ORIGIN attribute is set to be the URI of the registrar server used by the User Agent (i.e. the Request-URI of a REGISTER method).  
</t>
<t>
Other contexts can define a usage of the ORIGIN attribute to use an appropriate URI or URL. 
</t>
<section title="STUN Usage">
<t>
For STUN requests sent without authentication to a STUN server (i.e. STUN binding requests sent to a STUN server), the STUN client SHOULD include the ORIGIN attribute.  A STUN server can derive additional information for logging and analytics about the request through the ORIGIN attribute, such as the source of the request.  For example, an enterprise STUN server might only reply to STUN binding requests from certain domains.  
</t>
</section>
<section title="TURN Usage">
<t>
For STUN requests sent using the long-term authentication method, such as TURN <xref target="RFC5766" /> allocate requests, the STUN client SHOULD include the ORIGIN attribute.  A TURN server can use the ORIGIN attribute to determine which REALM to include in the authentication challenge.  A TURN server can also use the ORIGIN attribute after authentication to provide appropriate service.
</t>
</section>
<section title="ICE Usage">
<t>
For STUN requests sent using the short-term authentication method, such as ICE connectivity checks <xref target="RFC5245" />, the use of the ORIGIN attribute is NOT RECOMMENDED.  No valid use cases for the ORIGIN attribute have been identified to date.
</t>
</section>
</section>

    <section anchor="IANA" title="IANA Considerations">
      <t>This specification, if approved, adds a new value to the IANA "STUN Attributes Registry" created by <xref target="RFC5389" />.  The ORIGIN attribute value is TBD. </t>

    </section>

<section anchor="Security" title="Security Considerations">
<t>
The security considerations of <xref target="RFC6454" /> apply to this extension.  Servers using the information present in the STUN ORIGIN attribute need to realize that this attribute could be set arbitrarily by a non-browser client or modified by an intermediary.  The method proposed in this document is not meant to replace existing STUN authentication mechanisms but to provide additional information to the server for logging and analytics and how to handle the request after authentication.  
</t><t>
Just as browsers do not allow a web application to set the Origin header field via JavaScript, browsers should not allow a web application through JavaScript to set the STUN ORIGIN attribute.
</t><t>
If the STUN MESSAGE-INTEGRITY attribute is present, the contents of the ORIGIN attribute are integrity protected.  The strength of this protection is a function of the secret used to generate the MESSAGE-INTEGRITY value.
</t><t>
The STUN ORIGIN attribute does have privacy implications.  The recipient of the STUN request learns the web origin of the user. In addition, an on-path attacker could determine this information by inspecting STUN messages between the STUN client and STUN server, depending on the transport used.  This information is often available in other messages sent by the browser, such as DNS or HTTP requests.  However, in cases where secure DNS and secure HTTP is used, including the ORIGIN attribute over an unencrypted transport could leak this information.  STUN has a defined TLS transport; however, TLS transport is generally unsuitable for the real-time media flows that follow STUN requests and must use the same transport.  A DTLS transport for STUN would provide a very good privacy solution to this problem.  In cases where privacy is paramount, the ORIGIN attribute SHOULD NOT be included or only included if DTLS or TLS transport is used.
</t>
</section>



  </middle>

  <!--  *****BACK MATTER ***** -->

  <back>

    <references title="Normative References">
      <!-- Here we use entities that we defined at the beginning. -->

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?>

      <?rfc include="reference.I-D.ietf-rtcweb-overview.xml"?>

      <reference anchor='WebRTC-API'
           target='http://www.w3.org/TR/2012/WD-webrtc-20120821/'>
  <front>
    <title>WebRTC 1.0: Real-time Communication Between Browsers</title>
    <author fullname='Adam Bergkvist' surname='Bergkvist' initials='A. '/>
    <author fullname='Daniel C. Burnett' surname='Burnett' initials='D. '/>
    <author fullname='Cullen Jennings' surname='Jennings' initials='C. '/>
    <author fullname='Anant Narayanan' surname='Narayanan' initials='A. '/>
    <date year="2013" />
  </front>
  <seriesInfo name='W3C Working Draft' value='http://www.w3.org/TR/webrtc/'/>
</reference>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.5389.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.6454.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.5766.xml"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.5245.xml"?>            
      
      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.3261.xml"?>  
      
    </references>

   </back>
</rfc>
