diff --git a/core/src/Controllers/MoveDocument.php b/core/src/Controllers/MoveDocument.php index 7cd97535c3..570cbb53c0 100644 --- a/core/src/Controllers/MoveDocument.php +++ b/core/src/Controllers/MoveDocument.php @@ -55,6 +55,9 @@ protected function handle() $document = $this->getDocument($documentID); + // the form (a=51) checks the source document; the action must too, or the check is bypassable + $this->checkDocumentPermission($document->getKey(), 'access_permission_denied'); + $parents = $this->managerTheme->getCore()->getParentIds($newParentID); if (\in_array($document->getKey(), $parents, true)) { $this->managerTheme->alertAndQuit('error_movedocument2'); @@ -121,15 +124,7 @@ protected function processDisplay() : bool $id = $this->getElementId(); $document = $this->getDocument($id); - // check permissions on the document - $udperms = new Permissions(); - $udperms->user = $this->managerTheme->getCore()->getLoginUserID('mgr'); - $udperms->document = $document->getKey(); - $udperms->role = $_SESSION['mgrRole']; - - if (!$udperms->checkPermissions()) { - $this->managerTheme->alertAndQuit('access_permission_denied'); - } + $this->checkDocumentPermission($document->getKey(), 'access_permission_denied'); // Set the item name for logger $_SESSION['itemname'] = $document->pagetitle; @@ -158,6 +153,16 @@ protected function getDocument($id) : Models\SiteContent } protected function checkNewParentPermission($id) + { + $this->checkDocumentPermission($id, 'access_permission_parent_denied'); + } + + /** + * @param int $id + * @param string $lang lexicon key of the alert shown when access is denied + * @since 3.5.8 + */ + protected function checkDocumentPermission($id, string $lang): void { $udperms = new Permissions; $udperms->user = $this->managerTheme->getCore()->getLoginUserID('mgr'); @@ -168,6 +173,6 @@ protected function checkNewParentPermission($id) return; } - $this->managerTheme->alertAndQuit('access_permission_parent_denied'); + $this->managerTheme->alertAndQuit($lang); } } diff --git a/core/src/Controllers/Phpinfo.php b/core/src/Controllers/Phpinfo.php index 9166c5d3d1..e2ebf3032e 100644 --- a/core/src/Controllers/Phpinfo.php +++ b/core/src/Controllers/Phpinfo.php @@ -21,7 +21,7 @@ public function checkLocked(): ?string */ public function canView(): bool { - return $this->managerTheme->getCore()->hasPermission('logs'); + return $this->managerTheme->getCore()->hasPermission('settings'); } /** diff --git a/core/src/Controllers/SystemInfo.php b/core/src/Controllers/SystemInfo.php index 2383f04fec..660dcae672 100644 --- a/core/src/Controllers/SystemInfo.php +++ b/core/src/Controllers/SystemInfo.php @@ -27,7 +27,7 @@ public function checkLocked(): ?string public function canView(): bool { - return $this->managerTheme->getCore()->hasPermission('logs'); + return $this->managerTheme->getCore()->hasPermission('settings'); } public function getParameters(array $params = []): array diff --git a/core/tests/Unit/Security/ManagerAuthorizationGapsTest.php b/core/tests/Unit/Security/ManagerAuthorizationGapsTest.php new file mode 100644 index 0000000000..f1024f00bc --- /dev/null +++ b/core/tests/Unit/Security/ManagerAuthorizationGapsTest.php @@ -0,0 +1,44 @@ +checkDocumentPermission(\$document->getKey(), 'access_permission_denied');", $handle); + + expect($handle)->not->toBeFalse() + ->and($check)->not->toBeFalse() + ->and($check)->toBeLessThan($display) + ->and($check)->toBeLessThan(strpos($source, '$document->save();', $handle)); + + // the form keeps its own check + expect(strpos($source, "\$this->checkDocumentPermission(\$document->getKey(), 'access_permission_denied');", $display)) + ->not->toBeFalse(); +}); + +it('gates the phpinfo and system info pages on the settings right', function (string $class) { + $source = controllerSource($class); + + expect($source) + ->toContain("hasPermission('settings')") + ->and($source)->not->toContain("hasPermission('logs')"); +})->with(['Phpinfo', 'SystemInfo']); diff --git a/manager/views/frame/1.blade.php b/manager/views/frame/1.blade.php index ec426ff424..1bf30f8d20 100644 --- a/manager/views/frame/1.blade.php +++ b/manager/views/frame/1.blade.php @@ -361,6 +361,8 @@ function jsIconMarkup($icon) { {{ icon_html($_style['icon_user_secret']) }} {{ManagerTheme::getLexicon('view_logging')}} + @endif + @if (evo()->hasPermission('settings'))
  • {{ icon_html($_style['icon_info_circle']) }} {{ManagerTheme::getLexicon('view_sysinfo')}}