CBOR Web Token (CWT)Microsoftmbj@microsoft.comhttp://self-issued.info/Swedenerik@wahlstromstekniska.seSpotify ABBirger Jarlsgatan 61, 4trStockholm113 56Sweden+46702691499erdtman@spotify.comARM Ltd.6060Hall in TirolAustriaHannes.Tschofenig@arm.com
Security
ACE Working GroupInternet-DraftJSON Web TokenJWTClaimsConcise Binary Object RepresentationCBORCBOR Object Signing and EncryptionCOSEOAuthACE
CBOR Web Token (CWT) is a compact means of representing claims to be
transferred between two parties. The claims in a
CWT are encoded in the Concise Binary Object Representation (CBOR) and
CBOR Object Signing and Encryption (COSE) is used for added application
layer security protection. A claim is a piece of information asserted
about a subject and is represented as a name/value pair consisting of a
claim name and a claim value.
CWT is derived from JSON Web Token (JWT) but uses CBOR rather than JSON.
The JSON Web Token (JWT) is a standardized security token format
that has found use in OAuth 2.0 and OpenID Connect deployments, among other applications.
JWT uses JSON Web Signature (JWS) and
JSON Web Encryption (JWE) to secure the contents of the JWT,
which is a set of claims represented in JSON.
The use of JSON for encoding information is popular for
Web and native applications, but it is considered inefficient for some
Internet of Things (IoT) systems that use low power radio technologies.
An alternative encoding of claims is defined in this document. Instead
of using JSON, as provided by JWTs, this specification uses
CBOR and calls this new structure "CBOR Web Token (CWT)", which is a
compact means of representing secured claims to be transferred between two
parties. CWT is closely related to JWT. It references the JWT claims
and both its name and pronunciation are derived from JWT. To protect the
claims contained in CWTs, the CBOR Object Signing and Encryption (COSE)
specification is used.
The suggested pronunciation of CWT is the same as the English word
"cot".
In JSON, maps are called objects and only have one kind of map key: a
string. CBOR uses strings, negative integers, and unsigned
integers as map keys. The integers are used for compactness of
encoding and easy comparison. The inclusion of strings allows for an
additional range of short encoded values to be used.
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 BCP 14
when, and only when, they appear in all capitals, as shown here.
This document reuses terminology from JWT
and COSE .
The "StringOrURI" term in this specification has the same meaning and
processing rules as the JWT "StringOrURI" term defined in Section 2
of , except that it is represented as
a CBOR text string instead of a JSON text string.
The "NumericDate" term in this specification has the same meaning and
processing rules as the JWT "NumericDate" term defined in Section 2
of , except that it is represented as
a CBOR numeric date (from Section 2.4.1 of )
instead of a JSON number.
The encoding is modified so that the leading tag 1 (epoch-based date/time) MUST
be omitted.
The human-readable name used to identify a claim.
The CBOR map key used to identify a claim.
The CBOR map value representing the value of the claim.
The CBOR map that contains the claims conveyed by the CWT.
The set of claims that a CWT must contain to be considered valid is
context dependent and is outside the scope of this specification.
Specific applications of CWTs will require implementations to
understand and process some claims in particular ways. However, in
the absence of such requirements, all claims that are not understood
by implementations MUST be ignored.
To keep CWTs as small as possible, the Claim Keys are
represented using integers or text strings.
summarizes all keys
used to identify the claims defined in this document.
None of the claims defined below are intended to be
mandatory to use or implement. They rather provide
a starting point for a set of useful, interoperable claims.
Applications using CWTs should define which specific claims they
use and when they are required or optional.
The iss (issuer) claim has the same meaning and
processing rules as the iss claim defined in Section 4.1.1
of , except that the value is a StringOrURI.
The Claim Key 1 is used to identify this claim.
The sub (subject) claim has the same meaning and
processing rules as the sub claim defined in Section 4.1.2
of , except that the value is a StringOrURI.
The Claim Key 2 is used to identify this claim.
The aud (audience) claim has the same meaning and
processing rules as the aud claim defined in Section 4.1.3
of , except that the value of the audience claim
is a StringOrURI when it is not an array
or each of the audience array element values is a StringOrURI
when the audience claim value is an array.
The Claim Key 3 is used to identify this claim.
The exp (expiration time) claim has the same meaning
and processing rules as the exp claim defined in Section
4.1.4 of , except that the value is a NumericDate.
The Claim Key 4 is used to identify this claim.
The nbf (not before) claim has the same meaning
and processing rules as the nbf claim defined in Section
4.1.5 of , except that the value is a NumericDate.
The Claim Key 5 is used to identify this claim.
The iat (issued at) claim has the same meaning
and processing rules as the iat claim defined in Section
4.1.6 of , except that the value is a NumericDate.
The Claim Key 6 is used to identify this claim.
The cti (CWT ID) claim has the same meaning
and processing rules as the jti claim defined in Section
4.1.7 of , except that the value is a byte string.
The Claim Key 7 is used to identify this claim.
NameKeyValue typeiss1text stringsub2text stringaud3text stringexp4integer or floating-point numbernbf5integer or floating-point numberiat6integer or floating-point numbercti7byte string
The claim values defined in this specification MUST NOT be prefixed with
any CBOR tag. For instance, while CBOR tag 1 (epoch-based date/time)
could logically be prefixed to values of the
exp,
nbf, and
iat
claims, this is unnecessary, since the representation of the claim values
is already specified by the claim definitions.
Tagging claim values would only take up extra space without adding information.
However, this does not prohibit future claim definitions
from requiring the use of CBOR tags for those specific claims.
How to determine that a CBOR data structure is a CWT is application-dependent.
In some cases, this information is known from the application context,
such as from the position of the CWT in a data structure at which the value must be a CWT.
One method of indicating that a CBOR object is a CWT is the use of
the "application/cwt" content type by a transport protocol.
This section defines the CWT CBOR tag as another means for applications to
declare that a CBOR data structure is a CWT.
Its use is optional and is intended for use in cases in which
this information would not otherwise be known.
If present, the CWT tag MUST prefix a tagged object using one of the COSE CBOR tags.
In this example, the COSE_Mac0 tag is used.
The actual COSE_Mac0 object has been excluded from this example.
To create a CWT, the following steps are performed. The order of the
steps is not significant in cases where there are no dependencies
between the inputs and outputs of the steps.
Create a CWT Claims Set containing the desired claims.
Let the Message be the binary representation of the CWT Claims Set.
Create a COSE Header containing the desired set of Header
Parameters. The COSE Header MUST be valid per the
specification.
Depending upon whether the CWT is signed, MACed, or encrypted,
there are three cases:
If the CWT is signed, create a COSE_Sign/COSE_Sign1 object
using the Message as the COSE_Sign/COSE_Sign1 Payload; all
steps specified in for
creating a COSE_Sign/COSE_Sign1 object MUST be followed.
Else, if the CWT is MACed, create a COSE_Mac/COSE_Mac0 object
using the Message as the COSE_Mac/COSE_Mac0 Payload; all
steps specified in for
creating a COSE_Mac/COSE_Mac0 object MUST be followed.
Else, if the CWT is a COSE_Encrypt/COSE_Encrypt0 object,
create a COSE_Encrypt/COSE_Encrypt0 using the Message as
the plaintext for the COSE_Encrypt/COSE_Encrypt0 object;
all steps specified in
for creating a COSE_Encrypt/COSE_Encrypt0 object MUST be
followed.
If a nested signing, MACing, or encryption operation will be
performed, let the Message be the tagged COSE_Sign/COSE_Sign1,
COSE_Mac/COSE_Mac0, or COSE_Encrypt/COSE_Encrypt0, and return to Step 3.
If needed by the application, prepend the COSE object with the appropriate
COSE CBOR tag to indicate the type of the COSE object.
If needed by the application, prepend the COSE object with the CWT CBOR tag
to indicate that the COSE object is a CWT.
When validating a CWT, the following steps are performed. The order
of the steps is not significant in cases where there are no
dependencies between the inputs and outputs of the steps. If any of
the listed steps fail, then the CWT MUST be rejected -- that is,
treated by the application as invalid input.
Verify that the CWT is a valid CBOR object.
If the object begins with the CWT CBOR tag, remove it
and verify that one of the COSE CBOR tags follows it.
If the object is tagged with one of the COSE CBOR tags, remove it
and use it to determine the type of the CWT,
COSE_Sign/COSE_Sign1, COSE_Mac/COSE_Mac0, or
COSE_Encrypt/COSE_Encrypt0.
If the object does not have a COSE CBOR tag, the COSE message
type is determined from the application context.
Verify that the resulting COSE Header includes only parameters
and values whose syntax and semantics are both understood and
supported or that are specified as being ignored when not
understood.
Depending upon whether the CWT is a signed, MACed, or encrypted,
there are three cases:
If the CWT is a COSE_Sign/COSE_Sign1, follow the steps
specified in Section 4
(Signing Objects) for validating a COSE_Sign/COSE_Sign1
object. Let the Message be the COSE_Sign/COSE_Sign1 payload.
Else, if the CWT is a COSE_Mac/COSE_Mac0, follow the steps
specified in Section 6
(MAC Objects) for validating a COSE_Mac/COSE_Mac0 object.
Let the Message be the COSE_Mac/COSE_Mac0 payload.
Else, if the CWT is a COSE_Encrypt/COSE_Encrypt0 object,
follow the steps specified in
Section 5 (Encryption
Objects) for validating a COSE_Encrypt/COSE_Encrypt0 object.
Let the Message be the resulting plaintext.
If the Message begins with a COSE CBOR tag, then
the Message is a CWT that was the subject of nested signing, MACing,
or encryption operations. In this case, return to Step 1,
using the Message as the CWT.
Verify that the Message is a valid CBOR map; let the CWT Claims Set be this CBOR map.
The security of the CWT relies upon on the protections offered by COSE.
Unless the claims in a CWT are protected, an adversary can modify, add, or remove claims.
Since the claims conveyed in a CWT may be used to make authorization decisions,
it is not only important to protect the CWT in transit but also to ensure that
the recipient can authenticate the party that assembled the claims and created the CWT.
Without trust of the recipient in the party that created the CWT, no sensible authorization decision can be made.
Furthermore, the creator of the CWT needs to carefully evaluate each claim value prior to including it in the CWT
so that the recipient can be assured of the validity of the information provided.
While syntactically the signing and encryption operations for Nested
CWTs may be applied in any order, if both signing and encryption are
necessary, normally producers should sign the message and then encrypt
the result (thus encrypting the signature). This prevents attacks in
which the signature is stripped, leaving just an encrypted message, as
well as providing privacy for the signer. Furthermore, signatures
over encrypted text are not considered valid in many jurisdictions.
This section establishes the
IANA "CBOR Web Token (CWT) Claims" registry.
Registration requests are evaluated using the criteria described
in the Claim Key instructions in the registration template below
after a three-week review period on the cwt-reg-review@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 Experts may approve
registration once they are satisfied that such a specification will be published.
[[ Note to the RFC Editor:
The name of the mailing list should be determined in consultation
with the IESG and IANA. Suggested name: cwt-reg-review@ietf.org. ]]
Registration requests sent to the mailing list for review should use
an appropriate subject
(e.g., "Request to register claim: example").
Registration requests that are undetermined for
a period longer than 21 days can be brought to the IESG's attention
(using the iesg@ietf.org mailing list) for resolution.
Criteria that should be applied by the Designated Experts includes
determining whether the proposed registration duplicates existing functionality,
whether it is likely to be of general applicability
or whether it is useful only for a single application,
and whether the registration description is clear.
Registrations for the limited set of values between -256 and 255 and strings of length 1
are to be restricted to claims with general applicability.
IANA must only accept registry updates from the Designated Experts and should direct
all requests for registration to the review mailing list.
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 judgment of the other Experts.
Since a high degree of overlap is expected between the contents of
the "CBOR Web Token (CWT) Claims" registry and the "JSON Web Token Claims" registry,
overlap in the corresponding pools of Designated Experts would be useful
to help ensure that an appropriate level of coordination between the registries is maintained.
The human-readable name requested (e.g., "iss").
Brief description of the claim (e.g., "Issuer").
Claim Name of the equivalent JWT claim, as registered in .
CWT claims should normally have a corresponding JWT claim.
If a corresponding JWT claim would not make sense,
the Designated Experts can choose to accept registrations
for which the JWT Claim Name is listed as "N/A".
CBOR map key for the claim.
Different ranges of values use different registration policies .
Integer values from -256 to 255 and strings of length 1 are designated
as Standards Action. Integer values from -65536 to -257 and from 256 to 65535
and strings of length 2 are designated as Specification Required. Integer
values greater than 65535 and strings of length greater than 2 are
designated as Expert Review. Integer values less than -65536 are marked
as Private Use.
CBOR types that can be used for the claim value.
For Standards Track RFCs, list the "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.
Reference to the document or documents that specify the parameter, preferably including URIs that can be used to retrieve copies of the documents. An indication of the relevant sections may also be included but is not required.
Claim Name: (RESERVED)Claim Description: This registration reserves the key value 0.JWT Claim Name: N/AClaim Key: 0Claim Value Type(s): N/AChange Controller: IESGSpecification Document(s): [[ this specification ]]Claim Name: issClaim Description: IssuerJWT Claim Name: issClaim Key: 1Claim Value Type(s): text stringChange Controller: IESGSpecification Document(s): of [[ this specification ]]Claim Name: subClaim Description: SubjectJWT Claim Name: subClaim Key: 2Claim Value Type(s): text stringChange Controller: IESGSpecification Document(s): of [[ this specification ]]Claim Name: audClaim Description: AudienceJWT Claim Name: audClaim Key: 3Claim Value Type(s): text stringChange Controller: IESGSpecification Document(s): of [[ this specification ]]Claim Name: expClaim Description: Expiration TimeJWT Claim Name: expClaim Key: 4Claim Value Type(s): integer or floating-point numberChange Controller: IESGSpecification Document(s): of [[ this specification ]]Claim Name: nbfClaim Description: Not BeforeJWT Claim Name: nbfClaim Key: 5Claim Value Type(s): integer or floating-point numberChange Controller: IESGSpecification Document(s): of [[ this specification ]]Claim Name: iatClaim Description: Issued AtJWT Claim Name: iatClaim Key: 6Claim Value Type(s): integer or floating-point numberChange Controller: IESGSpecification Document(s): of [[ this specification ]]Claim Name: ctiClaim Description: CWT IDJWT Claim Name: jtiClaim Key: 7Claim Value Type(s): byte stringChange Controller: IESGSpecification Document(s): of [[ this specification ]]
This section registers the application/cwt media type
in the "Media Types" registry
in the manner described in RFC 6838,
which can be used to indicate that the content is a CWT.
Type name: application
Subtype name: cwt
Required parameters: N/A
Optional parameters: N/A
Encoding considerations: binary
Security considerations: See the Security Considerations section of [[ this specification ]]
Interoperability considerations: N/A
Published specification: [[ this specification ]]
Applications that use this media type:
IoT applications sending security tokens over HTTP(S), CoAP(S), and other transports.
Fragment identifier considerations: N/A
Additional information:Magic number(s): N/AFile extension(s): N/AMacintosh file type code(s): N/A
Person & email address to contact for further information:
IESG, iesg@ietf.org
Intended usage: COMMON
Restrictions on usage: none
Author: Michael B. Jones, mbj@microsoft.com
Change controller: IESG
Provisional registration? No
This section registers the CoAP Content-Format ID for the "application/cwt" media type
in the "CoAP Content-Formats" registry .
Media Type: application/cwtEncoding: - Id: TBD (maybe 61) Reference: [[ this specification ]]
This section registers the CWT CBOR tag
in the "CBOR Tags" registry .
CBOR Tag: TBD (maybe 61 to use the same value as the Content-Format)Data Item: CBOR Web Token (CWT)Semantics: CBOR Web Token (CWT), as defined in [[ this specification ]]Description of Semantics: [[ this specification ]]Point of Contact: Michael B. Jones, mbj@microsoft.comMedia TypesIANACoAP Content-FormatsIANAConcise Binary Object Representation (CBOR) TagsIANAJSON Web Token ClaimsIANA
This appendix includes a set of CWT examples that show how the CWT Claims Set can be protected.
There are examples that are signed, MACed, encrypted, and that use nested signing and encryption.
To make the examples easier to read, they are presented both as hex strings and
in the extended CBOR diagnostic notation described in Section 6 of .
Where a byte string is to carry an embedded CBOR-encoded item, the
diagnostic notation for this CBOR data item can be enclosed
in '<<' and '>>' to notate the byte string resulting from encoding the
data item, e.g., h'63666F6F' translates to <<"foo">>.
The CWT Claims Set used for the different examples
displays usage of all the defined claims. For signed and MACed
examples, the CWT Claims Set is the CBOR encoding as a byte string.
This section contains the keys used to sign, MAC, and encrypt the messages in this appendix.
Line breaks are for display purposes only.
This section shows a signed CWT with a single recipient and a full CWT Claims Set.
The signature is generated using the private key listed in
and it can be validated using the public key from .
Line breaks are for display purposes only.
This section shows a MACed CWT with a single recipient, a full CWT Claims Set,
and a CWT tag.
The MAC is generated using the 256-bit symmetric key from with a 64-bit truncation.
Line breaks are for display purposes only.
This section shows an encrypted CWT with a single recipient and a full CWT Claims Set.
The encryption is done with AES-CCM mode using the 128-bit symmetric key from with a 64-bit tag and 13-byte nonce, i.e., COSE AES-CCM-16-64-128.
Line breaks are for display purposes only.
This section shows a Nested CWT, signed and then encrypted, with a single recipient and a full CWT Claims Set.
The signature is generated using the private ECDSA key from
and it can be validated using the public ECDSA parts from .
The encryption is done with AES-CCM mode using the 128-bit symmetric key from
with a 64-bit tag and 13-byte nonce, i.e., COSE AES-CCM-16-64-128.
The content type is set to CWT to indicate that there are multiple
layers of COSE protection before finding the CWT Claims Set. The decrypted
ciphertext will be a COSE_sign1 structure. In this example, it is the same
one as in , i.e., a Signed CWT Claims Set.
Note that there is no limitation to the number of layers; this is an
example with two layers.
Line breaks are for display purposes only.
This section shows a MACed CWT with a single recipient and a simple
CWT Claims Set. The CWT Claims Set with a floating-point 'iat' value.
The MAC is generated using the 256-bit symmetric key from
with a 64-bit truncation.
Line breaks are for display purposes only.
This specification is based on JSON Web Token (JWT) ,
the authors of which also include Nat Sakimura and John Bradley.
It also incorporates suggestions made by many people, including
Carsten Bormann,
Alissa Cooper,
Esko Dijk,
Benjamin Kaduk,
Warren Kumari,
Carlos Martinez,
Alexey Melnikov,
Kathleen Moriarty,
Eric Rescorla,
Dan Romascanu,
Adam Roach,
Kyle Rose,
Jim Schaad,
Ludwig Seitz,
and
Göran Selander.
[[ RFC Editor: Is it possible to preserve the non-ASCII spellings of the names
Erik Wahlström and Göran Selander in the final specification? ]]
[[ to be removed by the RFC Editor before publication as an RFC ]]
-14
Cleaned up the descriptions of the numeric ranges of claim keys being registered
in the registration template for the "CBOR Web Token (CWT) Claims" registry,
as suggested by Adam Roach.
Clarified the relationships between the JWT and CWT "NumericDate" and "StringOrURI" terms,
as suggested by Adam Roach.
Eliminated unnecessary uses of the word "type",
as suggested by Adam Roach.
Added the text "IANA must only accept registry updates from the Designated Experts and should direct
all requests for registration to the review mailing list" from RFC 7519, as suggested by Amanda Baber of IANA,
which is also intended to address Alexey Melnikov's comment.
Removed a superfluous comma, as suggested by Warren Kumari.
Acknowledged additional reviewers.
-13
Clarified the registration criteria applied to different ranges of Claim Key values,
as suggested by Kathleen Moriarty and Dan Romascanu.
No longer describe the syntax of CWT claims as being the same as
that of the corresponding JWT claims, as suggested by Kyle Rose.
Added guidance about the selection of the Designated Experts, as suggested by Benjamin Kaduk.
Acknowledged additional reviewers.
-12
Updated the RFC 5226 reference to RFC 8126.
Made the IANA registration criteria consistent across sections.
Stated that registrations for the limited set of values between -256 and 255 and strings of length 1
are to be restricted to claims with general applicability.
Changed the "Reference" field name to "Description of Semantics" in the CBOR Tag registration request.
Asked the RFC Editor whether it is possible to preserve the non-ASCII spellings of the names
Erik Wahlström and Göran Selander in the final specification.
-11
Corrected the "iv" value in the signed and encrypted CWT example.
Mention CoAP in the application/cwt media type registration.
Changed references of the form "Section 4.1.1 of JWT <xref target="RFC7519"/>"
to "Section 4.1.1 of <xref target="RFC7519"/>" so that rfcmarkup will generate
correct external section reference links.
Updated Acknowledgements.
-10
Clarified that the audience claim value can be a single audience value or
an array of audience values, just as is the case for the JWT "aud" claim.
Clarified the nested CWT description.
Changed uses of "binary string" to "byte string".
-09
Added key ID values to the examples.
Key values for the examples are now represented in COSE_Key format
using CBOR diagnostic notation.
-08
Updated the diagnostic notation for embedded objects in the examples,
addressing feedback by Carsten Bormann.
-07
Updated examples for signing and encryption. Signatures are now
deterministic as recommended by COSE specification.
-06
Addressed review comments by Carsten Bormann and Jim Schaad.
All changes were editorial in nature.
-05
Addressed working group last call comments with the following changes:
Say that CWT is derived from JWT, rather than CWT is a profile of JWT.
Used CBOR type names in descriptions, rather than major/minor type numbers.
Clarified the NumericDate and StringOrURI descriptions.
Changed to allow CWT claim names to use values of any legal CBOR map key type.
Changed to use the CWT tag to identify nested CWTs instead of the CWT content type.
Added an example using a floating-point date value.
Acknowledged reviewers.
-04
Specified that the use of CBOR tags to prefix any of the claim values defined in this specification is NOT RECOMMENDED.
-03
Reworked the examples to include signed, MACed, encrypted, and nested CWTs.
Defined the CWT CBOR tag and explained its usage.
-02
Added IANA registration for the application/cwt media type.
Clarified the nested CWT language.
Corrected nits identified by Ludwig Seitz.
-01
Added IANA registration for CWT Claims.
Added IANA registration for the application/cwt CoAP content-format type.
Added Samuel Erdtman as an editor.
Changed Erik's e-mail address.
-00
Created the initial working group version based on draft-wahlstroem-ace-cbor-web-token-00.