Securing Verifiable Credentials using JSON Web Tokens

W3C Working Draft

More details about this document
This version:
https://www.w3.org/TR/2023/WD-vc-jwt-20230525/
Latest published version:
https://www.w3.org/TR/vc-jwt/
Latest editor's draft:
https://w3c.github.io/vc-jwt/
History:
https://www.w3.org/standards/history/vc-jwt
Commit history
Editors:
Orie Steele (Transmute)
Michael Jones (independent)
Michael Prorock (Mesur.io)
Feedback:
GitHub w3c/vc-jwt (pull requests, new issue, open issues)

Abstract

This specification defines how to secure Verifiable Credentials with JSON Web Tokens (JWT) [RFC7519], which build on JSON Web Signatures (JWS) [RFC7515]. This enables Verifiable Credentials to be easily integrated into ecosystems that already support JSON Web Tokens.

Status of This Document

This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.

This document was published by the Verifiable Credentials Working Group as a Working Draft using the Recommendation track.

Publication as a Working Draft does not imply endorsement by W3C and its Members.

This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

This document is governed by the 2 November 2021 W3C Process Document.

1. Introduction

JSON Web Token (JWT) [RFC7519] is a widely-used means of expressing claims to be transferred between two parties. Providing a representation of the Verifiable Credentials Data Model for JWT allows existing systems and libraries to participate in the ecosystem described in Section ecosystem overview. A JWT encodes a set of claims as a JSON object that is contained in a JSON Web Signature (JWS) [RFC7515] and/or JSON Web Encryption (JWE) [RFC7516]. For this specification, the use of JWE is out of scope.

1.1 Verifiable Credentials Data Model

This specification describes how to secure media types expressing Verifiable Credentials and Verifiable Presentations as described in the [VC-DATA-MODEL], using JWTs [RFC7519].

Note

The application/vc+jwt media type described in this specification defines an example of a unidirectional mapping to a base media type defined in the [VC-DATA-MODEL]; see Appendix A.4.1.

2. Securing JSON

This section provides guidance on how to use JSON [RFC7159] claimsets with JWT registered claims to construct a JWT that can be mapped to a verifiable credential. This section also describes how to use content types and token types to distinguish different representations of verifiable credentials.

Note

This representation relies on claims registered in the IANA JSON Web Token Claims Registry whenever possible.

Note

Production of this representation does not use vc+ld+json as an input.

2.1 Credential Header

typ MUST use the media type vc+jwt.

2.2 Credential

Note

The vc and vp claims MUST NOT be present when the content type header parameter is set to credential-claims-set+json.

2.3 Verifiable Credential

3. Securing the Core VC Data Model

The use of Verifiable Credentials often involves the representation and exchange of structured data in the form of JSON-LD as this is the format of the core data model. While JSON-LD provides a flexible and extensible format for describing data, it is important to note that it also provides a linkage between the data structure and semantic meaning of data.

This section outlines how JSON-LD encoded claimset can be secured using either JOSE or COSE.

A benefit to this approach is that payloads can be made to conform directly to the [VC-DATA-MODEL] without any mapping or transformation.

3.1 With JOSE

3.1.1 Securing JSON-LD VCs with JOSE

This section details how to secure data payloads with the type application/vc+ld+json with JOSE.

[rfc7515] MAY be used to secure this media type.

When using this approach, the typ MUST be vc+ld+jwt

When using this approach, the cty MUST be vc+ld+json

See Common JOSE Header Parameters for additional details regarding usage of typ and cty.

Examples
Credential Header
Credential
Verifiable Credential

3.1.2 Securing JSON-LD VPs with JOSE

This section details how to secure verifiable presentations with the type application/vp+ld+json with JOSE.

[rfc7515] MAY be used to secure this media type.

When using this approach, the typ MUST be vp+ld+jwt

When using this approach, the cty MUST be vp+ld+json

See Common JOSE Header Parameters for additional details regarding usage of typ and cty.

Examples
Presentation Header
Presentation
Verifiable Presentation

3.2 With COSE

COSE [rfc8152] is a common approach to encoding and securing information using CBOR [rfc8949]. Verifiable credentials MAY be secured using COSE [rfc8152] and MUST be identified through use of content types as outlined in this section.

3.2.1 Securing JSON-LD VCs with COSE

This section details how to secure data with the type application/vc+ld+json with COSE.

[rfc8152] MAY be used to secure this media type.

When using this approach, the type (TBD) MUST be vc+ld+cwt

When using this approach, the content type (3) MUST be application/vc+ld+json

See Common COSE Header Parameters for additional details.

See Concise Binary Object Representation (CBOR) Tags for additional details.

Issue 67: typ for COSE

There is no registered tag for typ in COSE.

This prevents following the guidance from the JWT BCP

4. Conformance

As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.

The key words MAY, MUST, and MUST NOT in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

5. Privacy Considerations

Verifiable Credentials often contain sensitive information that needs to be protected to ensure the privacy and security of organizations and individuals. This section outlines some privacy considerations relevant to implementers and users.

Implementers are advised to note and abide by all privacy considerations called out in the [VC-DATA-MODEL].

Implementers are additionally advised to reference the Privacy Consideration section of the JWT specification for privacy guidance.

In addition to the privacy recommendations in the [VC-DATA-MODEL], the following considerations are given:

These considerations are not exhaustive, and implementers and users are advised to consult additional privacy resources and best practices to ensure the privacy and security of Verifiable Credentials implemented using VC-JWT.

6. Security Considerations

This section outlines security considerations for implementers and users of this specification. It is important to carefully consider these factors to ensure the security and integrity of Verifiable Credentials when implemented using JWTs.

When implementing VC-JWTs, it is essential to address all security issues relevant to broad cryptographic applications. This especially includes protecting the user's asymmetric private and symmetric secret keys, as well as employing countermeasures against various attacks. Failure to adequately address these issues could compromise the security and integrity of Verifiable Credentials, potentially leading to unauthorized access, modification, or disclosure of sensitive information.

Implementers are advised to follow best practices and established cryptographic standards to ensure the secure handling of keys and other sensitive data. Additionally, conduct regular security assessments and audits to identify and address any vulnerabilities or threats.

Follow all security considerations outlined in [rfc7515] and [rfc7519].

When utilizing JSON-LD, take special care around remote retrieval of contexts and follow the additional security considerations noted in [json-ld11].

As noted in [rfc7515] when utilizing JSON [rfc7159], strict validation is a security requirement. If malformed JSON is received, it may be impossible to reliably interpret the producer's intent, potentially leading to ambiguous or exploitable situations. To prevent these risks, it is essential to use a JSON parser that strictly validates the syntax of all input data. It is essential that any JSON inputs that do not conform to the JSON-text syntax defined in [rfc7159] be rejected in their entirety by JSON parsers. Failure to reject invalid input could compromise the security and integrity of Verifiable Credentials.

A. IANA Considerations

This section is non-normative.

A.1 application/vc+jwt

This specification registers the application/vc+jwt Media Type specifically for identifying a JWT conforming to the Verifiable Credentials JWT format in the typ header.

Type name: application
Subtype name: application/vc+jwt
Required parameters: None
Encoding considerations: application/vc+jwt values are encoded as a series of base64url encoded values (some of which may be the empty string) each separated from the next by a single period ('.') character.
Security considerations:

As defined in this specification. See also the security considerations in [RFC7519].

Contact: W3C Verifiable Credentials Working Group public-vc-wg@w3.org

A.2 application/vc+ld+jwt

This specification registers the application/vc+ld+jwt Media Type specifically for identifying a JWT conforming to the Verifiable Credentials JWT format in the typ header.

Type name: application
Subtype name: vc+ld+jwt
Required parameters: None
Encoding considerations: application/vc+ld+jwt values are encoded as a series of base64url encoded values (some of which may be the empty string) each separated from the next by a single period ('.') character.
Security considerations:

As defined in this specification. See also the security considerations in [RFC7519].

Contact: W3C Verifiable Credentials Working Group public-vc-wg@w3.org

A.3 application/credential-claims-set-1.1+json

This specification registers the application/credential-claims-set-1.1+json MIME Media Type specifically for identifying a JWT Claims Set conforming to the Verifiable Credentials 1.1 JWT format in the cty header.

Type name: application
Subtype name: application/credential-claims-set-1.1+json
Required parameters: None
Encoding considerations: Resources that use the "application/credential-claims-set-1.1+json" Media Type are required to conform to all of the requirements for the "application/json" Media Type and are therefore subject to the same encoding considerations specified in Section 11 of [RFC7159].
Security considerations:

As defined in this specification. See also the security considerations in [RFC7519].

Contact: W3C Verifiable Credentials Working Group public-vc-wg@w3.org
Issue 42: Bikeshedding the name for the `vc-jwt` 1.1 `cty` value.

See the original PR here: #40

The original proposal was :

application/credential-1.1+json

The name was modified to:

application/credential-claims-set-1.1+json

The editors noted that "claim-set" is redundant.

A.4 Appendix

A.4.1 Example Mapping

The following describes a mapping from application/vc+jwt to application/vc+ld+json. This is one possible unidirectional mapping between 2.0 VC-JWTs and the VC Data Model; other such mappings are possible.

  • Extract iss, sub, iat, nbf, exp, jti, and aud as registered claims.
  • Set aside all other claims as subject claims.
  • To construct the VCDM-compliant JSON:
    • Set the value of @context to "https://www.w3.org/ns/credentials/v2".
    • Set the value of type to ["VerifiableCredential"].
    • Set the value of the issuer property to one of the following:
      • If the value of iss is a URL, use the value of iss.
      • If the value of iss is not a URL, use the concatenation of "urn:vc:" and the value of iss.
    • If jti is present, set the value of id to the concatenation of "urn:vc:" and the value of jti.
    • If nbf is present, set the value of validFrom to the dateTime obtained by converting the value of nbf from the NumericDate described in [RFC7519] to a dateTime as described in [XMLSCHEMA11-2].
    • If exp is present, set the value of validUntil to the dateTime obtained by converting the value of exp from the NumericDate described in [RFC7519] to a dateTime as described in [XMLSCHEMA11-2].
    • Set the value of credentialSubject to an object that contains the following properties:
      • If sub is present, set the value of the id property to the concatenation of "urn:vc:" and the value of sub.
      • Add all of the subject claims.

B. References

B.1 Normative references

[json-ld11]
JSON-LD 1.1. Gregg Kellogg; Pierre-Antoine Champin; Dave Longley. W3C. 16 July 2020. W3C Recommendation. URL: https://www.w3.org/TR/json-ld11/
[RFC2119]
Key words for use in RFCs to Indicate Requirement Levels. S. Bradner. IETF. March 1997. Best Current Practice. URL: https://www.rfc-editor.org/rfc/rfc2119
[RFC7159]
The JavaScript Object Notation (JSON) Data Interchange Format. T. Bray, Ed.. IETF. March 2014. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc7159
[RFC7515]
JSON Web Signature (JWS). M. Jones; J. Bradley; N. Sakimura. IETF. May 2015. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc7515
[RFC7519]
JSON Web Token (JWT). M. Jones; J. Bradley; N. Sakimura. IETF. May 2015. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc7519
[rfc8152]
CBOR Object Signing and Encryption (COSE). J. Schaad. IETF. July 2017. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc8152
[RFC8174]
Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words. B. Leiba. IETF. May 2017. Best Current Practice. URL: https://www.rfc-editor.org/rfc/rfc8174
[rfc8949]
Concise Binary Object Representation (CBOR). C. Bormann; P. Hoffman. IETF. December 2020. Internet Standard. URL: https://www.rfc-editor.org/rfc/rfc8949
[rfc9052]
CBOR Object Signing and Encryption (COSE): Structures and Process. J. Schaad. IETF. August 2022. Internet Standard. URL: https://www.rfc-editor.org/rfc/rfc9052
[VC-DATA-MODEL]
Verifiable Credentials Data Model v1.1. Manu Sporny; Grant Noble; Dave Longley; Daniel Burnett; Brent Zundel; Kyle Den Hartog. W3C. 3 March 2022. W3C Recommendation. URL: https://www.w3.org/TR/vc-data-model/

B.2 Informative references

[RFC7516]
JSON Web Encryption (JWE). M. Jones; J. Hildebrand. IETF. May 2015. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc7516
[XMLSCHEMA11-2]
W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes. David Peterson; Sandy Gao; Ashok Malhotra; Michael Sperberg-McQueen; Henry Thompson; Paul V. Biron et al. W3C. 5 April 2012. W3C Recommendation. URL: https://www.w3.org/TR/xmlschema11-2/