今天突然看到joomla爆出新的漏洞,个人比较感兴趣所以分析了下。
漏洞新闻:http://bobao.360.cn/learning/detail/3139.html
1、漏洞影响版本
joomla 3.4.4 to 3.6.3
利用CVE-2016-8870
,在网站关闭注册的情况下仍可创建用户
利用CVE-2016-8869
,进行提权
2、漏洞复现
2.1 利用CVE-2016-8870
创建用户
位于components/com_users/controllers
下的registration.php
和user.php
有如下代码:
首先是registration.php
下UsersControllerRegistration
类的register
函数的部分代码如下:
然后是user.php
下UsersControllerUser
类的register
函数的完整代码如下:
public function register()
{
JSession::checkToken('post') or jexit(JText::_('JINVALID_TOKEN'));
// Get the application
$app = JFactory::getApplication();
// Get the form data.
$data = $this->input->post->get('user', array(), 'array');
// Get the model and validate the data.
$model = $this->getModel('Registration', 'UsersModel');
$form = $model->getForm();
if (!$form)
{
JError::raiseError(500, $model->getError());
return false;
}
$return = $model->validate($form, $data);
// Check for errors.
if ($return === false)
{
// Get the validation messages.
$errors = $model->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
{
if ($errors[$i] instanceof Exception)
{
$app->enqueueMessage($errors[$i]->getMessage(), 'notice');
continue;
}
$app->enqueueMessage($errors[$i], 'notice');
}
// Save the data in the session.
$app->setUserState('users.registration.form.data', $data);
// Redirect back to the registration form.
$this->setRedirect('index.php?option=com_users&view=registration');
return false;
}
// Finish the registration.
$return = $model->register($data);
// Check for errors.
if ($return === false)
{
// Save the data in the session.
$app->setUserState('us