Open Bug 1801262 Opened 4 years ago Updated 3 years ago

Data clearing exceptions should apply to cookie jars when dFPI is enabled

Categories

(Toolkit :: Data Sanitization, defect, P3)

Firefox 107
defect

Tracking

()

People

(Reporter: bugzilla, Unassigned)

Details

Attachments

(3 files)

Attached file about_support.txt —

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:107.0) Gecko/20100101 Firefox/107.0

Steps to reproduce:

  1. Set "Delete cookies and site data when Firefox is closed" at about:preferences#privacy
  2. Ensure kinopoisk.ru is not whitelisted at "Manage exceptions"
  3. Go https://kinopoisk.ru
  4. Restart browser to trigger cookie auto delete cookies
  5. Go about:preferences#privacy, open "Manage data"

Actual results:

Cookie "kinopoisk.ru" is persisted

Expected results:

Cookie "kinopoisk.ru" deleted

same with yandex.ru cookies.
are whitelisted by firefox?

Can you reproduce this in safe mode? Though I'm not sure how an addon would mess with cookies like that.

This is more of a privacy issue for a non-standard feature than a sec issue, so I'm going to unhide it.

Group: firefox-core-security

The Bugbug bot thinks this bug should belong to the 'Core::Graphics: WebRender' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Graphics: WebRender
Product: Firefox → Core

I'm not sure if this should live under a toolkit storage kind of component or networking cookies. Probably the former. Of course, it depends on what exactly is happening.

Component: Graphics: WebRender → Untriaged
Product: Core → Firefox

(In reply to Andrew McCreight [:mccr8] from comment #2)

Can you reproduce this in safe mode? Though I'm not sure how an addon would mess with cookies like that.

This is more of a privacy issue for a non-standard feature than a sec issue, so I'm going to unhide it.

succesfully reproduced in safe mode

How are you restarting Firefox to clear cookies, and do you have session restore ("Startup - open previous windows and tabs") enabled?

Component: Untriaged → Data Sanitization
Flags: needinfo?(bugzilla)
OS: Unspecified → Linux
Product: Firefox → Toolkit
Hardware: Unspecified → x86_64

(In reply to :Gijs (he/him) from comment #6)

How are you restarting Firefox to clear cookies, and do you have session restore ("Startup - open previous windows and tabs") enabled?

How are you restarting Firefox to clear cookies

i have "Delete cookies and site data when Firefox is closed" checked on, open only tab kinopoisk.ru, and then close the only tab with "kinopoisk.ru"

do you have session restore ("Startup - open previous windows and tabs") enabled

no

Flags: needinfo?(bugzilla)

you can reproduce the bug in your own in about 10 sec, come on

(In reply to :Gijs (he/him) from comment #6)

How are you restarting Firefox to clear cookies, and do you have session restore ("Startup - open previous windows and tabs") enabled?

How are you restarting Firefox to clear cookies

to be more verbose:

  1. i ensure that no tabs open
  2. i ensure that there is no cookie "kinopoisk.ru" at about:preferences#privacy -> "Manage data"
  3. i ensure that "Clear history when Firefox closes" is checked on at about:preferences#privacy -> "History" section
  4. i ensure that "Cookies" is checked on in setting of "Clear history when Firefox closes" setting at about:preferences#privacy -> "History" section
  5. i open kinopoisk.ru in new tab
  6. i close kinopoisk.ru tab
  7. i close browser using "x" icon in top right corner of the firefox window
  8. i ensure firefox browser is closed using "ps -ef | grep firefox"
  9. i open firefox browser

is it clear enough?

Flags: needinfo?(gijskruitbosch+bugs)

Hey Vladislav,
You have experienced this issue for kinopoisk.ru/yandex.ru and the cookies of other sites are properly deleted right?
I have not managed to reproduce this yet, cookies for kinopoisk.ru are deleted after a restart for me.
The about support data also looks fine, though it says that you have a User.js, could you share this with us so we can make sure there is nothing in there that could be triggering this?
Thank you!

Flags: needinfo?(bugzilla)
Attached file user.js —

attached user.js as you asked

Flags: needinfo?(bugzilla)

(In reply to Vladislav from comment #8)

you can reproduce the bug in your own in about 10 sec, come on

The problem is that we can't (ie we've tried and we aren't able to reproduce the problem, cf. comment 10), so we need to figure out what is different between your environment and the one we're using.

Thank you for that user.js. On first sight the user.js does not look suspicious. Are the cookies only persisted if you do the cleaning on shutdown or are they also persisted if you clear without shutting Firefox down, via clear history or clear data ?

Flags: needinfo?(bugzilla)

(In reply to hpeuckmann from comment #13)

Thank you for that user.js. On first sight the user.js does not look suspicious. Are the cookies only persisted if you do the cleaning on shutdown or are they also persisted if you clear without shutting Firefox down, via clear history or clear data ?

if i manually clear history/data they, and all the cookies added to "exceptions" are removed

Flags: needinfo?(gijskruitbosch+bugs)
Flags: needinfo?(bugzilla)

Ok, interesting. Something that we can try is to get the logs from the sanitizer, to see if we fail there. But this is a bit laborious:

First of all you need to set the right log level:

  • Go to about:config and set browser.sanitizer.loglevel to All

Open the browser toolbox:

  • Open the web developer tools, click on the three dots menu ...and open the settings.
    under Advanced settings enable the check boxes for Enable browser chrome and add-on debuging toolbox andenable remote debugging.
    After that you should be able to open the browser toolbox, for example via the application menu under more tools .

Run the shutdown cleaning:

  • In the browser toolbox open the console.
    Type in and press enter:
var { Sanitizer } = ChromeUtils.import(
  "resource:///modules/Sanitizer.jsm"
);
  • Type in:
    Sanitizer.runSanitizeOnShutdown();
    hit enter and the sanitizer will run the code that is usually run on shutdown.

You can also find instructions on how to enable/open/use the browser toolbox here
Please share the logs you see with us.

Flags: needinfo?(bugzilla)
Attached file sanitizer.log —

added santizier log.
cookie "kinopoisk.ru" still persists after i run sanitizer manually following your instuctions.

Flags: needinfo?(bugzilla)

all the cookies i see in sanitizer log are from websites that i added to exceptions (about:preferences#privacy -> cookies and site data -> manage exceptions).

as for example: i added exception for sports.ru, and in log i see both senoval.sports.ru and sports.ru.

i see no kinopoisk.ru cookie in the log, so i can conclude it is ignored by sanitizer, and it is not removed.

Thank you for making that effort!

So, let me summarize what we know so far:

  • this only happens for the shutdown cleaning not for the cleaning processes during a running session
    -- for the most part the same code is running with the difference that we do not clear per principal during a session.
  • on shutdown, all exceptions are considered and all cookies are deleted, except for that one site "kinopoisk.ru"
  • The site does not show up in the logs, the sanitizer could be failing silently, but I don't think so. If its a bug in the code we should be experiencing this as well. I think its more likely that the principal for that site is somehow not provided to the sanitizer, also indicated by the fact that the cookies are cleared if we do not clear per principal.

Me and Paul were also thinking maybe those are session cookies that are restored somehow, if so they shouldn't show up in the sanitizer log, but they do show up in my log.

@Gijs any idea? Do you see anything in the about:support or user.js that looks suspicious?

Flags: needinfo?(gijskruitbosch+bugs)

Also, @Vladislav can you reproduce this with a fresh profile? I know you already tested this in safe mode but, to know if it is also reproducible with a fresh profile will be valuable.
You can create and launch a fresh profile via about:profiles.

Flags: needinfo?(bugzilla)

(In reply to hpeuckmann from comment #19)

Also, @Vladislav can you reproduce this with a fresh profile? I know you already tested this in safe mode but, to know if it is also reproducible with a fresh profile will be valuable.
You can create and launch a fresh profile via about:profiles.

hmm, couldn't reproduce with a new profile. all cookies are deleted as expected

Flags: needinfo?(bugzilla)

I think its more likely that the principal for that site is somehow not provided to the sanitizer, also indicated by the fact that the cookies are cleared if we do not clear per principal.

This seems like a reasonable explanation to me. What I'm less clear on is why we wouldn't get the principal for these cookies... I guess logging the hosts + origin attributes for Services.cookies.cookies where the host contains either yandex or kinopoisk might help figure that out?

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(hpeuckmann)

i found out the reason.

i have music.yandex.ru in exceptions.
if i delete it, and then restart browser - kinopoisk.ru and yandex.ru cookies are deleted as expected.

yandex uses some tricky way to authenticate user, that bypasses total cookie protection too: if i login with my account at music.yandex.ru i get recognized at yandex.ru, kinopoisk.ru, and the rest of yandex products.

btw i can't still understand what relation between exception "music.yandex.ru" and "kinopoisk.ru" (except both are products of yandex ecosystem): if kinopoisk is not added in exceptions, its cookie expected to be deleted.

Interesting, thank you for letting us know.
I can reproduce this behavior with an allow exception for yandex.

Flags: needinfo?(hpeuckmann)

Total cookie protection built into Firefox uses cookie jars per top-level site. This also changes our site data UI. That means all cookies that are set for and under kinopoisk.ru will be listed under the kinopoisk.ru entry. I haven't verified this yet, but I assume that kinopoisk.ru embeds music.yandex.ru. If you add an a exception for this Yandex domain its cookies won't be cleared on shutdown and will still show up in the manage data UI as kinopoisk.ru.
Once we confirm that this is happening we can either close the bug since this works as intended, or keep it for improving the UX. There is a bit a disconnect now that exceptions are still per-site but the data management UI groups per top level (what you see in the URL-bar).

B(In reply to Paul Zühlcke [:pbz] from comment #24)

If you add an a exception for this Yandex domain its cookies won't be cleared on shutdown and will still show up in the manage data UI as kinopoisk.ru

I dont get it, let's go through a few examples.

Environment:

  1. I have "Delete cookies and site data when Firefox is closed" enabled
  2. I have music.yandex.ru in exceptions

Example #1:

I log in to my account at music.yandex.ru, and go kinopoisk.ru in separate tab.
I get these cookies:

  1. kinopoisk.ru (top-level)
    1.1. music.yandex.ru (third-party)
  2. music.yandex.ru (top-level)

My expectations:
a) 1.1 is isolated until restart (because total cookie protection should isolate 3rd-party cookies)
b) 1 and 1.1 are removed on restart (1 is not whitelisted through exceptions)
c) 2 is persisted

Example #2:

I log in to my account at music.yandex.ru, and go yandex.ru in separate tab.
I get these cookies:

  1. yandex.ru (top-level)
    1.1. music.yandex.ru (third-party)
    1.2. kinopoisk.ru (third-party)

My expectations:
a) 1.1 and 1.2 are isolated until restart (because total cookie protection should isolate 3rd-party cookies)
b) 1, 1.1 and 1.2 are removed on restart (not whitelisted through exceptions)

Do i have wrong expectations?

Flags: needinfo?(pbz)

I don't know how yandex or kinopoisk sets cookies exactly, but let's assume they all set cookies in all contexts:

Example 1 seems accurate given music.yandex.ru is embedded and you also open both sites in the top level context. Cookie clearing exceptions currently do not take state partitioning (Total Cookie Protection) into account. That means your exception for music.yandex.ru will exempt any cookies from music.yandex.ru from being cleared, whether that's the in first-party or as an embedded third-party.

Your expectation a) generally applies given Total Cookie Protection is enabled..

Concerning b) whether this is expected behavior isn't clear. You could argue both ways:
Perhaps you have some settings stored for music.yandex.ru in the third-party context too and you don't want those to get cleared, thus you want to exempt music.yandex.ru anywhere.
At the same time I see how this is unintuitive to users especially since the data management UI only shows cookie jars now (like how you structured your example). Users may expect exceptions to only apply to the cookie jars.

Ben, when you're back in the office, do you think we should change our exceptions to apply to cookie jars, taking partitionKey into account, rather than the individual cookie hosts?

Flags: needinfo?(pbz) → needinfo?(bvandersloot)

(In reply to Paul Zühlcke [:pbz] from comment #26)

I don't know how yandex or kinopoisk sets cookies exactly, but let's assume they all set cookies in all contexts:

Example 1 seems accurate given music.yandex.ru is embedded and you also open both sites in the top level context. Cookie clearing exceptions currently do not take state partitioning (Total Cookie Protection) into account. That means your exception for music.yandex.ru will exempt any cookies from music.yandex.ru from being cleared, whether that's the in first-party or as an embedded third-party.

Your expectation a) generally applies given Total Cookie Protection is enabled..

Concerning b) whether this is expected behavior isn't clear. You could argue both ways:
Perhaps you have some settings stored for music.yandex.ru in the third-party context too and you don't want those to get cleared, thus you want to exempt music.yandex.ru anywhere.
At the same time I see how this is unintuitive to users especially since the data management UI only shows cookie jars now (like how you structured your example). Users may expect exceptions to only apply to the cookie jars.

Ben, when you're back in the office, do you think we should change our exceptions to apply to cookie jars, taking partitionKey into account, rather than the individual cookie hosts?

If I understand correctly, would this potentially break SSO style cookie uses unless you created exceptions for every site using the SSO identity provider? That would seem not great for that usecase...

Could a different solution be to show the second associated domain in the site data manager, perhaps in parens or something? I think this would alleviate the "surprise" here around why the yandex / kinopoisk cookies persist.

(In reply to :Gijs (he/him) from comment #27)

(In reply to Paul Zühlcke [:pbz] from comment #26)

I don't know how yandex or kinopoisk sets cookies exactly, but let's assume they all set cookies in all contexts:

Example 1 seems accurate given music.yandex.ru is embedded and you also open both sites in the top level context. Cookie clearing exceptions currently do not take state partitioning (Total Cookie Protection) into account. That means your exception for music.yandex.ru will exempt any cookies from music.yandex.ru from being cleared, whether that's the in first-party or as an embedded third-party.

Your expectation a) generally applies given Total Cookie Protection is enabled..

Concerning b) whether this is expected behavior isn't clear. You could argue both ways:
Perhaps you have some settings stored for music.yandex.ru in the third-party context too and you don't want those to get cleared, thus you want to exempt music.yandex.ru anywhere.
At the same time I see how this is unintuitive to users especially since the data management UI only shows cookie jars now (like how you structured your example). Users may expect exceptions to only apply to the cookie jars.

Ben, when you're back in the office, do you think we should change our exceptions to apply to cookie jars, taking partitionKey into account, rather than the individual cookie hosts?

If I understand correctly, would this potentially break SSO style cookie uses unless you created exceptions for every site using the SSO identity provider? That would seem not great for that usecase...

Could a different solution be to show the second associated domain in the site data manager, perhaps in parens or something? I think this would alleviate the "surprise" here around why the yandex / kinopoisk cookies persist.

Usually SSO logins use popups or top level redirects which grants them either first party cookie access because they're top level, or they automatically get storage access per our state partitioning heuristics. So I'm not too worried about this specific case.

We could update our site data manager to show partitioned data in some sort of hierarchy, but I think that's very hard to get right without confusing users. The current way we display storage is nice because it directly reflects the site the user has visited in the top level / what they saw in the urlbar.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
Summary: some cookies are persisted even with autodelete on exit set → Data clearing exceptions don't align with state partitioning and data manage UI

Ben, when you're back in the office, do you think we should change our exceptions to apply to cookie jars, taking partitionKey into account, rather than the individual cookie hosts?

Can you clarify what you mean by "taking partitionKey into account"?

My intuition reading the scrollback is that this is not obvious to users (or us) what the right thing to do for a singly-keyed UI element to do in the face of double-keying. My gut says that we should just use the domain the user provides as a list of top-level domains to permit to keep storage, clearing that same domain in third-party contexts since iframes appear to the user to be a part of the embedder origin's content.

Flags: needinfo?(bvandersloot) → needinfo?(pbz)

(In reply to Paul Zühlcke [:pbz] from comment #24)

Total cookie protection built into Firefox uses cookie jars per top-level site. This also changes our site data UI. That means all cookies that are set for and under kinopoisk.ru will be listed under the kinopoisk.ru entry. I haven't verified this yet, but I assume that kinopoisk.ru embeds music.yandex.ru. If you add an a exception for this Yandex domain its cookies won't be cleared on shutdown and will still show up in the manage data UI as kinopoisk.ru.
Once we confirm that this is happening we can either close the bug since this works as intended, or keep it for improving the UX. There is a bit a disconnect now that exceptions are still per-site but the data management UI groups per top level (what you see in the URL-bar).

looking at the partitionKey of the cookies that are persisted, we can confirm that kinopoisk.ru is indeed partitioned under .yandex.ru

Services.cookies.cookies.map(c => ({partitionKey: c.originAttributes.partitionKey, host: c.host}))

Array(16) [ {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, … ]
	0: Object { partitionKey: "", host: "addons.mozilla.org" }
	1: Object { partitionKey: "", host: "addons.mozilla.org" }
	2: Object { partitionKey: "(https,kinopoisk.ru)", host: ".yandex.ru" }
	3: Object { partitionKey: "(https,kinopoisk.ru)", host: ".yandex.ru" }
	4: Object { partitionKey: "(https,kinopoisk.ru)", host: ".yandex.ru" }
	5: Object { partitionKey: "(https,kinopoisk.ru)", host: ".yandex.ru" }
	6: Object { partitionKey: "", host: "addons.mozilla.org" }
	7: Object { partitionKey: "", host: ".yandex.ru" }
	8: Object { partitionKey: "", host: ".yandex.ru"

(In reply to hpeuckmann from comment #30)

looking at the partitionKey of the cookies that are persisted, we can confirm that kinopoisk.ru is indeed partitioned under .yandex.ru

Thank you for testing this! Just a small correct: It's the other way around, .yandex.ru cookies are partitioned under kinopoisk.ru. That's why kinopoisk.ru shows in the data management UI.

(In reply to bvandersloot from comment #29)

Ben, when you're back in the office, do you think we should change our exceptions to apply to cookie jars, taking partitionKey into account, rather than the individual cookie hosts?

Can you clarify what you mean by "taking partitionKey into account"?

My intuition reading the scrollback is that this is not obvious to users (or us) what the right thing to do for a singly-keyed UI element to do in the face of double-keying. My gut says that we should just use the domain the user provides as a list of top-level domains to permit to keep storage, clearing that same domain in third-party contexts since iframes appear to the user to be a part of the embedder origin's content.

Thanks! Yes, that does sound like the more intuitive solution and it would match our existing data UI + how we clear data better. Let's keep this bug for this work then. It's probably backlog though.

Flags: needinfo?(pbz)
OS: Linux → Unspecified
Hardware: x86_64 → Unspecified
Summary: Data clearing exceptions don't align with state partitioning and data manage UI → Data clearing exceptions should apply to cookie jars when dFPI is enabled

(In reply to bvandersloot from comment #29)

My intuition reading the scrollback is that this is not obvious to users (or us) what the right thing to do for a singly-keyed UI element to do in the face of double-keying. My gut says that we should just use the domain the user provides as a list of top-level domains to permit to keep storage, clearing that same domain in third-party contexts since iframes appear to the user to be a part of the embedder origin's content.

as a user i'd prefer this behavior to be configurable and well documented for end user.
i see it as radio/select box with 2 options

  1. current behavior
  2. behavior you described in quoted comment

a link "learn more" (as the most "lean" option) to see the details (and side effects) of each option right in the exceptions UI is necessary.

(In reply to Vladislav from comment #32)

(In reply to bvandersloot from comment #29)

My intuition reading the scrollback is that this is not obvious to users (or us) what the right thing to do for a singly-keyed UI element to do in the face of double-keying. My gut says that we should just use the domain the user provides as a list of top-level domains to permit to keep storage, clearing that same domain in third-party contexts since iframes appear to the user to be a part of the embedder origin's content.

as a user i'd prefer this behavior to be configurable and well documented for end user.
i see it as radio/select box with 2 options

  1. current behavior
  2. behavior you described in quoted comment

a link "learn more" (as the most "lean" option) to see the details (and side effects) of each option right in the exceptions UI is necessary.

good effect: in this case you can set current behavior as default option for users who has at least one exception, to avoid breaking his expectations/experience on browser update.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: