Skip to content

Commit 8530a30

Browse files
Merge pull request #8881 from nextcloud/backport/8879/stable33
[stable33] fix(share): detect if documentId is outside of share early
2 parents e77e9c4 + 8f97f88 commit 8530a30

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
@@ -22,6 +22,8 @@
2222
use OCP\AppFramework\Http\Response;
2323
use OCP\AppFramework\Middleware;
2424
use OCP\Constants;
25+
use OCP\Files\File;
26+
use OCP\Files\Folder;
2527
use OCP\Files\IRootFolder;
2628
use OCP\Files\NotPermittedException;
2729
use OCP\IL10N;
@@ -136,6 +138,17 @@ private function assertUserOrShareToken(ISessionAwareController $controller): vo
136138
throw new InvalidSessionException();
137139
}
138140

141+
if ($share->getNodeType() === 'folder') {
142+
$folder = $share->getNode();
143+
if (!$folder instanceof Folder) {
144+
throw new InvalidSessionException();
145+
}
146+
$file = $folder->getFirstNodeById($documentId);
147+
if (!$file instanceof File) {
148+
throw new InvalidSessionException();
149+
}
150+
}
151+
139152
if ($share->getPassword() !== null) {
140153
$shareIds = $this->session->get('public_link_authenticated');
141154
$shareIds = is_array($shareIds) ? $shareIds : [$shareIds];

0 commit comments

Comments
 (0)