Skip to content

Conversation

@sshambar
Copy link

Summary

Fixes an issue where samesite cookies are sent on status.php before session is started; cookies with webroots other than '/' therefore have the wrong name and lead to samesite cookie validation failures.

@sshambar sshambar requested a review from a team as a code owner August 19, 2025 22:40
@sshambar sshambar requested review from ArtificialOwl, come-nc and salmart-dev and removed request for a team August 19, 2025 22:40
@solracsf solracsf added the 3. to review Waiting for reviews label Aug 20, 2025
@solracsf solracsf added this to the Nextcloud 32 milestone Aug 20, 2025
Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

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

I do not understand enough about this, but a small question that bugged me when reading surrounding code.

lib/base.php Outdated
exit();
}
}
} elseif (!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I crazy or is that condition useless?
If count($_COOKIE) is <= 0, those can never be set?

So, an else would be enough.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I considered removing that, but I'm guessing someone put it there to make it clear which cookies are being set?

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
} elseif (!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) {
} else {
/* set nc_sameSiteCookielax and nc_sameSiteCookiestrict */

Something like that would be clearer then.

Copy link
Author

Choose a reason for hiding this comment

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

@come-nc Looks like a good plan, I've updated the commit

@come-nc come-nc requested a review from nickvergessen August 21, 2025 09:07
This was referenced Aug 22, 2025
Fixes an issue where samesite cookies are sent on status.php before
session is started; cookies with webroots other than '/' therefore
have the wrong name and lead to samesite cookie validation failures.

- resolves nextcloud#54227

Signed-off-by: Scott Shambarger <[email protected]>
@come-nc
Copy link
Contributor

come-nc commented Aug 28, 2025

@sshambar I looked into it and I think that #54713 would be a better fix.
Can you check if that fixes the issue as well?

@sshambar
Copy link
Author

@come-nc I can confirm that fixes the issue as well.

I did consider that approach, but I was concerned about adding extra work to the nextcloud "ping" target - it's used by liveness/readiness probes in the helm chart (and probably elsewhere) so probably should do as little as possible :)

@AndyScherzinger
Copy link
Member

@sshambar would you be fine if we go for / merge #54713 for the moment? We can still improve it from there

@sshambar
Copy link
Author

@AndyScherzinger - no problem, they both fix the issue :)

I might suggest updating the comment in the #54713 patch to state why the status.php is after the cookie_path setting, so the check's not moved later...

@come-nc
Copy link
Contributor

come-nc commented Sep 1, 2025

@AndyScherzinger - no problem, they both fix the issue :)

I might suggest updating the comment in the #54713 patch to state why the status.php is after the cookie_path setting, so the check's not moved later...

Added.
Closing this PR as I will merge the other one.

@come-nc come-nc closed this Sep 1, 2025
@AndyScherzinger AndyScherzinger removed this from the Nextcloud 32 milestone Sep 1, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2025

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect samesite cookies for status.php when webroot used

4 participants