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

Allow document.cookie and maybe Set-Cookie from the server to be controlled #85

Open
annevk opened this issue Sep 27, 2017 · 6 comments

Comments

@annevk
Copy link
Member

annevk commented Sep 27, 2017

It doesn't seem like a good idea to overload suborigins with this (see w3c/webappsec-suborigins#75).

@clelland
Copy link
Collaborator

I know that document.cookie has definitely been considered, from a performance perspective -- the idea would be to remove that attribute from the Document object, and require developers to use something like https://github.com/WICG/async-cookies-api instead.

It sounds, though, like you're thinking more about the security aspects of cookie manipulation -- is that true?

In that case, we'd want to restrict any current or future scriptable access to the cookie jar, not just document.cookie.

I would think that Set-Cookie, if read from the HTTP headers in the document, might still be acceptable -- any attacker who can manipulate headers could likely already override the policy anyway, but <meta http-equiv=Set-Cookie> would probably need to be controlled as well.

@clelland
Copy link
Collaborator

Although it looks like you may have been considering Set-Cookie already :)
whatwg/html#1950
whatwg/html#3076

@annevk
Copy link
Member Author

annevk commented Sep 27, 2017

Yeah http-equiv set-cookie is likely gone soon.

I agree that what I'm after should disable every JavaScript API for cookies. I guess I'm also somewhat convinced that HTTP Set-Cookie is at the same level so doesn't matter (although @mikewest did at one point have a CSP extension for it; maybe dropped for the same reason).

There's also something to say for whether outgoing requests should include cookies, but maybe that's best tracked in a separate issue.

@pabrai pabrai added the feedback label May 8, 2019
@Malvoz
Copy link
Contributor

Malvoz commented Jul 26, 2019

HTTP State Tokens also mention the potential need for opt-in and opt-out mechanisms as part of the process in (hopefully?) migrating away from cookies.

@clelland
Copy link
Collaborator

Cookies is an interesting case -- there are at least three sides to it.

Restricting document.cookie access is straightforward, I think -- it would probably fit nicely into the new sandboxing restrictions model, so you could opt out of doc.cookie usage on a per-document basis, and could prohibit access in subframes (if that was important to you) with a frame attribute which requires acknowledgment from the framed site.

Stopping Set-Cookie from having any effect is feels like it could operate in a similar manner, but Set-Cookie is defined at the HTTP layer, and so would take effect during FETCH, I suspect, long before we hit the "Create a Feature Policy for a browsing context from response" algorithm. (http-equive="set-cookie" is now gone)

Stopping cookies on outgoing requests is interesting. It might be similar to client hints, in that we can control the content of an outgoing request. It definitely fits into tracking protection, and it would be nice to find a way to enable credential-less subresources on the web. First-party cookies seems like the easiest issue to tackle; then possibly third-party subresources. I don't know if we can (or should) restrict cookies on framed document requests, or actual navigations, in any web-compatible way.

(Restricting first-party cookies doesn't have any effect on privacy that I can see, but it has nice properties w.r.t bandwidth and header size)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants