<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.nl" -->
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd' []>
<rfc ipr="trust200902" submissionType="IETF" category="std" xml:lang="en" consensus="yes" docName="draft-bdc-something-something-certificate-00">
<?rfc toc="yes"?><?rfc symrefs="yes"?><?rfc sortrefs="yes"?><?rfc compact="yes"?><?rfc subcompact="no"?><?rfc comments="no"?>
<front>
<title abbrev="Client-Cert Header">Client-Cert HTTP Header: Conveying Client Certificate Information from TLS Terminating Reverse Proxies to Origin Server Applications</title><author initials="B." surname="Campbell" fullname="Brian Campbell"><organization>Ping Identity</organization><address><postal><street></street>
</postal><email>bcampbell@pingidentity.com</email>
</address></author>
<date/>
<area>Security</area><workgroup>Aspirational</workgroup>
<abstract><t>This document defines the HTTP header field <spanx style="verb">Client-Cert</spanx> that allows a TLS terminating reverse proxy to convey information about the client certificate of a mutually-authenticated TLS connection to an origin server in a common and predictable manner.</t>
</abstract>

</front>

<middle>

<section anchor="Introduction" title="Introduction">
<t>A fairly common deployment pattern for HTTPS applications is to have the origin HTTP application servers sit behind a reverse proxy that terminates TLS connections from clients. The proxy is accessible to the internet and dispatches client requests to the appropriate origin server within a private or protected network. The origin servers are not directly accessible by clients and are only reachable through the reverse proxy. The backend details of this type of deployment are typically opaque to clients who make requests to the proxy server and see responses as though they originated from the proxy server itself. Although HTTPS is also usually employed between the proxy and the origin server, the TLS connection that the client establishes for HTTPS is only between itself and the reverse proxy server.</t>
<t>The deployment pattern is found in a number of varieties such as n-tier architectures, content delivery networks, application load balancing services, and ingress controllers.</t>
<t>Although not exceedingly prevalent, TLS client certificate authentication is sometimes employed and in such cases the origin server often requires information about the client certificate for its application logic. Such logic might include access control decisions, audit logging, and binding issued tokens or cookies to a certificate, and the respective validation of such bindings. The specific details from the certificate needed also vary with the application requirements. In order for these types of application deployments to work in practice, the reverse proxy needs to convey information about the client certificate to the origin application server. A common way this information is conveyed in practice today is by using non-standard headers to carry the certificate (in some encoding) or individual parts thereof in the HTTP request that is dispatched to the origin server. This solution works to some extent but interoperability between independently developed components can be cumbersome or even impossible depending on the implementation choices respectively made (like what header names are used or are configurable, which parts of the certificate are exposed, or how the certificate is encoded). A standardized approach to this commonly functionality could improve and simplify interoperability between implementations.</t>
<t>This document aspires to standardize an HTTP header field named <spanx style="verb">Client-Cert</spanx> that a TLS terminating reverse proxy adds to requests that it sends to the origin or backend servers. The header value contains the client certificate from the mutually-authenticated TLS connection between the client and reverse proxy, which enables the backend origin server to utilize the certificate in its application logic. The usage of the header, both the reverse proxy adding the header and the origin server relying on the header for application logic, are to be configuration options of the respective systems as they will not always be applicable.</t>

<section anchor="requirements-notation-and-conventions" title="Requirements Notation and Conventions">
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL NOT&quot;, &quot;SHOULD&quot;, &quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;NOT RECOMMENDED&quot;, &quot;MAY&quot;, and &quot;OPTIONAL&quot; in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"></xref> <xref target="RFC8174"></xref> when, and only when, they appear in all capitals, as shown here.</t>
</section>

<section anchor="terminology" title="Terminology">
<t>Phrases like TLS client certificate authentication or mutually-authenticated TLS are used throughout this document to refer to the process whereby, in addition to the normal TLS server authentication with a certificate, a client presents its X.509 certificate <xref target="RFC5280"></xref> and proves possession of the corresponding private key to a server when negotiating a TLS session.  In contemporary versions of TLS <xref target="RFC8446"></xref> <xref target="RFC5246"></xref> this requires that the client send the Certificate and CertificateVerify messages during the handshake and for the server to verify the CertificateVerify and Finished messages.</t>
</section>
</section>

<section anchor="http-header-field-and-processing-rules" title="HTTP Header Field and Processing Rules">

<section anchor="encoding" title="Encoding">
<t>The field-values of the HTTP header defined herein utilize the following encoded form.</t>
<t>A certificate is represented in text as an <spanx style="verb">EncodedCertificate</spanx>, which is the base64-encoded (Section 4 of <xref target="RFC4648"></xref>) DER <xref target="ITU.X690"></xref> PKIX certificate. The encoded value MUST NOT include any line breaks, whitespace, or other additional characters. ABNF <xref target="RFC5234"></xref> syntax for <spanx style="verb">EncodedCertificate</spanx> is shown in the figure below.</t>

<figure><artwork> EncodedCertificate = 1*( DIGIT / ALPHA / &quot;+&quot; / &quot;/&quot; ) 0*2&quot;=&quot; 

 DIGIT = &lt;Defined in Section B.1 of [RFC5234]&gt;  ; A-Z / a-z
 ALPHA = &lt;Defined in Section B.1 of [RFC5234]&gt;  ; 0-9  
</artwork></figure>

</section>

<section anchor="header" title="Client-Cert HTTP Header Field">
<t>In the context of a TLS terminating reverse proxy (TTRP) deployment, the TTRP makes the TLS client certificate available to the backend application with the following header field.</t>
<t>
<list style="hanging">
<t hangText="Client-Cert">
<vspace />The end-entity client certificate as an <spanx style="verb">EncodedCertificate</spanx> value.</t>
</list>
</t>
<t>The <spanx style="verb">Client-Cert</spanx> header field defined herein is only for use in HTTP requests and MUST NOT be used in HTTP responses.  It is a single HTTP header field-value as defined in Section 3.2 of <xref target="RFC7230"></xref>, which MUST NOT have a list of values or occur multiple times in a request.</t>
</section>

<section anchor="processing-rules" title="Processing Rules">
<t>This section outlines the applicable processing rules for a TLS terminating reverse proxy (TTRP) that has negotiated a mutually-authenticated TLS connection to convey the client certificate from that connection to the backend origin servers. Use of the technique is to be a configuration or deployment option and the processing rules described herein are for servers operating with that option enabled.</t>
<t>A TTRP negotiates the use of a mutually-authenticated TLS connection with the client, such as is described in <xref target="RFC8446"></xref> or <xref target="RFC5246"></xref>, and validates the client certificate per its policy and trusted certificate authorities.  Each HTTP request on the underlying TLS connection are dispatched to the origin server with the following modifications:</t>
<t>
<list style="numbers">
<t>The client certificate is be placed in the <spanx style="verb">Client-Cert</spanx> header field of the dispatched request as defined in <xref target="header"></xref>.</t>
<t>Any occurrence of the <spanx style="verb">Client-Cert</spanx> header in the original incoming request MUST be removed or overwritten before forwarding the request.</t>
</list>
</t>
<t>Requests made over a TLS connection where the use of client certificate authentication was not negotiated MUST be sanitized by removing any and all occurrences <spanx style="verb">Client-Cert</spanx> header field prior to dispatching the request to the backend server.</t>
<t>Forward proxies and other intermediaries MUST NOT add the <spanx style="verb">Client-Cert</spanx> header to requests.</t>
<t>Backend origin servers may then use the <spanx style="verb">Client-Cert</spanx> header of the request to determine if the connection from the client to the TTRP was mutually-authenticated and, if so, the certificate thereby presented by the client.</t>
</section>
</section>

<section anchor="sec" title="Security Considerations">
<t>The header described herein enable a reverse proxy and backend or origin server to function together as though, from the client's perspective, they are a single logical server side deployment of HTTPS over a mutually-authenticated TLS connection. Use of the <spanx style="verb">Client-Cert</spanx> header outside that intended use case, however, may undermine the protections afforded by TLS client certificate authentication. Therefore steps MUST be taken to prevent unintended use, both in sending the header and in relying on its value.</t>
<t>Producing and consuming the <spanx style="verb">Client-Cert</spanx> header 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 <spanx style="verb">Client-Cert</spanx> header thus requiring an &quot;opt-in&quot; to the functionality.</t>
<t>In order to prevent header injection, backend servers MUST only accept the <spanx style="verb">Client-Cert</spanx> header 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 header. Otherwise arbitrary clients can control the header value as seen and used by the backend server. It is important to note that neglecting to prevent header injection does not &quot;fail safe&quot; in that the nominal functionality will still work as expected even when malicious actions are possible. As such, extra care is recommended in ensuring that proper header sanitation is in place.</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 or origin server, for example, might be authenticated in some way with the insertion and consumption of the <spanx style="verb">Client-Cert</spanx> header 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-considerations" title="IANA Considerations">
<t>[[ TBD if this draft progresses, register the <spanx style="verb">Client-Cert</spanx> HTTP header field in the <eref target="https://www.iana.org/assignments/message-headers/message-headers.xhtml">"Permanent Message Header Field Names" registry</eref> defined in <xref target="RFC3864"></xref> ]]</t>
</section>

</middle>

<back>
<references title="Normative References">
<reference anchor="ITU.X690" target="">
  <front>
    <title>&#xA;Information Technology - ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER)&#xA;</title>
    <author>
      <organization>International Telecommunications Union</organization>
    </author>
    <date year="2015" month="August"></date>
  </front>
</reference>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4648.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5280.xml"?>
</references>
<references title="Informative References">
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3864.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-oauth-mtls.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5234.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7230.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8446.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5246.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7239.xml"?>
</references>

<section anchor="example" title="Example">
<t>In a hypothetical example where a TLS client presents the client and intermediate certificate from <xref target="example-chain"></xref> when establishing a mutually-authenticated TLS connection with the reverse proxy, the proxy would send the <spanx style="verb">Client-Cert</spanx> header shown in {#example-header} to the backend. Note that line breaks and whitespace have been added to the value of the header field in <xref target="example-header"></xref> for display and formatting purposes only.</t>
<figure anchor="example-chain" title="Certificate Chain (with client certificate first) ">
<artwork>-----BEGIN CERTIFICATE-----
MIIBqDCCAU6gAwIBAgIBBzAKBggqhkjOPQQDAjA6MRswGQYDVQQKDBJMZXQncyBB
dXRoZW50aWNhdGUxGzAZBgNVBAMMEkxBIEludGVybWVkaWF0ZSBDQTAeFw0yMDAx
MTQyMjU1MzNaFw0yMTAxMjMyMjU1MzNaMA0xCzAJBgNVBAMMAkJDMFkwEwYHKoZI
zj0CAQYIKoZIzj0DAQcDQgAE8YnXXfaUgmnMtOXU/IncWalRhebrXmckC8vdgJ1p
5Be5F/3YC8OthxM4+k1M6aEAEFcGzkJiNy6J84y7uzo9M6NyMHAwCQYDVR0TBAIw
ADAfBgNVHSMEGDAWgBRm3WjLa38lbEYCuiCPct0ZaSED2DAOBgNVHQ8BAf8EBAMC
BsAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwHQYDVR0RAQH/BBMwEYEPYmRjQGV4YW1w
bGUuY29tMAoGCCqGSM49BAMCA0gAMEUCIBHda/r1vaL6G3VliL4/Di6YK0Q6bMje
SkC3dFCOOB8TAiEAx/kHSB4urmiZ0NX5r5XarmPk0wmuydBVoU4hBVZ1yhk=
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIB5jCCAYugAwIBAgIBFjAKBggqhkjOPQQDAjBWMQswCQYDVQQGEwJVUzEbMBkG
A1UECgwSTGV0J3MgQXV0aGVudGljYXRlMSowKAYDVQQDDCFMZXQncyBBdXRoZW50
aWNhdGUgUm9vdCBBdXRob3JpdHkwHhcNMjAwMTE0MjEzMjMwWhcNMzAwMTExMjEz
MjMwWjA6MRswGQYDVQQKDBJMZXQncyBBdXRoZW50aWNhdGUxGzAZBgNVBAMMEkxB
IEludGVybWVkaWF0ZSBDQTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJf+aA54
RC5pyLA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GfLQPWDc
-----END CERTIFICATE-----
</artwork>
</figure>
<figure anchor="example-header" title="Header in HTTP Request to Origin Server ">
<artwork>Client-Cert: MIIBqDCCAU6gAwIBAgIBBzAKBggqhkjOPQQDAjA6MRswGQYDVQQKDBJM
 ZXQncyBBdXRoZW50aWNhdGUxGzAZBgNVBAMMEkxBIEludGVybWVkaWF0ZSBDQTAeFw0y
 MDAxMTQyMjU1MzNaFw0yMTAxMjMyMjU1MzNaMA0xCzAJBgNVBAMMAkJDMFkwEwYHKoZI
 zj0CAQYIKoZIzj0DAQcDQgAE8YnXXfaUgmnMtOXU/IncWalRhebrXmckC8vdgJ1p5Be5
 F/3YC8OthxM4+k1M6aEAEFcGzkJiNy6J84y7uzo9M6NyMHAwCQYDVR0TBAIwADAfBgNV
 HSMEGDAWgBRm3WjLa38lbEYCuiCPct0ZaSED2DAOBgNVHQ8BAf8EBAMCBsAwEwYDVR0l
 BAwwCgYIKwYBBQUHAwIwHQYDVR0RAQH/BBMwEYEPYmRjQGV4YW1wbGUuY29tMAoGCCqG
 SM49BAMCA0gAMEUCIBHda/r1vaL6G3VliL4/Di6YK0Q6bMjeSkC3dFCOOB8TAiEAx/kH
 SB4urmiZ0NX5r5XarmPk0wmuydBVoU4hBVZ1yhk=
</artwork>
</figure>
</section>

<section anchor="considerations-considered" title="Considerations Considered">

<section anchor="header-injection" title="Header Injection">
<t>This draft requires that the reverse proxy sanitize the headers of the incoming request by removing or overwriting any existing instances of the <spanx style="verb">Client-Cert</spanx> header before dispatching that request to the backend application. Otherwise, a client could inject its own <spanx style="verb">Client-Cert</spanx> header that would appear to the backend to have come from the reverse proxy. Although numerous other methods of detecting/preventing header injection are possible; such as the use of a unique secret value as part of the header name or value or the application of a signature, HMAC, or AEAD, there is no common general standardized mechanism. The potential problem of client header injection is not at all unique to the functionality of this draft and it would therefor be inappropriate for this draft to define a one-off solution. In the absence of a generic standardized solution existing currently, stripping/sanitizing the headers is the de facto means of protecting against header injection in practice today. Sanitizing the headers is sufficient when properly implemented and is normative requirement of <xref target="sec"></xref>.</t>
</section>

<section anchor="the-forwarded-http-extension" title="The Forwarded HTTP Extension">
<t>The <spanx style="verb">Forwarded</spanx> HTTP header field defined in <xref target="RFC7239"></xref> allows proxy components to disclose information lost in the proxying process. The TLS client certificate information of concern to this draft could have been communicated with an extension parameter to the <spanx style="verb">Forwarded</spanx> header field, however, doing so would have had some disadvantages that this draft endeavored to avoid. The <spanx style="verb">Forwarded</spanx> header syntax allows for information about a full the chain of proxied HTTP requests, whereas the <spanx style="verb">Client-Cert</spanx> header of this document is concerned only with conveying information about the certificate presented by the originating client on the TLS connection to the reverse proxy (which appears as the server from that client's perspective) to backend applications.  The multi-hop syntax of the <spanx style="verb">Forwarded</spanx> header is expressive but also more complicated, which would make processing it more cumbersome, and more importantly, make properly sanitizing its content as required by <xref target="sec"></xref> to prevent header injection considerably more difficult and error prone. Thus, this draft opted for the flatter and more straightforward structure of a single <spanx style="verb">Client-Cert</spanx> header.</t>
</section>

<section anchor="the-whole-certificate-and-only-the-whole-certificate" title="The Whole Certificate and Only the Whole Certificate">
<t>Different applications will have varying requirements about what information from the client certificate is needed, such as the subject and/or issuer distinguished name, subject alternative name(s), serial number, subject public key info, fingerprint, etc.. Furthermore some applications like <xref target="I-D.ietf-oauth-mtls"></xref> make use of the entire certificate. In order to accommodate the latter and ensure wide applicability by not trying to cherry-pick particular certificate information, this draft opted to pass the full encoded certificate as the value of the <spanx style="verb">Client-Cert</spanx> header.</t>
<t>The handshake and validation of the client certificate (chain) of the mutually-authenticated TLS connection is performed by reverse proxy.  With the responsibility of certificate validation falling on the proxy, only the end-entity certificate is passed to the backend - the root Certificate Authority is not included nor are any intermediates.</t>
</section>
</section>

<section anchor="acknowledgements" title="Acknowledgements">
<t>The author would like to thank the following individuals who've contributed in various ways ranging from just being generally supportive of bringing forth the draft to providing specific feedback or content:
Annabelle Backman,
Benjamin Kaduk,
Torsten Lodderstedt,
Kathleen Moriarty,
Mike Ounsworth,
Matt Peterson,
Justin Richer,
Rich Salz,
Rifaat Shekh-Yusef,
Travis Spencer,
and
Hans Zandbelt.</t>
<t>[[ Please let me know if you've been erroneously omitted or if you prefer not to be named ]]</t>
</section>

<section anchor="document-history" title="Document History">
<t>[[ To be removed by the RFC Editor before publication as an RFC (should that come to pass) ]]</t>
<t>draft-bdc-something-something-certificate-00</t>
<t>
<list style="symbols">
<t>Initial draft after a time constrained and rushed <eref target="https://datatracker.ietf.org/meeting/106/materials/slides-106-secdispatch-securing-protocols-between-proxies-and-backend-http-servers-00">secdispatch presentation</eref> at IETF 106 in Singapore with the recommendation to write up a draft (at the end of the <eref target="https://datatracker.ietf.org/meeting/106/materials/minutes-106-secdispatch">minutes</eref>) and some folks expressing interest despite the rather poor presentation</t>
</list>
</t>
</section>

</back>

</rfc>
