Skip to content

Commit 56a4f74

Browse files
Merge pull request #9070 from nextcloud/backport/8879/stable29
[stable29] fix(share): detect if documentId is outside of share early
2 parents bdf7534 + dc99772 commit 56a4f74

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)