From 7ed0af2a138a34e7c7005b95c85ffc791976a6cf Mon Sep 17 00:00:00 2001 From: Florian Mortgat <50440633+atm-florianm@users.noreply.github.com> Date: Wed, 19 Nov 2025 19:19:55 +0100 Subject: [PATCH 1/2] FIX DA027383: permissions not checked on HRM evaluation card (#36328) Permissions involved: - hrm->evaluation->readall: the user can view anyone's evaluations - hrm->evaluation->read: the user can only view their or their subordinates' evaluations --- htdocs/core/lib/security.lib.php | 20 +++++++++++++++++++- htdocs/hrm/evaluation_card.php | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index c29c0df7126..19768625ec1 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -401,6 +401,10 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $tableandshare = 'paiementcharge'; $parentfortableentity = 'fk_charge@chargesociales'; } + if ($features == 'evaluation') { + $features = 'hrm'; + $feature2 = 'evaluation'; + } // Get more permissions checks from hooks $parameters = array('features'=>$features, 'originalfeatures'=>$originalfeatures, 'objectid'=>$objectid, 'dbt_select'=>$dbt_select, 'idtype'=>$dbt_select, 'isdraft'=>$isdraft); @@ -834,7 +838,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $checkother = array('contact', 'agenda', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object $checktask = array('projet_task'); // Test for task object - $checkhierarchy = array('expensereport', 'holiday'); // check permission among the hierarchy of user + $checkhierarchy = array('expensereport', 'holiday', 'hrm'); // check permission among the hierarchy of user $checkuser = array('bookmark'); // check permission among the fk_user (must be myself or null) $nocheck = array('barcode', 'stock'); // No test @@ -1055,6 +1059,20 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl } } } + if ($feature == 'hrm' && in_array('evaluation', $feature2)) { + $useridtocheck = $object->fk_user; + + if ($user->hasRight('hrm', 'evaluation', 'readall')) { + // the user can view evaluations for anyone + return true; + } + if (!$user->hasRight('hrm', 'evaluation', 'read')) { + // the user can't view any evaluations + return false; + } + // the user can only their own evaluations or their subordinates' + return in_array($useridtocheck, $childids); + } } // For some object, we also have to check it is public or owned by user diff --git a/htdocs/hrm/evaluation_card.php b/htdocs/hrm/evaluation_card.php index e59ba7db462..97c77cbd76c 100644 --- a/htdocs/hrm/evaluation_card.php +++ b/htdocs/hrm/evaluation_card.php @@ -92,8 +92,8 @@ $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->enti // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); +$isdraft = ($object->status == Evaluation::STATUS_DRAFT) ? 1 : 0; +restrictedArea($user, $object->element, $object, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); if (!isModEnabled("hrm")) { accessforbidden(); } From 3608e9b1021fce474ac40e9e43017d1c68530bc5 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Wed, 26 Nov 2025 14:44:38 +0100 Subject: [PATCH 2/2] SEC: 7ed0af2a138a34e7c7005b95c85ffc791976a6cf