fix: force the Secure cookie flag when SameSite=None applies - #861
Open
kishore7snehil wants to merge 3 commits into
Open
fix: force the Secure cookie flag when SameSite=None applies#861kishore7snehil wants to merge 3 commits into
kishore7snehil wants to merge 3 commits into
Conversation
4 tasks
kishore7snehil
added a commit
that referenced
this pull request
Aug 31, 2026
…ersions (#862) ### Changes CI installs its dev tools from open version ranges and there is no committed `composer.lock`, so it recently pulled in a newer Rector (2.6.x). That version enables `IfToNullCoalescingAssignRector`, which is why the Rector job started failing on unrelated PRs. - The rule rewrites `if (null === $x) { $x = ...; }` guards to `$x ??= ...`, which is equivalent. - This affected four pre-existing spots: `src/Token.php`, `src/Token/Parser.php`, `src/Utility/HttpResponsePaginator.php`, and `src/Utility/HttpTelemetry.php`. - In `src/Token/Parser.php` the `@codeCoverageIgnore` markers were kept around the rewritten line, since it remains untestable with the current JWT encoding test libraries. - Behavior is unchanged. ### References Unblocks the Rector CI job on open PRs (#852, #853, #861). ### Testing - [ ] This change adds unit test coverage - [x] This change has been tested on the latest version of the platform/language ### Contributor Checklist - [x] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md) - [x] I have read the [Auth0 code of conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
When
responseModeisform_post, bothCookieStoreandSessionStoreunconditionally set the cookieSameSiteattribute toNone, because a cross-origin POST callback requires it. However, thesecureflag was still taken fromcookieSecure(defaultfalse), so the SDK could emit aSameSite=Nonecookie withoutSecure. Browsers reject aSameSite=Nonecookie that does not also carrySecure(RFC 6265bis), so this combination results in the cookie being dropped on modern browsers.This PR forces the
Secureflag on whenever the resolvedSameSiteisNone:🔒 Security Fix:
CookieStore::getCookieOptions()now setssecuretotruewhen the resolvedsamesitevalue isNone, after the existingSameSitenormalization, so bothform_postand an explicitcookieSameSiteofNoneare coveredSessionStore::start()applies the same rule to the native PHP session cookie params, forcingsecureon whenSameSite=Noneis in effectcookieSecurestill defaults tofalseand is otherwise unchanged. The$cookieSecuredocumentation now notes thatSecureis forced on whenSameSite=Noneapplies and recommends enabling it in productionApplications using the default
queryresponse mode are unaffected, as their cookies keep the same attributes. Forform_postapplications, the session and transient cookies now always carrySecureand are therefore only sent over HTTPS. Such deployments should serve the callback over HTTPS.References
N/A
Testing
Added
SameSite=None forces the Secure flag on even when cookieSecure is falseto theCookieStoreunit tests, asserting thatform_postyieldssamesite=Nonewithsecure=trueThis change adds unit test coverage
This change has been tested on the latest version of the platform/language
Contributor Checklist