Skip to content

feat(dav): restrict allowed file types on public share uploads - #66562

Open
vlotysh wants to merge 1 commit into
nextcloud:masterfrom
vlotysh:feat/restrict-allowed-file-types-share
Open

vlotysh wants to merge 1 commit into
nextcloud:masterfrom
vlotysh:feat/restrict-allowed-file-types-share

Conversation

@vlotysh

@vlotysh vlotysh commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Name-based check: file extension and IMimeTypeDetector::detectPath(), the file content is not inspected.
  • Regular upload: PUT → beforeBind → 415 Unsupported Media Type.
  • Chunked upload, early check: MKCOL uploads/<token>/<id> with a Destination header → beforeMkcol → 415 before the first chunk is sent.
  • Chunked upload, main check: chunks are skipped, the final MOVE .file is checked in beforeBind against the destination name, before the chunks are assembled.
  • MOVE/COPY of collections that are not part of the share (upload folders) → 403.
  • Shares without the upload.allowed_types attribute are not affected.

before
image

after
image

Checklist

AI (if applicable)

  • [ x] The content of this PR was partly or fully generated using AI

@vlotysh
vlotysh requested review from a team and skjnldsv as code owners November 13, 2026 15:13
@vlotysh
vlotysh requested review from CarlSchwan, GhassenKefi, icewind1991, kristian-zendato, pabzm and susnux and removed request for a team November 13, 2026 15:13
@vlotysh
vlotysh force-pushed the feat/restrict-allowed-file-types-share branch from 15a0d06 to 7c64154 Compare November 13, 2026 15:21
@susnux susnux added enhancement 3. to review Waiting for reviews labels Nov 13, 2026
@vlotysh
vlotysh force-pushed the feat/restrict-allowed-file-types-share branch 3 times, most recently from 5a07907 to 61382c1 Compare November 15, 2026 18:35

@icewind1991 icewind1991 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Backend wise, looks good otherwise

/**
* @param class-string $collectionClass
*/
private function isChildOf(string $path, string $collectionClass): bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The name of the method doesn't really match the functionality (anymore?).

Comment thread apps/dav/appinfo/v2/publicremote.php Outdated

$linkCheckPlugin = new PublicLinkCheckPlugin();
$filesDropPlugin = new FilesDropPlugin();
$allowedFileTypesPlugin = new AllowedFileTypesPlugin(Server::get(IMimeTypeDetector::class));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can directly get the AllowedFileTypesPlugin from Server::get instead of just it's constructor parameter.

This mainly removes friction if the params of AllowedFileTypesPlugin ever need to be changed in the future.

Signed-off-by: Vladyslav Lotysh <lotysh.vm@gmail.com>
Assisted-by: ClaudeCode:claude-opus-5-5
@vlotysh
vlotysh force-pushed the feat/restrict-allowed-file-types-share branch from 61382c1 to cb0b075 Compare November 17, 2026 18:58

This branch has not been deployed

No deployments
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 enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restrict file extension / mime type for file drop share

3 participants