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

iOS 18 does not allow a client application to specify SameSite=None #33164

Conversation

charliewolfe
Copy link
Member

@charliewolfe charliewolfe commented Sep 5, 2024

45ce92c

iOS 18 does not allow a client application to specify SameSite=None
https://bugs.webkit.org/show_bug.cgi?id=279153
rdar://135312438

Reviewed by Pascoe and Alex Christensen.

In the iOS 18 and macOS Sequoia betas, CFNetwork began treating cookies as SameSite=Lax by default. This
caused an issue where, when WebKit converts from its internal enum `Cookie::SameSitePolicy` to
`NSHTTPCookieStringPolicy`, we return nil for `SameSitePolicy::None`, which CFNetwork now interprets as
lax instead of none.

WebKit should explicitly return none when converting `WebCore::Cookie` to an `NSHTTPCookie`. We should
use a string constant for none, but one is not currently available in the SDK.

* Source/WTF/wtf/PlatformHave.h:
* Source/WebCore/platform/network/cocoa/CookieCocoa.mm:
(WebCore::coreSameSitePolicy):
(WebCore::nsSameSitePolicy):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:
(TEST(WKHTTPCookieStore, SetSameSiteCookiePolicies)):
(TEST(WKHTTPCookieStore, SetSameSiteCookiePoliciesNonPersistentStore)):

Canonical link: https://commits.webkit.org/283230@main

232cadd

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 wincairo-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 jsc-armv7
✅ 🛠 🧪 unsafe-merge 🛠 tv ✅ 🧪 jsc-armv7-tests
✅ 🛠 tv-sim
🛠 watch
✅ 🛠 watch-sim

@charliewolfe charliewolfe self-assigned this Sep 5, 2024
@charliewolfe charliewolfe added the New Bugs Unclassified bugs are placed in this component until the correct component can be determined. label Sep 5, 2024
finished = true;
}];
}];
TestWebKitAPI::Util::run(&finished);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you call clearCookies again after this test to leave no state behind?
Also, is it worth adding the same test with a non-persistent data store?
Also, could we test the actual functionality of a same-site:none cookie and see that it is sent correctly over the network?

Copy link
Member Author

@charliewolfe charliewolfe Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you call clearCookies again after this test to leave no state behind?

Yes.

Also, is it worth adding the same test with a non-persistent data store?

Sure.

Also, could we test the actual functionality of a same-site:none cookie and see that it is sent correctly over the network?

Can you clarify what you mean by this? Do you want me to do that in this test? There are several existing layout tests that verify SameSite=None cookies are sent correctly over the network.

@charliewolfe charliewolfe force-pushed the eng/iOS-18-does-not-allow-a-client-application-to-specify-SameSiteNone branch from 65bcd8e to d9ddccf Compare September 5, 2024 05:25
@charliewolfe charliewolfe force-pushed the eng/iOS-18-does-not-allow-a-client-application-to-specify-SameSiteNone branch from d9ddccf to 596ac99 Compare September 5, 2024 07:17
@charliewolfe charliewolfe force-pushed the eng/iOS-18-does-not-allow-a-client-application-to-specify-SameSiteNone branch from 596ac99 to 49080f0 Compare September 5, 2024 07:19
@charliewolfe charliewolfe force-pushed the eng/iOS-18-does-not-allow-a-client-application-to-specify-SameSiteNone branch 2 times, most recently from 1b5edda to 8f84319 Compare September 5, 2024 08:44
@chonkate
Copy link

chonkate commented Sep 5, 2024

Thanks all for looking into this! To ensure our teams and client applications are ready for this change ahead of the release, could I get some clarification on:

  • The expectation is for app developers to update cookie creation to explicitly include the SameSite policy with a string of none as shown below
let cookieProperties: [HTTPCookiePropertyKey: Any] = [
    .domain: "auth.organization.com",
    .path: "/",
    .name: "sampleCookie",
    .value: "sampleValue",
    .secure: "TRUE",
    .sameSitePolicy: "none",
]

Copy link
Contributor

@achristensen07 achristensen07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is sufficient.

Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm Outdated Show resolved Hide resolved
@charliewolfe charliewolfe force-pushed the eng/iOS-18-does-not-allow-a-client-application-to-specify-SameSiteNone branch from 8f84319 to 232cadd Compare September 5, 2024 17:32
@charliewolfe charliewolfe added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Sep 5, 2024
https://bugs.webkit.org/show_bug.cgi?id=279153
rdar://135312438

Reviewed by Pascoe and Alex Christensen.

In the iOS 18 and macOS Sequoia betas, CFNetwork began treating cookies as SameSite=Lax by default. This
caused an issue where, when WebKit converts from its internal enum `Cookie::SameSitePolicy` to
`NSHTTPCookieStringPolicy`, we return nil for `SameSitePolicy::None`, which CFNetwork now interprets as
lax instead of none.

WebKit should explicitly return none when converting `WebCore::Cookie` to an `NSHTTPCookie`. We should
use a string constant for none, but one is not currently available in the SDK.

* Source/WTF/wtf/PlatformHave.h:
* Source/WebCore/platform/network/cocoa/CookieCocoa.mm:
(WebCore::coreSameSitePolicy):
(WebCore::nsSameSitePolicy):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:
(TEST(WKHTTPCookieStore, SetSameSiteCookiePolicies)):
(TEST(WKHTTPCookieStore, SetSameSiteCookiePoliciesNonPersistentStore)):

Canonical link: https://commits.webkit.org/283230@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/iOS-18-does-not-allow-a-client-application-to-specify-SameSiteNone branch from 232cadd to 45ce92c Compare September 5, 2024 20:31
@webkit-commit-queue
Copy link
Collaborator

Committed 283230@main (45ce92c): https://commits.webkit.org/283230@main

Reviewed commits have been landed. Closing PR #33164 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 45ce92c into WebKit:main Sep 5, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Bugs Unclassified bugs are placed in this component until the correct component can be determined.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants