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

SameSite Cookie Support #175

Closed
glassfishrobot opened this issue May 2, 2017 · 27 comments
Closed

SameSite Cookie Support #175

glassfishrobot opened this issue May 2, 2017 · 27 comments
Labels
Enhancement New feature or request
Projects

Comments

@glassfishrobot
Copy link

Good morning,

I'm not sure if this is the best avenue to communicate this feedback, but while working on lift/framework#1828 we discovered that the current version of the Servlet API doesn't support the same-site cookie attribute.

I would like to propose an addition to javax.servlet.http.Cookie to add support for this attribute in Servlet API 4.0, which would give us a path forward in the Lift Framework for supporting it.

@glassfishrobot
Copy link
Author

@farmdawgnation Commented
@edburns @shingwaichan You two seem to be active on this project, but this issue hasn't gotten any attention since I opened it back in May. Am I in the wrong place for this discussion? Would you be open to a contribution to the API to support this?

@glassfishrobot
Copy link
Author

@dcominottim Commented
I am also interested in this. It definitely seems like an important addition.

@glassfishrobot
Copy link
Author

@edburns Commented
Hello @farmdawgnation and @dcominottim Same site cookie support is indeed important, but by the time this issue was filed, we were already in the rampdown for Servlet 4.0. Perhaps we can get to it in a future version. Thanks.

Ed

@glassfishrobot
Copy link
Author

@farmdawgnation Commented
Got it. What's the best way to get involved in future iterations?
On Wed, Aug 16, 2017 at 7:01 PM Edward Burns notifications@github.com
wrote:

Hello @farmdawgnation https://github.com/farmdawgnation and @dcominottim
https://github.com/dcominottim Same site cookie support is indeed
important, but by the time this issue was filed, we were already in the
rampdown for Servlet 4.0. Perhaps we can get to it in a future version.
Thanks.

Ed


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/javaee/servlet-spec/issues/175#issuecomment-322922905,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAl2nQ3Cx-H-SmrTO2ZN6DB1hEnGr84Oks5sY3S8gaJpZM4NOM7F
.

@glassfishrobot
Copy link
Author

@edburns Commented
I'm told there will be an announcement of some kind soon. It's a good idea to keep an eye on < https://blogs.oracle.com/developers/java-3 >.

@glassfishrobot
Copy link
Author

@asgs Commented
Just FYI - The HTTP WG has recently proposed an update to RFC 6265 to include SameSite attribute.

@glassfishrobot
Copy link
Author

@bes
Copy link

bes commented Jan 1, 2019

Hi!

This issue is quite important for web security, but many of the links in this thread are dead and there seems to be little or no movement for a while on this issue.

I have tried searching the internet for more information about the Servlet API and work on SameSite but this is the best thread I could find.

Could anyone with knowledge jump in and clarify what release this could potentially end up in, or at least what the status is?

Thanks!

@markt-asf
Copy link
Contributor

It is on the TODO list (i.e. is an open issue here) for the next release of the Servlet spec.

@aldaris
Copy link

aldaris commented Oct 6, 2019

Are PRs welcome for this RFE?

@markt-asf
Copy link
Contributor

Yes, but...

  1. We don't yet have the text for the spec document and I'd expect that would need updates as well as the code.
  2. While the Servlet spec document references RFC 6265, the Javadoc references the Netscape Cookie spec and RFC 2109. I think the Javadoc needs some updates to better align it with RFC 6265 (and that might trigger some debates about backwards compatibility)
  3. I don't know if anything in 2) would impact on the changes required for this issue.

Overall having a PR is better than not having one, I'm just trying to set the expectation that it might not get merged quickly.

aldaris added a commit to aldaris/servlet-api that referenced this issue Oct 14, 2019
@aldaris
Copy link

aldaris commented Oct 14, 2019

Not sure if support for SameSite cookies have to be covered at the same time as when the JavaDocs need to get restructured. I have filed #271 just in case.

@joakime
Copy link

joakime commented Nov 4, 2019

Google Chrome is going to start enforcing the SameSite Cookie attribute.

Chrome plans to implement the new model with Chrome 80 in February 2020. Mozilla and Microsoft have also indicated intent to implement the new model in Firefox and Edge, on their own timelines.

https://blog.chromium.org/2019/10/developers-get-ready-for-new.html

aldaris added a commit to aldaris/servlet-api that referenced this issue Nov 16, 2019
Signed-off-by: Peter Major <peter.major@forgerock.com>
aldaris added a commit to aldaris/servlet-api that referenced this issue Jan 6, 2020
Signed-off-by: Peter Major <peter.major@forgerock.com>
aldaris added a commit to aldaris/servlet-api that referenced this issue Jan 17, 2020
Signed-off-by: Peter Major <peter.major@forgerock.com>
@gregw gregw added the Enhancement New feature or request label Jan 18, 2020
@gregw gregw added this to To Do in 5.0 via automation Jan 18, 2020
@gregw gregw moved this from To Do to In Progress in 5.0 Jan 18, 2020
@gregw gregw removed this from In Progress in 5.0 Jan 20, 2020
@gregw gregw added this to To do in 5.1 via automation Jan 20, 2020
@cleankod
Copy link

cleankod commented Apr 14, 2020

Some browsers (for example Google Chrome) announced that they would require the SameSite directive to be present as a Cookie attribute. Otherwise the Cookie will not be sent by the browser. This was supposed to be required starting from April 2020, but due to COVID-19 crisis it was delayed (source). This means we have a little more time to get everything in place.

I would therefore reconsider making it a part of 5.x release and add it sooner, to the 4.x since 5.x may require other changes in dependent servers/frameworks thus making it that harder to introduce the SameSite support.

cleankod added a commit to cleankod/servlet-api that referenced this issue Apr 14, 2020
cleankod added a commit to cleankod/servlet-api that referenced this issue Apr 14, 2020
See jakartaee#175

Signed-off-by: Adam Klinkosz <spyro@o2.pl>
@lack3r
Copy link

lack3r commented Aug 18, 2020

Hi all. Google Chrome has released released a new version that blocks all cross-site cookies that do not have the SameSite attribute set. For more info have a look here https://www.chromium.org/updates/same-site. This applies to all chrome users. Therefore, I was wondering whether servlet-api will support this?

@joakime
Copy link

joakime commented Aug 18, 2020

@lack3r the discussion on the open PR at #271 seems to be that this change will be push out to Servlet 5.1 and not be part of Jakarta EE 9.

That means ...

  • The jakarta.servlet namespace is in use. (not the javax.servlet namespace of Servlet API 4.0 and older, which will never have another API update)
  • It will likely be part of the Jakarta EE 10 release process. (the first release of Jakarta EE that allows for API changes)
  • It will likely requires Java 11 or newer JVM.

But all is not lost, most containers, even ones on javax.servlet 3.x series, have container specific configurations to control the SameSite cookies now.

@fabianfrz
Copy link

Since this may make Jakarta EE entirely unusable if your links go cross domain, may I ask that there could be a Servlet API 4.1 at least which sill contain that and maybe some minor changes which are breaking? When those methods are not existing, the app will simply not use it and the current behaviour may be in place. The problem is that maybe you loose the JSESSIONID cookie so a back url in a request to another application will not work.

@stuartwdouglas
Copy link
Contributor

For legal reasons we are not allowed to do a Servlet 4.1 API, Oracle did not grant us permission to modify the javax namespace, so those API's are effectively frozen.

@fabianfrz
Copy link

@stuartwdouglas thanks for the information. Sounds stupid but that is nothing we can change. In that case we need to wait for Jakarta EE servlet API which supports that feature.

@gregw
Copy link
Contributor

gregw commented Dec 10, 2020

Is there something we can do to say least make a defacto standard for setting it using the existing API? Eg a context attribute to configure the session cookie setting and perhaps a cookie comment to control it for arbitrary set cookies?

I think most containers now support the mechanism, we just need to agree how to activate it within the 4.0 API in a portable way.

@stuartwdouglas
Copy link
Contributor

This seems reasonable. If we use jakarta. names for the attributes we could actually standardise this for 5.1, and then containers targeting the older versions could just implement it as well.

@fabianfrz
Copy link

@stuartwdouglas I think it would be better to implement it as an context attribute in v4 and mark it immediately as deprecated in the docs and 5.x only supports the new version (maybe still handle the old flag until the grace period is over).

It also does not work since the Cookie class does not support the flag. So since it must be configurable by cookie, The issue is, that this is some kind of a Map because a Cookie is identified by the combination {hostname, path, name}. The hostname is given by the container and the HTTP headers but the path and the name depend on the application. This means that you need to provide structured data in the context attribute.

@erik-brangs
Copy link

Will this be in Servlet 5.1? The associated pull request #271 hasn't been updated in a while.

@markt-asf
Copy link
Contributor

I was thinking of something along the lines of Cookie.setAttribute(String name,String value) to provide a generic solution that handles these, and any future attributes. We'd need to think about things like how to remove attributes, how to set attributes that don't have a value, what happens if this is used for an attribute where a method already exists etc. but I think those issues are all relatively simple to solve and it would provide a (hopefully) future proof solution. Similar functionality could be added to

I am very uneasy about adding a hack based on the existing API. I'd rather rely on the existing container specific mechanisms for current and previous spec versions.

@BalusC
Copy link
Member

BalusC commented Apr 17, 2021

Big +1 for Cookie#setAttribute as fallback for future attributes. The sooner this gets into API the better.

Once a new cookie attribute ends up in RFC, then it deserves its own API method and <cookie-config> entry such as as we already have for setSecure/<secure> and setHttpOnly/<http-only>.

Do note that SameSite is currently still in draft in RFC, so it's not more than reasonable that it's still not final in Servlet API.

@BalusC
Copy link
Member

BalusC commented Apr 26, 2021

I've prepped a PR to add Cookie#setAttribute: #399

gregw added a commit that referenced this issue May 17, 2021
* Add Cookie#setAttribute
#175
#271

* Skip null value from check for reserved token

* Alternative approach to cookie attribute handling
github.com//pull/399#discussion_r624276777

* Make sure path is referenced via constant

* In hindsight, token check doesn't need to be performed on value

* Match casing with spec; mapping is case insensitive anyway

* Optimized Cookie to lazily create attribute map

* Added junit test

* Updates from review

* Fixed quote

* surefire plugin

* Updates from review

* Updates from review

Co-authored-by: Bauke Scholtz <balusc@gmail.com>
@markt-asf
Copy link
Contributor

Fixed with #401

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
5.1
  
Done
Development

No branches or pull requests