diff --git a/pub/api/classes/API.php b/pub/api/classes/API.php index 00d8219..9f1757a 100644 --- a/pub/api/classes/API.php +++ b/pub/api/classes/API.php @@ -688,7 +688,7 @@ class API protected function buildDynamicQuery(string $tableName): array { - unset($this->baseQuery); + $this->baseQuery = ''; if (!$this->baseQuery) { $this->baseQuery = "SELECT * FROM " . $tableName; } diff --git a/pub/api/v1/access-rights/index.php b/pub/api/v1/access-rights/index.php index 8959dac..11319bf 100644 --- a/pub/api/v1/access-rights/index.php +++ b/pub/api/v1/access-rights/index.php @@ -14,7 +14,6 @@ if ($API_permissions->request_method === 'GET') { # to be made, get all the access-rights and implement the builder } elseif ($API_permissions->request_method === 'PUT') { - # when called from the frontend will not be forwarding to a url since when its called from the frontend it doesnt need a redirection $API_permissions->return_url = false; @@ -34,7 +33,13 @@ if ($API_permissions->request_method === 'GET') { # check if the user_group_uuid exists $_GET['builder'] = [1 => ['where' => [0 => 'user_group_uuid', 1 => $API_permissions->data['user_group_uuid']]]]; - $API_usergroups->getUsergroup(); + $user_group = $API_usergroups->getUsergroup(); + + # if the user updating the permissions is in a lower group (higher group weight number) prevent them for doing so to prevent + # Privilege escalation. + if ($user_group[0]['user_group_weight'] < $_SESSION['user']['user_group_weight']) { + $API_permissions->apiOutput(405, ['error' => 'You are not allowed to update this user since you are in a lower group']); + } # Update the permission $API_permissions->updateAccessRights(); diff --git a/pub/bin/locales/en.php b/pub/bin/locales/en.php index a606761..1045c43 100644 --- a/pub/bin/locales/en.php +++ b/pub/bin/locales/en.php @@ -301,4 +301,5 @@ return [ 'source_inserve_sync_licenses_desc' => 'This API call first executes the Sync cloud distributor companies action and then synchronizes all servers in an active, deleted, or trial state with Inserve licenses. It creates or updates server licenses in Inserve if they do not exist or if the license quantities differ from those in Sentri.', 'source_inserve_sync_subscriptions' => 'Sync server subscriptions', 'source_inserve_sync_subscriptions_desc' => 'This API call first executes the Sync cloud distributor companies action and then creates a subscription if it does not exist, or updates the subscription description if it does. It also creates subscription lines with the correct product_code entered in the custom source data JSON field.', + 'not_allowed_to_change_due_to_group_weight' => 'You are not permitted to modify these settings because has a lower group weight, which is used to enforce hierarchy and prevent privilege escalation.', ]; \ No newline at end of file diff --git a/pub/bin/locales/nl.php b/pub/bin/locales/nl.php index b5e6bfc..69f682f 100644 --- a/pub/bin/locales/nl.php +++ b/pub/bin/locales/nl.php @@ -301,4 +301,5 @@ return [ 'source_inserve_sync_licenses_desc' => 'Deze API-call voert eerst de Synchroniseer cloud-distributeurbedrijven actie uit en synchroniseert daarna alle servers in een actieve, verwijderde of trial status met Inserve-licenties. Het maakt serverlicenties in Inserve aan of werkt ze bij als ze niet bestaan of als de licentieaantallen afwijken van die in Sentri.', 'source_inserve_sync_subscriptions' => 'Synchroniseer serverabonnementen', 'source_inserve_sync_subscriptions_desc' => 'Deze API-call voert eerst de actie Sync cloud distributor companies uit en maakt vervolgens een abonnement aan als dit nog niet bestaat, of werkt de beschrijving van het abonnement bij als het wel bestaat. Daarnaast worden abonnementsregels aangemaakt met de juiste product_code die is ingevuld in het custom source data JSON-veld.', + 'not_allowed_to_change_due_to_group_weight' => 'U mag deze instellingen niet wijzigen omdat deze een lagere groepsgewichtwaarde hebben, wat wordt gebruikt om de hiƫrarchie af te dwingen en privilege-escalatie te voorkomen.' ]; \ No newline at end of file diff --git a/pub/bin/pages/portal-management/pageAccessControl_user_group_view.php b/pub/bin/pages/portal-management/pageAccessControl_user_group_view.php index b72b173..05b58f6 100644 --- a/pub/bin/pages/portal-management/pageAccessControl_user_group_view.php +++ b/pub/bin/pages/portal-management/pageAccessControl_user_group_view.php @@ -46,6 +46,15 @@ $stmt = $GLOBALS['pdo']->prepare($query); $stmt->execute([$user_group_uuid]); $group_permissions = $stmt->fetchAll(PDO::FETCH_ASSOC); +$toggleDisabled = false; +if ($user_group['user_group_weight'] < $_SESSION['user']['user_group_weight']) { + $toggleDisabled = true; +} + +if (!$API->checkPermissions('admin-access-control-permissions', 'RW', true)) { + $toggleDisabled = true; +} + # Set breadcrumb data array_push($GLOBALS['breadCrumbArray'], array('display' => __('user_groups'), 'href' => '/accesscontrol/#user-groups')); array_push($GLOBALS['breadCrumbArray'], array('display' => $user_group['user_group_name'], 'href' => '')); @@ -121,28 +130,35 @@ $pageNavbar->outPutNavbar();
- +