Skip to content

Commit dc99772

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 bdf7534 commit dc99772

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
@@ -17,6 +17,8 @@
1717
use OCP\AppFramework\Http\Response;
1818
use OCP\AppFramework\Middleware;
1919
use OCP\Constants;
20+
use OCP\Files\File;
21+
use OCP\Files\Folder;
2022
use OCP\Files\IRootFolder;
2123
use OCP\Files\NotPermittedException;
2224
use OCP\IL10N;
@@ -131,6 +133,17 @@ private function assertUserOrShareToken(ISessionAwareController $controller): vo
131133
throw new InvalidSessionException();
132134
}
133135

136+
if ($share->getNodeType() === 'folder') {
137+
$folder = $share->getNode();
138+
if (!$folder instanceof Folder) {
139+
throw new InvalidSessionException();
140+
}
141+
$file = $folder->getFirstNodeById($documentId);
142+
if (!$file instanceof File) {
143+
throw new InvalidSessionException();
144+
}
145+
}
146+
134147
if ($share->getPassword() !== null) {
135148
$shareIds = $this->session->get('public_link_authenticated');
136149
$shareIds = is_array($shareIds) ? $shareIds : [$shareIds];

0 commit comments

Comments
 (0)