fix(secure-view): allow server-side file reads in SecureViewWrapper#5587
Merged
fix(secure-view): allow server-side file reads in SecureViewWrapper#5587
Conversation
…rapper SecureViewWrapper::checkFileAccess() was blocking all non-WOPI fopen() and file_get_contents() calls on watermarked files, including server-side reads that never expose content to the user (e.g. TemplateManager reading a template file to copy it). Add isDirectFileServingRequest() to restrict the block to actual download endpoints (WebDAV, public shares, previews). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
elzody
approved these changes
Apr 24, 2026
Collaborator
elzody
left a comment
There was a problem hiding this comment.
This seems like a reasonable way to resolve this. I don't think the failing test is related; I will restart the workflow and it will likely pass. I'll also make a note of it to check for flakiness there in the future.
Collaborator
|
/backport to stable33 please |
Collaborator
|
/backport to stable32 please |
This was referenced Apr 24, 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.
Problem
SecureViewWrapper::checkFileAccess()was blocking all non-WOPIfopen()andfile_get_contents()calls on watermarked files, including server-side operationsthat never expose file content to the client.
The most visible symptom: creating a new file from a template fails with
"Unable to create new file from template" when Secure View is enabled for the
user's group.
TemplateManager::createFromTemplate()reads the template fileserver-side via
fopen(), which was incorrectly treated as a download attempt.Stack trace from the field:
Relation to #5577
This is a companion fix to #5577, which addressed a related Secure View regression
where
shouldSecure()calledfopen()internally, causing a recursiveForbiddenExceptionduring delete/trash operations. Both issues stem fromSecureViewWrapperwrapping too broadly and intercepting legitimate server-sidefile operations.
Fix
Server-side operations (template creation, background jobs, CLI) are either
non-GET or carry no HTTP context at all.
checkFileAccess()now checks the HTTP method. Only GET requests are blocked, which coversall real download vectors (WebDAV, public shares, ZIP folder downloads, preview
thumbnails) while leaving server-side reads untouched.