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

Warning in Chrome console: A cookie was set without the SameSite attribute. #14395

Closed
neunzehnachtneun opened this issue May 1, 2019 · 19 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc. c: Security For issues that make Matomo more secure. Please report issues through HackerOne and not in Github. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Milestone

Comments

@neunzehnachtneun
Copy link

neunzehnachtneun commented May 1, 2019

Note: More info why this should be fixed in a soon Matomo release below: #14395 (comment)

Hi together,
this is my first issue in this project, so hopefully I do it right.
I would like to request a new feature to improve privacy. At the moment it is possible yet to set the cookie lifetime to a shorter timespan and to set the cookie secure.
I suggest to also set the cookie attributes HttpOnly and SameSite=Strict, so privacy would be improved and cross site request attacks forgery could be prevented.

Thank you!

@fdellwing
Copy link
Contributor

As far as I'm aware of every cookie that can be httponly is httponly. Can you show one that is not that way?

@tsteur
Copy link
Member

tsteur commented May 1, 2019

What do you refer to here @neunzehnachtneun ? To the JS tracker? In JS you cannot set a cookie as httponly

@neunzehnachtneun
Copy link
Author

Thank you for answering! Yes, I refer to the JS-Tracker and, yes, you are totally right. I read a bit about javascript and cookies and it's totally useless to set the cookie header to httponly.

But also I read about the cookie header 'samesite=strict', which is possible to use with javascript and which I would like to use with matomo. What do you think about that?

@Findus23 Findus23 changed the title Feature request: cookie attributes HttpOnly SameSite=Strict Feature request: cookie attribute SameSite=Strict May 2, 2019
@fdellwing
Copy link
Contributor

fdellwing commented May 2, 2019

While using samesite you need to really take care of your cookie domain or you will run into a hell of a lot of trouble. This is especially important if you use a reverse proxy.

(This does not mean I'm against it, but it might be a breaking change for some people.)

@tsteur
Copy link
Member

tsteur commented May 2, 2019

You would also need to have matomo running on the very same domain? not even a subdomain? or would a subdomain still work?

@tsteur tsteur added this to the Backlog (Help wanted) milestone May 9, 2019
@tsteur tsteur added Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. labels May 9, 2019
@MichaelRoosz
Copy link
Contributor

samesite is a origin related setting and should be used with caution. it would have effects on the tracked data and most certainly break the 3rd party cookie in in many use cases

@Findus23 Findus23 modified the milestones: Backlog (Help wanted), 3.12.0 Sep 8, 2019
@Findus23
Copy link
Member

Findus23 commented Sep 8, 2019

Seems like this is becoming far more important: Chrome is planning to make all cookies that don't have an explicit SameSite option have SameSite=Lax by default. At the moment it is an optional flag (#same-site-by-default-cookies), but chrome 80 (release in the beginning of January 2020) will have it enabled by default.
https://www.chromestatus.com/feature/5088147346030592

(Disclaimer: I haven't fully understood the topic and the explanations are all a bit vague, so this might be incorrect)
This means that if your Matomo is on matomo.someagency.example any request that isn't from the same site (so someagency.example or www.someagency.example) won't recieve any cookies. If you have Matomo installed on the same "site" as the website you are tracking (so a subdomain or subdirectory) nothing should really change.
But in every other change this will break some things. One I noticed that is especially critical is the opt-out iframe. I guess the same will also happen for widgets without token_auth.

Simply updating all cookies to add a SameSite=None flag won't help much as on one hand SameSite is a useful security feature as it makes CSRF attacks far harder and on the other hand there is a bug in all current Safari versions (iOS and MacOS) that causes them to interpret SameSite=None as SameSite=Strict which will break even more things.

Another related change is that starting in chrome 80 all cookies with SameSite=None and without the secure flag will be rejected completly. (https://www.chromestatus.com/feature/5633521622188032) So Matomo instances without HTTPS (I hope there are hardly any left) might have even more problems if we try SameSite=None.

More Details:
https://web.dev/samesite-cookies-explained

@Findus23 Findus23 added c: Security For issues that make Matomo more secure. Please report issues through HackerOne and not in Github. and removed Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. labels Sep 8, 2019
@MichaelRoosz
Copy link
Contributor

MichaelRoosz commented Sep 19, 2019

When talking about the third party cookie (_pk_uid) and the opt out cookie, I guess the best setting for all setups with Matomo on its own (sub)domain is SameSite=None + secure. The Safari/iOS fix for SameSite=None will not be backported to iOS <13, so we should not write the SameSite attribute for ios and macos until most users are on a fixed version. This would mean that the third party feature and the opt-out iframe feature will require https. Which should not be an issue in 2019. If its possible an alternative solution for the opt out cookie on http should be implemented.

@tsteur
Copy link
Member

tsteur commented Sep 19, 2019

We could possibly also detect some browsers and send different headers for them? But of course be hard to test and maintain it all etc. Might be worth for some very popular browsers/versions.

@fdellwing
Copy link
Contributor

Screenshot_20190920_074220

Data from 20.09.2019 (https://david-smith.org/iosversionstats/)

@MichaelRoosz
Copy link
Contributor

Proposed values for the SameSite flag:

SameSite=None (but not for iOS or Safari on macOS):

  • Opt-Out IgnoreCookie (piwik_ignore)
  • 3rd Party Cookie (_pk_uid)

SameSite=Lax

  • PHP Session Cookie (MATOMO_SESSID) -> requires PHP >= 7.3: session.cookie_samesite=Lax
  • Language Manager Cookie (matomo_lang)

@MichaelRoosz
Copy link
Contributor

Proposed values for the secure flag:

  • set if Matomo runs on https
  • not set if Matomo runs on http (maybe add some warning, that it will not work with Chrome >=80?)

@Findus23
Copy link
Member

@MichaelHeerklotz
Both sound good to me and are about what I would have suggested.
But this also means that we would need to make it very explicit that using Matomo without HTTPS means:

  • that features are broken
  • that it is highly likely that you are in violation of privacy laws.

@mattab
Copy link
Member

mattab commented Oct 22, 2019

it would be great to fix this in the next minor release eg. 3.12.1 as we're starting to get reports that people see a a warning in their Chrome developer console:

A cookie associated with a cross-site resource at https://x.matomo.cloud/ was set without the SameSite attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with SameSite=None and Secure. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032"

@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Oct 22, 2019
@mattab mattab changed the title Feature request: cookie attribute SameSite=Strict Warning in Chrome console: A cookie was set without the SameSite attribute. Oct 22, 2019
@mattab mattab modified the milestones: 3.12.0, 3.13.0 Oct 22, 2019
@mattab mattab added the Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. label Oct 30, 2019
@tsteur
Copy link
Member

tsteur commented Nov 10, 2019

Not sure if this issue is maybe related? #15083

@Findus23
Copy link
Member

@tsteur I doubt this as #15083 also is reported in non-chrome browsers and I doubt many people are using Chrome Dev or Canary (two releases after the current one) which I think is the first one with this change.

@katebutler katebutler self-assigned this Nov 11, 2019
@KokoKoder
Copy link

KokoKoder commented Nov 15, 2019

Simply here to comfirm @MichaelHeerklotz proposition for default as value as they are in accordance with Chrome DevTools warning: "A future release of Chrome will only deliver cookies with cross-site requests if they are set with SameSite=None and Secure"

@jackherizsmith
Copy link

This still seems to be an issue, unless I have misunderstood something. Getting

A cookie associated with a cross-site resource at http://xxx.matomo.cloud/ was set without the SameSite attribute. It has been blocked, as Chrome now only delivers cookies with cross-site requests if they are set with SameSite=None and Secure.

Could you advise on how best to proceed?

@tsteur
Copy link
Member

tsteur commented Jan 17, 2021

@jackherizsmith can you maybe share with us on which page this is happening? Feel free to email us at support@matomo.cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. c: Security For issues that make Matomo more secure. Please report issues through HackerOne and not in Github. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Projects
None yet
Development

No branches or pull requests

9 participants