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

Task #187778 chore: Fix security issue on plugin users #36

Open
wants to merge 1 commit into
base: release-2.1.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/users/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// No direct access.
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;

/**
* User Api.
* Creates a new user, updates an existing user and gets data of an user
Expand Down Expand Up @@ -156,9 +159,17 @@ public function post()
*/
public function get()
{
$input = JFactory::getApplication()->input;
$id = $input->get('id', 0, 'int');
$xidentifier = $input->server->get('HTTP_X_IDENTIFIER', '', 'String');
$input = Factory::getApplication()->input;
$id = $input->get('id', 0, 'int');
$xidentifier = $input->server->get('HTTP_X_IDENTIFIER', '', 'String');
$user = Factory::getUser();

if (!$user->authorise('core.admin') && $id != $user->id)
Copy link
Member

Choose a reason for hiding this comment

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

Should this be hardcoded to core.admin ? I suggest you check for the com_users create & edit permission based on if it's a create or edit user case.

{
ApiError::raiseError(400, Text::_('JERROR_ALERTNOAUTHOR'));

return;
}

/*
* If we have an id try to fetch the user
Expand All @@ -171,7 +182,7 @@ public function get()

if (! $user->id)
{
ApiError::raiseError(400, JText::_('PLG_API_USERS_USER_NOT_FOUND_MESSAGE'));
ApiError::raiseError(400, Text::_('PLG_API_USERS_USER_NOT_FOUND_MESSAGE'));

return;
}
Expand All @@ -180,11 +191,9 @@ public function get()
}
else
{
$user = JFactory::getUser();

if ($user->guest)
{
ApiError::raiseError(400, JText::_('JERROR_ALERTNOAUTHOR'));
ApiError::raiseError(400, Text::_('JERROR_ALERTNOAUTHOR'));
}

$this->plugin->setResponse($user);
Expand Down