user.js icon indicating copy to clipboard operation
user.js copied to clipboard

discussion: persistent storage strategies [cookies, indexeddb + local dom]

Open Thorin-II opened this issue 9 years ago • 56 comments

Currently we have network.cookie.cookieBehavior set as 2 with a mention that You can set exceptions under site permissions or use an extension

0=allow all 1=allow same host 2=disallow all 3=allow 3rd party if it already set a cookie

We could change this to 1 as it would fix some underlying issues (but maybe raise some).

  • Blocking cookies also blocks local DOM storage, this causes Extensions that use local storage to break (1 example so far that demonstrates this, eCleaner, although he could fix this)
  • uMatrix (which not all users would want to or can use) can be used to default block all cookies (which negates the need to use site exceptions
  • FPI isolates cookies, in fact Arthur E from TOR has said he wants to enable ALL cookies including 3rd party in TBB in the future.
  • The downside to FPI and cookies is that any cookie extension cannot touch FPI cookies - hence default block all in uMatrix. You can only manually delete cookies (but I am sure they can be cleared on shutdown) - see 1381197
  • If cookies are allowed, you will also get a SB google cookie. It will show in your cookies UI, and you can manually delete it, but this a priviledged cookie in a separate jar and no extension is ever going to be allowed to delete it (Francois argued that it should be accessible to extensions, but they said NO - the bastards). To date I do not nor ever have had a google cookie. I do not know if uMatrix can block this instance (would be nice to know). May need a global google no cookie rule. See 1362834
  • Just to add .. PB mode cookies are protected from extensions as well
  • If cookies are allowed, this allows all sites to use local DOM storage. I am almost certain that uMatrix's blocking of the cookie will have no affect on access to local storage - so that then means it needs cleaning
  • Cookie extensions cannot clean local dom storage (yet)
  • Test page: http://dev-test.nemikor.com/web-storage/support-test/ (thanks @2glops )

Why can't ALL cookies be accessible in ALL modes (PB, FPI, TP+SB), as well as local dom storage

So, as you can see .. downsides, but upsides

Class, discuss!

Thorin-II avatar Aug 05 '17 19:08 Thorin-II

With FPI and PB mode - cookie addons are useless for cleaning. They are OK for blocking (see uMatrix) - so enabling cookies is FINE - my concern is the local storage

Thorin-II avatar Aug 05 '17 19:08 Thorin-II

3=allow 3rd party if it already set a cookie

Does it still work? Seems abandonware to me.

Atavic avatar Aug 05 '17 20:08 Atavic

^^ no idea, probably means nothing in the context of FPI as per domain (origin) will cause multiples of it. We're not even considering it anyway, so who cares :)

Edit: unless you meant that the value of 3 does not do what we say it does?

Thorin-II avatar Aug 05 '17 21:08 Thorin-II

FYI: https://bugzilla.mozilla.org/show_bug.cgi?id=1362834 - protected SB google cookie https://bugzilla.mozilla.org/show_bug.cgi?id=1381197 - FPI & cookies

Thorin-II avatar Aug 05 '17 21:08 Thorin-II

PS: I suggest if you are using FPI to delete all your cookies and let them get re-created so they have the correct attributes

Thorin-II avatar Aug 05 '17 21:08 Thorin-II

This is what I use: user_pref("network.cookie.cookieBehavior", 1); user_pref("dom.storage.enabled", false);

I don't block ALL cookies with uMatrix. Should I?

Occasionally I have to enable dom storage but after that I delete my entire Firefox folder.

I haven't seen any "SB google cookie". Ever. I have all the SB stuff disabled. Where should I check for this cookie?

Just-me-ghacks avatar Aug 06 '17 05:08 Just-me-ghacks

I haven't seen any "SB google cookie". Ever. I have all the SB stuff disabled. Where should I check for this cookie?

AFAIK, if you have it, it should be visible under about:preferences#privacy > View Cookies - see https://bugzilla.mozilla.org/show_bug.cgi?id=1362834

I don't block ALL cookies with uMatrix. Should I?

Why not? Use uM exceptions. Currently I have to allow an exception in both FF's site permissions AND uM, so setting cookies as 1st party removes a step - that is NOT the issue. The question is not really about cookies but about dom storage (which is in effect controlled by FF's internal cookie setting).

When I ditched Cookie Controller, I removed all my cookies, removed all cookie exceptions, FPI is on, and recreated site exceptions, created exceptions in uM, and recreated the cookies by visiting the sites (this to make sure all cookies are new with the right attributes etc) - seriously .. I now have a grand total of 7 cookies and 1 session cookie if it exists) = 8 sites total. Why bother allowing cookies by default. A whitelist saves so much BS. A block all also means much better control over them due to FPI & PB mode issues re extensions.


The equation is (remembering that the cookie setting also controls dom storage)

Either (network.cookie.cookieBehavior, dom.storage.enabled)

  1. cookie :x: dom storage :white_check_mark: (current)
  • means simply allow site exceptions (eg allow, allow for session) for sites that need dom (I have to admit I see very very little of this requirement with my web browsing) or a cookie for logins
  • You could still block the cookie itself (eg uMatrix) but the firefox internal pref means dom is granted (pretty sure uM blocking the cookie does not affect local dom = needs testing to confirm)
  • You still need to clear dom (for the few sites it gets set)
  1. cookie :white_check_mark: dom storage :white_check_mark:
  • by allowing cookies this allows dom storage, even if cookies are blocked in uM (needs test). This makes websites work = less breakage, but also allows WebExtensions that use local storage to also work (uBo may be one of these) :+1:
  • you still need to clear dom (but now its all sites, not a few) :-1:
  • note that FPI means cookies & dom storage are isolated which is good, but they are also re-used by their own first parties and can track you when reloading the site. This has always been the case
  1. cookie :x: dom storage :x:
  • idk
  1. cookie :white_check_mark: dom storage :x:
  • idk

Under site prefs is an option to Maintain Online Storage. IF this directly relates to dom storage, then the solution is number 4 - use site exceptions for cookies in uM with (default deny-all in uM) and FF site exceptions for dom storage to offer the perfect granular control - EDIT: But this would break web extensions and I can't see how you can grant an exception for those, and that was the whole point of this exercise

Thorin-II avatar Aug 06 '17 08:08 Thorin-II

I'm confused about your use of "dom storage" - What is that? I think you're mixing them up.

What kind of offline storage exists and where is it stored should be the first thing we clarify.

Afaik, there's

  • indexedDB (=disabled)
    • profiledir/storage/permanent/... (??) I've also seen /storage/temporary/...
  • "offline storage" which is apparently != indexedDB ?
    • storage.sqlite ?? storage-sync.sqlite ?? webappstore.sqlite ??
    • about:cache > appcache? disabled by browser.cache.offline.enable;false ?
  • WE's storage.local which is used to store a WE's settings
    • stored in profiledir/browser-extension-data/WE_ID/storage.js

Is there anything else? Which ones are you worried about? DOM storage is something completely different, basically variables, objects, etc that a sites JS defines and are temporarily stored in DOM.

earthlng avatar Aug 06 '17 13:08 earthlng

^^^^^ THIS one

/* 2705: disable DOM (Document Object Model) Storage
 * [WARNING] This will break a LOT of sites' functionality.
 * You are better off using an extension for more granular control ***/
   // user_pref("dom.storage.enabled", false); 

THIS is called local dom storage by almost everything I know <<< ELI5 WHERE THIS LIVES

Thorin-II avatar Aug 06 '17 17:08 Thorin-II

@fmarier : can you confirm that all identifying information in any SB google cookie is stripped out. I do not have one to look at. Is it a requirement (ToS) that a SB cookie even be used, because I update just fine and I block it

Thorin-II avatar Aug 06 '17 17:08 Thorin-II

Found that test page from MDN : http://dev-test.nemikor.com/web-storage/support-test/

Even with dom.storage.enabled=true, I notice : localStorage: not supported sessionStorage: limited to 0 k characters globalStorage: not supported

2glops avatar Aug 06 '17 17:08 2glops

^^ @2glops - did you allow a site exception for cookies for that test site? I disabled uM and uBo and NS temporarily for that site, added a cookie exception (site prefs) and clicked run the tests and nothing seems to happen.

Thorin-II avatar Aug 06 '17 18:08 Thorin-II

With site exception cookie (about:prefs), that returns : localStorage: limited to 5101 k characters sessionStorage: limited to 5101 k characters globalStorage: not supported

The tests seems to have completed (5 min run) but no dialog to confirm)

2glops avatar Aug 06 '17 18:08 2glops

Right, which is exactly what I have been saying, that the FF pref for cookies also controls the local storage doesn't matter if it is global or a site exception.

I got the same result with eCleaner - even though it doesn't need or set a cookie, it requires cookies enabled (0 or 1), as then allows local dom storage, which in turn meant the Web Ext could access it's saved settings

We need a test where a cookie is set and it uses local storage. So we can allow the site a cookie in FF, but block the cookie in uM, and see if local dom is still accessible

Thorin-II avatar Aug 06 '17 18:08 Thorin-II

This is interesting: https://addons.mozilla.org/en-US/firefox/addon/shim-storage/ (legacy addon - very old, 4 years abandoned but still works AFAIK from a comment on redditttt)

If your disabling localStorage or sessionStorage many sites stops working. Not cause they actually need the database, but cause they expect it to be there.

This extension allows you to define a list of domains where a shim should be defined so the page will actually work. No data will be stored anywhere outside the page.

NOTE: This extension has no effect if you don't set dom.storage.enabled to false.

So in effect:

  1. Allow cookies in FF (which in effect NOW stops blocking dom storage) but block all cookies in uMatrix by default. uM giving you granular control
  2. Deny dom.storage.enabled and use the shim storage extension for granular control

Wonder how hard it would be or if even possible in a WebExt? However, this still doesn't allow exceptions for Web Extensions local storage AFAIK, which is a problem. But that aside it does give some granular control for some problem sites - the other drawback is sites that actually need it will fail.

Just about ready to give up. I hope the new about:permissions gives a much more precise and thorough configuration (eg indexedb, dom storage, offline storage, cookies = and none are dependent on others, and extensions are exempt)

Thorin-II avatar Aug 08 '17 08:08 Thorin-II

Re: https://github.com/ghacksuserjs/ghacks-user.js/issues/188#issuecomment-320470847

3=allow 3rd party had it's own policy (P3P) that was taken down by google, inc. et al.

Atavic avatar Aug 08 '17 22:08 Atavic

Hey Pants, don't you get a bunch of error messages in the console after startup in 55? FF also uses indexedDB internally and disabling it might have unforeseen consequences. I've now enabled it again and will use PB windows to prevent sites from using it ie. if a site needs JS I'll make sure to open it in PB.

As for "Web Storage" (aka DOM Storage) uMatrix has an option to delete it for blocked hostnames. testpage: https://mdn.github.io/dom-examples/web-storage/ Information is stored in the webappsstore.sqlite file for websites and in the chromeappsstore.sqlite for [about:*] (source)

I'm using 1 as the cookie value (no 3rd party cookies), indexedDB enabled, dom.storage.enabled=true and clear cookies on shutdown which also deletes sites "localstorage".

earthlng avatar Aug 09 '17 09:08 earthlng

Looking in my "D:\Portable\FirefoxPortable\Data\profile\storage\permanent\" (which I assume is FF internals), I see date modified is all like 2 years old - heh

Thorin-II avatar Aug 09 '17 09:08 Thorin-II

You don't clean up your profile folder very much then, huh? xD

Why would mozilla provide an indexedDB pref that breaks INTERNAL code.

IDK but they do.

How can I see the console error messages when I start? EIL5 please.

I have to ELI5 a lot recently ;) start FF then Ctrl+Shift+J

earthlng avatar Aug 09 '17 10:08 earthlng

You don't clean up your profile folder very much then, huh

I do. There's nothing in there. ...\profile\storage\default and ...\profile\storage\temporary are empty ...\profile\storage\permanent has three sub-dirs: chrome, indexeddb+++fx-devtools and moz-safe-about+home and these are internal, so I don't care about cleaning them

I guess its been about 2 years since I toggled indexedDB on. My profile is well over 4 years old. I keep it clean as I can (removed dead prefs including extension ones).

Maybe with 57 I will start a brand new clean profile.

Thorin-II avatar Aug 09 '17 10:08 Thorin-II