Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement 1p Ephemeral Storage Functionality (functionality) #15906

Closed
pes10k opened this issue May 17, 2021 · 10 comments · Fixed by brave/brave-core#9624
Closed

Implement 1p Ephemeral Storage Functionality (functionality) #15906

pes10k opened this issue May 17, 2021 · 10 comments · Fixed by brave/brave-core#9624
Assignees
Labels
feature/shields/cookies Cookie controls implemented as part of Shields. feature/shields The overall Shields feature in Brave. OS/Desktop privacy-pod Feature work for the Privacy & Web Compatibility pod QA Pass-Linux QA Pass-macOS QA Pass-Win64 QA/Test-All-Platforms QA/Yes release-notes/exclude

Comments

@pes10k
Copy link
Contributor

pes10k commented May 17, 2021

It would be useful to be able to have Brave visit a site where 1p-storage was ephemeral, in the same way 3p storage is currently by default.

The functionality described here is not intended to cover the settings and options Brave would expose to users (that might or might not change), only to describe the needed underlying capabilities. How 1p ephemeral storage capabilities could be exposed to users, or deployed to benefit users, is covered in other issues (e.g., #15097, #15018, etc)

This would include the following necessary functionality:

  • "1p ephemeral storage sessions" are at site granularity
  • DOM storage and cookies in a "1p ephemeral storage session" would be cleared as soon as there have been no top level documents open for the site, for more than seconds
  • Other NetworkIsolationKey partitioned storage (HTTP cache, service workers, network cache, etc) would be similarly partitioned

Nice to have:

  • "1p ephemeral storage sessions" are isolated from the site's normal storage area. This means that I should be able to have example.org open in a tab using a standard shields configuration, then open a new example.org tab in "1p ephemeral storage" mode, and that storage set in the "1p ephemeral storage" session would be independent of the standard example.org tab
  • Similarly, you could have two different, independent "1p ephemeral storage sessions" at the same time, with the same site, both of which would be independent of standard 1p storage
  • "1p ephemeral storage session" tabs taint each other, using sessionStorage logic. So if I open a example.org in a "1p ephemeral storage session", and then i open another top level document in the same site from that document, both tabs see the same "1p ephemeral storage area". (This might seem obvious, but I imagine it gets tricky when you could have 2 or more separate "1p ephemeral storage sessions" with the same site.)
@pes10k pes10k added OS/Android Fixes related to Android browser functionality privacy-pod Feature work for the Privacy & Web Compatibility pod OS/Desktop labels May 17, 2021
@pes10k pes10k added feature/shields/cookies Cookie controls implemented as part of Shields. feature/shields The overall Shields feature in Brave. labels May 17, 2021
@pes10k pes10k changed the title Implement 1p Ephemeral Storage Functionality (internal) Implement 1p Ephemeral Storage Functionality (functionality) May 17, 2021
@bridiver
Copy link
Contributor

"Nice to have" is kind of a problem because I'm not sure what needs to be validated here or what happens to those things if we only implement part of this and do the rest later. Can we either create sub-tickets for this that exactly match the functionality in each PR or narrow down exactly what we are/have implemented?

@goodov
Copy link
Member

goodov commented Oct 14, 2021

This is currently a hidden feature behind a flag, but it can be tested:

  1. Enable First Party Ephemeral Storage feature in brave://flags.
  2. Add website to test into "Always clear cookies when windows are closed" list:
    image
  3. Test that a cookie value is persistent by opening multiple tabs of a website, for example https://yandex.com/internet. yandexuid value should stay the same.
  4. Close all tabs and reopen https://yandex.com/internet, a new yandexuid value should appear.

Also a localStorage and sessionStorage can be tested using https://dev-pages.brave.software/storage/frames.html and other similar pages. The stored values should disappear when all tabs with a tested website are closed.

@stephendonner
Copy link

stephendonner commented Oct 19, 2021

Verified PASSED using

Brave 1.32.74 Chromium: 95.0.4638.54 (Official Build) dev (x86_64)
Revision d31a821ec901f68d0d34ccdbaea45b4c86ce543e-refs/branch-heads/4638@{#871}
OS macOS Version 11.6 (Build 20G165)

Steps:

  1. new profile
  2. launched Brave
  3. enabled First Party Ephemeral Storage feature via brave://flags
  4. added [*.]yandex.com to Always clear cookies when windows are closed, in brave://settings/cookies
  5. opened https://yandex.com/internet 5x (5 tabs)
  6. noted the value of Content for the above
  7. closed all tabs and windows (but not Brave)
  8. opened https://yandex.com/internet in a single tab
  9. noted the value of Content for the above

Confirmed Content is different for the 1) group of 5 tabs with the same URL 2) same URL in a single tab

example example
Screen Shot 2021-10-19 at 3 55 15 PM Screen Shot 2021-10-19 at 3 56 07 PM

@goodov
Copy link
Member

goodov commented Oct 20, 2021

@stephendonner thank you! That's the result I expect, but not the result I'd like to see :) I should've written more detailed explanation of what we're trying to test.

  1. The Settings page and DevTools show cookies stored in a default persistent storage. If you visited a website without enabling the feature and adding a website into Always clear cookies when windows are closed list, the values will appear in these areas.
  2. By enabling 1PES for a website (enable feature, add a website to the list), we effectively redirect all cookie save/load actions into ephemeral storage (ES) which is not viewable via Settings page or DevTools.

We want to test the 1PES logic:

  1. The ability to keep cookies in ES while tabs with a tested website are opened
  2. A cleanup after tabs with a tested website are closed (but not the cleanup after full browser/window close!)

So in the end we want to see ephemeral cookies, but we cannot see them in the browser UI. To solve this, we can add custom test pages or we can use a website which shows its cookie values right on the page. The https://yandex.com/internet is a just an example of a website that does that:
image

To test 1PES we need to make sure that the cookie value is same while at least one of the tabs is opened, and after closing/reopening tabs, the ephemeral cookie value should be deleted and a website should create a new cookie value.

@stephendonner
Copy link

stephendonner commented Oct 21, 2021

Verified PASSED using

Brave 1.32.77 Chromium: 95.0.4638.54 (Official Build) dev (x86_64)
Revision d31a821ec901f68d0d34ccdbaea45b4c86ce543e-refs/branch-heads/4638@{#871}
OS macOS Version 11.6 (Build 20G165)

Steps:

  1. new profile
  2. launch Brave
  3. enabled First Party Ephemeral Storage feature in brave://flags
  4. added [*.]yandex.com to Always clear cookies when windows are closed, in brave://settings/cookies
  5. loaded yandex.com/internet in 5 new tabs
  6. noted the value for yandexuid was 83902131634853864, across all 5 tabs
  7. closed all tabs (but NOT the browser)
  8. loaded yandex.com/internet again in a single tab
  9. noted the value for yandexuid was 3676166601634853957
example example example example
Screen Shot 2021-10-21 at 2 56 02 PM Screen Shot 2021-10-21 at 3 05 30 PM Screen Shot 2021-10-21 at 3 05 36 PM Screen Shot 2021-10-21 at 3 06 04 PM

Verified PASSED using

Brave 1.32.78 Chromium: 95.0.4638.54 (Official Build) beta (64-bit)
Revision d31a821ec901f68d0d34ccdbaea45b4c86ce543e-refs/branch-heads/4638@{#871}
OS Linux

Steps:

  1. new profile
  2. launch Brave
  3. enabled First Party Ephemeral Storage feature in brave://flags
  4. added [*.]yandex.com to Always clear cookies when windows are closed, in brave://settings/cookies
  5. loaded yandex.com/internet in 5 new tabs
  6. noted the value for yandexuid was 1992171635195119, across all 5 tabs
  7. closed all tabs (but NOT the browser)
  8. loaded yandex.com/internet again in a single tab
  9. noted the value for yandexuid was 5004146051635195281
example example example example
Screen Shot 2021-10-25 at 1 51 47 PM Screen Shot 2021-10-25 at 1 52 29 PM Screen Shot 2021-10-25 at 1 52 48 PM Screen Shot 2021-10-25 at 1 55 08 PM

Verification passed on


Brave | 1.32.82 Chromium: 95.0.4638.54 (Official Build) dev (64-bit)
-- | --
Revision | d31a821ec901f68d0d34ccdbaea45b4c86ce543e-refs/branch-heads/4638@{#871}
OS | Windows 10 Version 21H1 (Build 19043.1288)

Logged a follow up issue #19006

Steps:

  1. new profile
  2. launch Brave
  3. added [*.]yandex.com to Always clear cookies when windows are closed, in brave://settings/cookies
  4. loaded yandex.com/internet in 5 new tabs
  5. noted the value for yandexuid was 965761951635271465, across all 5 tabs
  6. closed all tabs (but NOT the browser)
  7. loaded yandex.com/internet again in a single tab
  8. noted the value for yandexuid is still same 796542931635271605
example example example example example
image image image image image

@stephendonner
Copy link

@goodov sorry for the delay, and thanks for clarifying; how's the above look, now, verification-wise?

@goodov
Copy link
Member

goodov commented Oct 22, 2021

Yep, this is much better, thank you!

@stephendonner
Copy link

@goodov: I've tried to find the Android corollary, here, but so far am not finding it.

I'm not seeing a place where we can add the exception, noted in step 3, above, "added [*.]yandex.com to Always clear cookies when windows are closed, in brave://settings/cookies"

We have "Close tabs on exit," but that's for browser-session behavior, as is Clear data on exit.

@goodov
Copy link
Member

goodov commented Nov 9, 2021

@goodov: I've tried to find the Android corollary, here, but so far am not finding it.

I'm not seeing a place where we can add the exception, noted in step 3, above, "added [*.]yandex.com to Always clear cookies when windows are closed, in brave://settings/cookies"

We have "Close tabs on exit," but that's for browser-session behavior, as is Clear data on exit.

Huh, you're right. This option is not available on Android, but it's just a UI limitation, under the hood it should work. I guess we have to add this setting then.

@stephendonner
Copy link

stephendonner commented Nov 16, 2021

@goodov: I've tried to find the Android corollary, here, but so far am not finding it.
I'm not seeing a place where we can add the exception, noted in step 3, above, "added [*.]yandex.com to Always clear cookies when windows are closed, in brave://settings/cookies"
We have "Close tabs on exit," but that's for browser-session behavior, as is Clear data on exit.

Huh, you're right. This option is not available on Android, but it's just a UI limitation, under the hood it should work. I guess we have to add this setting then.

  1. Filed Implement adding site exceptions to Always clear cookies when tabs are closed #19476 to address this (which might/probably depends on another issue).
  2. Removed OS/Android as this isn't yet implemented.

@stephendonner stephendonner removed the OS/Android Fixes related to Android browser functionality label Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/shields/cookies Cookie controls implemented as part of Shields. feature/shields The overall Shields feature in Brave. OS/Desktop privacy-pod Feature work for the Privacy & Web Compatibility pod QA Pass-Linux QA Pass-macOS QA Pass-Win64 QA/Test-All-Platforms QA/Yes release-notes/exclude
Projects
None yet
7 participants