<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc SYSTEM "rfc2629-xhtml.ent">

<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>

<rfc xmlns:xi="http://www.w3.org/2001/XInclude" submissionType="IETF"
     category="std" consensus="true" number="8828" ipr="trust200902"
     obsoletes="" updates="" xml:lang="en" tocInclude="true" symRefs="true"
     sortRefs="true" version="3" docName="draft-ietf-rtcweb-ip-handling-12">

  <!-- xml2rfc v2v3 conversion 2.34.0 -->
  <front>
    <title abbrev="WebRTC IP Handling">WebRTC IP Address Handling
    Requirements</title>
    <seriesInfo name="RFC" value="8828"/>
    <author fullname="Justin Uberti" initials="J." surname="Uberti">
      <organization>Google</organization>
      <address>
        <postal>
          <street>747 6th St S</street>
          <city>Kirkland</city>
          <region>WA</region>
          <code>98033</code>
          <country>United States of America</country>
        </postal>
        <email>justin@uberti.name</email>
      </address>
    </author>

    <author fullname="Guo-wei Shieh" initials="G." surname="Shieh">
      <organization></organization>
      <address>
        <postal>
          <street>333 Elliott Ave W #500</street>
          <city>Seattle</city>
          <region>WA</region>
          <code>98119</code>
          <country>United States of America</country>
        </postal>
        <email>guoweis@gmail.com</email>
      </address>
    </author>

    <date  month="January" year="2021"/>
    <area>RAI</area>

    <abstract>
      <t>This document provides information and requirements for how IP
      addresses should be handled by Web Real-Time Communication (WebRTC) implementations.</t>
    </abstract>
  </front>
  <middle>
    <section numbered="true" toc="default">
      <name>Introduction</name>
      <t>One of WebRTC's key features is its support of peer-to-peer
      connections. However, when establishing such a connection, which involves
       connection attempts from various IP addresses, WebRTC may allow a web
       application to learn additional information about the user compared to an
       application that only uses the Hypertext Transfer Protocol (HTTP)
       <xref target="RFC7230" format="default"/>. This may be problematic in
       certain cases. This
       document summarizes the concerns and makes recommendations on how WebRTC
       implementations should best handle the trade-off between privacy and media
       performance.</t>
     </section>
     <section numbered="true" toc="default">
       <name>Terminology</name>
        <t>
    The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>",
    "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>",
    "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>",
    "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
    "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be
    interpreted as described in BCP 14 <xref target="RFC2119"/> <xref
    target="RFC8174"/> when, and only when, they appear in all capitals, as
    shown here.
        </t>

    </section>
    <section numbered="true" toc="default">
      <name>Problem Statement</name>
      <t>In order to establish a peer-to-peer connection, WebRTC
      implementations use Interactive Connectivity Establishment (ICE)
      <xref target="RFC8445" format="default"/>. ICE attempts to discover multiple IP
      addresses using techniques such as Session Traversal Utilities for NAT
      (STUN)
      <xref target="RFC5389" format="default"/> and Traversal Using Relays
      around NAT (TURN)
      <xref target="RFC5766" format="default"/> and then checks the
      connectivity of each
      local-address-remote-address pair in order to select the best one. The
      addresses that are collected usually consist of an endpoint's private
      physical or virtual addresses and its public Internet addresses.</t>
      <t>These addresses are provided to the web application so that
      they can be communicated to the remote endpoint for its checks. This
      allows the application to learn more about the local network
      configuration than it would from a typical HTTP scenario, in which the
      web server would only see a single public Internet address, i.e., the
      address from which the HTTP request was sent.</t>

      <t>The additional information revealed falls into three categories:
      </t>
      <ol spacing="normal" type="1">
        <li>If the client is multihomed, additional public IP addresses for the
        client can be learned. In particular, if the client tries to hide its
        physical location through a Virtual Private Network (VPN), and the VPN
        and local OS support routing over multiple interfaces (a "split-tunnel"
        VPN), WebRTC can discover not only the public address for the VPN, but
        also the ISP public address over which the VPN is running.</li>
        <li>If the client is behind a Network Address Translator (NAT), the
        client's private IP addresses, often
        <xref target="RFC1918" format="default"/> addresses, can be learned.</li>
        <li>If the client is behind a proxy (a client-configured "classical
        application proxy", as defined in
        <xref target="RFC1919" format="default" sectionFormat="comma"
	      section="3"/>), but direct access to the
        Internet is permitted, WebRTC's STUN checks will bypass the proxy and
        reveal the public IP address of the client. This concern also applies
        to the "enterprise TURN server" scenario described in
        <xref target="RFC7478" format="default" sectionFormat="comma"
	      section="2.3.5.1"/> if, as above, direct
        Internet access is permitted. However, when the term "proxy" is used in
        this document, it is always in reference to an
        <xref target="RFC1919" format="default"/> proxy server.</li>
      </ol>
      <t>Of these three concerns, the first is the most significant, because for some
      users, the purpose of using a VPN is for anonymity. However, different
      VPN users will have different needs, and some VPN users (e.g., corporate
      VPN users) may in fact prefer WebRTC to send media traffic directly --
      i.e., not through the VPN.</t>
      <t>The second concern is less significant but valid nonetheless. The core
      issue is that web applications can learn about addresses that are not
      exposed to the Internet; typically, these address are IPv4, but they can
      also be IPv6, as in the case of NAT64 <xref target="RFC6146" format="default"/>.
      While disclosure of the <xref target="RFC4941" format="default"/> IPv6 addresses
      recommended by <xref target="RFC8835"
      format="default"/> is fairly
      benign due to their intentionally short lifetimes, IPv4 addresses present
      some challenges. Although private IPv4 addresses often contain minimal
      entropy (e.g., 192.168.0.2, a fairly common address), in the worst case,
      they can contain 24 bits of entropy with an indefinite lifetime. As such,
      they can be a fairly significant fingerprinting surface. In addition,
      intranet web sites can be attacked more easily when their IPv4 address
      range is externally known.</t>
      <t>Private IP addresses can also act as an identifier that allows
      web applications running in isolated browsing contexts (e.g., normal and
      private browsing) to learn that they are running on the same device. This
      could allow the application sessions to be correlated, defeating some of
      the privacy protections provided by isolation. It should be noted that
      private addresses are just one potential mechanism for this correlation
      and this is an area for further study.</t>
      <t>The third concern is the least common, as proxy administrators can already
      control this behavior through organizational firewall policy, and
      generally, forcing WebRTC traffic through a proxy server will have
      negative effects on both the proxy and media quality.</t>
      <t>Note also that these concerns predate WebRTC; Adobe Flash Player has
      provided similar functionality since the introduction of Real-Time
      Media Flow Protocol (RTMFP) support
      <xref target="RFC7016" format="default"/> in 2008.</t>
    </section>
    <section numbered="true" toc="default">
      <name>Goals</name>
      <t>WebRTC's support of secure peer-to-peer connections facilitates
      deployment of decentralized systems, which can have privacy benefits. As
      a result, blunt solutions that disable WebRTC or make it significantly
      harder to use are undesirable. This document takes a more nuanced
      approach, with the following goals:
      </t>
      <ul spacing="normal">
        <li>Provide a framework for understanding the problem so that controls
        might be provided to make different trade-offs regarding performance and
        privacy concerns with WebRTC.</li>
        <li>Using that framework, define settings that enable peer-to-peer
        communications, each with a different balance between performance and
        privacy.</li>
        <li>Finally, provide recommendations for default settings that provide
        reasonable performance without also exposing addressing information in
        a way that might violate user expectations.</li>
      </ul>
    </section>
    <section numbered="true" toc="default">
      <name>Detailed Design</name>
      <section numbered="true" toc="default">
        <name>Principles</name>
        <t>The key principles for our framework are stated below:
        </t>
        <ol spacing="normal" type="1">
          <li>By default, WebRTC traffic should follow typical IP routing (i.e.,
          WebRTC should use the same interface used for HTTP traffic) and only
          the system's 'typical' public addresses (or those of an enterprise
          TURN server, if present) should be visible to the application.
          However, in the interest of optimal media quality, it should be
          possible to enable WebRTC to make use of all network interfaces to
          determine the ideal route.</li>
          <li>By default, WebRTC should be able to negotiate direct peer-to-peer
          connections between endpoints (i.e., without traversing a NAT or
          relay server) when such connections are possible. This ensures that
          applications that need true peer-to-peer routing for bandwidth or
          latency reasons can operate successfully.</li>
          <li>It should be possible to configure WebRTC to not disclose private
          local IP addresses, to avoid the issues associated with web
          applications learning such addresses. This document does not require
          this to be the default state, as there is no currently defined
          mechanism that can satisfy this requirement as well as the
          aforementioned requirement to allow direct peer-to-peer
          connections.</li>
          <li>By default, WebRTC traffic should not be sent through proxy
          servers, due to the media-quality problems associated with sending
          WebRTC traffic over TCP, which is almost always used when
          communicating with such proxies, as well as proxy performance issues
          that may result from proxying WebRTC's long-lived, high-bandwidth
          connections. However, it should be possible to force WebRTC to send
          its traffic through a configured proxy if desired.</li>
        </ol>
      </section>
      <section numbered="true" toc="default">
        <name>Modes and Recommendations</name>
        <t>Based on these ideas, we define four specific modes of WebRTC
        behavior, reflecting different media quality/privacy trade-offs:
        </t>
        <dl newline="true">
	  <dt>Mode 1 - Enumerate all addresses:</dt>
          <dd>WebRTC <bcp14>MUST</bcp14> use all network interfaces to
          attempt communication with STUN servers, TURN servers, or peers. This
          will converge on the best media path and is ideal when media
          performance is the highest priority, but it discloses the most
          information.</dd>
          <dt>Mode 2 - Default route + associated local addresses:</dt>
	    <dd>WebRTC
	    <bcp14>MUST</bcp14> follow the
          kernel routing table rules, which will typically cause media packets
          to take the same route as the application's HTTP traffic. If an
          enterprise TURN server is present, the preferred route <bcp14>MUST</bcp14> be
          through this TURN server. Once an interface has been chosen, the
          private IPv4 and IPv6 addresses associated with this interface <bcp14>MUST</bcp14>
          be discovered and provided to the application as host candidates.
          This ensures that direct connections can still be established in this
          mode.</dd>
          <dt>Mode 3 - Default route only: </dt>
          <dd>This is the same as Mode 2, except that
          the associated private addresses <bcp14>MUST NOT</bcp14> be provided; the only IP
          addresses gathered are those discovered via mechanisms like STUN and
          TURN (on the default route). This may cause traffic to hairpin
          through a NAT, fall back to an application TURN server, or fail
          altogether, with resulting quality implications.</dd>
          <dt>Mode 4 - Force proxy:</dt>
          <dd>This is the same as Mode 3, but when the
          application's HTTP traffic is sent through a proxy, WebRTC media
          traffic <bcp14>MUST</bcp14> also be proxied. If the proxy does not support UDP (as
          is the case for all HTTP and most SOCKS
          <xref target="RFC1928" format="default"/> proxies), or the WebRTC implementation does
          not support UDP proxying, the use of UDP will be disabled, and TCP
          will be used to send and receive media through the proxy. Use of TCP
          will result in reduced media quality, in addition to any performance
          considerations associated with sending all WebRTC media through the
          proxy server.</dd>
        </dl>
        <t>Mode 1 <bcp14>MUST NOT</bcp14> be used unless user consent has been provided. The
        details of this consent are left to the implementation; one potential
        mechanism is to tie this consent to getUserMedia (device permissions)
        consent, described in <xref target="RFC8827"
	format="default" sectionFormat="comma" section="6.2"/>.
        Alternatively, implementations can provide a specific
        mechanism to obtain user consent.</t>
        <t>In cases where user consent has not been obtained, Mode 2 <bcp14>SHOULD</bcp14> be
        used.</t>
        <t>These defaults provide a reasonable trade-off that permits trusted
        WebRTC applications to achieve optimal network performance but gives
        applications without consent (e.g., 1-way streaming or data-channel
        applications) only the minimum information needed to achieve direct
        connections, as defined in Mode 2. However, implementations <bcp14>MAY</bcp14> choose
        stricter modes if desired, e.g., if a user indicates they want all
        WebRTC traffic to follow the default route.</t>
        <t>Future documents may define additional modes and/or update the
        recommended default modes.</t>
        <t>Note that the suggested defaults can still be used even for
        organizations that want all external WebRTC traffic to traverse a proxy
        or enterprise TURN server, simply by setting an organizational firewall
        policy that allows WebRTC traffic to only leave through the proxy or
        TURN server. This provides a way to ensure the proxy or TURN server is
        used for any external traffic but still allows direct connections
        (and, in the proxy case, avoids the performance issues associated with
        forcing media through said proxy) for intra-organization traffic.</t>
      </section>
    </section>
    <section numbered="true" toc="default">
      <name>Implementation Guidance</name>
      <t>This section provides guidance to WebRTC implementations on how to
      implement the policies described above.</t>
      <section numbered="true" toc="default">
        <name>Ensuring Normal Routing</name>
        <t>When trying to follow typical IP routing, as required by Modes 2
        and 3, the simplest approach is
        to bind() the sockets used for peer-to-peer connections to the wildcard
        addresses (0.0.0.0 for IPv4, :: for IPv6), which allows the OS to route
        WebRTC traffic the same way as it would HTTP traffic. STUN and TURN
        will work as usual, and host candidates can still be determined as
        mentioned below.</t>
      </section>
      <section numbered="true" toc="default">
        <name>Determining Associated Local Addresses</name>
        <t>When binding to a wildcard address, some extra work is needed to
        determine the associated local address required by Mode 2, which we
        define as the source
        address that would be used for any packets sent to the web application
        host (assuming that UDP and TCP get the same routing treatment). Use of
        the web-application host as a destination ensures the right source
        address is selected, regardless of where the application resides (e.g.,
        on an intranet).</t>
        <t>First, the appropriate remote IPv4/IPv6 address is obtained by
        resolving the host component of the web application URI
        <xref target="RFC3986" format="default"/>. If the client is behind a proxy and cannot
        resolve these IPs via DNS, the address of the proxy can be used
        instead. Or, if the web application was loaded from a file:// URI
        <xref target="RFC8089" format="default"/> rather than over the network, the
        implementation can fall back to a well-known DNS name or IP
        address.</t>
        <t>Once a suitable remote IP has been determined, the implementation
        can create a UDP socket, bind() it to the appropriate wildcard address,
        and then connect() to the remote IP. Generally, this results in
        the socket being assigned a local address based on the kernel routing
        table, without sending any packets over the network.</t>
        <t>Finally, the socket can be queried using getsockname() or the
        equivalent to determine the appropriate local address.</t>
      </section>
    </section>
    <section numbered="true" toc="default">
      <name>Application Guidance</name>
      <t>The recommendations mentioned in this document may cause certain
      WebRTC applications to malfunction. In order to be robust in all
      scenarios, the following guidelines are provided for applications:
      </t>
      <ul spacing="normal">
        <li>Applications <bcp14>SHOULD</bcp14> deploy a TURN server with support for both UDP
        and TCP connections to the server. This ensures that connectivity can
        still be established, even when Mode 3 or 4 is in use, assuming the
        TURN server can be reached.</li>
        <li>Applications <bcp14>SHOULD</bcp14> detect when they don't have access to the full
        set of ICE candidates by checking for the presence of host candidates.
        If no host candidates are present, Mode 3 or 4 is in use; this
        knowledge can be useful for diagnostic purposes.</li>
      </ul>
    </section>
    <section numbered="true" toc="default">
      <name>Security Considerations</name>
      <t>This document describes several potential privacy and security concerns
      associated with WebRTC peer-to-peer connections and provides mechanisms
      and recommendations for WebRTC implementations to address these concerns.
      </t>
    </section>
    <section numbered="true" toc="default">
      <name>IANA Considerations</name>
      <t>This document has no IANA actions.</t>
    </section>
  </middle>
  <back>

    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.3986.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8089.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8445.xml"/>
	<xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.5389.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.5766.xml"/>
      </references>
      <references>
        <name>Informative References</name>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.1918.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.1919.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.1928.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.4941.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.6146.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7016.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7230.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7478.xml"/>


 <!--draft-ietf-rtcweb-security-arch: 8827 -->
 <reference anchor="RFC8827" target="https://www.rfc-editor.org/info/rfc8827">
 <front>
 <title>WebRTC Security Architecture</title>
 <author initials='E.' surname='Rescorla' fullname='Eric Rescorla'>
   <organization/>
 </author>
 <date month='January' year='2021'/>
 </front>
 <seriesInfo name="RFC" value="8827"/>
 <seriesInfo name="DOI" value="10.17487/RFC8827"/>
 </reference>

<!-- draft-ietf-rtcweb-transports-17: 8835 -->
<reference anchor="RFC8835" target="https://www.rfc-editor.org/info/rfc8835">
  <front>
    <title>Transports for WebRTC</title>
    <author initials="H." surname="Alvestrand" fullname="Harald Alvestrand">
      <organization />
    </author>
    <date month="January" year="2021" />
  </front>
  <seriesInfo name="RFC" value="8835" />
  <seriesInfo name="DOI" value="10.17487/RFC8835"/>
</reference>

      </references>
    </references>
    <section numbered="false" toc="default">
      <name>Acknowledgements</name>
      <t>Several people provided input into this document, including <contact fullname="Bernard
      Aboba"/>, <contact fullname="Harald Alvestrand"/>, <contact fullname="Youenn
      Fablet"/>, <contact fullname="Ted Hardie"/>, <contact fullname="Matthew Kaufmann"/>,
      <contact fullname="Eric Rescorla"/>, <contact fullname="Adam Roach"/>, and
	<contact fullname="Martin Thomson"/>.</t>
    </section>
  </back>
</rfc>
