1.1漏洞原因
1.1.1漏洞描述
图9 CVE-2018-6376
漏洞被描述为:在Joomla!在3.8.4之前,SQL语句中缺少类型转换导致Hathor postinstall消息中的SQL注入漏洞。
为了预防SQL注入攻击,而将输入到应用程序中的某些数据进行了“转义(escape)”,但是这些数据却又在“未被转义(Unescaped)”的查询窗体中重复使用。此时,攻击者可能注入的是一个PAYLOAD,这样就会构成一个SQL查询语句并被执行; 当用户可控数据以不安全的方式合并到数据库SQL查询中时,会出现SQL注入漏洞。攻击者可以提供精心设计的输入,以突破其输入出现的数据上下文,并干扰周围查询的结构。通常可以通过SQL注入提供各种破坏性攻击,包括读取或修改关键应用程序数据,干扰应用程序逻辑,升级数据库中的权限以及控制数据库服务器。当用户提供的数据由应用程序存储并随后以不安全的方式并入SQL查询时,就会出现二阶SQL注入。要检测漏洞,通常需要在一个位置提交合适的数据,然后使用一些以不安全的方式处理数据的其他应用程序功能。
这就是所谓的二阶SQL注入;通过Joomla中二阶SQL注入的例子来更进一步的理解[CVE-2018-6376]。
危害:可将低权限用户(Manager)提升为更高的的用户权限(Administrator或Super Administrator)。
1.1.2 漏洞代码分析
payload出库
SQL注入位于文件中administrator/templates/hathor/postinstall/hathormessage.php以下代码摘要显示了此漏洞。这是joomla自带的一套模板。
/**
-
Checks if hathor is the default backend template or currently used as default style.
-
If yes we want to show a message and action button.
-
@return bool
-
@since 3.7
*/
function hathormessage_postinstall_condition()
{
$db = JFactory::getDbo();
$user = JFactory::getUser();
$globalTemplate = ‘n/a’;
$template = ‘n/a’;// We can only do that if you have edit permissions in com_templates
/省略/// Get the current user admin style
$adminstyle = u s e r − > g e t P a r a m ( ′ a d m i n s t y l e ′ , ′ ′ ) ; ( 该 行 说 明 主 要 是 从 ‘ a d m i n s t y l e ’ 参 数 获 取 用 户 的 输 入 值 , 并 传 递 ‘ a d m i n s t y l e ’ 变 量 。 ) i f ( user->getParam('admin_style', ''); (该行说明主要是从‘admin_style’参数获取用户的输入值, 并传递‘adminstyle’变量。) if ( user−>getParam