3 “Cookie Purging” describes a technique that will periodically clear
4 cookies and site data of known tracking domains without user interaction
5 to protect against [bounce
6 tracking](https://privacycg.github.io/nav-tracking-mitigations/#bounce-tracking).
8 ## Protection Background
10 ### What similar protections do other browsers have?
12 **Safari** classifies sites as redirect trackers which directly or
13 shortly after navigation redirect the user to other sites. Sites which
14 receive user interaction are exempt from this. To detect bigger redirect
15 networks, sites may also inherit redirect tracker
16 [classification](https://privacycg.github.io/nav-tracking-mitigations/#mitigations-safari).
17 If a site is classified as a redirect tracker, any site pointing to it
18 will inherit this classification. Safari does not use tracker lists.
20 When the source site is classified as a tracker, Safari will purge all
21 storage, excluding cookies. Sites which receive user interaction within
22 seven days of browser use are exempt. If the destination site's URL
23 includes query parameters or URL fragments, Safari caps the lifetime of
24 client-side set cookies of the destination site to 24 hours.
26 **Brave** uses lists to classify redirect trackers. Recently, they have
27 rolled out a new protection, [Unlinkable Bouncing](https://brave.com/privacy-updates/16-unlinkable-bouncing/),
28 which limits first party storage lifetime. The underlying mechanism is
29 called “first-party ephemeral storage”. If a user visits a known
30 bounce-tracker which doesn’t have any pre-existing storage, the browser
31 will create a temporary first-party storage bucket for the destination
32 site. This temporary storage is cleared 30 seconds after the user closes
33 the last tab of the site.
35 **Chrome** and **Edge** currently do not implement any navigational
38 ### Is it standardized?
40 At this time there are no standardized navigational tracking
41 protections. The PrivacyCG has a [work item for Navigation-based Tracking Mitigations](https://privacycg.github.io/nav-tracking-mitigations/).
42 Also see Apple’s proposal
43 [here](https://github.com/privacycg/proposals/issues/6).
45 ### How does it fit into our vision of “Zero Privacy Leaks?”
47 Existing tracking protections mechanisms focus mostly on third-party
48 trackers. Redirect tracking can circumvent these mechanisms and utilize
49 first-party storage for tracking. Cookie purging contributes to the
50 “Zero Privacy Leaks” vision by mitigating this cross-site tracking
55 Metabug: [Bug 1594226 - \[Meta\] Purging Tracking Cookies](https://bugzilla.mozilla.org/show_bug.cgi?id=1594226)
57 ### What is the ship state of this protection in Firefox?
59 Shipped to Release in standard ETP mode
61 ### Is there outstanding work?
63 The mechanism of storing user interaction as a permission via
64 nsIPermissionManager has shown to be brittle and has led to users
65 getting logged out of sites in the past. The concept of a permission
66 doesn’t fully match that of a user interaction flag. Permissions may be
67 separated between normal browsing and PBM (Bug
68 [1692567](https://bugzilla.mozilla.org/show_bug.cgi?id=1692567)).
69 They may also get purged when clearing site data (Bug
70 [1675018](https://bugzilla.mozilla.org/show_bug.cgi?id=1675018)).
72 A proposed solution to this is to create a dedicated data store for
73 keeping track of user interaction. This could also enable tracking user
74 interaction relative to browser usage time, rather than absolute time
75 ([Bug 1637146](https://bugzilla.mozilla.org/show_bug.cgi?id=1637146)).
77 Important outstanding bugs:
78 - [Bug 1637146 - Use use-time rather than absolute time when computing whether to purge cookies](https://bugzilla.mozilla.org/show_bug.cgi?id=1637146)
80 ### Existing Documentation
82 - [https://developer.mozilla.org/en-US/docs/Web/Privacy/Redirect\_tracking\_protection](https://developer.mozilla.org/en-US/docs/Web/Privacy/Redirect_tracking_protection)
84 - [PrivacyCG: Navigational-Tracking Mitigations](https://privacycg.github.io/nav-tracking-mitigations/)
87 ## Technical Information
91 Cookie purging can be enabled or disabled by flipping the
92 `privacy.purge_trackers.enabled` preference. Further, it will only run if
93 the `network.cookie.cookieBehavior` pref is set to `4` or `5` ([bug 1643045](https://bugzilla.mozilla.org/show_bug.cgi?id=1643045) adds
94 support for behaviors `1` and `3`).
96 Different log levels can be set via the pref
97 `privacy.purge_trackers.logging.level`.
99 The time until user interaction permissions expire can be set to a lower
100 amount of time using the `privacy.userInteraction.expiration` pref. Note
101 that you will have to set this pref before visiting the sites you want
102 to test on, it will not apply retroactively.
104 ### How does it work?
106 Cookie purging periodically clears first-party storage of known
107 trackers, which the user has not interacted with recently. It is
109 [PurgeTrackerService](https://searchfox.org/mozilla-central/rev/cf77e656ef36453e154bd45a38eea08b13d6a53e/toolkit/components/antitracking/PurgeTrackerService.jsm),
111 [nsIPurgeTrackerService](https://searchfox.org/mozilla-central/rev/cf77e656ef36453e154bd45a38eea08b13d6a53e/toolkit/components/antitracking/nsIPurgeTrackerService.idl)
114 #### What origins are cleared?
116 An origin will be cleared if it fulfills the following conditions:
118 1. It has stored cookies or accessed other site storage (e.g.
119 [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API),
120 [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API),
121 or the [Cache API](https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage))
122 within the last 72 hours. Since cookies are per-host, we will
123 clear both the http and https origin variants of a cookie host.
125 2. The origin is [classified as a tracker](https://developer.mozilla.org/en-US/docs/Web/Privacy/Storage_Access_Policy#tracking_protection_explained)
126 in our Tracking Protection list.
128 3. No origin with the same base domain (eTLD+1) has a user-interaction
131 - This permission is granted to an origin for 45 days once a user
132 interacts with a top-level document from that origin.
133 "Interacting" includes scrolling.
135 - Although this permission is stored on a per-origin level, we
136 will check whether any origin with the same base domain has
137 it, to avoid breaking sites with subdomains and a
138 corresponding cookie setup.
140 #### What data is cleared?
142 Firefox will clear the [following data](https://searchfox.org/mozilla-central/rev/cf77e656ef36453e154bd45a38eea08b13d6a53e/toolkit/components/antitracking/PurgeTrackerService.jsm#205-213):
144 - Network cache and image cache
148 - DOM Quota Storage (localStorage, IndexedDB, ServiceWorkers, DOM
151 - DOM Push notifications
153 - Reporting API Reports
155 - Security Settings (i.e. HSTS)
157 - EME Media Plugin Data
159 - Plugin Data (e.g. Flash)
163 - Storage Access permissions granted to the origin
165 - HTTP Authentication Tokens
167 - HTTP Authentication Cache
169 **Note:** Even though we're clearing all of this data, we currently only
170 flag origins for clearing when they use cookies or other site storage.
172 Storage clearing ignores origin attributes. This means that storage will
174 [containers](https://wiki.mozilla.org/Security/Contextual_Identity_Project/Containers)
175 and isolated storage (i.e. from [First-Party Isolation](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/cookies#first-party_isolation)).
177 #### How frequently is data cleared?
179 Firefox clears storage based on the firing of an internal event called
180 [idle-daily](https://searchfox.org/mozilla-central/rev/cf77e656ef36453e154bd45a38eea08b13d6a53e/toolkit/components/antitracking/PurgeTrackerService.jsm#60,62,65),
181 which is defined by the following conditions:
183 - It will, at the earliest, fire 24h after the last idle-daily event
186 - It will only fire if the user has been idle for at least 3min (for
187 24-48h after the last idle-daily) or 1 min (for >48h after the
190 This means that there are at least 24 hours between each storage
191 clearance, and storage will only be cleared when the browser is idle.
192 When clearing cookies, we sort cookies by creation date and batch them
193 into sets of 100 (controlled by the pref
194 `privacy.purge_trackers.max_purge_count`) for performance reasons.
198 For debugging purposes, it's easiest to trigger storage clearing by
199 triggering the service directly via the [Browser Console command line](/devtools-user/browser_console/index.rst#browser_console_command_line).
200 Note that this is different from the normal [Web Console](/devtools-user/web_console/index.rst)
201 you might use to debug a website, and requires the
202 `devtools.chrome.enabled` pref to be set to true to use it interactively.
203 Once you've enabled the Browser Console you can trigger storage clearing
204 by running the following command:
207 await Components.classes["@mozilla.org/purge-tracker-service;1"]
208 .getService(Components.interfaces.nsIPurgeTrackerService)
209 .purgeTrackingCookieJars()
213 TODO: consider integrating
214 [https://developer.mozilla.org/en-US/docs/Web/Privacy/Redirect\_tracking\_protection](https://developer.mozilla.org/en-US/docs/Web/Privacy/Redirect_tracking_protection)
215 into firefox source docs. The article doesn’t really belong into MDN,
216 because it’s very specific to Firefox.