-
Notifications
You must be signed in to change notification settings - Fork 26
/
index.bs
420 lines (354 loc) · 21.2 KB
/
index.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<pre class='metadata'>
Title: Client Hints Infrastructure
Shortname: ClientHintsInfra
Level: 1
Status: CG-Draft
Group: WICG
URL: https://wicg.github.io/client-hints-infrastructure
Editor: Yoav Weiss, Google, [email protected], https://blog.yoav.ws
Abstract: Specification of the Client Hints infrastructure and its integration with Fetch and HTML
Markup Shorthands: markdown yes
Repository: WICG/client-hints-infrastructure
</pre>
<pre class="link-defaults">
spec:html; type:element; text:link
spec:html; type:element; text:script
spec:fetch; type:dfn; for:/; text:fetch
spec:fetch; type:dfn; for:Request; text:request
spec:fetch; type:dfn; text:client
spec:ServiceWorker; type:dfn; for:/; text:
spec:url; type:dfn; for:url; text:origin
spec:html; type:element; text:style
</pre>
<pre class=biblio>
{
"PERMISSIONS-POLICY": {
"authors": [
"Ian Clelland"
],
"href": "https://w3c.github.io/webappsec-permissions-policy/",
"publisher": "W3C",
"title": "Permissions Policy"
}
}
</pre>
<style>
table, th, td { border: 1px black solid; }
thead {background-color: yellow; }
</style>
Introduction {#intro}
=====================
Client Hints is collection of HTTP and user-agent features that enables
privacy-preserving, proactive content negotiation with an explicit third-party
delegation mechanism:
* Proactive content negotiation at the HTTP layer enables servers to request
delivery of specific hints, in order to enable optimized and automated
selection of resources based on a user's device, conditions and preferences,
and lets clients decide which hint requests they want to grant, with
per-hint and per-origin granularity.
* Integration of said mechanism with web concepts, defined in this document,
enables browsers to benefit from content adaptation, and have it play nicely with
current web restrictions (e.g. same-origin policy).
* The opt-in nature of the mechanism enables browsers to advertise requested
hint data (e.g. user agent and device characteristics) selectively to
secure-transport origins, instead of appending such data on every outgoing
request.
* Origin opt-in applies to same-origin assets only and delivery to third-party
origins is subject to explicit first party delegation via Permissions Policy,
enabling tight control over which third party origins can access requested
hint data.
The goal of Client Hints is to **reduce passive fingerprinting** on the web
while **enabling scalable and privacy preserving content adaptation** between
client and server, via a standardized set of content negotiation primitives at
the HTTP and user agent levels.
Infrastructure definition {#definition}
=========================
The specification of the Client Hints **infrastructure** is divided between the
following specifications and proposals:
* IETF [[!RFC8942]]
- Provides the motivation for Client Hints.
- Defines the fundamental Client Hints infrastructure:
- The `Accept-CH` response header, which servers may use to advertise
support for certain Client Hints.
- Provides both general guidelines, and formal requirements, about Client
Hints’ impact on caching, security, and privacy.
- Does *not* define any actual, particular hints – or say anything about how
Client Hints works in web contexts.
* Client Hints infrastructure - this document
- Defines how web clients should process the `Accept-CH` headers sent by servers.
- Defines the environment settings object state related to `Accept-CH`,
which stores information about which servers should get which hints.
- Defines how, and when, web clients should actually go about sending hints,
based on the state of their environment settings object.
- More specifically, it integrates the HTML web concepts with Fetch's
algorithms to make sure that opted-in hints are added to requests for
same-origin or delegated-to cross-origin requests. It also makes sure
hints are removed from not delegated-to cross-origin requests after
redirections.
- Integrates those concepts with the [[!HTML]] and [[!FETCH]] specifications,
by patching various concepts there.
* W3C Permissions Policy specification (<a href="https://w3c.github.io/webappsec-permissions-policy/#should-request-be-allowed-to-use-feature">relevant section</a>)
- In order to perform third party Client Hint delegation, Permissions Policy has
been extended to control features within fetch requests (rather than just Documents).
Environment settings object processing {#environment-settings-object-processing}
==============
<h3 id=concept-client-hints-set>Client hints set</h3>
<p>A <dfn>client hints set</dfn> is a
<a for=/>set</a> of [=client hints token=]s.
Accept-CH cache {#accept-ch-cache-definition}
----------------
An <dfn>Accept-CH cache</dfn> is owned by the user agent and is an [=ordered map=],
[=keyed=] on <dfn for="accept-ch-cache">origin</dfn> (an [=url/origin=]),
with a value of <dfn for="accept-ch-cache">client hints set</dfn> (a [=/client hints set=]).
The Accept-CH cache can effectively act as an alternative cookie store,
since sites can use each of the hints as a bit set on the client, and that information will be
communicated to them on every request. As such, a user agent MUST evict that
cache whenever the user clears their cookies or when session cookies expire.
Note: A site can clear the browser's `Accept-CH` cache for its origin by sending an empty `Accept-CH`
header in a response. This sets the origin's [=/client hints set=] to an empty set.
Note: As the cache can only be modified by the top-level frame, it is considered to be partitioned.
To <dfn>add a new Accept-CH cache entry</dfn> to the [=Accept-CH cache=],
given an [=accept-ch-cache/origin=] |origin| and a [=/client hints set=] |hintSet|,
[=map/set=] [=Accept-CH cache=][|origin|] to |hintSet|.
When asked to <dfn>retrieve the client hints set</dfn> given a |settingsObject|:
<ol>
<li>Let |hintSet| be an empty [=ordered set=].
<li>Let |originMatchingEntries| be the entries in the [=Accept-CH cache=] whose [=accept-ch-cache/origin=] is [=same origin=] with |settingsObject|'s [=environment settings object/origin=].
<li>For each entry in |originMatchingEntries|, for each token in its [=accept-ch-cache/client hints set=], [=set/append=] the token to |hintSet|.
<li>For each |hint| in |hintSet|, [=set/append=] |hint| to |settingsObject|'s [=environment settings object/client hints set=].
</ol>
When asked to <dfn abstract-op>update the Client Hints set</dfn> given a |settingsObject| and |response|:
<ol>
<li>Run [=retrieve the client hints set=] with |settingsObject|.
<li>If |settingsObject| is a [=non-secure context=], abort these steps.
<li>Let |browsingContext| be |settingsObject|'s [=environment settings object/global object=]'s [=Window/browsing context=].
<li>If the [=top-level browsing context=] does not equal |browsingContext|, abort these steps.
<li>If |response|'s `Accept-CH` header is present, parse the header field value according to the
`Accept-CH` header parsing rules, as a [=field-name=]. Add each parsed [=client hints token=] to |settingsObject|'s [=environment settings object/client hints set=].
<li>[=Add a new Accept-CH cache entry=] with |response|'s [=url/origin=] and |settingsObject|'s [=environment settings object/client hints set=].
</ol>
<dfn>Delegate-CH</dfn> {#delegate-ch-algo}
--------
Note: This metadata *appends* [=client hints token=]s to the [=environment settings object=]'s [=environment settings object/client hints set=]. It *does not* add those hints to the [=Accept-CH cache=].
<ol>
<li>Let |metaElement| be the <{meta}> element.
<li>If any <{link}>, <{style}>, or <{script}> elements have begun to execute, then return.
<li>If |metaElement| has no <{meta/name}> attribute, or if that attribute's value is not `delegate-ch`, then return.
<li>If |metaElement| has no <{meta/content}> attribute, or if that attribute's value is the empty string, then return.
<li>Let |settingsObject| be |metaElement|'s [=relevant settings object=].
<li>If |settingsObject| is a [=non-secure context=], abort these steps.
<li>Let |browsingContext| be |settingsObject|'s [=environment settings object/global object=]'s [=Window/browsing context=].
<li>If the [=top-level browsing context=] does not equal |browsingContext|, abort these steps.
<li>Let |permissionsPolicy| be |metaElement|'s node document's [=Document/permissions policy=].
<li>Let |delegateCHValue| be the value of |metaElement|'s <{meta/content}> attribute.
<li>Let |policyDirective| be the result of running [[permissions-policy#algo-parse-policy-directive]] on |delegateCHValue| and the [=url/origin=] of the |metaElement|'s node document.
<li>For each |feature|->|allowList| of |policyDirective|:
<ol>
<li>If |feature| is not a [=client hints token=], then continue.
<li>If |permissionsPolicy|[|feature|]'s [[PERMISSIONS-POLICY|permissions policy]] is `*`, then continue.
<li>Let |filteredAllowList| be an empty [=ordered set=].
<li>For each |item| in |allowList|:
<ol>
<li>If |item| is [=url/origin=] then [=set/Append=] |item| to |filteredAllowList|.
</ol>
<li>[=set/Append=] |feature| to |settingsObject|'s [=environment settings object/client hints set=] and [=set/Append=] |filteredAllowList| to |permissionsPolicy|[|feature|]'s [[PERMISSIONS-POLICY|permissions policy]].
</ol>
</ol>
Issue(110): Clarify detection of <{link}>, <{style}>, or <{script}> element execution.
Integration with HTML {#html}
===========
This specification integrates with the [[!HTML]] specification by patching the algorithms below:
Navigation response {#navigation-response}
----------
At [=process a navigate response=], after step 7 call [$update the Client Hints set$] with the [=relevant settings object=] and |response| as inputs.
Service Worker initialization {#service-worker-init}
-----------
At <a href="https://html.spec.whatwg.org/multipage/workers.html#set-up-a-worker-environment-settings-object">set up a worker environment settings object</a>,
after step 6, add the following step:
<ol>
<li>If <var ignore>worker global scope</var> implements {{ServiceWorkerGlobalScope}}, then set <var ignore="">settings object</var>'s [=environment settings object/client hints set=] to be a [=set/clone=] of <var ignore>outside settings</var>' [=environment settings object/client hints set=].
</ol>
Standard metadata names {#standard-metadata-names}
------------
For the section <a href="https://html.spec.whatwg.org/multipage/#standard-metadata-names">standard metadata names</a>,
add a subsection named `delegate-ch` with the [=Delegate-CH|outlined explanation=].
Extending environment settings object {#extending-environment-settings-object}
-------------
An [=environment settings object=] has a <dfn for="environment settings object">client hints set</dfn>: a [=/client hints set=], initially the empty set, used for [=fetches=] performed using the [=environment settings object=] as a [=request=] [=client=].
Request processing {#request-processing}
===========
When asked to <dfn abstract-op>append client hints to request</dfn> with |settingsObject| and |request| as input, run the
following steps:
<ol>
<li>If |request| is a [=non-subresource request=] for a "sharedworker" or "worker" [=request/destination=], exit without appending any hints to the [=request/header list=].
<li>Let |hintSet| be an empty [=/client hints set=].
<li>Run [=retrieve the client hints set=] with |settingsObject|.
<li>For each [=client hints token=] |lowEntropyHint| in the registry's [=low entropy hint table=], [=set/append=] |lowEntropyHint| to |hintSet|.
<li>If |request|'s [=request/client=] is not null, then for each [=client hints token=] |requestHint| in
|settingsObject|'s [=environment settings object/client hints set=], [=set/append=] |requestHint| to
|hintSet|.
<li>For each |hintName| in |hintSet|:
<ol>
<li>If |request| is not a [=navigation request=] for a "document" [=request/destination=] and if the result of running [[permissions-policy#algo-should-request-be-allowed-to-use-feature]]
given |request| and |hintName|'s associated feature in [[#policy-controlled-features]] returns `false`, then continue to next |hintName|.
<li>If the user agent decides, in an [=implementation-defined=] way (see [[#privacy]]), to omit this hint then continue.
<li>Let |value| be the result of running [=find client hint value=] with |hintName|.
<li>If the user agent decides, in an [=implementation-defined=] way (see [[#privacy]]), to modify |value| then do so.
<li>[=header list/append=] |hintName|/|value| to the [=request/header list=].
</ol>
</ol>
When asked to <dfn abstract-op>remove client hints from redirect if needed</dfn> with |request| as input, run the following steps:
<ol>
<li><p><a for=list>For each</a> <var>hintToken</var> in the list of [=client hints token=]s:
<ol>
<li><p>If <var>request</var>'s <a for=request>header list</a> <a for="header list">contains</a>
<var>hintToken</var>, then remove <var>hintToken</var> from |request|'s [=request/header list=].
</ol>
</ol>
Integration with Fetch {#fetch}
==============
This specification integrates with the [[!FETCH]] specification by patching the algorithms below:
In <a spec=FETCH>Main Fetch</a>, after step 9, run [$append client hints to request$] with the [=relevant settings object=] and |request| as input.
In [=HTTP-redirect fetch=], after step 11, run [$remove client hints from redirect if needed$] with |request| as input.
Feature Registry {#registry}
==========
Note: This section contains feature-specific definitions.
New features that rely on the Client Hints infrastructure need to add their respective definitions to this registry.
User Agents can implement some of those features without implementing others.
Client hints token {#client-hints-token-definition}
----------
A <dfn export>client hints token</dfn> is a [=byte-lowercase=] representation of one of
`Save-Data`,
`Sec-CH-DPR`,
`Sec-CH-Width`,
`Sec-CH-Viewport-Width`,
`Sec-CH-Viewport-Height`,
`Sec-CH-Device-Memory`,
`Sec-CH-RTT`,
`Sec-CH-Downlink`,
`Sec-CH-ECT`,
`Sec-CH-Prefers-Color-Scheme`,
`Sec-CH-Prefers-Reduced-Motion`,
`Sec-CH-UA`,
`Sec-CH-UA-Arch`,
`Sec-CH-UA-Bitness`,
`Sec-CH-UA-Full-Version`,
`Sec-CH-UA-Full-Version-List`,
`Sec-CH-UA-Mobile`,
`Sec-CH-UA-Model`,
`Sec-CH-UA-Platform`,
`Sec-CH-UA-Platform-Version`, or
`Sec-CH-UA-WoW64`.
Note: A client hints token will also match the request header sent by the user agent when
appropriate (as determined by the <a href="#request-processing">request processing algorithm</a>).
Policy-controlled features {#policy-controlled-features}
-------------
This document defines <dfn export>policy-controlled client hints features</dfn>,
the following [=policy-controlled features=]:
- <code><dfn export>ch-save-data</dfn></code> which has a [=default allowlist=] of `'*'`
- <code><dfn export>ch-dpr</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-width</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-viewport-width</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-viewport-height</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-device-memory</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-rtt</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-downlink</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-ect</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-prefers-color-scheme</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-prefers-reduced-motion</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-ua</dfn></code> which has a [=default allowlist=] of `'*'`
- <code><dfn export>ch-ua-arch</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-ua-bitness</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-ua-full-version</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-ua-full-version-list</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-ua-mobile</dfn></code> which has a [=default allowlist=] of `'*'`
- <code><dfn export>ch-ua-model</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-ua-platform</dfn></code> which has a [=default allowlist=] of `'*'`
- <code><dfn export>ch-ua-platform-version</dfn></code> which has a [=default allowlist=] of `'self'`
- <code><dfn export>ch-ua-wow64</dfn></code> which has a [=default allowlist=] of `'self'`
Issue: Should we tie low-entropy-ness to allowlists, generally?
Low-entropy hint table {#low-entropy-table}
-------
The <dfn export lt="low-entropy hint table|low entropy hint table">low-entropy hint table</dfn>
below defines hints that are safe to send by default due to their low amounts of entropy.
A <dfn export>high-entropy client hint</dfn> is a client hint that is not in the
<a>low-entropy hint table</a>.
<table>
<thead>
<tr>
<th><a for=header>Name</a>
<th><a for=header>Value</a>
<tbody>
<tr>
<td>`Save-Data`
<td>a suitable <a href="https://wicg.github.io/savedata/#save-data-request-header-field">Save-Data value</a>
<tr>
<td>`Sec-CH-UA`
<td>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua">UA value</a>
<tr>
<td>`Sec-CH-UA-Mobile`
<td>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-mobile">Mobile value</a>
<tr>
<td>`Sec-CH-UA-Platform`
<td>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform">Platform value</a>
</table>
Note: If the value transmitted by `Save-Data` is the empty string, the header will be omitted entirely.
This is done to reduce redundant header information sent by default.
Find client hint value {#find-client-hint-value-section}
------------
When asked to <dfn>find client hint value</dfn>, given |hint| as input, switch on |hint| and return the result:
<dl class=switch>
<dt>`Save-Data`
<dd>a suitable <a href="https://wicg.github.io/savedata/#save-data-request-header-field">Save-Data value</a>
<dt>`DPR`
<dd>a suitable <a href>DPR value</a>
<dt>`Viewport-Width`
<dd>a suitable <a href>Viewport-Width value</a>
<dt>`Viewport-Height`
<dd>a suitable <a href>Viewport-Height value</a>
<dt>`Width`
<dd>a suitable <a href>Width value</a>
<dt>`Device-Memory`
<dd>a suitable <a href="https://w3c.github.io/device-memory/#sec-device-memory-client-hint-header">Device-Memory value</a>
<dt>`RTT`
<dd>a suitable <a href="https://wicg.github.io/netinfo/#rtt-request-header-field">RTT value</a>
<dt>`Downlink`
<dd>a suitable <a href="https://wicg.github.io/netinfo/#downlink-request-header-field">Downlink value</a>
<dt>`ECT`
<dd>a suitable <a href="https://wicg.github.io/netinfo/#ect-request-header-field">ECT value</a>
<dt>`Prefers-Color-Scheme`
<dd>a suitable <a href="https://wicg.github.io/user-preference-media-features-headers/#sec-ch-prefers-color-scheme">color theme value</a>
<dt>`Prefers-Reduced-Motion`
<dd>a suitable <a href="https://wicg.github.io/user-preference-media-features-headers/#sec-ch-prefers-reduced-motion">Reduced-Motion value</a>
<dt>`UA`
<dd>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua">UA value</a>
<dt>`UA-Arch`
<dd>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-arch">Arch value</a>
<dt>`UA-Bitness`
<dd>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-bitness">Bitness value</a>
<dt>`UA-Full-Version`
<dd>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-full-version">Full-Version value</a>
<dt>`UA-Full-Version-List`
<dd>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-full-version-list">Full-Version-List value</a>
<dt>`UA-Mobile`
<dd>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-mobile">Mobile value</a>
<dt>`UA-Model`
<dd>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-model">Model value</a>
<dt>`UA-Platform`
<dd>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform">Platform value</a>
<dt>`UA-Platform-Version`
<dd>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform-version">Platform-Version value</a>
<dt>`UA-WoW64`
<dd>a suitable <a href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-wow64">WoW64 value</a>
</dl>
Issue: Links for image features are broken, need to actually define that and link to them.
Security and Privacy considerations {#privacy}
===========
This specification exposes information regarding the user's preferences and agent, which can be used as an active fingerprinting vector.
[=User agents=] implementing this specification need to be aware of that, and take that into consideration when deciding whether to implement specific hints,
modify their returned values for a given hint, or omit the hint entirely.
For example, the user might have a site specific setting to override or disable specific client hints to reduce the potential for fingerprinting.
Terms {#terms}
====
The following terms are defined in the HTTP specifications:
<dfn href="https://tools.ietf.org/html/rfc7230#section-3.2">field-name</dfn>