Skip to content

Conversation

@artonge
Copy link
Contributor

@artonge artonge commented May 14, 2025

This currently prevent directly accessing a resource when clicking on a link on a third party site. Example, clicking on https://example.com/public.php/dav/files/pqLWcA269zfzXez/?accept=zip in a GitHub comment.

Skipping the check is an issue with password protected shares, as it allows third party sites to request the resource when the user already entered the password, aka CSRF. So after removing the check from base.php, we need to add it again in the PublicAuth plugin.

We also add a redirect to be helpful to the user.

Warning: this adds the limitation that clicking on a direct download link for password protected shares will redirect you to the password form, and then to the main share view.
Another solution would be to do the redirect from the front-end.

Extra: replace the deprecated direct download URL by the new DAV one.

@artonge artonge added this to the Nextcloud 32 milestone May 14, 2025
@artonge artonge self-assigned this May 14, 2025
@artonge artonge requested a review from a team as a code owner May 14, 2025 09:42
@artonge artonge added the bug label May 14, 2025
@artonge artonge requested review from ArtificialOwl and nfebe and removed request for a team May 14, 2025 09:42
@artonge artonge added 3. to review Waiting for reviews feature: sharing feature: dav php Pull requests that update Php code labels May 14, 2025
@artonge artonge force-pushed the artonge/feat/do_not_require_samesite_strict_cookie_on_public.php branch 10 times, most recently from 0eef221 to d5be952 Compare May 21, 2025 12:32
@artonge artonge requested a review from a team as a code owner May 21, 2025 12:32
@artonge artonge requested review from sorbaugh and szaimen and removed request for a team May 21, 2025 12:32
@szaimen szaimen removed their request for review May 21, 2025 12:34
artonge added 2 commits May 21, 2025 16:01
This currently prevent directly accessing a ressource when clicking on a link on a third party site. Example, clicking on `https://example.com/public.php/dav/files/pqLWcA269zfzXez/?accept=zip` in a GitHub comment.

Skipping the check is an issue with password protected shares, as it allows third party sites to request the ressource when the user already entered the password, aka CSRF.  So after removing the check from `base.php`, we need to add the it again in the `PublicAuth` plugin.

We also add a redirect to be helpful to the user.

**Warning**: this adds the limitation that clicking on a direct download link for password protected shares will redirect you to the password form, and then to the main share view.

Fix #52482

Signed-off-by: Louis Chemineau <louis@chmn.me>
…endpoint

Follow-up of #48098

Signed-off-by: Louis Chemineau <louis@chmn.me>
@artonge artonge force-pushed the artonge/feat/do_not_require_samesite_strict_cookie_on_public.php branch from 95ed1fe to ec1db0c Compare May 21, 2025 14:02
@artonge artonge merged commit a48bc55 into master May 22, 2025
193 checks passed
@artonge artonge deleted the artonge/feat/do_not_require_samesite_strict_cookie_on_public.php branch May 22, 2025 08:30
@artonge
Copy link
Contributor Author

artonge commented May 22, 2025

/backport to stable31

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

Labels

3. to review Waiting for reviews bug feature: dav feature: sharing php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Public share link fails with "Strict Cookie has not been found in request" and 412 Precondition Failed when clicking, but works when copy-pasting

4 participants