<?xml version="1.0" encoding="us-ascii"?>
<?xml-stylesheet type='text/xsl' href='http://xml.resource.org/authoring/rfc2629.xslt' ?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">

<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>

<rfc category="std" docName="draft-jones-oauth-proof-of-possession-01.txt"
     ipr="trust200902">
  <front>
    <title abbrev="proof-of-possession for JWTs">Proof-Of-Possession Semantics for JSON Web Tokens (JWTs)</title>

    <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
      <organization>Microsoft</organization>
      <address>
        <email>mbj@microsoft.com</email>
        <uri>http://self-issued.info/</uri>
      </address>
    </author>

    <author fullname="John Bradley" initials="J." surname="Bradley">
      <organization abbrev="Ping Identity">Ping Identity</organization>
      <address>
	<email>ve7jtb@ve7jtb.com</email>
	<uri>http://www.thread-safe.com/</uri>
      </address>
    </author>

    <author initials="H." surname="Tschofenig" fullname="Hannes Tschofenig">
			<organization>ARM Limited</organization>
			<address>
				<postal>
					<street></street>
					<city></city>
					<code></code>
					<country>Austria</country>
				</postal>
				<phone></phone>
				<email>Hannes.Tschofenig@gmx.net</email>
				<uri>http://www.tschofenig.priv.at</uri>
			</address>
		</author>


    <date year="2014" />

    <area>Security</area>
    <workgroup>OAuth Working Group</workgroup>

    <keyword>RFC</keyword>
    <keyword>Request for Comments</keyword>
    <keyword>I-D</keyword>
    <keyword>Internet-Draft</keyword>
    <keyword>JSON Web Token</keyword>
    <keyword>JWT</keyword>
    <keyword>Proof of Possession</keyword>
    <keyword>Holder of Key</keyword>

    <abstract>
      <t>
        This specification defines how to express a declaration in a
	JSON Web Token (JWT)
	that the presenter of the JWT possesses a particular key
	and that the recipient can cryptographically confirm
	proof-of-possession of the key by the presenter.
	This property is also sometimes described as
	the presenter being a holder-of-key.
      </t>
    </abstract>

  </front>

  <middle>
    <section title="Introduction">
      <t>
        This specification defines how to express a declaration in a
	JSON Web Token (JWT) <xref target="I-D.ietf-oauth-json-web-token"/>
	that the presenter of the JWT possesses a particular key
	and that the recipient can cryptographically confirm
	proof-of-possession of the key by the presenter.
	This property is also sometimes described as
	the presenter being a holder-of-key.
     </t>
	 
	 <t>Envision the following use case. An OAuth 2.0 authorization server 
generates a JWT and places a symmetric key inside the newly introduced confirmation claim. This symmetric 
key is encrypted with a key known only to the authorization server and the recipient. The JWT is then sent 
to the presenter. Since the presenter is unable to obtain the encrypted symmetric key the authorization server 
conveys that symmetric key separately to the presenter. Now, the presenter is in possession of the symmetric key as
well as the JWT (which includes the confirmation claim element). When the presenter needs to utilize the JWT to a recipient 
it also needs to demonstrate possession of the symmetric key; the presenter, for example, uses the symmetric key in a challenge / response protocol with the recipient. 
The recipient is able to verify that it indeed interacts with the genuine presenter by decrypting the JWK contained inside the confirmation claim of the JWT. 
By doing this the recipient obtains the symmetric key, which it then uses to verify a cryptographically protected messages exchanged with the presenter. 
</t>
  </section>
  
  <!-- ====================================================================== -->

      <section title="Terminology">
        <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 RFC 2119 <xref target="RFC2119"/>.
        </t>
        <t>
          Unless otherwise noted, all the protocol parameter names and values are case sensitive.
        </t>
        <t>
	  This specification uses terms defined in
	  the JSON Web Token (JWT) <xref target="I-D.ietf-oauth-json-web-token"/>,
	  JSON Web Key (JWK) <xref target="I-D.ietf-jose-json-web-key"/>, and
	  JSON Web Encryption (JWE) <xref target="I-D.ietf-jose-json-web-encryption"/> specifications.
        </t>
	 
    </section>

	<!-- ====================================================================== -->

    <section title='Proof-Of-Possession Representation' anchor="PoP">
      <t>
	The presenter of a JWT declares that it possesses a particular key
	and that the recipient can cryptographically confirm
	proof-of-possession of the key by the issuer by including a
	<spanx style="verb">cnf</spanx> (confirmation) claim in the JWT
	whose value is a JSON object, with the JSON object containing a
	<spanx style="verb">jwk</spanx> (JSON Web Key) member
	identifying the key.
      </t>
      <t>
	The presenter can be identified in one of two ways by the JWT,
	depending upon the application requirements.
	If the JWT contains a <spanx style="verb">sub</spanx> (subject) claim,
	the presenter is the subject identified by the JWT.
	(In some applications, the subject identifier will be relative to
	the issuer identified by the <spanx style="verb">iss</spanx> (issuer) claim.)
	If the JWT contains no <spanx style="verb">sub</spanx> (subject) claim,
	the presenter is the issuer identified by the JWT
	using the <spanx style="verb">iss</spanx> (issuer) claim.
	The case in which the presenter is the subject of the JWT is analogous to
	SAML 2.0 <xref target="OASIS.saml-core-2.0-os"/> SubjectConfirmation usage.
	At least one of the <spanx style="verb">sub</spanx> and <spanx style="verb">iss</spanx>
	claims MUST be present in the JWT and in some use cases both MUST be present.
	In cases where the presenter shall be anonymous only the <spanx style="verb">iss</spanx> (issuer) claim may be present identifying the party that issued the JWT. 
      </t>

      <section title="Proof-of-Possession of an Asymmetric Key" anchor="PrivatePOP">

	<t>
	  When the key held by the issuer is an asymmetric key pair,
	  the value of the <spanx style="verb">jwk</spanx> member
	  is a JSON Web Key (JWK) <xref target="I-D.ietf-jose-json-web-key"/>
	  representing the public key.
	  The example shown in <xref target="JWT-AsymmetricKey"/> demonstrates such a declaration
	  in the JWT Claims Set of a JWT:
	</t>
	<figure title="JWT with a Confirmation Claim containing a Public Key" anchor="JWT-AsymmetricKey">
	  <artwork><![CDATA[
  {
   "iss":"xas.example.com",
   "aud":"http://auth.example.com",
   "exp":"1361398824",
   "nbf":"1360189224",
   "cnf":{
     "jwk":{
       "kid":"pk1"
       "kty":"EC",
       "use":"sig",
       "crv":"P-256",
       "x":"18wHLeIgW9wVN6VD1Txgpqy2LszYkMf6J8njVAibvhM",
       "y":"-V4dS4UaLMgP_4fY4j8ir7cl1TXlFdAgcx55o7TkcSA"
      }
    }
  }
]]></artwork>
	</figure>

	<t>
	  The JWK MUST contain the required elements of a JWK (as needed for the particular type)
	  and MAY contain other JWK elements. It is highly recommended to include the <spanx style="verb">kid</spanx> (key ID) element 
	  in the JWK as well since it allows the presenter and the recipient to later use this key id to refer to the exchanged key.
	</t>

      </section>

      <section title="Proof-of-Possession of a Symmetric Key" anchor="SymmetricPOP">

	<t>
	  When the key held by the issuer is a symmetric key,
	  the value of the <spanx style="verb">jwk</spanx> member
	  is an encrypted JSON Web Key (JWK) <xref target="I-D.ietf-jose-json-web-key"/>
	  encrypted with a key known to the recipient.
	  The rules for encrypting a JWK are found in
	  Section 6 of the JSON Web Key <xref target="I-D.ietf-jose-json-web-key"/> specification. 
	  Note that the JWE compact serialization is used. 
	</t>
	<t>
	  The example shown in <xref target="JWK-symmetricKey"/> illustrates a symmetric key that is subsequently
	  encrypted for use in the <spanx style="verb">jwk</spanx> member:
	</t>
	<figure anchor="JWK-symmetricKey" title="JWK with a Symmetric Key">
	  <artwork><![CDATA[
  {
   "kid":"sessionkey-1" 
   "kty":"oct",
   "alg":"HS256",
   "k":"ZoRSOrFzN_FzUA5XKMYoVHyzff5oRJxl-IXRtztJ6uE"
  }
]]></artwork>
	</figure>
	<t>
	  The UTF-8 <xref target="RFC3629"/> encoding of the JWK
	  shown in <xref target="JWK-symmetricKey"/> would be used as the JWE Plaintext.
	</t>
	<t>
	  An example JWE header is shown in <xref target="JWE-header"/>. It provides the necessary information 
for encrypting the JWK.
	</t>
	<figure anchor="JWE-header" title="Header of the JWE with Information about the Encryption of the Symmetric Key">
	  <artwork><![CDATA[
  {
   "kid":"longterm-12345"
   "alg":"RSA1_5",
   "enc":"A128CBC-HS256",
   "cty":"jwk+json",
  }
]]></artwork>
	</figure>
	<t>
	  The example in <xref target="JWT-SymmetricKey"/> illustrates a JWT with the encrypted symmetric key as the
	  <spanx style="verb">jwk</spanx> claim value:
	</t>
	<figure title="JWT with a Confirmation Claim containing the Encrypted Symmetric Key" anchor="JWT-SymmetricKey">
	  <artwork><![CDATA[
  {
   "iss": "https://server.example.com",
   "sub": "24400320",
   "aud": "s6BhdRkqt3",
   "nonce": "n-0S6_WzA2Mj",
   "exp": 1311281970,
   "iat": 1311280970,
   "cnf":{
     "jwk":
       "eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiY3R5Ijoi
        andrK2pzb24ifQ. ... (remainder of JWE omitted for brevity)"
     }
  }
]]></artwork>
	</figure>
	<t>
	  Note that the case in which the <spanx style="verb">jwk</spanx> claim
	  contains an unencoded JWK value and the case in which it contains
	  an encrypted JWK value can be distinguished by the type of the member value.
	  In the first case, the value is a JSON object containing the JWK and
	  in the second case, the value is a string containing the JWE JSON Serialization
	  of the encrypted JWK representation.
	</t>

      </section>

      <section title="Confirmation" anchor="Confirmation">
	<t>
	  The <spanx style="verb">cnf</spanx> (confirmation) claim is used in the JWT
	  to contain the <spanx style="verb">jwk</spanx> element because
	  a proof-of-possession key may not be the only means of confirming
	  the authenticity of the token.
	  This is analogous to the SAML 2.0 <xref target="OASIS.saml-core-2.0-os"/>
	  SubjectConfirmation element, in which a number of different
	  subject confirmation methods can be included,
	  including proof-of-possession key information.
	  When a recipient receives a <spanx style="verb">cnf</spanx> claim
	  with a member that it does not understand, it MUST ignore that member.
	</t>
	<t>
	  This specification defines a registry for these elements
	  in <xref target="CnfReg"/> and registers the <spanx style="verb">jwk</spanx>
	  member within the registry.
	</t>
      </section>

      <section title="Specifics Intentionally Not Specified" anchor="NotSpecified">
	<t>
	  Proof-of-possession is typically demonstrated by having the issuer sign
	  a value determined by the recipient using the key possessed by the issuer.
	  This value is sometimes called a "nonce" or a "challenge".
	</t>
	<t>
	  The means of communicating the nonce and the nature of its contents
	  are intentionally not described in this specification,
	  as different protocols will communicate this information in different ways.
	  Likewise, the means of communicating the signed nonce is also not specified,
	  as this is also protocol-specific.
	</t>
	<t>For a protocol that applies the mechanisms described in this document to the OAuth 2.0 context please take a look at <xref target="I-D.hunt-oauth-pop-architecture"/>.</t>
<!--	<t>
	  Note that there are another means of proving possession of the key
	  when it is a symmetric key is to encrypt the key to the recipient.
	  The means of obtaining a key for the recipient is likewise protocol-specific.
	</t>
-->       </section>

    </section>

	<!-- ====================================================================== -->

    <section anchor="Security" title="Security Considerations">
      <t>
        All of the normal security issues, especially in relationship
        to comparing URIs and dealing with unrecognized values, that
        are discussed in <xref target="I-D.ietf-oauth-json-web-token">JWT</xref> also apply
        here.
      </t>
	  <t>Similarly to other information included in a JWT it is necessary to apply data origin authentication and integrity protection (via a keyed message digest or a digital signature). Data origin authentication ensures that the recipient of the JWT learns about the entity that created the JWT since this will be important for any policy decisions. Integrity protection prevents an adversary from changing any elements conveyed within the JWT payload. Special care has to be applied when carrying symmetric keys inside the JWT since those do not only require integrity protection but also confidentiality protection. </t>
      <t>
        In addition, proof-of-possession introduces its own unique security issues.
	Possessing the key is only valuable if it is kept secret.
	Appropriate means must be used to ensure that unintended parties
	do not learn the symmetric key or the private key (in case of an asymmetric crypto-system).
      </t>
	  <t>A recipient may not understand the newly introduced "cnf" claim and may consequently treat it as a bearer token. While this is a legitimate concern it is outside the scope of this specification since demonstration the possession of the key associated with the "cnf" claim is not covered by this specification. For more details please consult <xref target="I-D.hunt-oauth-pop-architecture"/>. </t>
    </section>

	<!-- ====================================================================== -->

    <section anchor="IANA" title="IANA Considerations">

      <t>
	The following registration procedure is used for all the
	registries established by this specification.
      </t>
      <t>
	Values are registered with a Specification Required
	<xref target="RFC5226"/> after a two-week review period on the [TBD]@ietf.org mailing
	list, on the advice of one or more Designated Experts. However, to allow for the
	allocation of values prior to publication, the Designated Expert(s) may approve
	registration once they are satisfied that such a specification will be published.
      </t>
      <t>
	Registration requests must be sent to the [TBD]@ietf.org mailing list for review and
	comment, with an appropriate subject (e.g., "Request for access token type: example").
	[[ Note to the RFC Editor:
	The name of the mailing list should be determined in consultation
	with the IESG and IANA. Suggested name: jwt-reg-review. ]]
      </t>
      <t>
	Within the review period, the Designated Expert(s) will either approve or
	deny the registration request, communicating this decision to the review list and IANA.
	Denials should include an explanation and, if applicable, suggestions as to how to make
	the request successful.
	Registration requests that are undetermined for
	a period longer than 21 days can be brought to the IESG's attention
	(using the iesg@iesg.org mailing list) for resolution.
      </t>
      <t>
	Criteria that should be applied by the Designated Expert(s) includes
	determining whether the proposed registration duplicates existing functionality,
	determining whether it is likely to be of general applicability
	or whether it is useful only for a single application,
	and whether the registration makes sense.
      </t>
      <t>
	IANA must only accept registry updates from the Designated Expert(s) and should direct
	all requests for registration to the review mailing list.
      </t>
      <t>
	It is suggested that multiple Designated Experts be appointed who are able to
	represent the perspectives of different applications using this specification,
	in order to enable broadly-informed review of registration decisions.
	In cases where a registration decision could be perceived as
	creating a conflict of interest for a particular Expert,
	that Expert should defer to the judgement of the other Expert(s).
      </t>

    <section anchor="ClaimsRegistry" title="JSON Web Token Claims Registration">
	<t>
	  This specification registers the  <spanx style="verb">cnf</spanx> claim in the IANA
	  JSON Web Token Claims registry
	  defined in <xref target="I-D.ietf-oauth-json-web-token"/>.
	</t>

	   <section anchor='ClaimsContents' title='Registry Contents'>
	  <t> <?rfc subcompact="yes"?>
	  <list style='symbols'>
	    <t>
	      Claim Name: <spanx style="verb">cnf</spanx>
	    </t>
	    <t>
	      Claim Description: Confirmation
	    </t>
	    <t>
	      Change Controller: IESG
	    </t>
	    <t>
	      Specification Document(s): <xref target="Confirmation"/> of this document
	    </t>
	  </list>
	  </t>
	    </section>
	</section>

    <section title="JWT Confirmation Methods Registry" anchor="CnfReg">
	<t>
	  This specification establishes the
	  IANA JWT Confirmation Methods registry
	  for JWT <spanx style="verb">cnf</spanx> member values.
	  The registry records the confirmation method member
	  and a reference to the specification that defines it.
	</t>

        <section title="Registration Template" anchor="CnfTemplate">
          <t>
            <list style='hanging'>
              <t hangText='Confirmation Method Value:'>
                <vspace/>
                The name requested (e.g., "example").
		Because a core goal of this specification is for the resulting
		representations to be compact, it is RECOMMENDED that the name be short
		-- not to exceed 8 characters without a compelling reason to do so.
		This name is case-sensitive.
		Names may not match other registered names in a case-insensitive manner
		unless the Designated Expert(s) state that there is a compelling reason
		to allow an exception in this particular case.
              </t>
              <t hangText='Confirmation Method Description:'>
                <vspace/>
                Brief description of the confirmation method (e.g., "Example description").
              </t>
              <t hangText='Change Controller:'>
                <vspace/>
                For Standards Track RFCs, state "IESG". For others, give the name of the
                responsible party. Other details (e.g., postal address, email address, home page
                URI) may also be included.
              </t>
              <t hangText='Specification Document(s):'>
                <vspace/>
                Reference to the document(s) that specify the parameter, preferably including URI(s) that
                can be used to retrieve copies of the document(s). An indication of the relevant
                sections may also be included but is not required.
              </t>
            </list>
          </t>
        </section>

        <section title="Initial Registry Contents" anchor="CnfContents">
          <t> <?rfc subcompact="yes"?>
            <list style='symbols'>
              <t>
                Confirmation Method Value: <spanx style="verb">jwk</spanx>
              </t>
              <t>
                Confirmation Method Description: JSON Web Key or Encrypted JSON Web Key
              </t>
              <t>
                Change Controller: IESG
              </t>
              <t>
                Specification Document(s): <xref target="PoP"/> of [[ this document ]]
              </t>
            </list>
          </t>
	    </section>
	
    </section>

 </section>

	<!-- ====================================================================== -->

    <section title="Acknowledgements">
       <t>We would like to thanks James Manger for his review feedback. </t>
    </section>
<!-- ====================================================================== -->

  </middle>

  <back>
    <references title="Normative References">
      <?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml' ?>
      <?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.3629.xml' ?>
      <?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.5226.xml' ?>

	  <?rfc include="reference.I-D.ietf-jose-json-web-key"?>
	  <?rfc include="reference.I-D.ietf-jose-json-web-encryption"?>
	  <?rfc include="reference.I-D.ietf-oauth-json-web-token"?>
	  
    </references>

    <references title="Informative References">
	  <?rfc include="reference.I-D.hunt-oauth-pop-architecture"?>
      <?rfc include='http://xml.resource.org/public/rfc/bibxml2/reference.OASIS.saml-core-2.0-os.xml' ?>
    </references>

	<!--
    <section title="Open Issues" anchor="TBD">
      <t>
	In some conversations,
	we have said that it is the issuer of the JWT that possesses the key,
	and in some conversations,
	we have said that it is the presenter of the JWT that possesses the key.
	Which description should we use?
      </t>
    </section>
    --> 
	
    <section title="Document History" anchor="History">
      <t>
	[[ to be removed by the RFC Editor before publication as an RFC ]]
      </t>

	  <t>
        -01
        <list style='symbols'>
          <t>Updated affiliation.</t>
		  <t>Various editorial changes.</t>
          <t>Updates to the security consideration section based on review feedback by James Manager.</t>
		  <t>Included the kid element in the examples (as requested by James Manger).</t>
		  <t>Expanded the introduction section.</t>
		  <t>Moved the terminology/RFC2119 boilerplate text from the introduction to a separate terminology section.</t>
        </list>
      </t>
	  
      <t>
        -00
        <list style='symbols'>
          <t>Wrote the first draft.</t>
        </list>
      </t>
    </section>     

  </back>
</rfc>
