Skip to content

Commit

Permalink
Merge pull request #4240 from corentin-soriano/wrong_access_control
Browse files Browse the repository at this point in the history
SEC - Correct wrong access control
  • Loading branch information
nilsteampassnet authored Aug 25, 2024
2 parents f6d2bbb + e18e3cb commit e46e15c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@
) {
echo '
<li class="nav-item">
<a href="#" data-name="favourites" class="nav-link', $get['page'] === 'admin' ? ' favourites' : '', '">
<a href="#" data-name="favourites" class="nav-link', $get['page'] === 'favourites' ? ' active' : '', '">
<i class="nav-icon fa-solid fa-star"></i>
<p>
' . $lang->get('favorites') . '
Expand Down
14 changes: 12 additions & 2 deletions pages/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,19 @@
'user_key' => returnIfSet($session->get('key'), null),
]
);
// Handle the case

// Check user access and printing enabled
echo $checkUserAccess->caseHandler();
if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('export') === false) {
if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('export') === false
|| isset($SETTINGS['allow_print']) === false || (int) $SETTINGS['allow_print'] === 0
|| isset($SETTINGS['roles_allowed_to_print_select']) === false
|| empty($SETTINGS['roles_allowed_to_print_select']) === true
|| count(array_intersect(
explode(';', $session->get('user-roles')),
explode(',', str_replace(['"', '[', ']'], '', $SETTINGS['roles_allowed_to_print_select']))
)) === 0
|| (int) $session_user_admin === 1
) {
// Not allowed page
$session->set('system-error_code', ERR_NOT_ALLOWED);
include $SETTINGS['cpassman_dir'] . '/error.php';
Expand Down
7 changes: 5 additions & 2 deletions pages/favourites.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@
'user_key' => returnIfSet($session->get('key'), null),
]
);
// Handle the case

// Check user access and favourites enabled
echo $checkUserAccess->caseHandler();
if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('favourites') === false) {
if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('favourites') === false
|| isset($SETTINGS['enable_favourites']) === false || (int) $SETTINGS['enable_favourites'] === 0
|| (int) $session_user_admin === 1) {
// Not allowed page
$session->set('system-error_code', ERR_NOT_ALLOWED);
include $SETTINGS['cpassman_dir'] . '/error.php';
Expand Down
6 changes: 4 additions & 2 deletions pages/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@
'user_key' => returnIfSet($session->get('key'), null),
]
);
// Handle the case

// Check user access and import enabled
echo $checkUserAccess->caseHandler();
if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('import') === false) {
if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('import') === false
|| isset($SETTINGS['allow_import']) === false || (int) $SETTINGS['allow_import'] !== 1) {
// Not allowed page
$session->set('system-error_code', ERR_NOT_ALLOWED);
include $SETTINGS['cpassman_dir'] . '/error.php';
Expand Down
2 changes: 1 addition & 1 deletion vendor/teampassclasses/performchecks/src/PerformChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function userAccessPage($pageVisited): bool
// Definition
$pagesRights = array(
'user' => array(
'home', 'items', 'search', 'kb', 'favourites', 'suggestion', 'profile', 'import', 'export', 'folders', 'offline',
'home', 'items', 'search', 'kb', 'favourites', 'suggestion', 'profile', 'import', 'export', 'offline',
),
'manager' => array(
'home', 'items', 'search', 'kb', 'favourites', 'suggestion', 'folders', 'roles', 'utilities', 'users', 'profile',
Expand Down

0 comments on commit e46e15c

Please sign in to comment.