fix(sharing): enforce the read permission in the public preview endpoint (full-ci) - #41751
Merged
Merged
Conversation
publicpreview.php resolved the share by token and rendered the requested file without consulting the share's permission bitmask, unlike ShareController::downloadShare() and the public WebDAV route. Return 404 when the share does not carry PERMISSION_READ. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
DeepDiver1975
force-pushed
the
fix/publicpreview-read-permission
branch
from
July 28, 2026 12:43
eb4d504 to
6827343
Compare
jvillafanez
approved these changes
Jul 28, 2026
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.
Description
The public share preview endpoint (
apps/files_sharing/ajax/publicpreview.php) resolved the share by token and rendered the requested file without ever consulting the share's permission bitmask. It now returns404when the share does not carryPERMISSION_READ.This makes the endpoint consistent with the two sibling paths that serve content from a public link, both of which already enforced the read bit:
ShareController::downloadShare()—apps/files_sharing/lib/Controllers/ShareController.php:434PermissionsMaskstorage wrapper —apps/dav/appinfo/v1/publicwebdav.php:88The check is deliberately placed before any file name is resolved, so the response does not vary with the requested name.
Related Issue
n/a — reported privately.
Motivation and Context
publicpreview.phpwas the only content-serving public-link path without a permission check, so its behaviour diverged fromdownloadShare()and public WebDAV for shares that do not grant read access.How Has This Been Tested?
php -l apps/files_sharing/ajax/publicpreview.php— no syntax errorsphp-cs-fixerwith the ownCloud coding standard — 0 of 1 files fixableapps/files_sharing/tests/Controllers/ShareControllerTest.php— 12 tests, 45 assertions, OKcreate-only (4) →404;read(1),read+create(5),change(15) andall(31) are unaffected, so the four pre-existing scenarios that expect200from this endpoint still holdtests/acceptance/features/apiSharePublicLink1/accessToPublicLinkShare.feature, covering anuploadwriteonlypublic link share. These run in CI (this PR is titledfull-ciso theapiSharePublicLink1suite executes); they were not run locally as no server is available in that environment.Types of changes
Checklist:
🤖 Generated with Claude Code