Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix permissions issues on main.queries and users.queries. #4400

Merged

Conversation

corentin-soriano
Copy link
Contributor

@corentin-soriano corentin-soriano commented Oct 8, 2024

  • Use $session->get('user-id') instead of user input when only the user himself can perform this action.
  • Add additional checks on administratives tasks.
  • initialize_user_password removed because it is unused.

@tvnnn can you test this branch please?

@corentin-soriano corentin-soriano marked this pull request as ready for review October 8, 2024 13:00
@thevietronin
Copy link

Hi @corentin-soriano, it looks good to me, the fixes have resolved the vulnerabilities I reported.

@nilsteampassnet nilsteampassnet merged commit 654d98d into nilsteampassnet:master Oct 8, 2024
2 checks passed
$data_user = DB::queryfirstrow(
'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
WHERE email = %s',
$post_id
Copy link
Owner

@nilsteampassnet nilsteampassnet Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$post_id isn't initialized at this step

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to replace $post_id with $dataReceived['receipt']

// Manager of basic/ro users in this role but don't allow promote user to admin or managers roles
|| ((int) $session->get('user-manager') === 1
&& in_array($data_user['isAdministratedByRole'], $session->get('user-roles_array'))
&& (int) $post_is_admin !== 1 && (int) $data_user['admin'] !== 1
Copy link
Owner

@nilsteampassnet nilsteampassnet Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for $post_is_admin, $post_is_hr and $post_is_manager

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy/paste error.
We must check if the query returns a result and if the user has the right to administer the account found.
I will correct this tomorrow.

// Use id from session if user not admin or id not sent.
$userId = $session->get('user-id');
}

// Handle the case where no PWD is provided (user reset his own encryption keys).
if (empty($dataReceived['user_pwd']) && (int) $userId === $session->get('user-id')) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$userId is not initialized

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$filtered_user is expected.

@corentin-soriano corentin-soriano deleted the keyHandler_perms branch October 9, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants