Skip to content

Commit 032c261

Browse files
max-nextcloudbackportbot[bot]
authored andcommitted
fix(share): detect if documentId is outside of share early
Signed-off-by: Max <max@nextcloud.com>
1 parent a0b5a12 commit 032c261

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

lib/Middleware/SessionMiddleware.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
use OCP\AppFramework\Http\Response;
2424
use OCP\AppFramework\Middleware;
2525
use OCP\Constants;
26+
use OCP\Files\File;
27+
use OCP\Files\Folder;
2628
use OCP\Files\IRootFolder;
2729
use OCP\Files\NotPermittedException;
2830
use OCP\IL10N;
@@ -148,6 +150,17 @@ private function assertUserOrShareToken(ISessionAwareController $controller): vo
148150
throw new InvalidSessionException();
149151
}
150152

153+
if ($share->getNodeType() === 'folder') {
154+
$folder = $share->getNode();
155+
if (!$folder instanceof Folder) {
156+
throw new InvalidSessionException();
157+
}
158+
$file = $folder->getFirstNodeById($documentId);
159+
if (!$file instanceof File) {
160+
throw new InvalidSessionException();
161+
}
162+
}
163+
151164
if ($share->getPassword() !== null) {
152165
$shareIds = $this->session->get('public_link_authenticated');
153166
$shareIds = is_array($shareIds) ? $shareIds : [$shareIds];

0 commit comments

Comments
 (0)