privacycg / CHIPS

A proposal for a cookie attribute to partition cross-site cookies by top-level site
Other
116 stars 29 forks source link

Keying of "CHIPS" cookies should align with other state #40

Open annevk opened 2 years ago

annevk commented 2 years ago

I think the current model just adds the top-level site as an additional key.

However, this is inconsistent with plans for state elsewhere: https://github.com/privacycg/storage-partitioning/issues/25. I think it would be good if there was alignment there. Otherwise we end up with a world where what is considered "partitioned" for some state is not considered "partitioned" for other state, which I suspect will lead to a lot of confusion and subtle application bugs.

DCtheTall commented 2 years ago

Hey @annevk, thank you for staying on top of this and making sure cookies and storage are consistent.

Personally, I do not think cookie partitioning should include the ancestor chain bit. My thinking is that the only situation in which the ancestor chain bit on the storage key would be false are the same contexts that SameSite=Lax cookies are available and SameSite=None cookies would not be. So therefore, we did not think it was necessary to include this bit in the cookie partition key.

My understanding was that the ancestor chain bit was to make storage more like cookies, and that we need it to do things like making sure partitioned service workers have the correct site for cookies (i.e. null when they are registered in a frame that would otherwise be unable to access SameSite cookies).

What's more, we actually have a use case for Partitioned in first-party contexts as a less-restrictive form of SameSite (see First-party CHIPS). IIRC Microsoft Teams is interested in using Partitioned cookies in this way on embeds on their own top-level site which have a cross-site ancestor. @erik-anderson can you confirm this is the case?

annevk commented 2 years ago

Did you mean SameSite=None cookies are available and SameSite=Lax are not?

I think the problem with using different keys here is that we don't end up with a unified partitioning story. That's going to make it a lot harder to explain to web developers. It's also going to make it harder for auxiliary features, such as a request header or API that exposes whether you are in a partitioned context.

DCtheTall commented 1 year ago

Did you mean SameSite=None cookies are available and SameSite=Lax are not?

Yes, exactly. The ancestor chain bit was added to the partitioned storage key to enforce SameSite semantics in service workers and to prevent click jacking. That attack model is not a threat to partitioned cookies (since SameSite already exists), so we do not believe adding the ancestor chain bit is necessary.

In addition, we've also received feedback from partners that there are use cases where they would like the top-level document and a same-site embed with cross-site ancestors to share partitioned cookies.

bvandersloot-mozilla commented 1 year ago

I think the problem with using different keys here is that we don't end up with a unified partitioning story.

Ditto to this point.

In addition, we've also received feedback from partners that there are use cases where they would like the top-level document and a same-site embed with cross-site ancestors to share partitioned cookies.

Is this predicated on #51 resolving with first-party Partitioned cookies being different than regular first-party cookies?

johannhof commented 1 year ago

We discussed the "unified partitioning" concern at TPAC and elsewhere already, with the conclusion that the existence of SameSite fundamentally changes the threat consideration for cookies vs. storage and it's desirable to enable developers to opt-in to sharing cookies across cross-site ancestors.

DCtheTall commented 1 year ago

Closing this issue, since there is a consensus on @johannhof's last comment.

annevk commented 1 year ago

I thought @arturjanc still had reservations about this as website developers would likely forget about the subtleties once cross-site cookies are disabled in all browsers and think they are safe when they are not.

arturjanc commented 1 year ago

I still have these reservations, particularly if we were to apply this behavior to SameSite=None cookies (if this applies only to CHIPS/Partitioned cookies then it's a bit better, but IMHO remains a footgun). The reason is that any scenario where a given site has a cross-site iframe will allow that iframe to make credentialed requests to other endpoints within the top-level site, re-enabling a number of attacks that are prevented by default in a post-third-party cookie world.

In my view, we haven't heard of compelling enough use cases to ignore the cross-site ancestor chain bit for cookies that couldn't be addressed in other ways (e.g. by using new platform primitives such as FedCM, or by implementing application-specific functionality to pass data between the top-level document and a same-site-iframe-with-a-cross-site-ancestor context).

annevk commented 1 year ago

Thanks, let's reopen this based on that.

johannhof commented 1 year ago

@arturjanc This discussion is specifically about Partitioned cookies. But we're planning to discuss the overall idea of restricting cookies at the SameSite=None boundary in PrivacyCG and I agree that we should look at the existing use cases and developer concerns to decide on that. It's important to note that allowing for SameSite=None+Partitioned cookies may be a compromise for A > B > A scenarios that would make developers happy to some degree while providing a high amount of security through the opt-in nature of both (and the fact that both in combination are unsuitable for any other use case than A > B > A sharing).

The other possibility could be inventing a new cookie attribute or another kind of opt-in API that makes it more clear to developers (e.g. by name) that they're opting into an A > B > A scenario, and possibly provide customization options for that. It's not entirely clear to me that this effort (for both implementers and developers) is justified when weighing with the threat and the already available solution through CHIPS.

arturjanc commented 1 year ago

It's important to note that allowing for SameSite=None+Partitioned cookies may be a compromise for A > B > A scenarios that would make developers happy to some degree while providing a high amount of security through the opt-in nature of both

My main concern with this view is that, in practice, setting a cookie attribute (either SameSite=None or Partitioned) doesn't have the granularity we'd want from an opt-in into being loaded with credentials by a third party.

Authentication cookies are commonly set for the whole origin -- and sometimes, the whole site / eTLD+1 -- and developers need to set the least restrictive cookie attributes in order for their site to work. The presence of a single endpoint which depends on authentication/state in a third-party context (either SameSite=None or CHIPS) will likely require developers to set the appropriate attribute on their application's authn cookie. This, in turn, will expose all other endpoints in their origin/site to cross-site attacks (as long as there exists a document with a cross-site iframe, such as an ad, anywhere within the top-level site); for example, a cross-site iframe would be able to iframe a credentialed page from the top-level site and exploit clickjacking.

I think that rather than just ignoring the cross-site bit in the key for CHIPS to enable the A > B > A scenario, we'd want to have an opt-in that is more tightly scoped; for example:

Something like this should still allow the use cases we care about with relatively modest application-level work.

(FWIW I think this doesn't really address @annevk's original concern about partitioning consistency between different mechanisms because it allows two different behaviors depending on the presence of the opt-in...)

johannhof commented 1 year ago

developers need to set the least restrictive cookie attributes in order for their site to work. The presence of a single endpoint which depends on authentication/state in a third-party context (either SameSite=None or CHIPS) will likely require developers to set the appropriate attribute on their application's authn cookie.

Right, but the special thing about Partitioned + SameSite=None is that it only works for A > B > A, i.e. there's no other use case for developers to combine these attributes in a top-level context otherwise. I don't see why a developer would need to set these attributes on a cookie for some other functionality.

I think that rather than just ignoring the cross-site bit in the key for CHIPS

I think "ignoring" is a bit strong given that it still incorporates site for cookies through honoring SameSite rules (and again, in a way that would not be accidentally enabled to support other functionality).

A per-iframe opt-in via Permissions Policy, e.g.