├── README.md ├── bs-includes ├── copyright-tag.include ├── defaults-tag.include ├── footer-tag.include ├── header-tag.include ├── logo-tag.include └── status-tag-WD.include ├── images └── sequence_diagram.png ├── index.bs └── index.html /README.md: -------------------------------------------------------------------------------- 1 | # NOTE: The Tag is no longer working on this review, and will not be maintaining the associated document 2 | 3 | # client-certificates 4 | TAG spec review on keygen and use of client certificates in the web platform 5 | -------------------------------------------------------------------------------- /bs-includes/copyright-tag.include: -------------------------------------------------------------------------------- 1 | Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark and document use rules apply. 2 | -------------------------------------------------------------------------------- /bs-includes/defaults-tag.include: -------------------------------------------------------------------------------- 1 | { 2 | "Mailing List": "www-tag@w3.org", 3 | "Mailing List Archives": "https://lists.w3.org/Archives/Public/www-tag/" 4 | } 5 | -------------------------------------------------------------------------------- /bs-includes/footer-tag.include: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /bs-includes/header-tag.include: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | [TITLE] 6 | 7 | 8 | 10 | 11 | 12 | 13 |
14 |

15 |

[TITLE]

16 |

[LONGSTATUS], 17 |

18 |
19 |
20 | 21 |
22 |
23 | 24 |

Abstract

25 |
26 | 27 |

Status of this document

28 |
29 |
30 | 31 |

Table of Contents

32 |
33 |
34 | -------------------------------------------------------------------------------- /bs-includes/logo-tag.include: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /bs-includes/status-tag-WD.include: -------------------------------------------------------------------------------- 1 | 2 |

3 | This document has been produced by the 4 | W3C Technical Architecture Group (TAG). 5 | This document is a work in progress and represents the rough consensus of the TAG. 6 |

-------------------------------------------------------------------------------- /images/sequence_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/w3ctag/client-certificates/4db745a8ffcadaf7b16da51769a77e4cca94596b/images/sequence_diagram.png -------------------------------------------------------------------------------- /index.bs: -------------------------------------------------------------------------------- 1 |
 
  2 | Title: Keygen and Client Certificates
  3 | Group: tag
  4 | Shortname: client-certificates 
  5 | Status: WD
  6 | Level: 1
  7 | Editor: Travis Leithead, Microsoft https://www.microsoft.com/, travil@microsoft.com 
  8 | ED: https://w3ctag.github.io/client-certificates
  9 | Abstract: The TAG considers the HTML <keygen> element and its use cases; related 
 10 | 	security issues are also reviewed and requirements and a recommendation to replace 
 11 | 	<keygen> is presented.
 12 | Default Biblio Status: current 
 13 | !Participate: GitHub w3ctag/client-certificates (file an issue; open issues)
 14 | 
15 | 16 | # <keygen> and use cases 17 | 18 | The HTMLKeygenElement [[HTML5]] enables web sites to generate a public/private key pair during form submission (see also Public Key Cryptography). <keygen> is a browser feature grandfathered into the HTML5 specification. This element is a form-associated element with UI, but does not expose its generated private key to JavaScript. (Note: a Service Worker [[service-workers]] may be able to retrieve the public key from a form submission request.) The private key is stored in a secured browser-managed or OS-managed key store on behalf of the user. 19 | 20 | The primary use case for <keygen> is to establish a trusted identity for an individual; the identity can later be used to authenticate to a web site or set of web sites. Because it uses an identity tied to a private key, authentication is fundamentally more secure than systems which use shared passwords. 21 | 22 | Extending the above use case, <keygen> is commonly the first stage in provisioning a user's device to receive a client certificate. For example, <keygen> is used to generate the key material for later inclusion in an X509 certificate. The certificate is intended to be long-lived and may serve to authenticate wireless accounts, educational portals, internal business intranets, etc. 23 | 24 | Sequence diagram showing how keygen provisions a client certificate. 25 | 26 | The diagram above describes a typical scenario in which the <keygen> element is used for provisioning a client certificate. 27 | 28 | 1. The user agent navigates to a provisioning site (at a specific origin). The HTML resource containing the keygen element with optional challenge attribute is received by the user agent. The keygen element is included in a form intended to be submitted back to the server. 29 | 2. The user may select from among two options in the keygen element's UI to choose a "weak" or "strong" key length. 30 | 3. The user submits the form. Alternately, JavaScript code in the user agent can submit the form. When submitted the keygen element causes an asymmetric key pair to be generated: a public and private key. These keys are not exposed via a DOM API (although the public key may be retrieved from the form in an installed Service Worker). 31 | 4. The private key is used to optionally sign a challenge and then it is placed into a secure key store (either browser or OS-provided). 32 | 5. The public key is encoded (ASN.1 DER) and submitted in the form to the server. 33 | 6. In the POST response, the server may have packaged the public key and other related information into a client certificate which is sent with an application/x-x509-*-cert mimetype to the user agent. The user agent relays this certificate into the user's certificate store for later use. 34 | 35 | # Client certificates and user agents 36 | 37 | Keygen is one way to generate the crypto material needed for a client certificate in the browser (the Web Crypto API [[webcryptoapi]] provides another--though it has drawbacks described later). Once a client certificate has been issued and registered with the user agent (either via a browser or OS-supplied certificate store), the certificate may be used for authentication. This is relatively uncommon; when it does happen, user agents do not provide a good experience. 38 | 39 | A server can require a TLS client certificate to be used when it receives a request for a protected resource. The server may also include a challenge to be signed by the client as proof that the user has possession of the private key associated with the public key in the client certificate. Starting with the server's response to the protected resource request, the experience typically follows this pattern: 40 | 41 | 1. The user agent asks the user to select a client certificate to use in the negotiation (there may be more than one). One or more client certificates are presented to the user. Little effort is made to differentiate or extract meaningful information from each certificate in order to help the user select the right one. The user chooses a certificate. 42 | 2. [Typically] a second prompt (issuing from the secure keystore) is presented to confirm and approve use of a private key in order to perform a signature (for the challenge). Unfortunately, little context is actually provided in the message presented to the user, making it unclear why and for what purpose the private key is being accessed. 43 | 3. The signed challenge and client certificate are sent to the server for verification to release the resource. 44 | 45 | Note: The ability to use client certificates for authentication is currently not allowed in the HTTP2 protocol (it requires an older TLS re-negotiation protocol). The IETF is investigating how to improve support for client certificate authentication in HTTP2. 46 | 47 | # Threat Model 48 | 49 | User agents are now considering removing support for the <keygen> element due (in part) to security issues present in its design and implementation. The following threat model frames these issues. 50 | 51 | The trust boundaries in the threat model separate the user agent and server, as well as the user agent and secure keystore. 52 | 53 | ## User agent/server boundary 54 | 55 | This trust boundary may be either protected via an HTTPS connection, or open using an untrusted link. The keygen element is not currently considered a "powerful feature" and thus it works in both insecure and secure contexts [[powerful-features]]. (Keygen would certainly be considered a powerful feature by today's standards.) When using an insecure connection, the content provided by the server cannot be trusted, including the behavior of script from that resource. 56 | 57 | ## User agent/secure keystore boundary 58 | 59 | Some user agents defer to their host OS to manage and secure crypto key material (an alternative, e.g., in Mozilla Firefox, is to have a browser-provided keystore). For host OS-managed cases, a trust boundary exists between the user agent and the OS (data that flows across this boundary is generally implicitly trusted). The risk to user agents relying on an OS-provided keystore is that changes to the keystore have a global impact on the user's device. This is particularly dangerous if keystore changes happen without user-consent and automatically by script. Since the host OS's keystore is a shared resource, all apps are put at risk. Of course, when the browser implements its own keystore, the risk to the OS and other applications is mitigated. 60 | 61 | ## Known Threats 62 | 63 | 1. Untrusted script can launch denial-of-service attacks against the user's keystore, since form submission (including keygen) does not require user action. 64 | 2. Keygen form submission has unmitigated access to the keystore; script can affect either 1) global OS state changes without user permission, or 2) origin-unaware certificate installation (in user agents that implement their own keystore). At a minimum, this violates the same origin policy. 65 | 3. While not specifically impacting keygen, user agents may automatically install client certificates via a special mime-type. As noted, this can affect state outside the boundary of the browser sandbox without user permission. 66 | 67 | # Principles 68 | 69 | * Web pages must not be allowed to change shared state outside the browser sandbox without user permission; such permission may be indirectly granted by a related explicit user action. The user must be in control. This principle is correctly applied to resources such as cameras and microphones in WebRTC and Geolocation, which all ask for permission from the user before enabling access (which may simultaneously cause implicit revocation of the resource by another entity). 70 | 71 | * Users must be able to create identity on the web which can be shared with others. For example, people identify themselves using their Facebook or Twitter names: a site can then log them in using a form of redirected authentication involving facebook.com or twitter.com, and then can give them access to things, allow them to participate, etc, as a function of that identity. Public key based systems are generally superior to these in that they use private and public keys instead of passwords, and their strength is not tied to the user's ability to generate a good password. 72 | 73 | # Replacing <keygen> 74 | 75 | The keygen element should be replaced by a new API better suited for modern day application requirements. While keygen can conceivably be updated in some ways improve its hashing algorithm and container formats, for example, its function as an element tied to form submission locks it into a specific declarative protocol. While convenient in some respects, it is also limiting in that it is not very extensible, cannot be applied in scenarios outside of its protocol (e.g., outside of form submission scenarios), and isn't designed with user-permission in mind. We believe keygen isn't suitable for updating in its existing form; rather we think starting over with a new API untethered from the past has the better potential to succeed. In order to better understand the requirements for an API intended to replace keygen, we first consider where it is weak and what improvements should be made to meet modern requirements. 76 | 77 | * The MD5 hashing algorithm, as currently defined in HTML5 and interoperably implemented in several user agents is quite dated. Security researchers now recommend more secure hashing algorithms such as SHA-2. 78 | * Keygen is a powerful feature. Its use should be restricted to a secure context. 79 | * Keygen must not write private keys into origin-unaware keystores without user permission. User permission must be granted prior to writing new private keys into any keystore (whether OS-provided or not). 80 | * Keygen's operations are potentially compute-intensive and should be asynchronous in order to not block user interaction (as can happen in form submission currently). Asynchronous operation is also necessary for obtaining user permission. 81 | * Keygen's container structure for uploading public key material to the server is dated. Alternative, or author-defined container structures should be available. 82 | * The user interface for keygen should be reconsidered. Users are not in the best position to evaluate which type of key strength is needed. This is usually a requirement of the server. Perhaps no user interface is required. 83 | * Add basic extensibility to keygen, such as the capability to add additional meta-data requests for client certificate extensions, certificate expiration requests, etc. 84 | 85 | Additionally, any installation of a client certificate (e.g., the application/x-x509-*-cert mimetype) must also require user consent. 86 | 87 | In seeking for a replacement to keygen, we also consider what capabilities are already provided by the Web Crypto API: 88 | 89 | * The CryptoKey interface is designed as a general read-only abstraction over key material. The object itself can be used as a proxy for the key material without disclosing the actual key material. 90 | * APIs needed to generate public/private CryptoKey objects are already defined (generateKey/deriveKey). 91 | * A flag is available to protect the key material from extraction (the extractable flag in the generation APIs). 92 | 93 | Unfortunately, the current capabilities in the Web Crypto API are unsuitable as a direct-replacement for keygen because: 94 | 95 | * Protection of the private key material in the CryptoKey is opt-in. 96 | * There is no mechanism to write to the device's secure keystore (if available) 97 | 98 | However, the objects and abstractions defined in the Web Crypto API are a good foundation on which to design a replacement for keygen. We note that provisioning of keys is currently declared out-of-scope in the current Web Crypto API spec. New work on a keygen replacement would have key provisioning in scope. 99 | 100 | # Requirements and Recommendations 101 | 102 | In order to replace keygen and simultaneously provide a better way for establishing a trusted identity on the web, we recognize the following requirements. The solution: 103 | 104 | * should be similar in workflow and user experience to creating an account with a password. It would omit the steps of checking if the user has picked a strong password including redundant password verification steps. 105 | * should include a mechanism to associate some personal information (e.g., a nickname, color, picture, biometric, etc) to the key so that it can be readily selected in the future. 106 | * must be considered a "powerful feature" and only available under secure contexts. 107 | * must not release the raw private key material to script at any time. Private keys used as a basis for a person's identity should be considered sensitive such that even script should not be trusted with access to the key material. 108 | * must be asynchronous and require user permission to install the private key into any origin-independent shared persistent storage. Unlike origin-specific storage which follows the same-origin policy, origin-unaware (or general use) storage represents a change to the user's environment outside the scope of web page and the user must be aware of and authorize any such changes. 109 | * must be asynchronous and require user permission to use a private key from any origin-independent shared persistent storage. This is needed in order to protect the privacy of the private key. 110 | * should allow the user to delegate the key persistence and generation to separate secure hardware. Different key generation scenarios may require different assurances in relation to the keystore and/or key generation. 111 | 112 | Given these requirements, we recognize that an "improved keygen element" could be built using the new solution as a foundation (e.g., using web components). 113 | 114 | We also call on implementations to improve the client certificate UI experience in order to make client-certificate use in authentication more accessible to general users. 115 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Keygen and Client Certificates 5 | 6 | 7 | 993 | 994 | 995 | 996 | 997 |
998 |

999 |

Keygen and Client Certificates

1000 |

W3C Working Draft,

1001 |
1002 |
1003 |
This version: 1004 |
https://w3ctag.github.io/client-certificates 1005 |
Editor: 1006 |
(Microsoft) 1007 |
Participate: 1008 |
GitHub w3ctag/client-certificates (file an issue; open issues) 1009 |
1010 |
1011 |
1012 | 1013 |
1014 |
1015 |

Abstract

1016 |
1017 |

The TAG considers the HTML <keygen> element and its use cases; related 1018 | 1019 | security issues are also reviewed and requirements and a recommendation to replace 1020 | <keygen> is presented.

1021 |
1022 |

Status of this document

1023 |
1024 |

This document has been produced by the W3C Technical Architecture Group (TAG). 1025 | This document is a work in progress and represents the rough consensus of the TAG.

1026 |
1027 |

Table of Contents

1028 |
1029 | 1048 |
1049 |
1050 |

1. <keygen> and use cases

1051 |

The HTMLKeygenElement [HTML5] enables web sites to generate a public/private key pair during form submission (see also Public Key Cryptography). <keygen> is a browser feature grandfathered into the HTML5 specification. This element is a form-associated element with UI, but does not expose its generated private key to JavaScript. (Note: a Service Worker [service-workers] may be able to retrieve the public key from a form submission request.) The private key is stored in a secured browser-managed or OS-managed key store on behalf of the user.

1052 |

The primary use case for <keygen> is to establish a trusted identity for an individual; the identity can later be used to authenticate to a web site or set of web sites. Because it uses an identity tied to a private key, authentication is fundamentally more secure than systems which use shared passwords.

1053 |

Extending the above use case, <keygen> is commonly the first stage in provisioning a user’s device to receive a client certificate. For example, <keygen> is used to generate the key material for later inclusion in an X509 certificate. The certificate is intended to be long-lived and may serve to authenticate wireless accounts, educational portals, internal business intranets, etc.

1054 |

Sequence diagram showing how keygen provisions a client certificate.

1055 |

The diagram above describes a typical scenario in which the <keygen> element is used for provisioning a client certificate.

1056 |
    1057 |
  1. 1058 |

    The user agent navigates to a provisioning site (at a specific origin). The HTML resource containing the keygen element with optional challenge attribute is received by the user agent. The keygen element is included in a form intended to be submitted back to the server.

    1059 |
  2. 1060 |

    The user may select from among two options in the keygen element’s UI to choose a "weak" or "strong" key length.

    1061 |
  3. 1062 |

    The user submits the form. Alternately, JavaScript code in the user agent can submit the form. When submitted the keygen element causes an asymmetric key pair to be generated: a public and private key. These keys are not exposed via a DOM API (although the public key may be retrieved from the form in an installed Service Worker).

    1063 |
  4. 1064 |

    The private key is used to optionally sign a challenge and then it is placed into a secure key store (either browser or OS-provided).

    1065 |
  5. 1066 |

    The public key is encoded (ASN.1 DER) and submitted in the form to the server.

    1067 |
  6. 1068 |

    In the POST response, the server may have packaged the public key and other related information into a client certificate which is sent with an application/x-x509-*-cert mimetype to the user agent. The user agent relays this certificate into the user’s certificate store for later use.

    1069 |
1070 |

2. Client certificates and user agents

1071 |

Keygen is one way to generate the crypto material needed for a client certificate in the browser (the Web Crypto API [webcryptoapi] provides another--though it has drawbacks described later). Once a client certificate has been issued and registered with the user agent (either via a browser or OS-supplied certificate store), the certificate may be used for authentication. This is relatively uncommon; when it does happen, user agents do not provide a good experience.

1072 |

A server can require a TLS client certificate to be used when it receives a request for a protected resource. The server may also include a challenge to be signed by the client as proof that the user has possession of the private key associated with the public key in the client certificate. Starting with the server’s response to the protected resource request, the experience typically follows this pattern:

1073 |
    1074 |
  1. 1075 |

    The user agent asks the user to select a client certificate to use in the negotiation (there may be more than one). One or more client certificates are presented to the user. Little effort is made to differentiate or extract meaningful information from each certificate in order to help the user select the right one. The user chooses a certificate.

    1076 |
  2. 1077 |

    [Typically] a second prompt (issuing from the secure keystore) is presented to confirm and approve use of a private key in order to perform a signature (for the challenge). Unfortunately, little context is actually provided in the message presented to the user, making it unclear why and for what purpose the private key is being accessed.

    1078 |
  3. 1079 |

    The signed challenge and client certificate are sent to the server for verification to release the resource.

    1080 |
1081 |

Note: The ability to use client certificates for authentication is currently not allowed in the HTTP2 protocol (it requires an older TLS re-negotiation protocol). The IETF is investigating how to improve support for client certificate authentication in HTTP2.

1082 |

3. Threat Model

1083 |

User agents are now considering removing support for the <keygen> element due (in part) to security issues present in its design and implementation. The following threat model frames these issues.

1084 |

The trust boundaries in the threat model separate the user agent and server, as well as the user agent and secure keystore.

1085 |

3.1. User agent/server boundary

1086 |

This trust boundary may be either protected via an HTTPS connection, or open using an untrusted link. The keygen element is not currently considered a "powerful feature" and thus it works in both insecure and secure contexts [powerful-features]. (Keygen would certainly be considered a powerful feature by today’s standards.) When using an insecure connection, the content provided by the server cannot be trusted, including the behavior of script from that resource.

1087 |

3.2. User agent/secure keystore boundary

1088 |

Some user agents defer to their host OS to manage and secure crypto key material (an alternative, e.g., in Mozilla Firefox, is to have a browser-provided keystore). For host OS-managed cases, a trust boundary exists between the user agent and the OS (data that flows across this boundary is generally implicitly trusted). The risk to user agents relying on an OS-provided keystore is that changes to the keystore have a global impact on the user’s device. This is particularly dangerous if keystore changes happen without user-consent and automatically by script. Since the host OS’s keystore is a shared resource, all apps are put at risk. Of course, when the browser implements its own keystore, the risk to the OS and other applications is mitigated.

1089 |

3.3. Known Threats

1090 |
    1091 |
  1. 1092 |

    Untrusted script can launch denial-of-service attacks against the user’s keystore, since form submission (including keygen) does not require user action.

    1093 |
  2. 1094 |

    Keygen form submission has unmitigated access to the keystore; script can affect either 1) global OS state changes without user permission, or 2) origin-unaware certificate installation (in user agents that implement their own keystore). At a minimum, this violates the same origin policy.

    1095 |
  3. 1096 |

    While not specifically impacting keygen, user agents may automatically install client certificates via a special mime-type. As noted, this can affect state outside the boundary of the browser sandbox without user permission.

    1097 |
1098 |

4. Principles

1099 | 1105 |

5. Replacing <keygen>

1106 |

The keygen element should be replaced by a new API better suited for modern day application requirements. While keygen can conceivably be updated in some ways improve its hashing algorithm and container formats, for example, its function as an element tied to form submission locks it into a specific declarative protocol. While convenient in some respects, it is also limiting in that it is not very extensible, cannot be applied in scenarios outside of its protocol (e.g., outside of form submission scenarios), and isn’t designed with user-permission in mind. We believe keygen isn’t suitable for updating in its existing form; rather we think starting over with a new API untethered from the past has the better potential to succeed. In order to better understand the requirements for an API intended to replace keygen, we first consider where it is weak and what improvements should be made to meet modern requirements.

1107 | 1123 |

Additionally, any installation of a client certificate (e.g., the application/x-x509-*-cert mimetype) must also require user consent.

1124 |

In seeking for a replacement to keygen, we also consider what capabilities are already provided by the Web Crypto API:

1125 | 1133 |

Unfortunately, the current capabilities in the Web Crypto API are unsuitable as a direct-replacement for keygen because:

1134 | 1140 |

However, the objects and abstractions defined in the Web Crypto API are a good foundation on which to design a replacement for keygen. We note that provisioning of keys is currently declared out-of-scope in the current Web Crypto API spec. New work on a keygen replacement would have key provisioning in scope.

1141 |

6. Requirements and Recommendations

1142 |

In order to replace keygen and simultaneously provide a better way for establishing a trusted identity on the web, we recognize the following requirements. The solution:

1143 | 1159 |

Given these requirements, we recognize that an "improved keygen element" could be built using the new solution as a foundation (e.g., using web components).

1160 |

We also call on implementations to improve the client certificate UI experience in order to make client-certificate use in authentication more accessible to general users.

1161 |
1162 |

References

1163 |

Informative References

1164 |
1165 |
[WebCryptoAPI] 1166 |
Ryan Sleevi; Mark Watson. Web Cryptography API. 11 December 2014. CR. URL: https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html 1167 |
[HTML5] 1168 |
Ian Hickson; et al. HTML5. 28 October 2014. REC. URL: http://www.w3.org/html/wg/drafts/html/master/ 1169 |
[POWERFUL-FEATURES] 1170 |
Mike West; Yan Zhu. Privileged Contexts. 24 April 2015. WD. URL: https://w3c.github.io/webappsec/specs/powerfulfeatures/ 1171 |
[SERVICE-WORKERS] 1172 |
Alex Russell; Jungkee Song; Jake Archibald. Service Workers. 25 June 2015. WD. URL: https://slightlyoff.github.io/ServiceWorker/spec/service_worker/ 1173 |
1174 | 1175 | 1176 | --------------------------------------------------------------------------------