<?xml version="1.0" encoding="US-ASCII"?>
<?xml-stylesheet type='text/xsl' href='http://xml2rfc.tools.ietf.org/authoring/rfc2629.xslt' ?>
<!DOCTYPE rfc PUBLIC "-//IETF//DTD RFC 2629//EN" "http://xml2rfc.tools.ietf.org/authoring/rfc2629.dtd">

<rfc category="std" docName="draft-campbell-tokbind-ttrp-01" ipr="trust200902">

  <?rfc toc="yes" ?>
  <?rfc tocdepth="5" ?>
  <?rfc symrefs="yes" ?>
  <?rfc sortrefs="yes"?>
  <?rfc strict="yes" ?>
  <?rfc compact="yes" ?>
  <?rfc subcompact="no" ?>

  <front>
    <title abbrev="Token Binding and TLS Termination">HTTPS Token Binding with TLS Terminating Reverse Proxies</title>

    <author fullname="Brian Campbell" initials="B." surname="Campbell">
      <organization>Ping Identity</organization>
      <address>
	    <email>brian.d.campbell@gmail.com</email>
      </address>
    </author>

    <date />

    <area>General</area>
    <workgroup>Internet Engineering Task Force</workgroup>

    <keyword>Token Binding</keyword>
    <keyword>Reverse Proxy</keyword>
    <keyword>TLS Termination</keyword>
    <keyword>Provided-Token-Binding-ID</keyword>
    <keyword>Referred-Token-Binding-ID</keyword>

    <abstract>
      <t>
        This document defines common HTTP header fields that enable
        a TLS terminating reverse proxy to convey information about the validated Token Binding Message
        sent by the client to a backend server, which enables that backend server to bind, or verify the binding
        of, cookies and other security tokens to the client's Token Binding key.
      </t>
    </abstract>
  </front>

  <middle>
    <section anchor="Introduction" title="Introduction">
      <t>
        <xref target="I-D.ietf-tokbind-https">Token Binding over HTTP</xref>
        provides a mechanism that enables HTTP
        servers to cryptographically bind cookies and other security tokens
        to a key held by the browser or other HTTP client,
        possession of which is proven on the <xref target="RFC5246">TLS</xref> connections
        over which the tokens are used.
        When Token Binding is negotiated in the TLS handshake <xref target="I-D.ietf-tokbind-negotiation"/>
        the client sends an
        encoded Token Binding Message <xref target="I-D.ietf-tokbind-protocol"/>
        as a header in each HTTP request, which proves possession
        of one or more private keys held by the client. The public portion of the
        keys are represented in the Token Binding IDs of the Token Binding Message
        and for each one there is a signature over some data, which includes the exported keying material
        <xref target="RFC5705"/> of the TLS connection. An HTTP server issuing
        cookies or other security tokens can associate them with the Token Binding ID, which
        ensures those tokens cannot be used successfully over a different TLS connection
        or by a different client than the one to which they were issued.
      </t>
      <t>
        A fairly common deployment architecture for HTTPS applications is to have the backend HTTP application
        servers sit behind a reverse proxy that terminates TLS. The proxy is accessible to the internet and
        dispatches client requests to the appropriate backend server within a private or protected network.
        The backend servers are not directly accessible outside the private network and are only reachable
        through the reverse proxy. The details of such deployments are typically opaque to clients
        who make requests to the proxy server and see responses as though they originated
        from the proxy server itself. TLS connections for HTTPS are established between
        each client and the reverse proxy server.
      </t>
      <t>
        Token Binding facilitates a binding of security tokens to a key held by the client by way of
        the TLS connection between that client and the server.

        In a deployment where TLS is terminated by a reverse proxy, however, the
        TLS connection is between the client and the proxy while the backend server is likely the
        system that will issue cookies or other security tokens.

        Additional steps are therefore needed to enable the use of
        Token Binding in such deployment architectures. In the absence of a standardized approach,
        different implementations will address it differently, which will make interoperability
        between implementation difficult or impossible without complex configurations or custom integrations.
      </t>
      <t>
        This document standardizes
        HTTP header field names that a
        TLS terminating reverse proxy (TTRP) adds to requests that it sends to the backend servers.
        The headers contain the information from the validated Token Binding Message
        sent by the client to the proxy with the <spanx style="verb">Sec-Token-Binding</spanx> header,
        thus enabling the backend server to bind, or verify the binding of,
        cookies and other security tokens to the client's Token Binding key.
        The usage of the
        headers, both the reverse proxy adding it and the application server using them to
        bind cookies or other tokens, are to be configuration options of the respective
        systems as they will not always be applicable.
      </t>
      <section anchor="rnc" title="Requirements Notation and Conventions">
	<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
	"SHOULD", "SHOULD NOT", "RECOMMENDED", "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 anchor="headers-and-rules" title="HTTP Header Fields and Processing Rules">

      <section anchor="headers" title="Token Binding ID HTTP Header Fields">
        <t>
          <xref target="I-D.ietf-tokbind-protocol">The Token Binding Protocol</xref>
          recommends that implementations make Token Binding IDs
          available to the application as opaque byte sequences, enabling those
          applications to use the Token Binding IDs when generating and verifying
          bound tokens. In the context of a TLS terminating reverse proxy (TTRP)
          deployment, the provided and referred Token Binding IDs are made available
          to the backend application as the <spanx style="verb">Provided-Token-Binding-ID</spanx>
          and <spanx style="verb">Referred-Token-Binding-ID</spanx> HTTP headers respectively.
          The value of both headers is an <spanx style="verb">EncodedTokenBindingID</spanx>, for which the
          ABNF <xref target="RFC5234"/> syntax is shown in <xref target="abnf"/> below.
          <spanx style="verb">EncodedTokenBindingID</spanx> is a single HTTP header field-value as defined in
          Section 3.2 of <xref target="RFC7230"/>, which MUST NOT have a list of values or occur multiple times
          in a request. An <spanx style="verb">EncodedTokenBindingID</spanx> is only for use in HTTP requests
          and MUST NOT to be used in HTTP responses.
        </t>
        <figure anchor="abnf" title="Encoded Token Binding ID Header ABNF">
          <artwork><![CDATA[
    EncodedTokenBindingID = *( DIGIT / ALPHA /  "-" / "_" )

    DIGIT = <Defined in Section B.1 of [RFC5234]>
    ALPHA = <Defined in Section B.1 of [RFC5234]>
       ]]></artwork></figure>
        <t>
          The value of an <spanx style="verb">EncodedTokenBindingID</spanx> is a base64url encoding of
          the TokenBindingID byte sequence (see section 3 of <xref target="I-D.ietf-tokbind-protocol"/>)
          using the URL and
          filename safe alphabet described in Section 5 of
          <xref target="RFC4648"/>, with all trailing pad characters '=' omitted
          and without the inclusion of any line breaks, whitespace, or other
          additional characters.
        </t>
      </section>

      <section anchor="rules" title="Processing Rules">
        <t>
          This section defines the applicable processing rules for a
          TLS terminating reverse proxy (TTRP) and backend server(s) to provide server side support of
          <xref target="I-D.ietf-tokbind-https">Token Binding over HTTP</xref>
          using the HTTP headers described in <xref target="headers"/>.
          Use of the technique is to be a configuration or deployments option and
          the processing rules described herein are for servers operating with that option enabled.
        </t>
        <t>
          A TTRP negotiates the use of Token Binding with the client per
          <xref target="I-D.ietf-tokbind-negotiation"/>
          and validates the Token Binding Message as defined in
          <xref target="I-D.ietf-tokbind-protocol">The Token Binding Protocol</xref>
          and
          <xref target="I-D.ietf-tokbind-https">Token Binding over HTTP</xref>
          for each HTTP request on
          the underlying TLS connection. Requests with a valid Token Binding Message (and meeting
          any other authorization or policy requirements of the TTRP) are dispatched to the backend
          server with the following modifications.

          <list style="numbers">
            <t>
              The
              <spanx style="verb">Sec-Token-Binding</spanx>
              header in the
              original incoming request MUST be removed from the request that is dispatched to the backend
              server.
            </t>
            <t>
              The Token Binding ID of the provided Token Binding of the Token Binding Message
              MUST be placed in the
              <spanx style="verb">Provided-Token-Binding-ID</spanx>
              header field of the dispatched request using the format defined in <xref target="headers"/>.
            </t>
            <t>
              If the Token Binding Message contains a referred Token Binding, the referred Token Binding ID
              MUST be placed in the
              <spanx style="verb">Referred-Token-Binding-ID</spanx>
              header field of the dispatched request using the format defined in <xref target="headers"/>.
              Otherwise, the
              <spanx style="verb">Referred-Token-Binding-ID</spanx>
              header field MUST NOT be present in the dispatched request.
            </t>
            <t>
              Any occurrence of the <spanx style="verb">Provided-Token-Binding-ID</spanx> or
              <spanx style="verb">Referred-Token-Binding-ID</spanx>
              header in the original incoming request MUST be removed or overwritten before forwarding the request.
            </t>

          </list>

          Requests made over a TLS connection where the use of Token Binding was not negotiated MUST be sanitized
          by removing any occurrences of the
          <spanx style="verb">Provided-Token-Binding-ID</spanx>
          and
          <spanx style="verb">Referred-Token-Binding-ID</spanx>
          header fields prior to
          dispatching the request to the backend server.
        </t>
        <t>
          Forward proxies and other intermediaries MUST NOT add
          the <spanx style="verb">Provided-Token-Binding-ID</spanx>
          or <spanx style="verb">Referred-Token-Binding-ID</spanx> header to requests.
        </t>
      </section>
      <section anchor="examples" title="Examples">
        <t>
          Extra line breaks and whitespace have been added to the following examples
          for display and formatting purposes only.
        </t>

        <section anchor="example-provided" title="Provided Token Binding ID">

        <t>
          The following <spanx style="verb">Sec-Token-Binding</spanx> header is from
          an HTTP request made over a TLS connection between the client
          and the TTRP where the use of Token Binding has been negotiated
          (The base64url-encoded representation of the exported keying material,
          which can be used to validate the Token Binding Message, for that
          connection is <spanx style="verb">AYVUayPTP9RmELNpGjFl6Ykm2CUx7pUMxe35yb11dgU</spanx>).
          The encoded Token Binding Message has the provided Token Binding the
          client uses with the server.
        </t>

        <figure title="Header in HTTP Request to TTRP" anchor="http-to-ttrp-provided">
          <artwork><![CDATA[
 Sec-Token-Binding: AIkAAgBBQKzyIrmcY_YCtHVoSHBut69vrGfFdy1_YKTZfFJv
  6BjrZsKD9b9FRzSBxDs1twTqnAS71M1RBumuihhI9xqxXKkAQEtxe4jeUJU0WezxlQ
  XWVSBFeHxFMdXRBIH_LKOSAuSMOJ0XEw1Q8DE248qkOiRKzw3KdSNYukYEPmO21bQi
  3YYAAA
]]></artwork>
        </figure>

        <t>
          After validating the Token Binding Message, the TTRP removes the
          <spanx style="verb">Sec-Token-Binding</spanx> header and adds the following
          <spanx style="verb">Provided-Token-Binding-ID</spanx> header with the
          provided Token Binding ID to the request that is dispatched to the
          backend server.
        </t>
        <figure title="Header in HTTP Request to Backend Server" anchor="http-to-back-provided">
          <artwork><![CDATA[
 Provided-Token-Binding-ID: AgBBQKzyIrmcY_YCtHVoSHBut69vrGfFdy1_YKTZ
   fFJv6BjrZsKD9b9FRzSBxDs1twTqnAS71M1RBumuihhI9xqxXKk
]]></artwork>
        </figure>
      </section>



        <section anchor="example-both" title="Provided and Referred Token Binding IDs">

          <t>
            The following <spanx style="verb">Sec-Token-Binding</spanx> header is from
            an HTTP request made over a TLS connection between the client
            and the TTRP where the use of Token Binding has been negotiated
            (The base64url-encoded representation of the exported keying material,
            which can be used to validate the Token Binding Message, for that
            connection is <spanx style="verb">wEWWCP1KPxfq-QL4NxYII_P4ti_9YYqrTpGs28BZEqE</spanx>).
            The encoded Token Binding Message has the provided Token Binding the
            client uses with the server as well as the referred Token Binding that it
            uses with a different server.
          </t>

          <figure title="Header in HTTP Request to TTRP" anchor="http-to-ttrp-both">
            <artwork><![CDATA[
 Sec-Token-Binding: ARIAAgBBQCfsI1D1sTq5mvT_2H_dihNIvuHJCHGjHPJchPav
  NbGrOo26-2JgT_IsbvZd4daDFbirYBIwJ-TK1rh8FzrC-psAQMyYIqXj7djGPev1dk
  jV9XxLYGCyqOrBVEtBHrMUCeo22ymLg3OiFcl_fmOPxJbjxI6lKcF0lyfy-dSQmPIe
  zQ0AAAECAEFArPIiuZxj9gK0dWhIcG63r2-sZ8V3LX9gpNl8Um_oGOtmwoP1v0VHNI
  HEOzW3BOqcBLvUzVEG6a6KGEj3GrFcqQBAHQm0pzgUTXKLRamuKE1pmmP9I3UBVpoe
  1DBCe9H2l1VPpsImakUa6crAqZ-0CGBmji7bYzQogpKcyxTTFk5zdwAA
]]></artwork>
          </figure>

          <t>
            After validating the Token Binding Message, the TTRP removes the
            <spanx style="verb">Sec-Token-Binding</spanx> header and adds the following
            <spanx style="verb">Provided-Token-Binding-ID</spanx> and
            <spanx style="verb">Referred-Token-Binding-ID</spanx> headers,
            with the provided and referred Token Binding IDs respectively,
            to the request that is dispatched to the backend server.
          </t>
          <figure title="Headers in HTTP Request to Backend Server" anchor="http-to-back-both">
            <artwork><![CDATA[
 Provided-Token-Binding-ID: AgBBQCfsI1D1sTq5mvT_2H_dihNIvuHJCHGjHPJc
   hPavNbGrOo26-2JgT_IsbvZd4daDFbirYBIwJ-TK1rh8FzrC-ps
 Referred-Token-Binding-ID: AgBBQKzyIrmcY_YCtHVoSHBut69vrGfFdy1_YKTZ
   fFJv6BjrZsKD9b9FRzSBxDs1twTqnAS71M1RBumuihhI9xqxXKk
]]></artwork>
          </figure>
        </section>


      </section>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>
        The headers described herein enable a reverse proxy and backend server
        to function together as though they are single logical server side deployment of HTTPS Token Binding.
        Use of the headers outside that intended use case, however, may undermine the protections
        afforded by Token Binding. Therefore steps MUST be taken to prevent unintended use, both in
        sending the headers and in relying on their value.
      </t>
      <t>
        Producing and consuming the headers SHOULD be
        a configurable option, respectively, in a reverse proxy and backend server
        (or individual application in that server). The default configuration for both should be
        to not use the headers thus requiring an "opt-in" to the functionality.
      </t>
      <t>
        Reverse proxies SHOULD only add the headers to requests that are forwarded to trusted backend servers.
      </t>
      <t>
        Backend servers MUST only accept the headers from trusted reverse proxies.
        And reverse proxies MUST sanitize the incoming request before forwarding it on
        by removing or overwriting any existing instances of the headers.
        Otherwise arbitrary clients can control the header values as seen
        and used by the backend server.
      </t>
      <t>
        The communication between a reverse proxy and backend server needs to be secured
        against eavesdropping and modification by unintended parties.
      </t>
      <t>
        The configuration options and request sanitization are necessarily functionally of the
        respective servers. The other requirements can be met in a number of ways, which
        will vary based on specific deployments. The communication between a reverse proxy and
        backend server, for example, might be over a mutually authenticated TLS with the
        insertion and consumption headers
        occurring only on that connection. Alternatively the network topology might
        dictate a private network such that the backend application is only able to accept requests
        from the reverse proxy and the proxy can only make requests to that server. Other
        deployments that meet the requirements set forth herein are also possible.
      </t>
    </section>

    <section anchor="IANA" title="IANA Considerations">
    <section anchor="header-reg" title="HTTP Message Header Field Names Registration">
    <t>
      This document specifies the following new HTTP header fields,
      registration of which is requested in the "Permanent Message Header Field Names" registry
      defined in <xref target="RFC3864"/>.
    </t>
	  <t>
      <?rfc subcompact="yes"?>
      <list style="symbols">
        <t>
          Header Field Name: <spanx style="verb">Provided-Token-Binding-ID</spanx>
        </t>
        <t>
          Applicable protocol: HTTP
        </t>
        <t>
          Status: standard
        </t>
        <t>
          Author/change Controller: IETF
        </t>
        <t>
          Specification Document(s): [[ this specification ]]
        </t>
      </list>
   </t>
   <t>
      <list style="symbols">
        <t>
          Header Field Name: <spanx style="verb">Referred-Token-Binding-ID</spanx>
        </t>
        <t>
          Applicable protocol: HTTP
        </t>
        <t>
          Status: standard
        </t>
        <t>
          Author/change Controller: IETF
        </t>
        <t>
          Specification Document(s): [[ this specification ]]
        </t>
      </list>
    </t>
      <?rfc subcompact="no"?>
    </section>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2119"?>
      <?rfc include="http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.4648"?>
      <?rfc include="http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.5234"?>
      <?rfc include="http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.5246"?>
      <?rfc include="http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.5705"?>
      <?rfc include="http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7230"?>

      <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.draft-ietf-tokbind-negotiation-08.xml' ?>
      <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.draft-ietf-tokbind-protocol-14.xml' ?>
      <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.draft-ietf-tokbind-https-09.xml' ?>
    </references>

   <references title="Informative References">
      <?rfc include="http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.3864"?>
   </references>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>
	The author would like to thank the following people for their various contributions to the specification:
        Vinod Anupam,
        Dirk Balfanz,
        John Bradley,
        Jeff Hodges,
        Subodh Iyengar,
        Leif Johansson,
        Yoav Nir,
        Andrei Popov,
        Eric Rescorla,
        Piotr Sikora,
        Martin Thomson,
        Hans Zandbelt
        and others (please let me know, if you've contributed and I've forgotten you).
      </t>
    </section>

    <section anchor="TBD" title="Open Issues">
      <t>
	<list style="symbols">
	  <t>
      During discussions at a side meeting in Chicago (IETF 98) there seemed to be general support for having
      the TTRP rename the "Sec-Token-Binding" header to something else and
      pass the full original EncodedTokenBindingMessage to the backend server via a different
      header (maybe "TTRP-Token-Binding" or something) in addition to the "Provided-Token-Binding-ID"
      and if applicable the "Referred-Token-Binding-ID" headers defined herein. The idea was largely that the
      backend server "might need it for something" so pass the whole thing along just in case.
      However, as I sat down to write this draft, I couldn't bring myself to add it in the main text.
      On thinking about it more, it feels inefficient/duplicative and rather inelegant.
      And without the EKM, much
      of the data not already made available via the Token Binding IDs is meaningless (e.g. the signature value).
      Data in TokenBinding.extensions, if extensions are present, might be useful to the backend server.
      But might also only be useful/meaningful at the TTRP where the initial TLS connection is terminated.
      I really don't know. Perhaps any extensions, if present, should be passed to the backend via different
      header(s)? Or maybe it would be more appropriate to not attempt to cover TokenBinding.extensions in this
      document and defer to the definition of individual extensions to say how/if they are to be handled in
      a TTRP type deployment?
	  </t>
        </list>
      </t>
    </section>

    <section anchor="History" title="Document History">
      <t>[[ to be removed by the RFC Editor before publication as an RFC ]]</t>
      <t>
        draft-campbell-tokbind-ttrp-01
        <list style="symbols">
          <t>Minor editorial fixes.</t>
          <t>Add to the Acknowledgements.</t>
        </list>
      </t>
      <t>
        draft-campbell-tokbind-ttrp-00
 <list style="symbols">
   <t>
     Initial draft based on 'consensus to work on the problem' from the Seoul meeting [1][2]
     and reflecting the consensus approach from discussions at the Chicago meeting [3].
     <vspace/><vspace/>
     [1] https://www.ietf.org/proceedings/97/minutes/minutes-97-tokbind-01.txt (minutes from Seoul)
     <vspace/>
     [2] https://www.ietf.org/proceedings/97/slides/slides-97-tokbind-reverse-proxies-00.pdf (slides from Seoul)
     <vspace/>
     [3] https://mailarchive.ietf.org/arch/msg/unbearable/_ZHI8y2Vs5WMP8VMRr7zroo_sNU (summary of discussion)
   </t>
	</list>
      </t>

    </section>

  </back>
</rfc>
