@@ -92,6 +92,13 @@ <h1>Clear Site Data</h1>
92
92
spec: WORKERS; urlPrefix: http://www.w3.org/TR/workers/
93
93
type: interface
94
94
text: Worker
95
+ spec: SERVICE-WORKERS; urlPrefix: http://www.w3.org/TR/service-workers/
96
+ type: dfn
97
+ text: register; url: register-algorithm
98
+ text: scope url; url: dfn-scope-url
99
+ text: service worker registration; url: dfn-service-worker-registration
100
+ type: method
101
+ text: unregister(); for: ServiceWorkerRegistration; url: navigator-service-worker-unregister
95
102
spec: RFC5234; urlPrefix: https://tools.ietf.org/html/rfc5234
96
103
type: dfn
97
104
text: VCHAR; url: appendix-B.1
@@ -147,23 +154,71 @@ <h2 id="intro">Introduction</h2>
147
154
148
155
This document defines a new mechanism to deal with removing data from these
149
156
and other types of local storage, giving web developers the ability to clear
150
- out a user's local cache of data via either the < a > Clear-Site-Data</ a >
151
- HTTP response header, or the TBD JavaScript API .
157
+ out a user's local cache of data via the < a > Clear-Site-Data</ a > HTTP response
158
+ header.
152
159
153
160
< h3 id ="examples "> Examples</ h3 >
154
161
155
162
< h4 id ="example-signout "> Signing Out</ h4 >
156
163
157
164
A user signs out of Super Secret Social Network via a CSRF-protected POST to
158
- < code > https://supersecretsocialnetwork.com/logout</ code > , and the site author
159
- wishes to ensure that locally stored data is removed as a result.
165
+ < code > https://supersecretsocialnetwork.example. com/logout</ code > , and the site
166
+ author wishes to ensure that locally stored data is removed as a result.
160
167
161
168
They can do so by sending the following HTTP header in the response:
162
169
163
170
< pre >
164
171
< a > Clear-Site-Data</ a > : *
165
172
</ pre >
166
173
174
+ < h4 id ="example-targeted "> Targeted Clearing</ h4 >
175
+
176
+ A user signs out of Megacorp Inc.'s site via a CSRD-protected POST to
177
+ < code > https://megacorp.example.com/logout</ code > . Megacorp has a large number
178
+ of services available as subdomains, so many that it's not entirely clear
179
+ which of them would be safe to clear as a response to a logout action. One
180
+ option would be to simply clear everything, and deal with the fallout.
181
+ Megacorp's CEO, however, once lost hours and hours of progress in "Irate
182
+ Ibix" due to inadvertant site-data clearing, and so is refuses to allow such
183
+ a sweeping impact to the site's users.
184
+
185
+ The developers know, however, that the "Minus" application is certainly safe
186
+ to clear out. They can target this specific subdomain by including a request
187
+ to that subdomain as part of the logout landing page (ideally as a
188
+ CORS-enabled, CSRF-protected POST):
189
+
190
+ < pre >
191
+ fetch("https://minus.megacorp.example.com/clear-site-data",
192
+ {
193
+ method: "POST",
194
+ mode: "cors",
195
+ headers: new Headers({
196
+ "CSRF": "[< em > insert sekrit token here</ em > ]"
197
+ })
198
+ });
199
+ </ pre >
200
+
201
+ That endpoint would return proper CORS headers in response to that request's
202
+ preflight, and would return the following header for the actual request:
203
+
204
+ < pre >
205
+ < a > Clear-Site-Data</ a > : *; < a > includeSubdomains</ a >
206
+ </ pre >
207
+
208
+ < h4 id ="example-keepcookies "> Keep Critical Cookies</ h4 >
209
+
210
+ A user opts-out of interest-based advertising via a CSRF-protected POST to
211
+ < code > https://ads-are-awesome.example.com/optout</ code > . The site author
212
+ wishes to remove DOM-accessible data which might contain tracking information,
213
+ but needs to ensure that the opt-out cookie which the user has just received
214
+ isn't wiped along with it.
215
+
216
+ They can do so by sending the following HTTP header in the response:
217
+
218
+ < pre >
219
+ < a > Clear-Site-Data</ a > : < a > retainCookies</ a > ; < a > includeSubdomains</ a >
220
+ </ pre >
221
+
167
222
< h4 id ="example-killswitch "> Kill Switch</ h4 >
168
223
169
224
Super Secret Social Network's developers learn that the site was vulnerable
@@ -177,7 +232,7 @@ <h4 id="example-killswitch">Kill Switch</h4>
177
232
following HTTP header in a response to wipe out local sources of data:
178
233
179
234
< pre >
180
- < a > Clear-Site-Data</ a > : *
235
+ < a > Clear-Site-Data</ a > : *; < a > includeSubdomains </ a >
181
236
</ pre >
182
237
183
238
Note: Installing a Service Worker guarantees that a request will go out to
@@ -198,10 +253,8 @@ <h3 id="goals">Goals</h3>
198
253
5. Resources from an origin are removed from the user agent's local cache.
199
254
6. All of the above can be propagated to an origin's host's subdomains.
200
255
7. All of the above can be propagated to the HTTP version of an HTTPS origin.
201
-
202
- ISSUE: What do we do about today's multi-tab, multi-window user agents? Should
203
- we also neuter open browsing contexts in the affected origins? Close open
204
- windows?
256
+ 8. None of the above can be bypassed by a maliciously active document that
257
+ retains interesting data in memory, and rewrites it if it's cleared.
205
258
</ section >
206
259
207
260
< section >
@@ -536,8 +589,18 @@ <h4 id="clear-dom">
536
589
ISSUE: The [[WEBDATABASE]] spec is fairly unhelpful here with
537
590
regard to deletion details.
538
591
592
+ 5. For each < var > registration</ var > in the user agent's set of
593
+ < a > registered</ a > < a > service worker registrations</ a > :
594
+
595
+ 1. If [[#matches-origin]] returns < a > < code > Matches</ code > </ a > when
596
+ executed on < var > registration</ var > 's < a > scope URL</ a > 's
597
+ < a > origin</ a > , < var > origin</ var > , and < code > subdomain state</ code > :
598
+
599
+ 1. Execute {{ServiceWorkerRegistration/unregister()}} on
600
+ < var > registration</ var > .
539
601
540
- ISSUE: Define how we clear Filesystems, Dedicated Workers, Shared Workers, Service Workers, etc.
602
+ ISSUE: We still need to spell out Filesystems, Dedicated Workers, Shared
603
+ Workers, etc. (This isn't an exhaustive list. We should fix that too.)
541
604
542
605
ISSUE: How do we say something about plugins here? Point out to
543
606
< a href ="https://wiki.mozilla.org/NPAPI:ClearSiteData "> NPP_ClearSiteData</ a > ?
0 commit comments